Archive

Archive for November, 2011

Windows 8 and building Metro apps

November 23, 2011 2 comments

I had a great time speaking at the Charlotte Enterprise Developers Guild last night.

Here are the slides and code for the presentation I made on Windows 8 and building Metro applications. We had a great turnout!

Thanks to everyone who came out and have a great Thanksgiving….

Advertisements

Win 8 & Building Metro Apps

November 19, 2011 Leave a comment

I will be speaking this Tuesday, November 22 at the Charlotte Enterprise Developer’s Guild in Charlotte, NC on Windows 8 and Building Metro applications. I will also be doing the same presentation on Thursday, December 15 at the WNC Developers Guild in Asheville, NC.

Here is my presentation summary:

Microsoft introduced a lot of new tools and goodies at the Build Conference in September. Let’s take a look and see what Windows 8 is all about. We will examine what it means to be “Metro” as well as roll up our sleeves and see what it takes to build an application. We will take a look at the tooling support in Windows 8 by looking at the developer preview for Visual Studio 2011 and Expression Blend. Come out and see what it takes to develop an application in Windows 8.

Look forward to seeing you there!

WCF RIA Services – “The maximum uri length of 2083 was exceeded.”

November 2, 2011 Leave a comment

I came across this exception the other day and thought it was weird enough to merit a post on it. In the enterprise system that I have designed I have the concept of a quick search and advanced search capabilities. You can see an example of quick search below:

When the user performs a quick search, the results are loaded into the Sidebar as well as into a DataPager for paging the data. Quick search is handled by allowing a user to enter in a ID or a business name. I handle this by creating two FilterDescriptors that operate against the properties that I want as shown below:

SearchFilterDescriptors.Add(new SearchFilterDescriptor("ID", FilterOperator.IsEqualTo, PropertyType.Integer));
SearchFilterDescriptors.Add(new SearchFilterDescriptor("Name", FilterOperator.StartsWith, PropertyType.String));

This works just fine in scenarios when I know exactly what I want to filter against but there are scenarios that I don’t know what the filter definition is going to be ahead of time. This is where the Advanced search screen comes into play:

With this screen, a user can select many properties that make up an “Account” record and then click the search button. A back-end process is created to find the set of records found and then I am dynamically creating FilterDescriptor objects. It was When I used a search criteria that brought back a lot of records that I received the following error:

Doing some research, I found this forum’s post as well as this blog entry discussing what I could do to fix this.

The interesting thing to note is that WCF RIA Services uses GET by default for all Query attributes. This explains why I was getting the exception due to the fact that I was building a query string that was larger than the maximum length.

It turns out that all I really needed to do was make a slight modification to my Query on the server as shown below:

[Query(HasSideEffects=true)]
public IQueryable<Organization> ReturnOrganization()
{
    return this.ObjectContext.Organization
        .OrderBy(x => x.OrganizationName);
}

By adding the HasSideEffects=true parameter WCF RIA Services uses Post instead of the default Get. Now we can have as complex a query as we want. This allowed me to have a dynamic advanced search screen and not worry about how many filters I was creating.

The way I accomplished this dynamically was by creating an instance of a FilterDescriptorCollection

var filter = new FilterDescriptorCollection();
foreach(var item in e.Value)
{
    var dto = item;
    filter.Add(new FilterDescriptor("ID", FilterOperator.IsEqualTo, dto.Value));
}
_eventAggregator.GetEvent<AdvancedSearchEvent>().Publish(filter);

I use Prism’s EventAggregator to send an event so that the other screen can be notified of the Advanced Search Event. On the main screen, I have this code in place to apply the filter:

public void OnAdvancedSearchEvent(FilterDescriptorCollection filter)
{
    if (filter.Count > 0)
    {
        View.DDS.FilterDescriptors.Clear();
        View.DDS.FilterOperator = FilterDescriptorLogicalOperator.Or;
        foreach(var item in filter)
        {
            var fd = item;
            View.DDS.FilterDescriptors.Add(fd);
        }
        View.DDS.Load();
    }
}

Another approach to this could be to handle the filter completely on the server and use a boolean parameter to indicate when to use the filter. Since my filter information was actually coming from the database I could have accomplished the same user experience but I would have never run into the this exception.

Hope this helps….

Windows 8 and building Metro apps

November 2, 2011 Leave a comment

I will be doing a presentation on Tuesday, November 22 at the Charlotte’s Enterprise Developers Guild. Here is a summary of what I will be presenting:

Microsoft introduces a lot of new tools and goodies at the Build Conference in September. Let’s take a look and see what Windows 8 is all about. We will examine what it means to be “Metro” as well as roll up our sleeves and see what it takes to build an application. We will take a look at the tooling support in Windows 8 by looking at the developer preview for Visual Studio 2011 and Expression Blend. Come out and see what it takes to develop an application in Windows 8.

Looking forward to it!

Categories: English Tags: , , ,

Raleigh Code Camp

November 2, 2011 Leave a comment

I will be presenting the following topic “Building a Windows Phone 7 App using JSON/ASP.NET MVC Data Service Layer” at the Raleigh Code Camp this weekend. We will take a look at leveraging ASP.NET MVC and JSON to become your best friend from the point of data serialization. Want to build a simple WP7 application? Want a simple way to pass data back and forth from the server? JSON seems to be the obvious choice when developing web applications, how does it work when developing WP7 applications? I am looking forward to it!

Categories: English Tags: , , , , ,