Welcome to TheRunTime.com

We are a community of technical bloggers devoted to improving the business of development. This is a place where you will find expert advice on some of the advanced technical topics facing developers today. There will also be tutorials geared at novice developers, and content about the business aspects we must all deal with. Our number one commitment is to keep the content in our main feed relevant, reliable, and useful to you. I hope you enjoy our site and encourage you to subscribe to the main feed today.

Latest Posts

TUX: Next Meeting - Wed. Jan 14th 7:00pm

If you missed the MSDN Flash (thanks, Joe or whoever got us listed... I forgot to do it), here’s what’s going on.

Shawn Cady will continue his 8 part series on "What is User Experience?" If you missed the first one you will still get something out of this one. (We will be putting that first one online in the future). This was a great presentation and not to be missed. His first one was very informative, fun, and at times veering into some dangerous territory (we talked about UX on certain types of web sites that a polite "G Rated" blog like mine doesn’t talk about... but it was all in a tasteful fashion, so no reason to worry about us).

Jay Kimble (me) will be taking Marc Aniol’s example from last meeting and will simplify the JavaScript code by utilizing the new declarative aspects of the new MS Ajax 4 Preview JS library. For those who don’t know declarative in this case means that we can make for less code by attaching functionality via attributes on the HTML tags.

Everything starts at 7:00pm although Pizza will be there a little earlier. We try to shut things down by 9:00pm.

[Small update: if you need directions, etc, go to the TUX website for those details].

posted @ 1/7/2009 11:41 AM by Jay Kimble

Your Products Aren't "I"s

I develop software, and by extension write a lot of text intended for another person, ranging from on-screen labels, full-blown user manuals, FAQs, tips, e-mails, even comments in code. Having to write means that when I read, I do so with a critical eye.

I'm not qualified to give a complete overview of writing styles for different situations, but I can tell you one thing I hate wherever I read it: anthropomorphism.

Anthropomorphism is making something human (see the Wikipedia definition here) - for example, the way help text is presented using the Office Assistant (Clippy). Any text that describes a non-human product using "I..." makes me angry. Angry, people.

Contrast these real-life blurbs I found on the back of two of my wife's conditioner bottles:

Blurb 1: I'm deliciously hydrating. Give your hair a drink. I say you can never have too much of a good thing. So say "hello" to a deep dousing of lush hydration with my rich formula...Blurb 2: Sparkle and shine with my new limited edition conditioner. With delicate cashmere extracts and light reflecting crystals to leave your hair soft and smooth with a shimmering shine. Collette Dinnigan.

See how confusing the first one is? It took me a couple of times reading over it to understand who the "I" was. Was it me (the reader)? Surely no self-respecting copy-writer would give human attributes to the liquid in the bottle?

The second one is written as if it's a personal note from Australian fashion designer Collette Dinnigan but yet maintains a "casual professional" tone. Much better.

Please, your products aren't "I"s.

Thomas is on holidays, sunning himself (Christmas and New Year fall smack in the middle of the Australian summer - a great time to have the month off!)

Tags: , , ,

posted @ 1/7/2009 10:27 PM by Thomas Williams

Test Driven Development (TDD) or Behavior Driven Development (BDD)

[Sorry it’s been a long day and this is a rather stream of consciousness post... ]

If you have followed my blogging for any length of time you’ve seen me jousting (sometimes shouting) with the Agile crowd of Testing First. Actually I think my complaints have been more in line with some of the nuances of their architectural advice. We won’t get into that arena right now though.

[Digging out my best Katy Perry voice]

So, I tried BDD and I liked it
Yep, you heard me right. Not only that by I fired up moq and mocked/isolated/faked/doubled (pick a word for "fake version of an object") in one of my tests. And, oh yeah, I did it all first. Since you are all in shock, let me throw one more thing out there. I used SpecUnit.Net to do this all. You may not know what the big deal in that is. SpecUnit.Net was written by none other than Scott Bellware (he would be the guy I spent a lot of time shouting at in my blog).

Ok, so now that all the shock has died down, you may be wondering how this all happened. Again, if you’ve been following along, you would see that I have had a serious fascination with BDD. In fact last month I went to a CodeCamp and attended a session by Sean Chambers (session content is mostly presented in this post). It really hit some chords, and I vowed to try it the next easy opportunity I could.

So yesterday after Christmas break, my boss tells me, "I’m changing all your priorities. Here’s your new priority/project." I was then given a spec document with some rules for how the new feature would work (lot’s of use cases). On the spot I saw this as a perfect BDD opportunity. I built a test project/solution, added in all our support DLL projects and began to write Contexts, Observations, and Concerns (all BDD terms). I let the tests lead me and today I needed to test one final thing and realized that I should isolate things so I used moq which caused me to make a few API changes. All in all it was an excellent experience. I ended up with 2 concerns, 46 observations/tests, and 2 Contexts. I used Scott B’s reporting tool and got a couple warnings about my tests that implied that I might have a context hiding there which is probably true.

For the unenlightened, let me try to (poorly) define the terms. Context roughly equates to your setup code for each test; it’s a little more involved than that, but essentially you should have a context where all this runs. Observation is pretty much a test (although they should correlate to your "rules" from the spec document). A Concern is like a way to categorize all this stuff together, it can go beyond a single test class, but the idea is that you probably have say an "Order System"; that would be a concern. The Observations might be "do not ship the product if the customer hasn’t paid (there would be a context of "Customer has Paid" and "Customer has not paid"). Again this is all really , really rough... go to a real BDD gurus site.

