/// <summary> /// /// </summary> public void PrepareVocabs() { TraceManager.SmartTrace.TraceIn(); vdefs = new Hashtable(); try { RuleSetDeploymentDriver rsdd = new RuleSetDeploymentDriver(this.server, this.database); RuleStore store = rsdd.GetRuleStore(); VocabularyInfoCollection vocabularyInfos = store.GetVocabularies(RuleStore.Filter.All); foreach (VocabularyInfo vi in vocabularyInfos) { Vocabulary v = store.GetVocabulary(vi); foreach (VocabularyDefinition o in v.Definitions) { if (!vdefs.ContainsKey(o.Id)) { vdefs.Add(o.Id, o); } } } } catch (Exception ex) { TraceManager.SmartTrace.TraceError(ex); } TraceManager.SmartTrace.TraceOut(); }
public void TestRuleStore() { string fileLoc = "Unittest.json"; string key = "password123"; string templateName = "Empty"; string saveKey = "testKey"; string saveValue = "testVal"; if (File.Exists(fileLoc)) { File.Delete(fileLoc); } RuleStore newStore = RuleStore.Create(fileLoc, key); newStore.Rules.Add( new Rule(RuleTemplate.GetByName(templateName)) { Properties = new Dictionary <string, object>() { { saveKey, saveValue }, { "key2", 1 } } }); newStore.WriteToDisc(); var readStore = RuleStore.Open(fileLoc, key); Assert.AreEqual(saveValue, readStore.Rules.First().Properties[saveKey]); Assert.IsTrue(readStore.Rules.First().Templates.First().Name == templateName); File.Delete(fileLoc); }
public void ExportRule(string filename, string rulesetName) { RuleSetDeploymentDriver driver = new RuleSetDeploymentDriver(); try { RuleStore ruleStore = driver.GetRuleStore(); RuleSetInfoCollection ruleSets = ruleStore.GetRuleSets(rulesetName, RuleStore.Filter.Latest); if (ruleSets.Count != 1) { DoRuleEvent("ExportRule", string.Format("No Ruleset named {0} exists in rule store {1}", rulesetName, ruleStore.Location)); return; } driver.ExportRuleSetToFileRuleStore(ruleSets[0], filename); } catch (RuleEngineConfigurationException confEx) { DoRuleEvent("ExportRule", string.Format("Rule engine configuration exception: {0}", confEx.Message), true); } catch (RuleEngineArgumentNullException nullEx) { DoRuleEvent("ExportRule", string.Format("Rule engine argument null exception: {0}", nullEx.Message), true); } DoRuleEvent("ExportRule", string.Format("Rule {0} saved to {1}", rulesetName, filename)); }
/// <summary> /// /// </summary> /// <returns></returns> public BizTalkBaseObjectCollectionEx GetRuleSets() { TraceManager.SmartTrace.TraceIn(); BizTalkBaseObjectCollectionEx ruleSets = new BizTalkBaseObjectCollectionEx(); try { RuleSetDeploymentDriver rsdd = new RuleSetDeploymentDriver(this.server, this.database); RuleStore rs = rsdd.GetRuleStore(); RuleSetInfoCollection rsic = rs.GetRuleSets(Microsoft.RuleEngine.RuleStore.Filter.All); foreach (RuleSetInfo rsi in rsic) { RuleArtifact ra = new RuleArtifact(); ra.Name = rsi.Name; ra.MajorVersion = rsi.MajorRevision; ra.MinorVersion = rsi.MinorRevision; ra.QualifiedName = ra.Name + "," + ra.MajorVersion + "," + ra.MinorVersion; ruleSets.Add(ra); } } catch (Exception ex) { TraceManager.SmartTrace.TraceError(ex); } TraceManager.SmartTrace.TraceOut(); return(ruleSets); }
private void Bt_Ready_Click(object sender, RoutedEventArgs e) { try { RuleStore store; if (CreateNew) { if (File.Exists(FilePath)) { File.Delete(FilePath); } store = RuleStore.Create(FilePath, Pb_Key.Password); } else { store = RuleStore.Open(FilePath, Pb_Key.Password); } var window = new MainWindow(store); window.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show(string.Format("Exception:\n{0}\n\n{1}", ex.Message, ex.ToString())); } }
public List <RuleSetInfo> GetRuleSets() { List <RuleSetInfo> ruleSetList = new List <RuleSetInfo>(); RuleSetDeploymentDriver driver = new RuleSetDeploymentDriver(); try { RuleStore ruleStore = driver.GetRuleStore(); RuleSetInfoCollection ruleSets = ruleStore.GetRuleSets(RuleStore.Filter.All); if (ruleSets.Count <= 0) { return(ruleSetList); } for (int i = 0; i < ruleSets.Count; i++) { ruleSetList.Add(ruleSets[i]); } } catch (RuleEngineConfigurationException confEx) { DoRuleEvent("GetRuleSets", string.Format("Rule engine configuration exception: {0}", confEx.Message), true); } catch (RuleEngineArgumentNullException nullEx) { DoRuleEvent("GetRuleSets", string.Format("Rule engine argument null exception: {0}", nullEx.Message), true); } return(ruleSetList); }
public static void UnDeployVocabulary(string vocabName, string serverName, string databaseName, TaskLoggingHelper log) { log.LogMessage("Ready to undeploy Vocabulary name {0}.", new object[] { vocabName }); Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver driver; if ((databaseName != string.Empty) && (serverName != string.Empty)) { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(serverName, databaseName); } else { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); } RuleStore ruleStore = driver.GetRuleStore(); VocabularyInfoCollection vocabularies = ruleStore.GetVocabularies(vocabName, RuleStore.Filter.All); foreach (VocabularyInfo vocabulary in vocabularies) { log.LogMessage("Found vocabulary {0} with version {1}.{2}.", new object[] { vocabulary.Name, vocabulary.MajorRevision, vocabulary.MinorRevision }); } log.LogMessage("Start Undeploy...", new object[] { }); try { ruleStore.Remove(vocabularies); } catch { throw; } log.LogMessage("Vocabularies with name {0} removed.", new object[] { vocabName }); }
private static void ProcessVocabularies( DeployRulesCommandLine cl, Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd) { RuleStore ruleStore = dd.GetRuleStore(); VocabularyInfoCollection vInfo = ruleStore.GetVocabularies(cl.vocabularyName, RuleStore.Filter.All); Version version = ParseVersion(cl.ruleSetVersion); VocabularyInfo matchingVocabularyInfo = null; foreach (VocabularyInfo currentRsi in vInfo) { if (currentRsi.MajorRevision == version.Major && currentRsi.MinorRevision == version.Minor) { matchingVocabularyInfo = currentRsi; break; } } if (matchingVocabularyInfo == null) { Console.WriteLine( "No published vocabulary with name '" + cl.vocabularyName + "' and version '" + cl.ruleSetVersion + "'."); } else if (cl.unpublish) { Console.WriteLine("Unpublishing vocabulary '{0}' version {1}.{2}...", cl.vocabularyName, version.Major, version.Minor); ruleStore.Remove(matchingVocabularyInfo); } }
public void ExportVocabulary(string filename, string vocabName) { RuleSetDeploymentDriver driver = new RuleSetDeploymentDriver(); try { RuleStore ruleStore = driver.GetRuleStore(); VocabularyInfoCollection vocabularies = ruleStore.GetVocabularies(vocabName, RuleStore.Filter.All); if (vocabularies.Count < 1) { DoRuleEvent("ExportVocabulary", string.Format("No Vocabulary named {0} exists in rule store {1}", vocabName, ruleStore.Location)); return; } driver.ExportVocabularyToFileRuleStore(vocabularies[0], filename); } catch (RuleEngineConfigurationException confEx) { DoRuleEvent("ExportVocabulary", string.Format("Rule engine configuration exception: {0}", confEx.Message), true); } catch (RuleEngineArgumentNullException nullEx) { DoRuleEvent("ExportVocabulary", string.Format("Rule engine argument null exception: {0}", nullEx.Message), true); } DoRuleEvent("ExportVocabulary", string.Format("Vocabulary {0} saved to {1}", vocabName, filename)); }
//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 export private static void CopyPolicies(RuleStore sourceRuleStore, RuleStore targetRuleStore) { RuleSetInfoCollection rulesetInfoList = sourceRuleStore.GetRuleSets(RuleStore.Filter.All); foreach (RuleSetInfo item in rulesetInfoList) { RuleSet policy = sourceRuleStore.GetRuleSet(item); targetRuleStore.Add(policy); } }
//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); } } }
private static void ProcessPolicies( DeployRulesCommandLine cl, Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd) { RuleStore ruleStore = dd.GetRuleStore(); RuleSetInfoCollection rsInfo = ruleStore.GetRuleSets(cl.ruleSetName, RuleStore.Filter.All); Version version = ParseVersion(cl.ruleSetVersion); RuleSetInfo matchingRuleSetInfo = null; foreach (RuleSetInfo currentRsi in rsInfo) { if (currentRsi.MajorRevision == version.Major && currentRsi.MinorRevision == version.Minor) { matchingRuleSetInfo = currentRsi; break; } } if (matchingRuleSetInfo == null) { Console.WriteLine( "No published ruleset with name '" + cl.ruleSetName + "' and version '" + cl.ruleSetVersion + "'."); } else if (cl.undeploy) { Console.WriteLine("Undeploying rule set '{0}' version {1}.{2}...", cl.ruleSetName, version.Major, version.Minor); if (dd.IsRuleSetDeployed(matchingRuleSetInfo)) { dd.Undeploy(matchingRuleSetInfo); } else { Console.WriteLine(" Rule set is not currently deployed."); } if (cl.unpublish) { Console.WriteLine("Unpublishing rule set '{0}' version {1}.{2}...", cl.ruleSetName, version.Major, version.Minor); ruleStore.Remove(matchingRuleSetInfo); } } else { Console.WriteLine("Deploying rule set '{0}' version {1}.{2}...", cl.ruleSetName, version.Major, version.Minor); dd.Deploy(matchingRuleSetInfo); } }
// for export private static void CopyVocabularies(RuleStore sourceRuleStore, RuleStore targetRuleStore) { 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)) { targetRuleStore.Add(vocabItem); } } }
/// <summary> /// подключается к БД и возвращает все vocab(включая default vocab) из БД /// </summary> /// <param name="serverName"></param> /// <param name="dbName"></param> /// <returns></returns> public static VocabularyInfo[] GetVocabularyInfoSet(string serverName, string dbName) { RuleStore vocabStore = ((IRuleSetDeploymentDriver)Microsoft.RuleEngine.RemoteUpdateService.RemoteUpdateService.LocateObject(Configuration.DeploymentDriverClass, Configuration.DeploymentDriverDll, new ArrayList() { serverName, dbName }.ToArray())).GetRuleStore(); var vocabularyInfoCollection = vocabStore.GetVocabularies(RuleStore.Filter.All); var vocabularySet = new VocabularyInfo[vocabularyInfoCollection.Count]; vocabularyInfoCollection.CopyTo(vocabularySet, 0); return(vocabularySet); }
/// <summary> /// подключается к БД и возвращает все rule из БД /// </summary> /// <param name="severName"></param> /// <param name="dbName"></param> /// <returns></returns> public static RuleSetInfo[] GetRuleSetInfo(string severName, string dbName) { RuleStore ruleStore = ((IRuleSetDeploymentDriver)Microsoft.RuleEngine.RemoteUpdateService.RemoteUpdateService.LocateObject(Configuration.DeploymentDriverClass, Configuration.DeploymentDriverDll, new ArrayList() { severName, dbName }.ToArray())).GetRuleStore(); var ruleSetInfoCollection = ruleStore.GetRuleSets(RuleStore.Filter.All); var ruleSet = new RuleSetInfo[ruleSetInfoCollection.Count]; ruleSetInfoCollection.CopyTo(ruleSet, 0); return(ruleSet); }
public MainWindow(RuleStore store) { InitializeComponent(); Store = store; Lv_RulesOverview.ItemsSource = Store.Rules; this.Closing += (sender, e) => { if (StoreChanged) { if (MessageBox.Show("There are unsaved changes, save them?", "Save changes?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Store.WriteToDisc(); } } }; }
public static void FindRuleAndUpdate(string dataStoreName, ReferenceData aRef, List <IDataRule> rules, DataMapType mapType, Guid mapId) { var aRule = aRef.StoreReferences.Where(x => x.DataStoreName.Equals(dataStoreName) && x.MapID == mapId && x.GetType().Equals(typeof(RuleStore))).FirstOrDefault(); if (aRule == null) { RuleStore nRule = new RuleStore(); nRule.DataStoreName = dataStoreName; nRule.Rules = rules; nRule.MapType = mapType; nRule.ParamterCount = rules.Count; aRef.StoreReferences.Add(nRule); } else { ((RuleStore)aRule).Rules = rules; } }
public void DeployRuleSet(RuleSet ruleSet, string server, string database, bool deploy) { DoRuleEvent("DeployRuleSet", string.Format("Ready to {3} Ruleset {0} with version {1}.{2}.", new object[] { ruleSet.Name, ruleSet.CurrentVersion.MajorRevision, ruleSet.CurrentVersion.MinorRevision, deploy ? "deploy" : "publish" })); Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver driver; if ((server != string.Empty) && (database != string.Empty)) { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(server, database); } else { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); } RuleStore ruleStore = driver.GetRuleStore(); try { ruleStore.Add(ruleSet, true); } catch (RuleStoreRuleSetAlreadyPublishedException) { DoRuleEvent("DeployRuleSet", string.Format("Ruleset {0} is already published", new object[] { ruleSet.Name }), true); } catch { throw; } if (deploy) { try { driver.Deploy(new RuleSetInfo(ruleSet.Name, ruleSet.CurrentVersion.MajorRevision, ruleSet.CurrentVersion.MinorRevision)); } catch (RuleEngineDeploymentAlreadyDeployedException) { DoRuleEvent("DeployRuleSet", string.Format("Ruleset {0} is already deployed.", new object[] { ruleSet.Name }), true); } catch { throw; } DoRuleEvent("DeployRuleSet", string.Format("Deployed Ruleset {0} with version {1}.{2}.", new object[] { ruleSet.Name, ruleSet.CurrentVersion.MajorRevision, ruleSet.CurrentVersion.MinorRevision })); } }
private bool TryCreateStore(out RuleStore ruleStore) { try { if (!string.IsNullOrEmpty(StorePath) && !string.IsNullOrEmpty(StoreKey)) { ruleStore = RuleStore.Open(StorePath, StoreKey); LastRulestoreUpdate = Environment.TickCount; return(true); } else { ruleStore = null; return(false); } } catch { ruleStore = null; return(false); } }
public void CreateDataTable(RuleStore rules, DataStore store) { store.ActualData = new DataTable(); int maxRows = 0; foreach (BaseRule aRule in rules.Rules) { if (aRule.MaxRecords > maxRows) { maxRows = aRule.MaxRecords; } DataColumn newColumn = new DataColumn(aRule.FieldName, Type.GetType(aRule.FieldDataType)); store.ActualData.Columns.Add(newColumn); } for (int row = 0; row < maxRows; row++) { DataRow newRow = store.ActualData.NewRow(); store.ActualData.Rows.Add(newRow); } }
public static void DeployVocabulary(Vocabulary[] vocabularies, string server, string database, TaskLoggingHelper log) { for (int i = 0; i < vocabularies.Length; i++) { log.LogMessage("Ready to deploy Vocabulary {0} with version {1}.{2}.", new object[] { vocabularies[i].Name, vocabularies[i].CurrentVersion.MajorRevision, vocabularies[i].CurrentVersion.MinorRevision }); } Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver driver; if ((server != string.Empty) && (database != string.Empty)) { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(server, database); } else { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); } RuleStore ruleStore = driver.GetRuleStore(); try { for (int i = 0; i < vocabularies.Length; i++) { ruleStore.Add(vocabularies[i], true); } } catch (RuleStoreVocabularyAlreadyPublishedException exception) { log.LogMessage("Vocabulary {0} already exists.", new object[] { exception.VocabularyName }); } catch { throw; } for (int i = 0; i < vocabularies.Length; i++) { log.LogMessage("Deployed Vocabulary {0} with version {1}.{2}.", new object[] { vocabularies[i].Name, vocabularies[i].CurrentVersion.MajorRevision, vocabularies[i].CurrentVersion.MinorRevision }); } }
/// <summary> /// /// </summary> /// <param name="ruleSet"></param> /// <param name="outputFolder"></param> /// <returns></returns> public string ExportRuleSetToFile(RuleArtifact ruleSet, string outputFolder) { TraceManager.SmartTrace.TraceIn(); string fileName = null; try { RuleSetDeploymentDriver rsdd = new RuleSetDeploymentDriver(this.server, this.database); RuleStore store = rsdd.GetRuleStore(); RuleSetInfo rsi = new RuleSetInfo(ruleSet.Name, ruleSet.MajorVersion, ruleSet.MinorVersion); VocabularyInfoCollection referencedVocabs = store.GetReferencedVocabularies(rsi); RuleSet rs = store.GetRuleSet(rsi); fileName = Path.Combine(outputFolder, ruleSet.XmlFileName); rsdd.ExportRuleSetToFileRuleStore(rsi, fileName); fileName = Path.Combine(outputFolder, ruleSet.HtmlFileName); StreamWriter sw = new StreamWriter(fileName); RuleSetWriter writer = new RuleSetWriter(sw); writer.VocabularyDefinitions = vdefs; writer.WriteRuleSet(rs, referencedVocabs, sw); sw.Flush(); sw.Close(); } catch (Exception ex) { TraceManager.SmartTrace.TraceError(ex); TraceManager.SmartTrace.TraceError("FileName will be set to NULL"); } TraceManager.SmartTrace.TraceOut(); return(fileName); }
public void TestRuleTemplateStore() { string fileLoc = "Unittest.json"; string key = "password123"; if (File.Exists(fileLoc)) { File.Delete(fileLoc); } RuleStore newStore = RuleStore.Create(fileLoc, key); Rule rule = new Rule(RuleTemplate.GetByName("Basic"), RuleTemplate.GetByName("Application")); newStore.Rules.Add(rule); newStore.WriteToDisc(); var readStore = RuleStore.Open(fileLoc, key); Assert.IsTrue(readStore.Rules.First().Templates.Count() == 2); Assert.IsTrue(readStore.Rules.First().Templates.FirstOrDefault(rt => rt.Name == "Basic") != null); Assert.IsTrue(readStore.Rules.First().Templates.FirstOrDefault(rt => rt.Name == "Application") != null); File.Delete(fileLoc); }
// 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 void ctxViewRule_Click(object sender, EventArgs e) { DataMapType theType = EnumPlus.ConvertString(typeof(DataMapType), mppedObjectsTree.SelectedNode.Tag.GetType().Name); var store = Result.ReferenceInfo.StoreReferences.Where(x => x.MapType == theType); if (store != null) { IDataRule storeRule = null; switch (theType) { case DataMapType.FieldColumnMap: case DataMapType.PropertyColumnMap: RuleStore rStore = (RuleStore)store.First(); storeRule = rStore.Rules.Where(x => x.FieldName.Equals(mppedObjectsTree.SelectedNode.Text.Trim())).FirstOrDefault(); break; case DataMapType.MethodParameterMap: RuleStore rpStore = (RuleStore)store.Where(x => x.DataStoreName.Equals(mppedObjectsTree.SelectedNode.Text.Trim()) && x.ParamterCount.Equals(lstMapDetails.Items.Count)).First(); storeRule = rpStore.Rules.Where(x => x.FieldName.Equals(lstMapDetails.SelectedItems[0].SubItems[0].Text.Trim())).First(); break; } DisplayRule(storeRule, false); } }
/// <inheritdoc /> public async Task InitAsync(int?tenantId, string ruleName) { CurrentRuleInfo = await RuleStore.GetRuleAsync(tenantId, ruleName); }
public void UnDeployRuleSet(string ruleName, string server, string database) { DoRuleEvent("UnDeployRuleSet", string.Format("Ready to undeploy Rule name {0}.", new object[] { ruleName })); Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver driver; if ((server != string.Empty) && (database != string.Empty)) { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(server, database); } else { driver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); } RuleStore ruleStore = driver.GetRuleStore(); RuleSetInfoCollection ruleSets = ruleStore.GetRuleSets(ruleName, RuleStore.Filter.All); foreach (RuleSetInfo ruleSet in ruleSets) { DoRuleEvent("UnDeployRuleSet", string.Format("Found Ruleset {0} with version {1}.{2}.", new object[] { ruleSet.Name, ruleSet.MajorRevision, ruleSet.MinorRevision })); } DoRuleEvent("UnDeployRuleSet", string.Format("Start Undeploy...", new object[] { })); bool bCont = true; while (bCont && ruleSets.Count > 0) { try { driver.Undeploy(ruleSets); bCont = false; } catch (RuleEngineDeploymentNotDeployedException ex) { DoRuleEvent("UnDeployRuleSet", string.Format("Ruleset {0} with version {1}.{2} was not deployed.", new object[] { ex.RuleSetName, ex.MajorVersion, ex.MinorVersion }), true); // remove from ruleSets and try again for (int i = 0; i < ruleSets.Count; i++) { if (ruleSets[i].Name.Equals(ex.RuleSetName) && ruleSets[i].MajorRevision == ex.MajorVersion && ruleSets[i].MinorRevision == ex.MinorVersion) { ruleSets.RemoveAt(i); break; } } } catch { throw; } } // We only need to ones published now ruleSets = ruleStore.GetRuleSets(ruleName, RuleStore.Filter.Published); foreach (RuleSetInfo ruleSet in ruleSets) { DoRuleEvent("UnDeployRuleSet", string.Format("Found Ruleset {0} with version {1}.{2} to be removed.", new object[] { ruleSet.Name, ruleSet.MajorRevision, ruleSet.MinorRevision })); } if (ruleSets.Count > 0) { DoRuleEvent("UnDeployRuleSet", string.Format("Start Remove...", new object[] { })); try { ruleStore.Remove(ruleSets); } catch { throw; } } }