示例#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);
                }
            }
        }
示例#2
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);
            }
        }
示例#3
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);
                }
            }
        }
        /// <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);
        }
示例#5
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);
     }
 }