All posts by Julie

Astoria CTP Refresh for VS 2008 Beta 2 is out

Just a quick pointer to Pablo Castro’s announcement that a new CTP for Astoria is out that will work with vS2008 Beta2.

An important note, this is a refresh of the CTP, which is based on the early prototype. The actual production code that they are working on is a totally different set of bits. Hmm, for safetey’s sake, I better just quote Pablo:

NOTE: let me stress that this is a refresh of the May CTP, which is based on the initial prototype of Astoria. All of the features/design options we’re discussing here in this blog (e.g. last post about payload formats) are in the context of the production version of Astoria which we are in the process of building. The production version incorporates a ton of feedback that we received over the last few months plus our own more detailed thinking of what should the system look like. So expect to see quite a few differences between the CTP and the production code once we start shipping the production version. The principles will all be the same, but the details will vary.

Vermont IT Jobs: Web Application Developer in Middlebury (great company to work for!)

This a job with one of my mentoring clients, Co-Operative Insurance. I absolutely love going to their office and working with these people. It’s a small team in a large company. Nice, friendly folks. And it’s in Middlebury which is a great place to work.

Web Application Development

Excellent opportunity for a qualified programmer with web application design, development, and implementation experience!

Work on the complete product development lifecycle of our B2B extranet, including requirements gathering, technical design specification creation, coding, testing, deployment, post-production support, documentation and maintenance.

Must have 2-5 years’ development experience with Visual Studio 2003/2005 as well as JavaScript, (X)HTML, ASP.net, VB.net and XML. Pluses include insurance industry knowledge and experience with CSS and with version control software such as SourceSafe or Vault. Solid UI design skills get you multiple pluses.

To join our hard-working, fun IS team in producing quality apps, you must be an organized, self-motivating team player, an excellent communicator and attentive to detail. You must be willing and able to work both independently and with a team, depending on the assignment.

Co-operative Insurance Companies is a $50 million property and casualty insurer in VT and NH.  We offer a competitive benefits package and a schedule that allows for work/life balance.

For immediate consideration, please forward a copy of your resume to jobs@ciui.net.

Mark Mullin on WCF & SOA at Vermont .NET tonight

We are really looking forward to this talk by Mark Mullin tonight at VTdotNET!

We also have some great WCF books to give away: Learning WCF by Michele Leroux Bustamante (thanks OReilly and INETA) and Pro WCF: Practical Microsoft SOA Implementation from APress.

Thanks to Infragistics, we will be raffling off two licenses to NetAdvantage for .NET. One of the raffles will actually be a fund-raising raffle.

We also have shirts and swag courtesy of CodeZone and piles of CoDe Magazine and aspnetPRO to give away.

And thanks to Verio’s sponsorship of INETA, I am able to offer Verio’s free webhosting to Vermont .NET members who show up at the meeting tonight.

Since it’s such a nice day (and I have just absolutely NO work to do ;-)), and Mark is being so generous with his time (driving up from New Hampshire) and cash (there’s gas $ and hotel involved), I am going to take him on a 1.5 hour cruise on Lake Champlain aboard the Spirit of the Ethan Allen this afternoon. Hey, running a user group is HARD work, y’know?

Silverlight Ink – Searching in Google

Loren Heiny has been working on a cool Silverlight annotation app to user Silverlight and a stylus to do Google and Technorati searches. It’s called SearchTip and is live on TabletPC Post.

There is a lot that is really interesting about this. (And it’s visually appealing too!) First of all, he has a YouTube video where he compares using this (earlier version) on a Mac to using Inkwell on the Mac (when you have a tablet ala Wacom attached to the Mac) and demonstrates the superiority of Microsoft’s handwriting recognition. I was lucky enough to attend an SDR at Microsoft a few years ago where the man who ran the whole reco team explained to us how they made it all work. I can’t imagine anybody being able to come close to their investment or acheivement with handwriting recognition, so it was great to see Loren being able to really compare apples to apples (no pun originally intended, but oh well!)

Next is the fact that Loren is doing handwriting recognition from the InkPresenter in Silverlight. Not an easy feat. Once the reco is done, the result can get passed to a google service and voila you get your results displayed.

