コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// This function allows you to obtain a definition value from a Vocabulary in the Business Rules Engine.
        /// </summary>
        /// <param name="definitionName">Definition Name e.g. Value1</param>
        /// <param name="vocabularyName">Name of Vocabulary i.e. Config</param>
        /// <returns>Return Constant Value</returns>
        public static string GetBusinessRuleValue(string definitionName, string vocabularyName)
        {
            // RuleStore Object
            RuleStore rlsRuleStore;
            // Vocab Info collection
            VocabularyInfoCollection vicVocabInfo;
            // Vocab itself
            Vocabulary vocVocab;
            // Provides the default deployment driver used to import, export, deploy, un-deploy, and
            // set tracking configuration for published rule sets and vocabularies,
            // and to retrieve their deployment characteristics.
            RuleSetDeploymentDriver rsdDriver = new RuleSetDeploymentDriver();

            // The current RuleStore
            rlsRuleStore = rsdDriver.GetRuleStore();
            // Set Vocabulary based on Vocabulary collection
            vicVocabInfo = rlsRuleStore.GetVocabularies(vocabularyName, RuleStore.Filter.All);
            // Get the vocabulary itself
            vocVocab = rlsRuleStore.GetVocabulary(vicVocabInfo[0]);
            // Get the definition
            VocabularyDefinition vocDef = vocVocab.Definitions.GetByName(definitionName);
            // Set LiteralDefition
            LiteralDefinition literalDefinition = vocDef as LiteralDefinition;

            // Return Value
            return(literalDefinition.Value.ToString());
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vocabulary"></param>
        /// <param name="outputFolder"></param>
        /// <returns></returns>
        public string ExportVocabularyToFile(RuleArtifact vocabulary, string outputFolder)
        {
            string fileName = null;

            TraceManager.SmartTrace.TraceIn();

            try
            {
                RuleSetDeploymentDriver rsdd = new RuleSetDeploymentDriver(this.server, this.database);
                VocabularyInfo          vi   = new VocabularyInfo(vocabulary.Name, vocabulary.MajorVersion, vocabulary.MinorVersion);
                fileName = Path.Combine(outputFolder, vocabulary.XmlFileName);
                rsdd.ExportVocabularyToFileRuleStore(vi, fileName);
            }
            catch (Exception ex)
            {
                TraceManager.SmartTrace.TraceError(ex);
                TraceManager.SmartTrace.TraceError("FileName will be set to NULL");
            }

            TraceManager.SmartTrace.TraceOut();
            return(fileName);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="databaseServer"></param>
 /// <param name="databaseName"></param>
 public BREManager(string databaseServer, string databaseName)
 {
     _driver = new RuleSetDeploymentDriver(databaseServer, databaseName);
 }
コード例 #10
0
 /// <summary>
 /// Ctor
 /// </summary>
 public BREManager()
 {
     _driver = new RuleSetDeploymentDriver();
 }