Showing posts with label Biztalk tools. Show all posts
Showing posts with label Biztalk tools. Show all posts

Wednesday, August 06, 2008

BizTalk Business Rules Engine Handy functions in .NET

Working with the BizTalk 2006 R2 BRE api, I find myself going back to this code to start of as a base. These 2 functions get ALL of the versions of the policies or vocabularies.  If you want to work with only the latest, or the published ones, change the RulesStore.Filter enum to whatever your needs.

List of Policies

   1: public void GetPoliciesList()
   2: {
   3:     Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver breDriver =
   4:         new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
   5:     Microsoft.RuleEngine.RuleStore breStore = breDriver.GetRuleStore();
   6:  
   7:     Microsoft.RuleEngine.RuleSetInfoCollection colPolInfo = null;
   8:     colPolInfo = breStore.GetRuleSets(RuleStore.Filter.All);
   9:     foreach (RuleSetInfo pInfo in colPolInfo)
  10:     {
  11:         Trace.WriteLine(string.Format("bts- Info = [{0}].v.{1}.{2}",
  12:             pInfo.Name, pInfo.MajorRevision, pInfo.MinorRevision));
  13:  
  14:         //get the policies to extract rules
  15:         Microsoft.RuleEngine.RuleSet pol = breStore.GetRuleSet(pInfo);
  16:         Trace.WriteLine(string.Format("bts- Count = [{0}]", pol.Rules.Count));
  17:     }
  18: }

This is how to get a list of all policies published on the BRE database.  Once you get all of the RuleSets, you can loop through each of them to retrieve the actual rules behind them.  Before getting to the rules, you need to get a RuleSet out of the RuleSetInfo.


List of Vocabularies



   1: public void GetVocabulariesList()
   2: {
   3:     Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver breDriver = 
   4:         new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
   5:     Microsoft.RuleEngine.SqlRuleStore sqlRuleStore = (SqlRuleStore)breDriver.GetRuleStore();
   6:  
   7:     Microsoft.RuleEngine.VocabularyInfoCollection colVocInfo = null;
   8:     colVocInfo = sqlRuleStore.GetVocabularies(RuleStore.Filter.All);
   9:     foreach (VocabularyInfo vInfo in colVocInfo)
  10:     {
  11:         Trace.WriteLine(string.Format("bts- vInfo = [{0}].v.{1}.{2}",
  12:             vInfo.Name, vInfo.MajorRevision, vInfo.MinorRevision));
  13:  
  14:         //get the vocabulary to extract collection of definitions
  15:         Microsoft.RuleEngine.Vocabulary voc = sqlRuleStore.GetVocabulary(vInfo);
  16:         Trace.WriteLine(string.Format("bts- Count = [{0}]", voc.Definitions.Count));
  17:     }
  18: }

This is how to get a list of all vocabularies published on the BRE database.  If you need to see how to get to all of the definitions on a particular vocabulary, see my previous post: How to access BRE Vocabularies from .NET.


Noticed that there are some subtle differences in how you retrieve each piece of information.  For Policies you get a RuleStore while to get the Vocabularies you need to get a SQLRuleStore.


As usual, feedback is always welcome if you use this code.

Tuesday, November 06, 2007

My Biztalk Tools

For our group [Connected system] we started talking about what each of us was using to develop on BizTalk.

We come out with a list of tools. Here I am going to publish the tools that I have installed and that I used most of the time.

DebugView: of course this is the number one. ;) I like to use it with a filter, so that I only see the trace information that I send. For instance I pre-append the word: bts- to all of my trace.writelines.
System.Diagnostics.Trace.WriteLine(String.Format("bts- args: [{0}]", args));

DTC Tester Tool: this will test the configuration of your Distributed Transaction settings. It will come in handy when you have to setup BizTalk in multiple environments.


Biztalk Best Practice Analyzer tool: this will evaluate the installation of BizTalk. Helpful in those cases that you come into a client that has pre-installed BizTalk on their environment.

It not only analyzes your BizTalk installation, but it also give you the documentation as to why this is important. It also gives you the steps to go about fixing any problems that it find with your configuration.


SmartPaster: this is one of those ideas that one person implements, and now after using it a few times, I can't live without. Nice work.


CopySourceAsHtml: I use this add-in to html-encode my source code before I post it on my blog.



Biztalk Documenter: This tool out of codeplex is a good addition to that *finish* touch on your projects. One thing that I like about it is that it takes a snapshot of your orchestration and create the MSDN style documentation. It is also a great tool to document those BRE's. It creates a treeview like view of all your rules and their predicates. I run this during and at the end of the projects to document my artifacts and Business Rules Policies and Vocabularies.


Notepad 2: Another free tool that is in my list of AWESOME tools to use. No installation required and it provides all of the functionality needed from a simple editor. One of the features that I like the most of this editor is the fact that it can format XML and it has the Always On Top option.!! I love to be able to copy long xpath's from the Biztalk schemas and paste on this editor. Keeping it on top of the other windows, make it very useful.

FoxitReader: I am a big fan of NOT installing tools. Specially when I am at a customer site, and have to use their equipment. I love to put my thumb drive in and be able to use any of the the tools in there without having to install them. FoxIt has a small footprint, and it lighting fast to open any PDF document.

Process Explorer: Yet another jewel from SysInternals. This one is a better task manager. it is very useful to see some of the process that are running on the background, and some of those *hidden* programs on the network.

WebService Studio: I have talked about this tool in the past here. It is still my favorite tool to quickly test an asmx web service.

Database Publishing Wizard: good to get data to and from different sql servers. I used it primarily to get schemas from the customer environment to my vpc sandbox, so that I can reproduce whatever condition/data that they require.


XML Spy: Although it is a commercial tool, I love their grid representation for xml schemas and just plain xml data. I have been a fan of this product since XML Spy version 3.0...!!

vs

Another cool feature of this tool is that it can instantiate Soap request into a web service.



HyperSnap: my screen capture tool of preference. I like the fact that you can capture a region and then you can save that snapshot to any of the major picture formats out there.

Beyond Compare 2: Windiff is child's play when you compare it to Beyond Compare 2. Download the 30-day and try it yourself. It allows you to visually pinpoint differences in 2 files down to the character that is not equal. It also provides editing within the comparison main screen, and it allows you to synch any changes from either of the files into the other one.

ReSharper 3.0: Last but not least my FAVORITE add-in for visual studio 2005.!! I started using this product back on DotNet 1.1, and I have been hooked on it ever since.