by community-syndication | Apr 22, 2010 | BizTalk Community Blogs via Syndication
In two of my previous entries I outlined functionality and patterns used in the AppFabric Cache. In this entry I wanted to expand and look at another area of functionality that people have come to expect when working with cache technology.
This expectation is the ability to tag content with more information than just the key. As you start to examine this expectation you will soon find yourself asking if the tagged data can be related to each other and finally if it is possible to remove the related data.
One of the nice things about the AppFabric Cache is that it is so easy to work with and can be so simple. Then, if needed, like with this topic, you can take advantage of the addition functionality. This is where the real benefits of AppFabric Cache come into play over the other cache alternatives.
Lets take a deeper look at tagging. Tagging is essentially assigning one or more string values to an object contained in the cache. The object in the cache can then be retrieved by using the tag or multiple tags. When you tag an object, all of the tagged objects will reside within a region. A region is an additional container inside the cache. Because regions are optional, if you want to use them you need to explicitly create them at runtime within your application code. You can setup different regions for different types of related data. When you utilize regions, you have the option to retrieve all objects in that region and therefore by default have setup a solution that now provides you access to all the dependent data. We can take this one step further in that you can also delete all of the data within a region and not have to worry about looping through all entries to find the specific keys and their dependencies.
As an example we could create a region called ‘Beverages’ and then we could cache all of the beverages we sell and tag each item by the type of beverage such as Soft Drink, Wine, Beer. We could even go one step further and provide multiple tags so that we could further segment the Wine category into White or Red or Merlot, Zinfandel, Riesling, etc. At this point the application could retrieve all of the catalog items based on the search criteria that were entered.
Lets look at how we can setup the region and tags. We will also look at the methods that are available to interact with objects using tags and lastly, how we can manage the data in the cache; adding, retrieving and deleting.
Setting Up a Region:
The code that follows assumes that you already now how to create a cache (either through code or through the PowerShell cmdlets (as found in my previous post here)).
To create a region we already need to have the cache created. Once that is done, we can pass in the cache name, use the GetCache method and then call the CreateRegion method passing in a region name. We can create as many regions as we need based on the manner in which you wish to segment the data. One thing to keep in mind however is that there can be performance implications when using regions. The code below shows how we can create the region.
private void CreateRegion(string CacheName, string RegionName)
{
//This can also be kept in a config file
var config = new DataCacheFactoryConfiguration();
config.Servers = new List<DataCacheServerEndpoint>
{
new DataCacheServerEndpoint(Environment.MachineName, 22233)
};
DataCacheFactory dcf = new DataCacheFactory(config);
if (dcf != null)
{
var dataCache = dcf.GetCache(CacheName);
dataCache.CreateRegion(RegionName);
}
}
Now that we have a cache with a region created lets look at the methods that are available to interact with tags
Methods to work with tagging (from MSDN):
Method |
Description |
|---|
GetObjectsByTag |
Provides a simple way to access objects that contain tags (exact match, intersection, or union). The region name is a required parameter. |
GetObjectsByAnyTag |
Returns a list of objects that have tags matching any of the tags provided in the parameter of this method. |
GetObjectsByAllTags |
Returns a list of objects that have tags matching all of the tags provided in the parameter of this method. |
GetObjectsInRegion |
Returns a list of all objects in a region. This method is useful when you do not know all the tags used in the region. |
GetCacheItem |
Returns a DataCacheItem object. In addition to the cached object and other information associated with the cached object, the DataCacheItem object also includes the associated tags. |
Add |
When adding an object to cache, this method supports associating tags with that item in the cache. |
Put |
When putting an object into cache, this method can be used to replace tags associated with a cached object. |
Remove |
This method deletes the cached object and any associated tags. |
Managing the data in the cache
There are a number of methods to get objects out of the cache but logically I like to start in terms of adding to the cache first. So, lets take a look at the put method. The put method will update an object that already has a key that is contained in the cache (whereas the Add will return an exception if the key is already present). The put method can also update or add new tags to an existing object in the cache. As we look at the Put method signature below we can see that this version of the method accepts the key and value just as the other overrides of the Put method do but this one also adds on a collection of tags as well as the name of the region that the cached item will reside in.
public DataCacheItemVersion Put (
string key,
Object value,
IEnumerable<DataCacheTag> tags,
string region
)
The code below shows how we can use the Put method and include multiple tags
private void InsertCacheObjectWithTag(string CacheName, string RegionName)
{
//This can also be kept in a config file
var config = new DataCacheFactoryConfiguration();
config.Servers = new List<DataCacheServerEndpoint>
{
new DataCacheServerEndpoint(Environment.MachineName, 22233)
};
DataCacheFactory dcf = new DataCacheFactory(config);
if (dcf != null)
{
List<DataCacheTag> tags = new List<DataCacheTag>
{
new DataCacheTag(“Wine”),
new DataCacheTag(“Red”),
new DataCacheTag(“Merlot”)
};
var dataCache = dcf.GetCache(CacheName);
dataCache.Put(“WineKey”, “WineValue”, tags, RegionName);
}
}
Now we can look at the methods to retrieve objects. There are four main Get methods. We can get by tag, any tag, all tags and finally any object that exists in the region no matter what tag. The GetObjectsInRegion method is what provides us the ability to implement a scenario in which all cached objects are related and can be treated as a group. The related data can also be removed by called dataCache.RemoveRegion(RegionName) just as we called the CreateRegion method above.
For people that have been working with Memcached you can delete dependent data through the cas (check and set) operation. The reason that I bring this up is that more people are familiar with Memcached and therefore I am asked if AppFabric Caching has this or that functionality. What I am finding is that it has the same functionality and more. It is just implemented a bit differently.
Anyways, if we want to retrieve all the objects in the cache that have a Wine tag we can use the GetObjectsByTag as shown below:
public IEnumerable<KeyValuePair<string, object>> GetLookUpCacheDataByTag(string TagValue)
{
var config = new DataCacheFactoryConfiguration();
config.Servers = new List<DataCacheServerEndpoint>
{
new DataCacheServerEndpoint(Environment.MachineName, 22233)
};
DataCacheFactory dcf = new DataCacheFactory(config);
var cache = dcf.GetCache(cacheName);
DataCacheTag dct = new DataCacheTag(TagValue);
return cache.GetObjectsByTag(dct, regionName); //regionName could either be passed in or an internal variable
}
and lastly, we can remove items based on a tag. I already mentioned that we can call the RemoveRegion method to remove all the related data that is grouped together in a region. If there is a specific item that you want removed then you can call the Remove method and pass in the key. If you wanted to delete based on a tag value then you would have to call one of the GetXXX methods, obtain the key, and then call the Remove method by passing the returned key value.
by community-syndication | Apr 22, 2010 | BizTalk Community Blogs via Syndication
We recently released a new free Silverlight 4 Training Kit that walks you through building business applications with Silverlight 4. You can browse the training kit online or alternatively download an entire offline version of the training kit.
The training material is structured on teaching how to use the new Silverlight 4 features to build an end to end business application. The training kit includes 8 modules, 25 videos, and several hands on labs. Below is a breakdown and links to all of the content.
[In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu]
Module 1: Introduction
Click here to watch this module.
In this video John Papa and Ian Griffiths discuss the key areas that the Building Business Applications with Silverlight 4 course focuses on. This module is the overview of the course and covers many key scenarios that are faced when building business applications, and how Silverlight can help address them.

