Exemplo n.º 1
0
        //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);
                }
            }
        }
Exemplo n.º 2
0
        //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);
                }
            }
        }
Exemplo n.º 3
0
        // 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);
            }
        }
Exemplo n.º 4
0
        // 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);
                }
            }
        }
Exemplo n.º 5
0
        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 }));
            }
        }
        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 });
            }
        }
Exemplo n.º 7
0
        // 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);
                    }
                }
            }
        }
Exemplo n.º 8
0
 // 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);
     }
 }
Exemplo n.º 9
0
        // 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);
                    }
                }
            }
        }
Exemplo n.º 10
0
        // 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);
                }
            }
        }