Loren has done some amazing work with the Tablet APIs for a number of years and always thinks out of the box. So I love that he’s taking his ideas and applying them to Silverlight.

 

Of course, you don’t need a tabletpc to draw in silverlight, but as awesome as the recognition is, I don’t think it’s fair to ask it to recognize mouse drawn handwriting. But it’s not bad. Reco returns a list of guesses, sorted by best to worst. Here I’m using an earlier version which does google searching and trying it with my mouse on a regular (non-tablet) desktop.

So you can click on the guess (I clicked on Steins) and it will show you the next guess on it’s list. Heinz was next, then a few more clicks (just to see) got me off the track. oops. This is not a reflection of the reco or of Loren’s app. I’m only playing around with the mouse for fun (and laziness since my tablet is upstairs.) So while the reco may not be great when you aren’t using a stylus which has about 10 times the resolution as a mouse, Silverlight’s ability to collect the ink data from the mouse is still pretty impressive.

You can see Loren doing this. and how impressive it truly is using a Tablet, in his YouTube demo video.

You can clear your writing with the x, and of course, when you have the correct reco displayed, click Search.

Using LINQ to query Outlook emails joined with SQL data

I watched part 2 of Jim Wooley’s ASP.NET Podcast show on LINQ and was really impressed with the creativity of his examples. Having dug deeply in order to write LINQ in Action along with Fabrice Marguerie and Steve Eichert, he’s way past the how-to basics and able to see the bigger picture of leveraging LINQ.

In his demo, he starts with some simple querying of the file system – a good demonstration of using linq against objects, but by the time he gets to the end of the demo, he is using JOIN to build queries that combine file system info with data pulled from the database.

I knew I wanted to do something like that but I couldn’t just copy him, no matter how flattering. So I thought about it for a while… what data is on my computer that I might want to extend with some database data? Then I thought of Outlook.

Thankfully, John Goalby had already written some posts on querying Outlook data with LINQ. So I was well on my way!

I created a few new email accounts for some employees of companies in AdventureWorksLT and sent emails to myself with their accounts. Then I created contact records for them in Outlook in my own account, making sure that I typed in the company names to match the database. Now I had some test data.

