/// <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();
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public BizTalkBaseObjectCollectionEx GetVocabularies()
        {
            TraceManager.SmartTrace.TraceIn();

            BizTalkBaseObjectCollectionEx vocabularies = new BizTalkBaseObjectCollectionEx();

            try
            {
                RuleSetDeploymentDriver rsdd = new RuleSetDeploymentDriver(this.server, this.database);
                RuleStore rs = rsdd.GetRuleStore();

                VocabularyInfoCollection vic = rs.GetVocabularies(Microsoft.RuleEngine.RuleStore.Filter.All);

                foreach (VocabularyInfo vi in vic)
                {
                    RuleArtifact ra = new RuleArtifact();
                    ra.Name          = vi.Name;
                    ra.MajorVersion  = vi.MajorRevision;
                    ra.MinorVersion  = vi.MinorRevision;
                    ra.QualifiedName = ra.Name + "," + ra.MajorVersion + "," + ra.MinorVersion;
                    vocabularies.Add(ra);
                }
            }
            catch (Exception ex)
            {
                TraceManager.SmartTrace.TraceError(ex);
            }

            TraceManager.SmartTrace.TraceOut();
            return(vocabularies);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 5
0
        public List <VocabularyInfo> GetVocabularies()
        {
            List <VocabularyInfo>   vocabularyList = new List <VocabularyInfo>();
            RuleSetDeploymentDriver driver         = new RuleSetDeploymentDriver();

            try
            {
                RuleStore ruleStore = driver.GetRuleStore();
                VocabularyInfoCollection vocabularies = ruleStore.GetVocabularies(RuleStore.Filter.All);
                if (vocabularies.Count < 1)
                {
                    return(vocabularyList);
                }
                for (int i = 0; i < vocabularies.Count; i++)
                {
                    vocabularyList.Add(vocabularies[i]);
                }
            }
            catch (RuleEngineConfigurationException confEx)
            {
                DoRuleEvent("GetVocabularies", string.Format("Rule engine configuration exception: {0}", confEx.Message), true);
            }
            catch (RuleEngineArgumentNullException nullEx)
            {
                DoRuleEvent("GetVocabularies", string.Format("Rule engine argument null exception: {0}", nullEx.Message), true);
            }
            return(vocabularyList);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 7
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);
                }
            }
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo 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);
                    }
                }
            }
        }
Ejemplo n.º 10
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);
                    }
                }
            }
        }
Ejemplo n.º 11
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);
                }
            }
        }