So does that mean you’d switched ships, Jay?
Not exactly. I mean at one level it means that I will be developing more code this way whenever I can. I think I’ll always stay my own pragmatic self (which is not to say that Agile guys aren’t pragmatic... I’ve met my share of them now and they aren’t who I’ve been beat up by). I will be adopting some of their practices where it makes sense. I finally got a testing success so who knows where I’m heading.

Advice for the Agile Evangelist
I think you guys need to abandon TDD as a starting point. BDD makes more sense to the average corporate developer. Every project has specs (no matter what you call them). Writing tests using those specs first really makes sense. It’s why I was very interested in this methodology the first time I read about it. The methodology also answers all those newbie questions immediately. Stuff like

- Do I gotta test first? [yep, if you want to make sure your code passes the spec’s rules... it’ll also help you see the edge cases that should have questions raised with the customer/client/business owner]

- What do I test? [You test the spec. First and foremost... I know this skirts into dangerous waters here... but convincing people to test something will lead to more testing if it proves to make code more stable, etc.]

I found it easy to get into the "red, green, refactor" rhythm, and even caught some minor problems along the way. I imagine a newbie would have the same result. Now from here you have a platform to talk about improving someone’s ability to test.

The end-result for my code
Well, time will tell, but my back-end API changes don’t allow the UI to violate any of the rules. It was the type of spec where I have some fields that cannot be changed which has some additional effects on other objects. When a field is read only it CAN’T be written to. The individual properties enforce this functionality. Additionally the other rules were easy to implement. And all this happens outside of the Data Layer and not in the UI Layer (thank heavens!) I know none of this is rocket science, but there are a really large number of places in the UI where these things can be violated (I needed to make sure the Business Objects took care of business).

posted @ 1/6/2009 7:36 PM by Jay Kimble

Client-side Scripting 101 Part 1: The Reasons

[Welcome to my multi-part tutorial on. I know I did an introduction earlier in the month, but before we dig in deep into this I thought it would be good to get a few questions out of the way.]

Why is this (Client-side Scripting) all that important to me?
You may be thinking "Hey Jay, my company bought Telerik/Component Arts/Component One/{fill in some other ASP.NET tools suite} and it seems to do everything I need and more. I can see some places where a little client-side code is helpful, but it’s not that important, is it?"

Well, I’m definitely not one to criticize the third party tools vendors, but their tools are just that tools. If your site grows large enough you will run into a place where you need to tweak their tools, and my experience is that all the ones I’ve mentioned have really nice client-side APIs that underlie their server-side components. Stuff that will really let you push the envelope of their tools. But, you probably already know that. The hard part is for all the great things these tools can do, sometimes you need something else (usually a little more light weight). In order to do this you need a background in client-side technologies so that you are able to assess your solutions. 

For instance, in my day job I created an MS Ajax behavior that takes a regular HTML table and adds a selection behavior. We did this to replace the big name grid we are using because, while this grid does amazing things, it also comes with a price of a heavy footprint and a larger than desired viewstate (we’re trying to slim our pages for performance sake). I also have created 2 additional behaviors: one injects client-side paging to a regular HTML table, and the other provides sorting functionality via the column header row. All of these behaviors inherit from a common class that wraps the table. My lightweight behaviors are simple components that can handle up to about 1000 rows which make them really useful for smaller sets of data. I tried them on as many as 5000 rows which gave OK but sluggish performance, and with 10,000 rows was simply unusable (I was using all three components, so it might be possible to use say just the paging and get decent performance).

It comes in handy to be able to build these types of lightweight components (which incidentally only took me about 40 hours to build all 3 which included server-side extenders).

Our first term: Client-side (or Ajax) Behavior
Since I have thrown the term "behavior" out a couple of times, let’s go ahead and define what it is exactly. In the realm of MS Ajax (and other frameworks), a client-side behavior is a client-side component/class that injects functionality into an HTML element. In MS Ajax, it is a separate component that is associated with an HTML element. When activated, it usually sets up UI events (onclick, onfocus, etc.) to intercept some UI interaction and apply new interactions. It can also inject additional css classes/styles or html elements on the page to apply a particular look (which is what the Ajax Control Toolbox’s Drop Shadow and the Rounded Corners behaviors do). It all depends on what the component needs to do. If you have played with any MS Ajax toolbox on the server side, you have probably throw Ajax Extender controls on a form; extenders are a server-side wrapper for the client behaviors. I hope that’s clear. If not fire off some comments to me at the bottom of this post and I’ll try to better explain in the comments (and will update this accordingly).

One of my goals for this blog series is to take you from knowing a little bit about client-scripting (and maybe nothing) to being able to build your own behaviors and extenders.

JavaScript is like a foreign language to me... Why couldn’t this be easier?
This may shock you, but I struggle with it too -- and I’m a(n admittedly) self-proclaimed guru with it. Two weeks ago (I was off last week) I wrote a very simple JavaScript component/class and I forgot something. I set up a timer event and it wasn’t making the call correctly into my class. Eventually I realized that what was happening was that I was calling a method within my JavaScript class and the instance of that class was being lost. I needed to use the MS Ajax "Function.createDelegate" function to get a wrapper function that wouldn’t lose the instance of my class. This is a total pain in the you-know-where. I actually told my boss that this is the exact reason I use Script# since it takes care of this stuff for me.

What the Heck is Script#?
Script# is a life saver! It is the invention of Nikhil Kothari (MS Ajax Architect and SilverLight2 Architect, and he is one of my heroes... I hope I get to meet him at Mix09). What it does is let you write C# code in Visual Studio against a framework (either Nikhil’s or MS Ajax... there are also jQuery extensions and a few others for it as well). This framework has a set of CoreLib replacements (System, etc.) that consist of set of .NET dlls and a set of JS client libraries. When you compile this code, you get a DLL which can be used in other Script# projects (yes, there are VS templates for creating a new Script# project), and  a set of JS files (debug and shrunk runtime versions). Script# makes it easy to create multiple inherited classes (an object tree if you will) as well as it handles things like passing functions around.