Module 2: WCF RIA Services
Click here to explore this module.
In this lab, you will create a web site for managing conferences that will be the basis for the other labs in this course. Don’t worry if you don’t complete a particular lab in the series – all lab manual instructions are accompanied by completed solutions, so you can either build your own solution from start to finish, or dive straight in at any point using the solutions provided as a starting point.
In this lab you will learn how to set up WCF RIA Services, create bindings to the domain context, filter using the domain data source, and create domain service queries.
Videos
Module 2.1 – WCF RIA Services
Ian Griffiths sets up the Entity Framework and WCF RIA Services for the sample Event Manager application for the course. He covers how to set up the services, how the Domain Services work and the role that the DomainContext plays in the sample application. He also reviews the metadata classes and integrating the navigation framework.
Module 2.2 – Using WCF RIA Services to Edit Entities
Ian Griffiths discusses how he adds the ability to edit and create individual entities with the features built into WCF RIA Services into the sample Event Manager application. He covers data binding fundamentals, IQueryable, LINQ, the DomainDataSource, navigation to a single entity using the navigation framework, and how to use the Visual Studio designer to do much of the work .
Module 2.3 – Showing Master/Details Records Using WCF RIA Services
Ian Griffiths reviews how to display master/detail records for the sample Event Manager application using WCF RIA Services. He covers how to use the Include attribute to indicate which elements to serialize back to the client. Ian also demonstrates how to use the Data Sources window in the designer to add and bind controls to specific data elements. He wraps up by showing how to create custom services to the Domain Services.
Module 3 – Authentication, Validation, MVVM, Commands, Implicit Styles and RichTextBox
Click here to visit this module.
This lab demonstrates how to build a login screen, integrate ASP.NET authentication, and perform validation on data elements. Model-View-ViewModel (MVVM) is introduced and used in this lab as a pattern to help separate the UI and business logic. You will also learn how to use implicit styling and the new RichTextBox control.
Videos
Module 3.1 – Authentication
Ian Griffiths covers how to integrate a login screen and authentication into the sample Event Manager application. Ian shows how to use the ASP.NET authentication and integrate it into WCF RIA Services and the Silverlight presentation layer.
Module 3.2 – MVVM
Ian Griffiths covers how to Model-View-ViewModel (MVVM) patterns into the sample Event Manager application. He discusses why MVVM exists, what separated presentation means, and why it is important. He shows how to connect the View to the ViewModel, why data binding is important in this symbiosis, and how everything fits together in the overall application.
Module 3.3 -Validation
Ian Griffiths discusses how validation of user input can be integrated into the sample Event Manager application. He demonstrates how to use the DataAnnotations, the INotifyDataErrorInfo interface, binding markup extensions, and WCF RIA Services in concert to achieve great validation in the sample application. He discusses how this technique allows for property level validation, entity level validation, and asynchronous server side validation.
Module 3.4 – Implicit Styles
Ian Griffiths discusses how why implicit styles are important and how they can be integrated into the sample Event Manager application. He shows how implicit styles defined in a resource dictionary can be applied to all elements of a particular kind throughout the application.
Module 3.5 – RichTextBox
Ian Griffiths discusses how the new RichTextBox control and it can be integrated into the sample Event Manager application. He demonstrates how the RichTextBox can provide editing for the event information and how it can display the rich text for selection and copying.
Module 4 – User Profiles, Drop Targets, Webcam and Clipboard
Click here to visit this module.
This lab builds new features into the sample application to take the user’s photo. It teaches you how to use the webcam to capture an image, use Silverlight as a drop target, and take advantage of programmatic access to the clipboard.
- Link
- Download Source
- Download Lab Document
Videos
Module 4.1 – Webcam
Ian Griffiths demonstrates how the webcam adds value to the sample Event Manager application by capturing an image of the attendee. He discusses the VideoCaptureDevice, the CaptureDviceConfiguration, and the CaptureSource classes and how they allow audio and video to be captured so you can grab an image from the capture device and save it.
Module 4.2 – Drag and Drop in Silverlight
Ian Griffiths demonstrates how to capture and handle the Drop in the sample Event Manager application so the user can drag a photo from a file and drop it into the application. Ian reviews the AllowDrop property, the Drop event, how to access the file that can be dropped, and the other drag related events. He also reviews how to make this work across browsers and the challenges for this.
Module 5 – Schedule Planner and Right Mouse Click
Click here to visit this module.
This lab builds on the application to allow grouping in the DataGrid and implement right mouse click features to add context menu support.
- Link
- Download Source
- Download Lab Document
Videos
Module 5.1 – Grouping and Binding
Ian Griffiths demonstrates how to use the grouping features for data binding in the DataGrid and how it applies to the sample Event Manager application. He reviews the role of the CollectionViewSource in grouping, customizing the templates for headers, and how to work with grouping with ItemsControls.
Module 5.2 – Layout Visual States
Ian Griffiths demonstrates how to use the Fluid UI animation support for visual states in the ListBox control DataGrid and how it applies to the sample Event Manager application. He reviews the 3 visual states of BeforeLoaded, AfterLoaded, and BeforeUnloaded.
Module 5.3 – Right Mouse Click
Ian Griffiths demonstrates how to add support for handling the right mouse button click event to display a context menu for the Event Manager application. He demonstrates how to handle the event, show a custom context menu control, and integrate it into the scheduling portion of the application.
Module 6 – Printing the Schedule
Click here to visit this module.
This lab teaches how to use the new printing features in Silverlight 4. The lab walks through the PrintDocument class and the ViewBox control, while showing how to print multiple pages of content using them.
- Link
- Download Source
- Download Lab Document
Videos
Module 6.1 – Printing and the Viewbox
Ian Griffiths demonstrates how to add the ability to print the schedule to the sample Event Manager application. He walks through the importance of the PrintDocument class and its members. He also shows how to handle printing the visual tree and how the ViewBox control can help.
Module 6.2 – Multi Page Printing
Ian Griffiths expands on his printing discussion by showing how to handle printing multiple pages of content for the sample Event Manager application. He shows how to paginate the content and points out various tips to keep in mind when determining the printable area.
Module 7 – Running the Event Dashboard Out of Browser
Click here to visit this module.
This lab builds a dashboard for the sample application while explaining the fundamentals of the out of browser features, how to handle authentication, displaying notifications (toasts), and how to use native integration to use COM Interop with Silverlight.
- Link
- Download Source
- Download Lab Document
Videos
Module 7.1 – Out of Browser
Ian Griffiths discusses the role of an Out of Browser application for administrators to manage the events and users in the sample Event Manager application. He discusses several reasons why out of browser applications may better suit your needs including custom chrome, toasts, window placement, cross domain access, and file access. He demonstrates the basic technique to take your application and make it work out of browser using the tools.
Module 7.2 – NotificationWindow (Toasts) for Elevated Trust Out of Browser Applications
Ian Griffiths discusses the how toasts can be used in the sample Event Manager application to show information that may require the user’s attention. Ian covers how to create a toast using the NotificationWindow, security implications, and how to make the toast appear as needed.
Module 7.3 – Out of Browser Window Placement
Ian Griffiths discusses the how to manage the window positioning when building an out of browser application, handling the windows state, and controlling and handling activation of the window.
Module 7.4 – Out of Browser Elevated Trust Application Overview
Ian Griffiths discusses the implications of creating trusted out of browser application for the Event Manager sample application. He reviews why you might want to use elevated trust, what features is opens to you, and how to take advantage of them. Topics Ian covers include the dynamic keyword in C# 4, the AutomationFactory class, the API to check if you are in a trusted application, and communicating with Excel.
Module 8 – Advanced Out of Browser and MEF
Click here to visit this module.
This hands-on lab walks through the creation of a trusted out of browser application and the new functionality that comes with that. You will learn to use COM Automation, handle the window closing event, set custom window chrome, digitally sign your Silverlight out of browser trusted application, create a silent install option, and take advantage of MEF.
- Link
- Download Source
- Download Lab Document
Videos
Module 8.1 – Custom Window Chrome for Elevated Trust Out of Browser Applications
Ian Griffiths discusses how to replace the standard operating system window chrome with customized chrome for an elevated trusted out of browser application. He covers how it is important to handle close, resize, minimize, and maximize events. Ian mentions that the tooling was not ready when he shot this video, but the good news is that the tooling now supports setting the custom chrome directly from the property page for the Silverlight application.
Module 8.2 – Window Closing Event for Out of Browser Applications
![clip_image006[14] clip_image006[14]](https://weblogs.asp.net/blogs/scottgu/clip_image00614_329E2034.gif)
Ian Griffiths discusses the WindowClosing event and how to handle and optionally cancel the event.
Module 8.3 – Silent Install of Out of Browser Applications
Ian Griffiths discusses how to use the SLLauncher executable to install an out of browser application. He discusses the optional command line switches that can be set including how the emulate switch can help you emulate the install process. Ian also shows how to setup a shortcut for the application and tell the application where it should look for future updates online.
Module 8.4 – Digitally Signing Out of Browser Application
Ian Griffiths discusses how and why to digitally sign an out of browser application using the signtool program. He covers what trusted certificates are, the implications of signing (or not signing), and the effect on the user experience.
Module 8.5 – The Value of MEF with Silverlight
Ian Griffiths discusses what MEF is, how your application can benefit from it, and the fundamental features it puts at your disposal. He covers the 3 step import, export and compose process as well as how to dynamically import XAP files using MEF.
Summary
As you can probably tell from the long list above – this series contains a ton of great content, and hopefully provides a nice end-to-end walkthrough that helps explain how to take advantage of Silverlight 4 (and all its new features).
Hope this helps,
Scott
by community-syndication | Apr 21, 2010 | BizTalk Community Blogs via Syndication
Well this post is more of a note to myself on how to do this and is the 1st of many that have been backing up behind a broken DNN site, which has now been fixed.
So a bit of history on this issue, in version of BizTalk before 2009, HWS was installed as part of BizTalk and installing HWS it setup all the necessary configuration to make BTSHTTPReceive.dll work in IIS, with BizTalk 2009 HWS was removed from BizTalk and BTSHTTPReceive.dll was not longer automatically configured to work in IIS. So hear are the instruction to make it work in IIS, specifically IIS 7.
Configuring BTSHTTPReceive.dll on x86 version of Windows 2008 with IIS 7
Open IIS Manager (not the 6.0 version), click on the machine name in the tree, then click on “Handler Mapping” in the Features View:
Then click on “Add Script Map” in the Action pane:
On the “Add Script Map” window set the following values:
Request path: BTSHTTPReceive.dll
Executable: \HttpReceive\BTSHTTPReceive.dll
Name:
Then click the “Request Restrictions” button:
On the Verb Tab, Type POST
On the Access Tab, Select Script
Click OK to close the “Request Restrictions” window
Click OK to close the “Add Script Map” window
This warning windows then appears, Click Yes
The BTSHTTPReceive entry will now appear in the Handler Mapping window at the bottom of the Enabled section.
You can now create your IIS virtual directory and BTS Receive location as you have done previously.
Configuring BTSHTTPReceive.dll on x64 version of Windows 2008 with IIS 7
This is the same process for the x64 version, but BizTalk has supplied a x64 version of BTSHTTPReceive.dll, so perform the same steps as above but with the following changes to the “Add Script Map” window:
Executable: \HttpReceive64\BTSHTTPReceive.dll
One additional note about the x64 environment, you can run both 32bit and 64bit application in IIS, the Application Pool has a setting to control this, under the advanced settings:
So you may want to setup both the script mapping for 32bit and 64bit on your x64 systems.
Hope this helps when you need to setup a HTTP receive location in BizTalk.
More details on whole BTSHTTPReceive.dll setup and configuration can be found here: http://technet.microsoft.com/en-us/library/aa559072(BTS.10).aspx