First I tested out a query where I joined MailItems from my inbox with ContactItems from my contact. (Note that I did this in VB since John’s examples are in C#, so this gives a little more sample code for people to discover.)

Dim ol As Outlook._Application = New Outlook.Application
Dim inbox = ol.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

Dim contactfolder As Outlook.MAPIFolder = ol.ActiveExplorer.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

Dim emails = 
From email In inbox.Items.OfType(Of Outlook.MailItem)() Select email
Dim contacts = From contact In contactfolder.Items.OfType(Of Outlook.ContactItem)() Select contact

Dim
emailswithcompany = From email In emails Join contact In contacts _
    On email.SenderEmailAddress Equals contact.Email1Address _
    Select email, contact.CompanyName

For Each emailwithco In emailswithcompany
    Debug.Print(String.Format(“{0} from {1}: {2}”, _
       emailwithco.email.SenderName, emailwithco.CompanyName, emailwithco.email.Subject))
Next

This worked fine. I got a list of the sender and subject from the emails and company names from the contact records.

  • Katherine Harding from Sharp Bikes: Order 40 Shifters
  • John Harding from Sharp Bikes: modification to recent order
  • Keith Harris from Progressive Sports: vendor appreciation party

Then I queried the database and did a JOIN with the above results. It was funny to see how the types and subtypes kept growing as I built this up in layers. It’s nice to have things organized, but if I were starting from scratch, I might do this a bit differently so that my resulting types aren’t so complex*.

Dim awdc As New awlinqDataContext
Dim custSalesPerson = From cust In awdc.AWCustomers Select cust.CompanyName, cust.SalesPerson
Dim emailswithcompanysp = From emailco In emailswithcompany _
   Join cust In custSalesPerson _
   On cust.CompanyName Equals emailco.CompanyName _
   Select emailco, cust.SalesPerson

For Each emailwithcosalesp In emailswithcompanysp 
  Debug.Print(String.Format(“{0} from {1}: {2}” & NewLine & “SalesPerson:{3}”, _
    emailwithcosalesp.emailco.email.SenderName, _
    emailwithcosalesp.emailco.CompanyName, _
    emailwithcosalesp.emailco.email.Subject, _
    emailwithcosalesp.SalesPerson))
Next

And voila!

  • Katherine Harding from Sharp Bikes: Order 40 Shifters
    SalesPerson:adventure-works\josé1
  • John Harding from Sharp Bikes: modification to recent order
    SalesPerson:adventure-works\josé1
  • Keith Harris from Progressive Sports: vendor appreciation party
    SalesPerson:adventure-works\david8

Now I could write an app that can distribute email to the correct sales people when they come into a general mail box! Well, I supposed I could have done it prior to having LINQ (or maybe in Exchange which I know nothing about), just with a lot more effort!

*I couldn’t resist streamlining the final solution.

Dim ol As Outlook._Application = New Outlook.Application
Dim inbox = ol.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim contactfolder As Outlook.MAPIFolder = ol.ActiveExplorer.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
Dim emails = From email In inbox.Items.OfType(Of Outlook.MailItem)() Select email
Dim contacts = From contact In contactfolder.Items.OfType(Of Outlook.ContactItem)() Select contact
Dim awdc As New awlinqDataContext
Dim custSalesPerson = From cust In awdc.AWCustomers Select cust.CompanyName, cust.SalesPerson

‘now query across emails, contacts and custSalesPerson in one query

Dim emailcontactsp = From email In emails Join contact In contacts _
  On email.SenderEmailAddress Equals contact.Email1Address _
  Join custsalesp In custSalesPerson On contact.CompanyName Equals custsalesp.CompanyName _
  Select email, contact.CompanyName, custsalesp.SalesPerson

For Each ecsp In emailcontactsp
Debug.Print(String.Format(“{0} from {1}: {2}” & NewLine & “SalesPerson:{3}”, _
   ecsp.email.SenderName, _
   ecsp.CompanyName, _
   ecsp.email.Subject, _
   ecsp.SalesPerson))
Next

Re-Visiting an old VB6 problem – the disappearing mouse wheel-scrolling functionality

A million years ago, when Windows 2000 came out, many VB6 developers got calls from users that the scroll wheel stopped working in their VB6 applications.

It didn’t take long for the fix (Install Intellimouse v4.0) to get shared on newsgroups and forums. (This was pre-blog days; do you even remember those?)

I have a client who has that Intellimouse install tucked away on the server to apply to new computers being set up with my old apps and it’s worked charmingly for years.

But a few months ago, a user got a new p.c. and the fix didn’t work. His job requires him to make heavy use of a function that has a big FlexGrid and not having the ability to use the scroll wheel definitely cramped his style and impeded the efficiency of his work.

I found a KB that offered a solution for the IDE, but not compiled exes. I dug into the mouse drivers on his compuer but there was no way to uninstall them.

Finally, on the VB newsgroups, MVP Ken Halter suggested a code fix that was on PlanetSourceCode.

Scroll Wheel Support: http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=48722&lngWId=1

It contains two modules that futz around with some Win32 stuff to get the scroll wheel to be noticed by VB6. You need to add those modules to your project and then make a call to a function passing in the window handler of your control when you fire up your form and then a detach function as you unload the form.

Simple as heck and worked like a charm!

(and generated this very happy note from the user: IT WORKS!!!  THANKS!!)

Query Notifications and LINQ to SQL – Well I’ll be, you *can* do it (with caveats)

I’m ashamed that this is STILL on my to-do list as I have probably written and presented more about Query Notification than most people. But I see via Roger Jennings blog that Ryan Dunn has the key of the implementation posted on his blog (by way of a hot tip from Mike Pizzo on the DP* team :-)).

To activate Query Notification, you need to get a query “registered” in SQL Server’s Service Broker then listen for a notification.

ADO.NET 2.0’s SqlDependency class does all the dirty work then all you need to do is create a SqlDependency object and attach it to a SqlCommand before you execute it. When the command gets to the server, the server sees the dependency and sets up the watch and the notification in Service Broker. When SQL Server sees something change that would impact the results of your query, it fires back a notification. SqlDependency has an event handler to catch that notification as well as other properties to interact with it.