So that means I don’t have to know anything about JS right? Cool!
Hang on there! You will need to know a little bit about this stuff as it will help you read the code generated by JS. You can always patch bugs with Script#, but testing will (at this time) always exist in the JS side (in a browser), so you need to know enough to get around the source code that gets generated. The line numbers will always point to a line in the generated JavaScript (for instance), so your going to need to be able to read the JavaScript file and determine where the problems exist (you can still fix the code in your C# code, and can write debug messages that show up in the JavaScript console (or in VS if you are debugging the script running in IE).

So next up will be a column on JS OOP Basics.

posted @ 1/2/2009 10:13 PM by Jay Kimble

C# Style Attributes in Script#/Javascript

[If you aren’t knee deep into Script# or JavaScript this post might not make any sense. If you are into BDD (or TDD) you might want to read further to see some ideas I’m playing with. If you write TDD tools for running tests... please read further... ]

[NOTE (For Joe Only): Joe, yes, this is a "shiny stuff" post; some day it might have a practical use at which point I’ll write a non-alpha geek version of this post which will be a tutorial of how to use this to make your life easier.]

One of the things I’ve been looking for again is a way to create C#-Style (or even Java-Style) attributes on a function in JavaScript. Mind you, I’m the author of such a library, but making it work in Script# is a bit of a pain. To do it would require me writing in Script# something like this (and I’ll give away what I want to do as well):

   1: // NOTE: what follows is something I could do not something that is fully working
   2: // the JS Style Attributes work and that is all
   3:  
   4: [Concern()]
   5: public myClass
   6: {
   7:     public myClass()
   8:     {
   9:         Script.Literal("/*--@Concern()--*/");
  10:     }
  11:  
  12:     [Observation("When adding a person, full name should not be blank")]
  13:     public void When_adding_a_person_full_name_should_not_be_blank()
  14:     {
  15:         Script.Literal("/*--@Concern("When adding a person, full name should not be blank")--*/");
  16:         // Test Code appears here
  17:     }
  18: }


See that Script.Literal in the constructor? That’s required for my JS Attributes Library and for Script#. You see we have to force a comment into Script#, and do it in a manner that the comment ends up in the runtime version (non-debug version) of the code.

So why would I want to use regular attributes as well ("they don’t make their way into the JS code, right?"). Well, since my BDD experimentation is starting to be seen. I’ve started experimenting using Test Driven.Net with Script# assemblies (I took a Bertrand Le Roy’s Simple Test framework for JavaScript and converted it to Script# (I also made a couple enhancements, so I could target alternate consoles... instead of just html). After hooking everything up, I ran the DLL through reflector and sure enough, it decompiled into my exact source code. Next I tried running it with Test Driven.Net personal with no luck... not sure what I need to do to get it running actually, but I bet if I had a Test Attribute that would start sending me in the right direction.

Regardless, I’m not all that interested in regular xUnit style frameworks; I really want BDD. One of the things I started doing was investigating all the BDD style frameworks for .NET. Almost all of them inherit from NUnit, so if I wanted to say port Scott Bellware’s SpecUnit to JavaScript/Script#, then I would need to have an NUnit implementation and a recent one. Recent NUnit implementations all use Attributes which is how we get here. [For the acronym police: BDD stands for Behavior Driven Development... I won’t attempt to define it as I would probably get it wrong, but it’s a variation on Test Driven Development -- TDD... BDD emphasizes testing specs, user stories, use cases, etc.]

BDD with JavaScript
One of the things I’ve been thinking about is how something like Script# DLLs lend themselves for testing. Seriously. If you take an UI behavior approach to components, then you need to isolate the functionality by creating a fake element (or more than one), attach the behavior and then start firing events on the model to make sure that the desired results happen. For instance if I have a draggable element then I want to make sure that the element shows the hand cursor when the mouse passes over the element as well as when the mouse button is down and the mouse is moved does the element’s position changes, etc. I keep thinking that this should be infinitely easier in the DLL as an abstraction then in the actual browser. Of course one needs to test various browsers, but if your math is off for instance, it won’t matter which browser you use.

Why BDD and not TDD? Well, I usually have a list of rules that the UI Behavior should adhere to before I ever write a line of code. This is a perfect fit for a BDD style of test first (and yes, I want to do BDD testing first... I know that’s shocking, but I do want to try it... for how I TRY to build JS components quality is usually a huge factor that BDD would greatly help).

posted @ 12/20/2008 11:19 PM by Jay Kimble

Script# - Literal feature... How did I miss this one?

Today, I’m doing some work with Script# and I ran into the one thing about Script# that I don’t like: there are a few areas where Script# just isn’t able to perform some task. This happens a lot when you are developing Atlas (MS Ajax) components instead of using Nikhil’s ScriptFX client library.

Today I ran into one of those areas. Specifically I needed to dynamically add/remove options from a select element. In JS this is a breeze for me, but Script#'s SelectElement’s options array is defined as a dictionary which doesn’t allow for adding elements. In the process of doing it I ran across an article on how to do it in a more DOM-compliant manner (read that as "the standard way you’re supposed to do it"). The article is over here.

Anyway, I originally used Script.Eval, but I knew that was going to put some ugly code in my resulting Javascript files (I really do hate that).

While I was doing that I noticed the reference to "Script.Literal" in my intellisense, so I grabbed the docs and took a look. To my amazement this new element did away with this limitation once and for all.

Here’s what it does. It lets you emit your own script code into the resulting script. So I could use the above article and reference properties that don’t exist in the Script# implementation. That really rocks!

So you could do something like this:

// Hide all elements of a certain type in my doc and hide them 
// (this is a contrived example, I know)
public void HideAllElementsOfType(string tagName)
{
   Script.Literal("$(tagName).css('display', 'none')"); // this is a JQuery call
}

In the resulting JS there will be something like this (I’m manually doing this so it won’t be exact here):

function hideAllElementsOfType(tagName)
{
    $(tagName).css('display', 'none');
}

You see? it took the string in the literal and injected it into the source. Using a "$" is not possible with Script#/C#, but we were able to inject it into our code with no problems.  Literal also supports String.Format syntax as well. This is so cool! It means that it is trivial to get around Script# limitations and still get good performance (no need to litter your code with Eval)

posted @ 12/10/2008 3:41 PM by Jay Kimble

Managing Reporting Services Subscriptions

Reporting Services offers two "out of the box" methods to manage subscriptions (subscriptions are scheduled report executions, controlled by Reporting Services):

  • Each report has a "Subscriptions" tab (depending on permissions) which shows your/all subscriptions (again, depending on permissions) for that report only
  • All your subscriptions can be managed using the "My Subscriptions" link in the top right-hand corner of Report Manager

There's one key thing missing from the two methods: how does an administrator or power user manage all subscriptions in Reporting Services?

The Query

I'm going to provide a starting point for a better way to manage Reporting Services Subscriptions - a query that looks at the ReportServer database directly and lists all Subscriptions.

There are plenty of ways this could be improved. Two improvements that spring to mind are copying the data out of the ReportServer database on a schedule so you're not querying live, OLTP-type data, and to further develop the query into a report. Maybe I'll deal with those enhancements in a future blog post.

Back to the query. I've tested it in SQL Server 2005 only, so I'll invoke my "Thomas Williams sez" rule to use at your own risk. And I should add another warning: since the tables aren't documented, they could be changed and this query could fail. Lastly, I haven't covered the SELECT permissions required to run this query here. You've been warned!

Some XML columns are involved so the query looks a little convoluted initially:

USE [ReportServer]
GO

;WITH 
[SUBJECT]([SubscriptionID], [SubjectLine]) AS 
(
 
--CTE with Subject lines from e-mail Subscriptions from XML like: 
 --  <ParameterValues>
 --    <ParameterValue>
 --      <Name>TO</Name>
 --      <Value>email@address.com</Value>
 --    </ParameterValue>
 --    <ParameterValue>
 --      <Name>IncludeReport</Name>
 --      <Value>True</Value>
 --    </ParameterValue>
 --    <ParameterValue>
 --      <Name>RenderFormat</Name>
 --      <Value>PDF</Value>
 --    </ParameterValue>
 --    <ParameterValue>
 --      <Name>Subject</Name>
 --      <Value>THE SUBJECT LINE</Value>
 --    </ParameterValue>
 --    ..
 --  </ParameterValues>
 
SELECT  I.[SubscriptionID], 
         
--just get the subject line here 
         
I1.rows.value('Value [1]''VARCHAR(500)'AS [SubjectLine] 
 
FROM    (
          
--if the Subscription is an e-mail, get the XML fragment which contains the subject line 
          
SELECT  S.[SubscriptionID], 
                  
--add a "root" element to create well-formed XML to the "ExtensionSettings"
                  --(in case it's NULL) 
                  
CONVERT(XML, N'<Root>' CONVERT(NVARCHAR(MAX), S.[ExtensionSettings]) + N'</Root>'AS [ExtensionSettings]
          
FROM    ReportServer.dbo.[Subscriptions] S WITH (NOLOCK
          
WHERE   --only get e-mail subscriptions 
                  
S.[DeliveryExtension] 'Report Server Email' 
         
) I CROSS APPLY 
             
--pull out elements in the "ParameterValues/ParameterValue" hierarchy 
             
I.ExtensionSettings.nodes('/Root/ParameterValues/ParameterValue'AS I1(rows) 
 
WHERE   --only get the Subject field 
         
I1.rows.value('Name [1]''VARCHAR(100)''Subject' 

--get subscription data for all users
SELECT  --unique ID for this Subscription 
        
S.[SubscriptionID], 
        
--is the subscription Inactive (<> 0)?
        
S.[InactiveFlags], 
        
--XML fragment which contains PATH (if file) or TO (if e-mail)
        --also has render settings like "render format"
        
S.[ExtensionSettings], 
        
--e-mail subject (if an e-mail subscription) 
        
[SUBJECT].[SubjectLine], 
        
--when the subscription was modified 
        
S.[ModifiedDate], 
        
--internally put-together description of subscription 
        
S.[Description], 
        
--user-friendly message for what happened the last time the subscription ran 
        --which may be "New Subscription" 
        
S.[LastStatus], 
        
--is this a "TimedSubscription" or one-off
        
S.[EventType], 
        
--XML fragment describing the timing and recurrence 
        
S.[MatchData], 
        
--the time the subscription was last run (may be NULL) 
        
S.[LastRunTime], 
        
--is this an e-mail ("Report Server Email") or file share ("Report Server FileShare")?
        
S.[DeliveryExtension], 
        
--start date and end date for schedule 
        
SC.[StartDate], SC.[EndDate], 
        
--other schedule information (we could get exactly the schedule here, but needs
        --to be re-assembled from multiple fields) 
        --???
        
SC.[Flags], SC.[RecurrenceType], SC.[State], 
        
--report path and name 
        
C.[Path], C.[Name], 
        
--owner name 
        
[U1].[UserName] AS [Owner], 
        
--modified by name 
        
[U2].[UserName] AS [ModifiedBy], 
        
--URL direct to the subscription 
        
[URL] 'http://<YOUR_SERVER_HERE>/Reports/Pages/SubscriptionProperties.aspx?ItemPath=' + C.[Path] + '&IsDataDriven=False&SubscriptionID=' + CAST(S.[SubscriptionID] AS VARCHAR(80)), 
        
--URL to the "Subscriptions" tab on the report (which can be used to delete the subscription) 
        
[URL2] 'http://<YOUR_SERVER_HERE>/Reports/Pages/Report.aspx?ItemPath=' + C.[Path] + '&SelectedTabId=SubscriptionsTab' 
FROM    --actual subscriptions
        
ReportServer.dbo.[Subscriptions] S WITH (NOLOCKLEFT OUTER JOIN 
            
--report details from Catalog 
            
ReportServer.dbo.[Catalog] C WITH (NOLOCKON 
                
S.[Report_OID] C.[ItemID] LEFT OUTER JOIN 
            
--Users (owner)
            
ReportServer.dbo.[Users] [U1] WITH (NOLOCKON 
                
S.[OwnerID] [U1].[UserID] LEFT OUTER JOIN 
            
--Users (modified by) 
            
ReportServer.dbo.[Users] [U2] WITH (NOLOCKON 
                
S.[ModifiedByID] [U2].[UserID] LEFT OUTER JOIN 
            
--Subscription Schedules 
            
ReportServer.dbo.[ReportSchedule] RS WITH (NOLOCKON 
                
S.[SubscriptionID] RS.[SubscriptionID] LEFT OUTER JOIN 
            
--Schedules 
            
ReportServer.dbo.[Schedule] SC WITH (NOLOCKON 
                
RS.[ScheduleID] SC.[ScheduleID] LEFT OUTER JOIN 
            
--Subjects CTE from e-mail subscriptions 
            
[SUBJECT] ON 
                
S.[SubscriptionID] [SUBJECT].[SubscriptionID]

The first bit of SQL in the "SUBJECT" common table expression gets the "Subject" line for e-mail subscriptions only. The default screens in Report Manager do not display the subject, but it came in handy for me so I've left it here.

Next, the query pulls all the relevant (and some not-so relevant) fields from the Subscriptions table, joined with the Catalog table, the Users table (twice, once for owner, once for "modified by"), the Report Schedule table and the Schedule table. These tables aren't documented at MSDN, as far as I can tell, but I've gathered together as much as I can find of column descriptions into comments in the query.

If you want this script to generate the correct URLs for your server, replace "<YOUR_SERVER_HERE>" with your server name. I do not recommend using the tables for changing data, but you can use the URL's generated by this query to change or delete existing subscriptions using the Report Manager interface.

Related Posts on Thomas Williams Tech Blog: Hiding and Showing Columns Based On a Parameter in Reporting Services, Quick Tip: Retrieving Report Definitions from the Catalog Table in the ReportServer Database, Reporting Services Heatmap, Leaving out Parameters on SQL Reporting Services

Tags: , , , ,

posted @ 12/8/2008 1:37 PM by Thomas Williams

Tampa Code Camp 2008 Wrap up

Yesterday I had an excellent day at the Tampa Code Camp. My wife gave me a vacation day from the family (thank you!) which makes for a good day that I can just hang out catch a couple sessions, speak, and connect with a few other geeks.

I have attached my slides and sample projects to this post (the sample solution requires that you have Script# installed). I also attached my MS Ajax Cheat sheets as well.

Normally that would be all that I would put up here, but there were some additional things that happened as a result of me meeting a few people. BTW, I absolutely love Code Camps, but usually not for the presentations. I normally end up meeting a couple people that I have a really cool conversation with. In this case I had a little chat one of my attendees that got me thinking. Morgan mentioned that she would love to see me do something that would help someone like her wrap her head around all this client scripting stuff (she’s an experience Windows Developer whose now having to build some web sites and is starting to see the need to be able to dive deeper than throwing an UpdatePanel on a form.

She got me thinking about doing what I’ve started thinking of as "Dive Deep" into ClientScript.  I wanted to do another Day of Ajax (but I think Joe is a little hesitant to let me do it as in the past I have tended to dive just below the stuff I’m currently doing losing most of the people in the room... actually my talk yesterday was probably another one of those... sorry, if you were one of those people...) Actually Joe wasn’t the only one who kind of shot me down, so an event sounds out of the question.

New Blog post series (for Morgan and folks like her)
Since I can’t do another Day of Ajax (well, I could if someone wanted to give me a facility to do it in...), I’ve started thinking about doing a series of blog posts to help someone go from minimal knowledge (I can drop a control on a WebForm) to being able to customize a behavior/extender in the Ajax Control Toolbox and to be able to build your own controls. These skills really go outside your core MS skills... you need to be able to look at things a little differently. These blog posts will have source code in JavaScript and in Script# (since I imagine a lot of people doing ASP.NET would rather leverage a skill that they use on a regular basis). We’ll be leveraging both the MS Ajax ClientScript library and the jQuery library.

I’ll try to get some of this going this week and will try to regularly blog about it.... with the holidays please forgive me if I fall behind.

I was right BDD is cool and translates to my world really well
I also had some conversations with Sean Chambers and Chris Bennage. Between conversations I have had with Chad Myers and Sean, I have a decent agile community in Los Techies who seem to be less thick skinned and are really good at communicating their methodology in a very clear manner without being zealots. My conversations with Chirs really showed me the practicality of the whole discipline (looking forward to having more conversations with Y’all). I actually attended Sean’s BDD talk and found it really enlightening... I’m looking for a good project to try BDD on (and BDD first). If I can manage to not tick off Mr. Reynolds, maybe I can find some Agile friends in Florida that I can pick a few things up from (I leave it all open ended at that).

So you’ll probably hear some posts around this subject as well. I actually had Chris admit that he over-architected a sample once (which has probably been my problem with some of this stuff... FWIW, all my conversations about DI seem fairly stupid at the moment as what I build typically is DI in some form or another). Anyway, BDD is something I’ll definitely be exploring a little more (since I was given a copy of TypeMock, I’ll be exploring that was well).

Summary
All in all a really great day for me.

Here’s the files Slides

      

posted @ 12/7/2008 3:36 PM by Jay Kimble

Hanselminutes Podcast

image At the very last minute before Scott left for Africa, Dan Fernandez and I were able to do a quick episode of Hanselminutes to promote our book.  Have a listen to learn a bit more about our book, the projects it contains, how they were developed, and some issues we ran into when trying to use some technologies in a way they weren’t intended to be used.  Head over to the main site to stream the show in your browser or download in a variety of other formats.

Cross Posted from www.brianpeek.com.

posted @ 12/7/2008 2:29 PM by Brian Peek

SQL Server Agent Job E-Mail Notification Query

I'm about to have a couple of weeks holiday over Christmas (lucky me!) and one of the tasks my boss asked me to do before I went was make sure that e-mail notifications that were directed to me only, should be re-assigned to our entire team.

We rely on SQL Server Agent Jobs and these can be set to notify operators when the job fails, succeeds, or completes (regardless of the outcome). After quickly looking through a couple of jobs, I found plenty that were only notifying me (oops). I needed a more foolproof way to identify the jobs that needed changing.

In addition to setting the e-mail operator to be our team e-mail, I also took the opportunity to also make sure that the job writes to the Event Log on failure and has a valid category (I blogged about Job Categories - and how you can set up your own - back in April 2008).

Here's the query I used, which lists all jobs apart from Reporting Services subscription jobs (which have GUIDs as names) and disabled jobs:

  1. --*** SQL Server Agent Jobs and selected properties, by Thomas Williams ***
  2. --*** this query has been tested on SQL Server 2005 only ***
  3. --For more information on the sysjobs table, see:
  4. --  http://msdn.microsoft.com/en-us/library/ms189817.aspx
  5. --For more information on sysoperators, see:
  6. --  http://msdn.microsoft.com/en-us/library/ms188406.aspx
  7. SELECT  --Job name
  8.         [Job Name] = sj.[name],
  9.         --Job owner
  10.         [Owner] = SUSER_SNAME(sj.[owner_sid]),
  11.         --Job category e.g. "Database Maintenance", "Report Server", "[Uncategorized (Local)]"
  12.         [Category] = c.[name],
  13.         --Operator to be e-mailed (may be NULL)
  14.         [Email Operator] = o.[name],
  15.         --notification in Event log (notify when job fails, succeeds, always, never)
  16.         [Event LOG Notification] = CASE sj.[notify_level_eventlog]
  17.             WHEN 0 THEN 'Never'
  18.             WHEN 1 THEN 'When the job succeeds'
  19.             WHEN 2 THEN 'When the job fails'
  20.             WHEN 3 THEN 'When the job completes (regardless of the job outcome)'
  21.             ELSE 'UNKNOWN' END,
  22.         --e-mail notification (notify when job fails, succeeds, always, never)
  23.         [Email Notification] = CASE sj.[notify_level_email]
  24.             WHEN 0 THEN 'Never'
  25.             WHEN 1 THEN 'When the job succeeds'
  26.             WHEN 2 THEN 'When the job fails'
  27.             WHEN 3 THEN 'When the job completes (regardless of the job outcome)'
  28.             ELSE 'UNKNOWN' END
  29. FROM    msdb.dbo.[sysjobs] sj LEFT OUTER JOIN
  30.             --E-Mail Operator
  31.             msdb.dbo.[sysoperators] o ON
  32.                 sj.[notify_email_operator_id] = o.[id] LEFT OUTER JOIN
  33.             --Job categories
  34.             msdb.dbo.[syscategories] C ON
  35.                 sj.[category_id] = c.[category_id]
  36. WHERE   --ignore auto-created jobs (Reporting Services schedules)
  37.         NOT (sj.[name] LIKE '_____________-____-____-____________') AND
  38.         --only enabled Jobs
  39.         sj.[enabled] = 1
  40. ORDER BY sj.[name]

One thing I came across while auditing jobs was e-mail notifications on success or completion (rather than just on failure). Our team agreed that if we needed a special notification on success or completion that we would use sp_send_dbmail in a job step, and leave the job notifications for errors only.

Tags: , , ,

posted @ 12/2/2008 1:45 PM by Thomas Williams

Head Banger Is Now Available on Xbox LIVE Community Games

xboxboxart Several friends and I work together to write “indie” video games under the brand Ganksoft EntertainmentYou may recall that for Maker Faire 2007, we created a very simple rhythm-based music game (think Rock Band or Dance Dance Revolution) using XNA called Head Banger.

With Microsoft’s official release of Xbox LIVE Community Games with the New Xbox Experience, we decided to blow the dust off of Head Banger, add a couple songs, integrate it bit more with Community Games and XNA 3.0 and release it.  It is now available for purchase for 200 Microsoft Points (or, as with all Arcade and Community games, there’s a free trial) straight from the Community Games section of the Games Marketplace on your Xbox 360.  It will be listed under New Releases for a little while, otherwise you can go to All Games and then the letter H to find it.  Additionally, you can view the official Marketplace page on the new web-based Xbox LIVE Marketplace site.

Please give the trial a go and let us know what you think!  And, if you think it’s worth 200 points ($2.50), we’d be happy to have you purchase it so it will move up the “popularity” list.  Thanks!

 screen1_Web

Cross Posted from www.brianpeek.com.

posted @ 11/29/2008 5:43 PM by Brian Peek

JQuery Hover Fading on Mouse Over and Mouse Out Without Images

I've been playing with the excellent JQuery JavaScript library for a while now. Recently I came across a technique for fading in and out two images based on mouse over and mouse out; and I wanted to see if I could create a fade-in and fade-out hover effect without the images.

It's a testament to the robustness and flexibility of JQuery that I could do this in so little code, with so little knowledge. Admittedly my first go can be CPU-intensive, however the code is short and sweet - include JQuery and JQuery UI, mark your elements with a CSS class called "fadeThis", and put the snippet of script below into your document's HEAD:

  1.   <script type="text/javascript">
  2.     // adapted from http://www.incg.nl/blog/2008/hover-block-jquery
  3.     // and http://greg-j.com/static-content/hover-fade-redux.html
  4.     $(document).ready(function() {
  5.       $('.fadeThis').hover(
  6.         function () {
  7.           $(this).animate({backgroundColor:'Yellow', color:'Red'}, {queue:false,duration:500});
  8.         }, function () {
  9.           $(this).animate({backgroundColor:'#ececed', color:'#777777'}, {queue:false,duration:500});
  10.         });
  11.     });
  12.   </script>

The one-line functions starting with $(this).animate... fade the background and text colors on mouse over and mouse out for a subtle effect. One limitation is that I haven't found a good way to fade the border color, yet (and keep in mind I'm using Internet Explorer, so YMMV).

If you're into low-impact progressive enhancement, you can also reference the needed libraries from central Google hosting like so:

  1.   <!-- include Google's AJAX API loader -->
  2.   <script src="http://www.google.com/jsapi"></script>
  3.   <!-- load JQuery and UI from Google (need to use UI to animate colors) -->
  4.   <script type="text/javascript">
  5.     google.load("jquery", "1.2.6");
  6.     google.load("jqueryui", "1.5.2");
  7.   </script>

I hope this little snippet can form the basis of something useful for someone. It's a nice effect that fades in and out, all without the use of images.

Tags: , , ,

posted @ 11/24/2008 4:17 PM by Thomas Williams

"Subsonic" for Services found: Subsonic 3 + ADO.NET Data Services (Astoria)

About a month ago if you asked me what was big in my dev world (in other words what are you looking for).  I would have promptly told you that I was looking for the "Subsonic" of services. In other words I wanted to create a database and hook a connection string and have everything generated for me... I want drop dead simple.

Astoria was as close as I could get, but it didn’t quite achieve what I was looking for. Don’t get me wrong, it’s easy enough. I’m just not sure what I think of EF yet which is not to say that I don’t like it... just that I sometimes want something simple. Rob Teixeira has noted that for some there are "too many knobs." I’d have to say I’m somewhat in that camp (although I’m not very informed either and I’m not a huge lover of Linq to SQL either).

I love the simplicity of Subsonic. I really do, and I really want to leverage something that simple for building a Data Service. Rob Conery (I love Rob... You can have ScottHa or Haacked... I’ll take Conery... He’s my hero!) recently released a preview of Subsonic 3.0 which is fully Linq-Queryable and also has the normal Subsonic Query engine... it’s the best of all worlds (except it’s not backwards compatible).

Since my readings from John Papa’s book taught me that Astoria doesn’t need an EF model that regular classes could work, and I have a personal project that could use an easier more service friendly manner of editing/viewing data, I decided to try this out.

Preview 1 was an abysmal failure. Well, to be fair I quit because Preview 2 came out. I stuck with Preview 2 and earlier today I got it all working.

  1. Here’s how to do it. #1 follow Rob’s instructions (on any of the links I’ve provided and get Subsonic stuff working). I did all this in a separate DLL project.
  2. Create a regular web site (or web project)
    1. make sure there is a connection string in the web.config that has the same name as the "ProviderName" variable in the _Settings.tt file
    2. Add an ADO.NET Data Service to your web site/project.
    3. Add this attribute to your service class
      [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)] 
    4. Next set the DataService T type to the "DB" class of your Subsonic generated class. It will look something like this:
      public class NorthwindService : DataService<Northwind.DB>
  3. Tada! You are done...

A couple notes

Both Preview 1 and 2 build a class model that exposes an object/class called "DB." Think of this class as "Context" (even though EF and Linq2SQL context classes do a lot more). For the sake of Astoria, you just need a class that exposes all your entities in an IQueryable manner (which "DB" will do).

I ran into one error that was messing me up. If you make name of your Primary Key IDs "ID" then everything in the above worked fine. If it didn’t I am going to provide an alternate set of templates (TT files) for you to use. What’s missing is that Astoria expects an "ID" property. You can get around this by tagging each entity class with

[System.Data.Services.Common.DataServiceKey("{tablename_id}")]  

This also means that you have to include the System.Data.Services.Client.DLL in your Subsonic project.

My TT files (based on Preview 2)

I added a new variable in _Settings.tt that let’s you turn off the attribute used for setting the PK in your entity classes. It’s called "EnableForUseWIthAstoria." Here they are :

Closing thoughts

With all this in hand you should be able to create Astoria Services with any DB that Subsonic supports (which I believe is a larger number than what EF currently supports.

Additionally, like Rob Conery, I want to stress this is all experimental. This code might run off with your wife, children, it might decide to use your PC late at night to play video games thereby increasing your electricity, etc. (in other words this is all experimental right now... have fun with it, and be careful ... you probably don’t want to use it for live/mission critical code).

posted @ 11/18/2008 2:02 PM by Jay Kimble

Sign up for Mozy Free Online Backup with me, and get more

Get more space when you refer a friend For a limited time, we're doubling the amount of bonus space you get when you share Mozy with a friend. Share Mozy now and earn an extra 256 MB 512 MB of backup space for you AND your friend. http://mozy.com/?ref=22Z98B

I'm not much good at writing ad copy, so I've just pasted verbatim an e-mail promotion for the excellent Mozy free online backup (valid up to November 30th 2008).

It's free, easy to use, has 2GB of free space, works with Windows or Mac, and if you sign up using my referral code we both get an extra 512MB!

Tags: , , ,

posted @ 11/18/2008 9:54 PM by Thomas Williams

Animated Musical Holiday Lights at TVUG

image I’ll be presenting a session on building your own holiday musical light show using Phidget boards and .NET at this month’s Tech Valley User Group.  I’ve previously written an article about this topic on the Coding4Fun site, and there will be a full chapter on this in our upcoming “Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More” book.  Here are the session details…

Abstract: This month, learn how to build an animated light show set to music, much like the famous holiday light show videos you may have seen on YouTube.  This session will cover how to build the hardware, how to build the software, and how to combine them to create a synchronized musical show for your home.
When: Tuesday November 18th, 2008 - 6:30-9PM
Where: VersaTrans Solutions, Latham, NY

Hope to see you at the session!

Cross Posted from www.brianpeek.com.

posted @ 11/15/2008 4:57 AM by Brian Peek

WiiEarthVR Article and Source Code Posted

I previously talked about my WiiEarthVR project shown at PDC project, and now I have posted the article for the application up at the Coding4Fun site.  Full source code is available.  You’ll need some hardware to make this go, namely a Wiimote, Nunchuk, Wii Fit Balance Board and a pair of Vuzix VR920 glasses, but the hardware can be toggled on or off depending on your own setup.  The VR920 glasses are pretty cool in that they also work with a variety of FPS games on your PC with a custom driver they include.

The article will, among other things, teach you how to use Virtual Earth 3D from a managed host (i.e. a WinForms app, not a web page), how to talk to the Wiimote, Nunchuk and Wii Fit Balance Board, how to retrieve the head tracking data from the VR920 glasses from .NET, and how to draw stereoscopic 3D images to the VR920 glasses from .NET.  Quite a bit packed in there…

Anyway, have a read and, as always, questions and comments are welcome.

Cross Posted from www.brianpeek.com.

posted @ 11/14/2008 4:32 AM by Brian Peek

WiimoteLib v1.6 Released

image A new version of my managed Wiimote library for .NET has been released.  You can find version 1.6 up at CodePlex now.  The changes are as follows:

v1.6.0.0

  • Added "center of gravity" calculation to the Wii Fit Balance Board (thanks to Steven Battersby)
  • Structs are now marked [Serializable] (suggested by Caio)
  • Battery property is now a float containing the calculated percentage of battery remaining
  • BatteryRaw is the byte value that used to be stored in the Battery property
  • WiimoteTest app now reads extensions properly when inserted at startup
  • Exposed HID device path in new HIDDevicePath property on Wiimote object
  • Changed the time delay on writes to 50ms from 100ms...this should improve responsiveness of setting LEDs and rumble

I feel like I’m running out of things to implement and bugs to fix.  I know that’s not true.  So, I want to hear from the people using my library…

What features/bugs do you want to see added/fixed?  Please leave a comment here or contact me directly so I can create a master list.  Thanks!

Cross Posted from www.brianpeek.com.

posted @ 11/13/2008 5:56 PM by Brian Peek

TUX: Update...

Last night we had a fabulous night at TUX. I really think we are starting to hit stride now. Shawn Cady (our resident Dev-signer) did a fantastic presentation on using heatmaps for UX analysis. Before launching into this demo he decided to do a fabulous overview of UX. His thoughts echoed my own as I was planning on having an open discussion on this very topic.

I would be remiss if I missed mentioning that Marc Aniol followed up with a demonstration of Astoria (ADO.NET Data Services) being used with MS Ajax Templates (and Virtual Earth, and a little jQuery). It was very natural for Marc to frame his very practical demo in light of UX.

Don’t worry if you missed Shawn’s talk, we’re planning on revisiting this topic in January (that’s right we are taking the month of December off). If you came the first week and haven’t come back, you need to come back. Why? Last night was the first night that I felt like we addressed some of the issues with the first night (like "what was I/Jay thinking doing a hardcore JS discussion for the first meeting?") Seriously, I am very excited about TUX and not just as a I guy helping to run it.

Our plan is to record the follow up "What is UX?" session and make it available on our TUX user group site. After that we will require all speakers to review this video and to put their talk into context of this discussion (of course, this isn’t a hard rule... we’ll always help the speaker frame their talk).

What we are about at TUX is exploring this topic of User Experience, and trying to learn together how we can all do a better job of making our apps friendlier to our users and provide a decent experience to them.

posted @ 11/13/2008 12:28 PM by Jay Kimble

I'm a Lumberjack

Lumberjack And I’m okay. Indeed, last week saw a payoff for one of those hygiene things you do because you know that you “should”.

A Logging Story

Allow me to share what happened (feel free to skip this section).