public ArrayList GetFacts(string policyName)
        {
            #region From rules Engine

            ArrayList shortermFacts = new ArrayList();
            Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
            RuleStore sqlrs;
            sqlrs = dd.GetRuleStore();
            RuleSetInfoCollection rsInfoCollection = sqlrs.GetRuleSets(policyName, RuleStore.Filter.Latest);
            foreach (RuleSetInfo rsInfo in rsInfoCollection)
            {
                RuleSet   ruleset     = sqlrs.GetRuleSet(rsInfo);
                ArrayList bindingList = Microsoft.RuleEngine.RuleSetBindingFinder.GetBindings(ruleset);
                foreach (object o in bindingList)
                {
                    if (o is Microsoft.RuleEngine.ClassBinding)
                    {
                        Microsoft.RuleEngine.ClassBinding cb = o as Microsoft.RuleEngine.ClassBinding;
                        if (cb.TypeName != "TrackSource.BizTalkRules.LongTermFactsWrapper")
                        {
                            shortermFacts.Add(Activator.CreateInstance(cb.Type));
                        }
                    }
                }
            }
            return(shortermFacts);

            #endregion
        }
        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);
            }
        }
        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);
            }
        }
Пример #4
0
        private static void ExecuteRulesEngine(IBaseMessage pInMsg, string rulesPolicy)
        {
            Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver rulesDriver = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
            SqlRuleStore sqlRuleStore = (SqlRuleStore)rulesDriver.GetRuleStore();
            RuleSetInfoCollection rsic = sqlRuleStore.GetRuleSets(rulesPolicy, RuleStore.Filter.All);
            RuleSet rs = sqlRuleStore.GetRuleSet(rsic[0]);

            Microsoft.RuleEngine.RuleEngine engine = new Microsoft.RuleEngine.RuleEngine(rs);
            engine.Assert(pInMsg);
            engine.Execute();
        }