SqlNotification is a more low level approach for complex scenarios where you want to have more control over the process. Here you need to create your own listener.

ASP.NET also uses Query Notification with the SqlCacheDependency object as well as dynamically engaging it in the Page directive.

The obvious (if you have played with this stuff) problem here is that with LINQ to SQL, we are not executing the command ourselves. So how do we register a query with service broker and how do we listen for it?

Rather than attaching the SqlDependency to a SqlCommand, you can expliclty wire up some instructions to have the SqlDependency taken along when a call is made to SqlServer. Pretty cool, although I’m already wondering about how I might want to control that. Certainly you don’t want to attempt to register EVERY SINGLE query with Service Broker. Many will fail anyway and when that happens you get an immediate notice about the failure. There are a limited scope of scenarios in which QueryNotification is a benefit (oft-called and infrequently changing data e.g. “states in the u.s.” “categories of items we sell”) and plenty of rules about what is and is not a valid query for notification. With a blanket approach, you could be creating a performance nightmare.

The key is the CallContext class, which is buried in System.Runtime.Remoting.Messaging. I’ve never heard of it before and would never ever have figured this out on my own! Here’s more info on CallContext.

Here’s the critical line of code from Ryan’s post which has a more complete example of using SqlDependency in it’s simplest form, which is always the right place to start.

  System.Runtime.Remoting.Messaging.CallContext.SetData(“MS.SqlDependencyCookie”, dependency.Id)

So now my todo list is getting edited. I will have to see how to control this puppy and also what happens when you use the asp.net page directive.

(*DP=Data Programmability)

LINQ to SQL and stored procedures

I’ve been watching Roger Jennings blog as he forayed into hammering on the use of stored procs in LINQ to SQL. Like a great and supportive pal, I sat on the sidelines while he dug dizzyingly deeper and deeper to try to work out issues with what a stored proc actually returns (different than using LINQ to get dynamic sql) and it’s impact on paging with databound asp.net controls as well as loading children. It also impacts the use of LINQDataSource.

I definitely have an interest as I’m doing some more talks on LINQ and Databinding later this fall.

Today he reports that with the required obsessive persistence (grin) and help from Matt Warren, he’s only solved one of the issues he was running into and 1/4 of another one. (It took me a while to figure out his math on that!)

Here is are the related posts:

Problems Using Stored Procedures for LINQ to SQL Data Retrieval  This post has been updated to reflect his up-to-date findings.

Update and summary of the problem is included at the top of this post LINQ and Entity Framework Posts for 9/14/2007+

On a related front, Mike Taulty has started digging into disconnected LINQ to SQL. Mike is one of the web services gentry in my mind, so I definitely trust his conclusions. Rick Strahl has some interesting posts on it as well. I’ve been trying to work out the same scenarios with Entity Framework (with XML serialization and binary) and the challenges and solutions are pretty similar so there’s a ton that we can learn from each other.

Entities, Viewstate and postback

I was fiddling with Entity Framework in a website and was happy to see how smoothly objects serialize (binary serialization) across postbacks.

Query for one customer along with their SalesOrderHeaders:

  Dim query = (From cust In aw.Customer.Include(“SalesOrderHeader”) Where cust.CustomerID = 151)

Grab that customer into an object:

Note, I’ve found a problem with using .First in the query… Include is not working, so this is a temporary long way around…

  For Each c In query
    cust=c
  Next

Now shove it in viewstate

  ViewState.Add(“mycust”,c)

Postback, then recall the customer:

 cust = ViewState(“mycust”)

Be sure that cust is explicitly cast to a Customer.

You will find that not only is the customer in tact with it’s EntityKey, but all of the SalesOrder headers are there as well. So as far as I can tell, it was retained in its entirety.

Be careful however with assumptions about object state!

If you make a change to the object before adding it to ViewState, when you rehydrate the object, the state information won’t survive. This is expected behavior. The ObjectContext is responsible for managing the state of it’s objects. When you detach, you lose the state.

I’ve been playing with different ways of dealing with that if you care at all about concurrency when you do updates – using SaveChanges or using stored procedures. You can see a very long discussion of this in the forums if you are interested.