Example #1
0
        public void Test3()
        {
            Dictionary <string, string> theReadData       = new Dictionary <string, string>();
            List <TransferRule>         theConvertedRules = RuleConverter.Convert(theReadData);

            Assert.AreEqual(0, theConvertedRules.Count);
        }
Example #2
0
        public void Test2()
        {
            //多个标点
            Dictionary <string, string> theReadData = new Dictionary <string, string>();

            theReadData.Add("全部数据", ":Sep_Release1670:[TAccount(AccountFilter)][TAccountAuth];Hrmis_Release1670:[TLeaveRequest][TLeaveRequestItem(leaveRequestItemFilter)][TLeaveRequestFlow]");
            try
            {
                RuleConverter.Convert(theReadData);
                Assert.Fail();
            }
            catch (ApplicationException ae)
            {
                Assert.IsTrue(ae.Message.Contains("根据当前数据迁移的配置文件读取的规则不正确,以下分别是2个规则的字符串"));
            }

            //少个括号
            Dictionary <string, string> theReadData1 = new Dictionary <string, string>();

            theReadData1.Add("全部数据", "Sep_Release1670:[TAccount(AccountFilter)][TAccountAuth];Hrmis_Release1670:[TLeaveRequest][TLeaveRequestItem(leaveRequestItemFilter][TLeaveRequestFlow]");
            try
            {
                RuleConverter.Convert(theReadData1);
                Assert.Fail();
            }
            catch (ApplicationException ae)
            {
                Assert.IsTrue(ae.Message.Contains("根据当前数据迁移的配置文件读取的规则不正确,以下分别是2个规则的字符串"));
            }
        }
Example #3
0
        public void Test1()
        {
            Dictionary <string, string> theReadData = new Dictionary <string, string>();

            theReadData.Add("全部数据", "Sep_Release1670:[TAccount(AccountFilter)][TAccountAuth];Hrmis_Release1670:[TLeaveRequest][TLeaveRequestItem(LeaveRequestItemFilter)][TLeaveRequestFlow]");
            List <TransferRule> theConvertedRules = RuleConverter.Convert(theReadData);

            //第一个规则
            Assert.AreEqual(1, theConvertedRules.Count);
            TransferRule theRule = theConvertedRules[0];

            Assert.AreEqual("全部数据", theRule.RuleName);
            Assert.AreEqual(2, theRule.DbsToTransfer.Count);
            //第一个数据库
            Assert.AreEqual("Sep_Release1670", theRule.DbsToTransfer[0].DbName);
            Assert.AreEqual(2, theRule.DbsToTransfer[0].TablesToTransfer.Count);
            Assert.AreEqual("TAccount", theRule.DbsToTransfer[0].TablesToTransfer[0].TableName);
            Assert.AreEqual("AccountFilter", theRule.DbsToTransfer[0].TablesToTransfer[0].TableFilterName);
            Assert.AreEqual("TAccountAuth", theRule.DbsToTransfer[0].TablesToTransfer[1].TableName);
            Assert.AreEqual("", theRule.DbsToTransfer[0].TablesToTransfer[1].TableFilterName);
            //第二个数据库
            Assert.AreEqual("Hrmis_Release1670", theRule.DbsToTransfer[1].DbName);
            Assert.AreEqual(3, theRule.DbsToTransfer[1].TablesToTransfer.Count);
            Assert.AreEqual("TLeaveRequest", theRule.DbsToTransfer[1].TablesToTransfer[0].TableName);
            Assert.AreEqual("", theRule.DbsToTransfer[1].TablesToTransfer[0].TableFilterName);
            Assert.AreEqual("TLeaveRequestItem", theRule.DbsToTransfer[1].TablesToTransfer[1].TableName);
            Assert.AreEqual("LeaveRequestItemFilter", theRule.DbsToTransfer[1].TablesToTransfer[1].TableFilterName);
            Assert.AreEqual("TLeaveRequestFlow", theRule.DbsToTransfer[1].TablesToTransfer[2].TableName);
            Assert.AreEqual("", theRule.DbsToTransfer[1].TablesToTransfer[2].TableFilterName);
        }
Example #4
0
        private void ConvertImpl()
        {
            var rules     = Rules.Where(x => x.IsSelected).Select(x => x.Node).ToImmutableArray();
            var converter = new RuleConverter(SelectedProfileType.Node, SelectedCharacteristicType.Node, rules);

            foreach (var datafileStatus in DatafileConversionStatuses)
            {
                datafileStatus.ConversionProgressValue = 0.3;
                var catalogueBase = (CatalogueBaseNode)datafileStatus.Info.Document.GetRoot();
                var converted     = converter.Convert(catalogueBase);
                datafileStatus.ConversionProgressValue = 0.9;
                using (var file = File.Open(datafileStatus.Info.Document.Filepath, FileMode.Create))
                {
                    GetSaveAction(converted)?.Invoke(file);
                }
                datafileStatus.ConversionProgressValue = 1;
            }

            Action <Stream> GetSaveAction(CatalogueBaseNode catalogueBase)
            {
                if (catalogueBase is CatalogueNode catalogue)
                {
                    return(catalogue.Serialize);
                }
                if (catalogueBase is GamesystemNode gamesystem)
                {
                    return(gamesystem.Serialize);
                }
                return(null);
            }
        }
Example #5
0
        public void Test4()
        {
            Dictionary <string, string> theReadData = new Dictionary <string, string>();

            theReadData.Add("全部数据", "Sep_Release1670:[TAccount][TAccountAuth];Hrmis_Release1670:[TLeaveRequest][TApplication(TApplicationFilter)][TLeaveRequestFlow]");
            List <TransferRule> theConvertedRules = RuleConverter.Convert(theReadData);

            Assert.AreEqual(1, theConvertedRules.Count);
            Console.WriteLine(theConvertedRules[0]);
        }
Example #6
0
        private static SystemWatcher GetSystemWatcherSettings()
        {
            var ruleValidationService             = new RuleValidation();
            var watchedDirectoryValidationService = new WatchedDirectoryValidation();

            var ruleConvertionService             = new RuleConverter(ruleValidationService);
            var watchedDirectoryConvertionService = new WatchedDirectoryConverter(watchedDirectoryValidationService);
            var systemWatcherConvertionService    = new SystemWatcherConverter(ruleConvertionService, watchedDirectoryConvertionService);

            var systemWathcerSection = (SystemWatcherConfigurationSection)
                                       ConfigurationManager.GetSection("systemWatcher");

            return(systemWatcherConvertionService.Convert(systemWathcerSection));
        }
    private void populateDynamicActivity()
    {
        //get the list of rules from repository
        var rules =
            ObjectFactory
            .Container
            .GetInstance <IRuleRepository>()
            .Rules
            .ToList();

        //Declare a dynamic property as the view model
        var inProperty = new DynamicActivityProperty
        {
            Name = "Model",
            Type = typeof(InArgument <HomeIndexViewModel>)
        };

        _dynamicActivity = new DynamicActivity()
        {
            Properties = { inProperty }
        };

        //Import references
        Common.AddVbSetting(activity);

        var sequence = new Sequence();

        activity.Implementation = () => sequence

                                  //Sort Descending - those added first are lowest priority
                                  var sortedRules = rules.OrderBy(x => x.Priority).ToList();

        foreach (var inRule in rules)
        {
            var outRule = RuleConverter.ToIfActivity(inRule);
            sequence.Activities.Add(outRule);
        }
    }