September 7, 2012 at 3:01 PM

For a recent project I had to work with Windows Server AppFabric Caching. One of the requirements was to retrieve the CacheStatistics from the AppFabric cache.

To retrieve these statistics you have to use PowerShell by using following commands:

clip_image001

 

Offcourse we needed this data in our .NET Application and not in PowerShell.
We needed to call the PowerShell cmdlets from our .NET Application to be able to retrieve that data. This is how we did it.

First of all add a reference to the following assemblies:

clip_image001[6]

 

The next step is to initialize the PowerShell RunSpace and initialize all the necessary values and objects as shown below:

clip_image001[8]

 

When the pipeline is created we can start sending commands; Always start your command sequence with the "Use-CacheCluster" command.
In the code below you can see how we actually retrieved the CacheStatistics from the AppFabric Cache.

clip_image001[10]

 

For a full list of the available AppFabric Caching PowerShell cmdlets please see following links:

http://msdn.microsoft.com/en-us/library/hh475806
http://msdn.microsoft.com/en-us/library/hh851388

 

Enjoy!

 

Glenn


June 22, 2012 at 2:40 PM

For a recent project I needed to create and modify the party settings for a specific party through code.

All the ‘basic’ settings like UNA/UNB/Validation/… where rather easy to configure and are pretty straight forward.

However when wanting to configure the UNG segment, we ran into some issues.

 

But first things first, let’s create a new Party

image

 

To modify the EDI properties through code you need to initialize/load a Partner profile as shown below

image

 

When you loaded/created the Partner profile it’s rather straight forward to modify the basic Party Settings.

image

 

The real problem started when we had to create a UNG segment trough code.
To create a UNG you need to create a PartnerEdifactReceiverGroupUpdatable object and add it to the EdifactReceiver as shown below:

image

 

The actual problem here is that the PartnerEdifactReceiverGroupUpdatable class has no constructors defined. Also extending the base class

or implementing the interface did not give us the desired result.

 

After some investigation we ran into the GetUninitializedObject method from the FormatterServices class (http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatterservices.getuninitializedobject.aspx).

This method will create a new object of a class without calling the constructor, that way we initialized a new instance of PartnerEdifactReceiverGroupUpdatable and managed to create the UNG segment as show below.

 

image

 

Enjoy!

 

Glenn Colpaert

Posted in: BizTalk | EDI/AS2 | General

Tags: