static void CleanUp(string RSName) { // Clean up deployed ruleset Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); RuleStore sqlrs; bool bDeployed = false; sqlrs = dd.GetRuleStore(); RuleSetInfoCollection rss = new RuleSetInfoCollection(); rss = sqlrs.GetRuleSets(RSName, RuleStore.Filter.Latest); int i = 0; if (rss.Count > 0) { for (i = 0; i < rss.Count; i++) { bDeployed = dd.IsRuleSetDeployed(rss[i]); if (bDeployed) { dd.Undeploy(rss[i]); } sqlrs.Remove(rss[i]); } } } // End of Cleanup()
public static VocabularyInfoCollection GetPublishedVocabularies() { Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); SqlRuleStore ruleStore = (SqlRuleStore)dd.GetRuleStore(); return(ruleStore.GetVocabularies(RuleStore.Filter.Published)); }
private static void ExportPolicies() { // RuleSetDeploymentDriver has the following important methods Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); // SqlRuleStore - gives access t0 the rule engine database SqlRuleStore sqlRuleStore = (SqlRuleStore)dd.GetRuleStore(); // Establish the export file FileRuleStore fileRuleStore = new FileRuleStore(policyExportPath); CopyPolicies(sqlRuleStore, fileRuleStore, dd); }
public static void ExportVocabularies() { // RuleSetDeploymentDriver has the following important methods Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); // SqlRuleStore - gives access t0 the rule engine database SqlRuleStore sqlRuleStore = (SqlRuleStore)dd.GetRuleStore(); // Establish the export file FileRuleStore fileRuleStore = new FileRuleStore(vocabExportPath); CopyVocabularies(sqlRuleStore, fileRuleStore); }
public static string GetRules(RuleSetInfo ruleSetInfo) { string savedPath = Path.Combine(GenericHelper.GetTempFolder(Environment.MachineName), string.Format("{0}_{1}_{2}.xml", ruleSetInfo.Name, ruleSetInfo.MajorRevision.ToString(), ruleSetInfo.MinorRevision.ToString())); Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); dd.ExportRuleSetToFileRuleStore(ruleSetInfo, savedPath); string data = File.ReadAllText(savedPath, Encoding.UTF8); File.Delete(savedPath); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(data); return(xDoc.Beautify()); }
public static RuleSetInfoCollection GetNamedRuleSets(string name) { RuleSetInfoCollection namedRuleCollection = new RuleSetInfoCollection(); Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); RuleSetInfoCollection ruleCollection = dd.GetDeployedRuleSets(); foreach (RuleSetInfo rule in ruleCollection) { if (rule.Name == name) { namedRuleCollection.Add(rule); } } return(namedRuleCollection); }
public static int UnDeployPolicy(string policyName, int majorVersion, int minorVersion, out string message) { int result = 0; try { Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver rdd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); RuleSetInfo rsi = new RuleSetInfo(policyName, majorVersion, minorVersion); rdd.Undeploy(rsi); message = "Successfully Un-Deployed"; } catch (Exception exe) { message = exe.Message; return(-1); } return(result); }
public static int DeleteVocabulary(string name, int majorVersion, int minorVersion, out string message) { int result = 0; try { VocabularyInfo vInfo = new VocabularyInfo(name, majorVersion, minorVersion); Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver rdd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); SqlRuleStore ruleStore = (SqlRuleStore)rdd.GetRuleStore(); ruleStore.Remove(vInfo); message = "Successfully Deleted"; } catch (Exception exe) { message = exe.Message; return(-1); } return(result); }
public static int Import(string fileName, out string message) { int result = 0; try { Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); // SqlRuleStore - gives access t the rule engine database SqlRuleStore sqlRuleStore = (SqlRuleStore)dd.GetRuleStore(); dd.ImportAndPublishFileRuleStore(fileName); message = "Successfully imported and published"; } catch (Exception exe) { message = exe.Message; return(-1); } return(result); }
static void DeployRuleSet(RuleSet ruleset) { // Clean up the existing ruleset(s) in the rule store first // before publishing and deploying veriosn 1.0 CleanUp(ruleset.Name); // now we have the ruleset, need to copy it to the database Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); RuleStore sqlrs; sqlrs = dd.GetRuleStore(); // add the RuleSet to the database (and publish it) try { sqlrs.Add(ruleset, true); } catch (RuleStoreRuleSetAlreadyPublishedException) { Console.WriteLine("Warning: Ruleset \"" + ruleset.Name + "\" is already published"); } catch { throw; } // now deploy the ruleset try { dd.Deploy(new RuleSetInfo(ruleset.Name, ruleset.CurrentVersion.MajorRevision, ruleset.CurrentVersion.MinorRevision)); } catch (RuleEngineDeploymentAlreadyDeployedException) { Console.WriteLine("Warning: Ruleset \"" + ruleset.Name + "\" is already deployed"); } catch { throw; } }
static void CleanUp() { // Clean up deployed ruleset Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); RuleStore sqlrs; bool bDeployed = false; sqlrs = dd.GetRuleStore(); RuleSetInfoCollection rss = new RuleSetInfoCollection(); rss = sqlrs.GetRuleSets("SampleRuleset", RuleStore.Filter.All); int i = 0; if (rss.Count > 0) { for (i = 0; i < rss.Count; i++) { bDeployed = dd.IsRuleSetDeployed(rss[i]); if (bDeployed) { dd.Undeploy(rss[i]); } sqlrs.Remove(rss[i]); } } try { // Delete the SampleRuleStore.xml File.Delete("SampleRuleStore.xml"); } catch { Console.Write("Cannot delete SampleRuleStore.xml as it is being edited currently. Please delete this file before you run the sample again."); } }
public static RuleSetInfoCollection GetDeployedRuleSets() { Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); return(dd.GetDeployedRuleSets()); }
//Importing policies private static void CopyPolicies(RuleStore sourceRuleStore, RuleStore targetRuleStore, Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd) { RuleSetInfoCollection sourceRulesetInfoList = sourceRuleStore.GetRuleSets(RuleStore.Filter.All); RuleSetInfoCollection targetRulesetInfoList = targetRuleStore.GetRuleSets(RuleStore.Filter.All); foreach (RuleSetInfo targetItem in targetRulesetInfoList) { if (targetItem.Published) { } } foreach (RuleSetInfo item in sourceRulesetInfoList) { RuleSet policy = sourceRuleStore.GetRuleSet(item); RuleSet targetPolicy = targetRuleStore.GetRuleSet(item); try { System.Console.Out.WriteLine("Importing Policy ({0}) ..", policy.Name); targetRuleStore.Add(policy); } catch (Microsoft.RuleEngine.RuleStoreRuleSetAlreadyPublishedException e) { System.Console.Out.WriteLine("Importing Policy ({0}) : (RuleStoreRuleSetAlreadyPublishedException) Undeploying RulesetInfo {1}", policy.Name, item.Name); //dd.Undeploy(item); //System.Console.Out.WriteLine("Importing Policy ({0}) : (RuleStoreRuleSetAlreadyPublishedException) Successfully undeployed RulesetInfo {1}, next remove policy ", policy.Name, item.Name); bool toDeploy = false; try { targetRuleStore.Remove(policy); } catch (Microsoft.RuleEngine.RuleStoreRuleSetDeployedException ex) { dd.Undeploy(item); targetRuleStore.Remove(policy); toDeploy = true; } targetRuleStore.Add(policy); targetRuleStore.Publish(policy); if (toDeploy) { dd.Deploy(item); toDeploy = false; } } catch (Microsoft.RuleEngine.RuleStoreRuleSetDeployedException e) { System.Console.Out.WriteLine("Importing Policy ({0}) : (RuleStoreRuleSetDeployedException) Undeploying RulesetInfor {1}", policy.Name, item.Name); dd.Undeploy(item); targetRuleStore.Remove(policy); targetRuleStore.Add(policy); dd.Deploy(item); } } }
// for import private static void CopyVocabularies(RuleStore sourceRuleStore, RuleStore targetRuleStore, Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd) { VocabularyInfoCollection vocabInfoList = sourceRuleStore.GetVocabularies(RuleStore.Filter.All); foreach (VocabularyInfo vocabInfoItem in vocabInfoList) { Vocabulary vocabItem = sourceRuleStore.GetVocabulary(vocabInfoItem); string[] excludedVocabularyNames = { "Predicates", "Common Values", "Common Sets", "Functions" }; if (!excludedVocabularyNames.Contains(vocabItem.Name)) { try { targetRuleStore.Add(vocabItem); } catch (Exception e) { //targetRuleStore.Remove(vocabItem); //targetRuleStore.Add(vocabItem); //targetRuleStore.Publish(vocabItem); } } } }
private static void ImportPolicies() { // RuleSetDeploymentDriver has the following important methods Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); // SqlRuleStore - gives access t0 the rule engine database SqlRuleStore sqlRuleStore = (SqlRuleStore)dd.GetRuleStore(); // Establish the export file FileRuleStore fileRuleStore = new FileRuleStore(policyExportPath); CopyPolicies(fileRuleStore, sqlRuleStore, dd); }