Пример #1
0
        private void MigrateCommonRules(TypiconVersion typiconEntity)
        {
            Console.WriteLine("MigrateCommonRules()");

            Timer timer = new Timer();

            timer.Start();

            string folderPath = Path.Combine(FOLDER_PATH, TYPICON_NAME, "Common");

            FileReader fileReader = new FileReader(folderPath);

            IEnumerable <(string name, string content)> files = fileReader.ReadAllFromDirectory();

            foreach ((string name, string content)file in files)
            {
                CommonRule commonRule = new CommonRule()
                {
                    Name             = file.name,
                    RuleDefinition   = file.content,
                    TypiconVersionId = typiconEntity.Id,
                    //Owner = typiconEntity
                };
                typiconEntity.CommonRules.Add(commonRule);
            }

            timer.Stop();
            Console.WriteLine(timer.GetStringValue());
        }
Пример #2
0
        private void ReloadCommonRules(string folder, TypiconVersion typiconVersion)
        {
            string folderPath = Path.Combine(folder, typiconVersion.Typicon.SystemName, "Common");

            FileReader fileReader = new FileReader(folderPath);

            IEnumerable <(string name, string content)> files = fileReader.ReadAllFromDirectory();

            foreach ((string name, string content) in files)
            {
                CommonRule commonRule = typiconVersion.CommonRules.FirstOrDefault(c => c.Name == name);

                if (commonRule == null)
                {
                    commonRule = new CommonRule()
                    {
                        Name             = name,
                        RuleDefinition   = content,
                        TypiconVersionId = typiconVersion.Id
                    };
                    typiconVersion.CommonRules.Add(commonRule);
                }
                else
                {
                    commonRule.RuleDefinition = content;
                }
            }
        }
Пример #3
0
        private void MigrateCommonRules(TypiconEntity typiconEntity)
        {
            Console.WriteLine("MigrateCommonRules()");

            Timer timer = new Timer();

            timer.Start();

            string folderPath = Path.Combine(Properties.Settings.Default.FolderPath, typiconEntity.Name, "Common");

            FileReader fileReader = new FileReader(folderPath);

            IEnumerable <(string name, string content)> files = fileReader.ReadAllFromDirectory();

            foreach ((string name, string content)file in files)
            {
                CommonRule commonRule = new CommonRule()
                {
                    Name           = file.name,
                    RuleDefinition = file.content,
                    Owner          = typiconEntity
                };
                typiconEntity.CommonRules.Add(commonRule);
            }

            timer.Stop();
            Console.WriteLine(timer.GetStringValue());
        }
Пример #4
0
 private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (PrintControlFromTool != null)
     {
         ContentControlBase control = CommonRule.LoadClassInstance <ContentControlBase>(this.GetType().Namespace, PrintControlFromTool.GetType().Name);
         Canvas.SetTop(control, PrintControlFromToolOfPosition.Y);
         Canvas.SetLeft(control, PrintControlFromToolOfPosition.X);
         AddPrinControlEventHandle(control);
         canvasSpace.Children.Add(control);
         //更新放置坐标到控件相应属性
         PropertyModel pX = GetPropertyItemByName(control.Propertys, "pX");
         if (pX != null)
         {
             pX.Value = Math.Floor(PrintControlFromToolOfPosition.X);
         }
         PropertyModel pY = GetPropertyItemByName(control.Propertys, "pY");
         if (pY != null)
         {
             pY.Value = Math.Floor(PrintControlFromToolOfPosition.Y);
         }
         CurrentControlBase   = control;
         PrintControlFromTool = null;
         this.Cursor          = null;
     }
 }
Пример #5
0
        private void OnPrintKeyValueChanged(PropertyChangedFromTextBoxEventArgs property)
        {
            BarCodeControl   c       = (BarCodeControl)property.PrintControl;
            PropertyModel    p       = property.Property;
            TextBox          textBox = property.TextBox;
            DependencyObject d       = DependencyHelper.FindVisualChildByName(c, "pText");

            if (d != null)
            {
                Type t = d.GetType();
                if (t == typeof(TextBlock))
                {
                    TextBlock r     = d as TextBlock;
                    string    value = (string)Convert.ChangeType(p.Value, typeof(string));
                    if (CommonRule.HasChinese(p.Value.ToString()))
                    {
                        p.Value      = c.PrintKeyValue;
                        textBox.Text = c.PrintKeyValue;
                        return;
                    }
                    r.Text          = value;
                    c.PrintKeyValue = r.Text;
                }
            }
        }
Пример #6
0
 /// <summary>
 /// 拖动添加打印控件
 /// </summary>
 public void AddPrinControlByDrag()
 {
     if (IsMouseEnter && PrintControlFromTool != null)
     {
         ContentControlBase control = CommonRule.LoadClassInstance <ContentControlBase>(this.GetType().Namespace, PrintControlFromTool.GetType().Name);
         Canvas.SetTop(control, PrintControlFromToolOfPosition.Y);
         Canvas.SetLeft(control, PrintControlFromToolOfPosition.X);
         AddPrinControlEventHandle(control);
         canvasSpace.Children.Add(control);
         //更新放置坐标到控件相应属性
         PropertyModel pX = GetPropertyItemByName(control.Propertys, "pX");
         if (pX != null)
         {
             pX.Value = Math.Floor(PrintControlFromToolOfPosition.X);
         }
         PropertyModel pY = GetPropertyItemByName(control.Propertys, "pY");
         if (pY != null)
         {
             pY.Value = Math.Floor(PrintControlFromToolOfPosition.Y);
         }
         CurrentControlBase   = control;
         PrintControlFromTool = null;
         this.Cursor          = null;
     }
 }
Пример #7
0
        private void ReloadCommonRules(TypiconEntity typiconEntity, string folderPath)
        {
            folderPath = Path.Combine(folderPath, typiconEntity.Name, "Common");

            FileReader fileReader = new FileReader(folderPath);

            IEnumerable <(string name, string content)> files = fileReader.ReadAllFromDirectory();

            foreach ((string name, string content) in files)
            {
                CommonRule commonRule = typiconEntity.GetCommonRule(c => c.Name == name);

                if (commonRule == null)
                {
                    commonRule = new CommonRule()
                    {
                        Name           = name,
                        RuleDefinition = content,
                        Owner          = typiconEntity
                    };
                    typiconEntity.CommonRules.Add(commonRule);
                }
                else
                {
                    commonRule.RuleDefinition = content;
                }
            }
        }
Пример #8
0
        protected override void InnerInterpret(IRuleHandler handler)
        {
            //if (handler.IsAuthorized<CommonRuleElement>())
            //{
            //находим правило
            CommonRule commonRule = SerializerRoot.QueryProcessor.Process(new CommonRuleQuery(handler.Settings.TypiconVersionId, CommonRuleName));

            var container = commonRule?.GetRule <ExecContainer>(SerializerRoot);

            if (container?.IsValid == true)
            {
                //имеется Правило и оно верно составлено
                //значит просто включаем его
                container.ChildElements.ForEach(c => c.Interpret(handler));
            }
            //}
        }
Пример #9
0
        private void ImportCommonRules(TypiconVersion version, List <CommonRuleProjection> commonRules)
        {
            commonRules.ForEach(c =>
            {
                var rule = new CommonRule()
                {
                    Name           = c.Name,
                    RuleDefinition = c.RuleDefinition,
                    TypiconVersion = version
                };

                version.CommonRules.Add(rule);

                //Синхронизируем Переменные Устава
                rule.SyncRuleVariables(_serializerRoot);
            });
        }
 /// <summary>
 /// 索引处理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tbIndexs_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tbIndexs.Text))
     {
         CurrentPrintControl.FunctionData.FunctionIndexs        = null;
         CurrentPrintControl.FunctionData.FunctionIndexsCaption = string.Empty;
     }
     else
     {
         try
         {
             CurrentPrintControl.FunctionData.FunctionIndexs        = CommonRule.ParseIndexs(tbIndexs.Text);
             CurrentPrintControl.FunctionData.FunctionIndexsCaption = tbIndexs.Text;
         }
         catch
         {
             CurrentPrintControl.FunctionData.FunctionIndexs        = null;
             CurrentPrintControl.FunctionData.FunctionIndexsCaption = string.Empty;
             tbIndexs.Text = string.Empty;
         }
     }
 }
Пример #11
0
        public override IEnumerable <ValidationResult> Validate(CommonRuleEditModel model)
        {
            var errors = ValidateRule(model);

            if (string.IsNullOrEmpty(model.Name))
            {
                errors.Add(new ValidationResult($"Наименование обязательно для заполнения", new List <string>()
                {
                    "Name"
                }));
            }
            else
            {
                //проверяем на уникальность DaysFromEaster
                CommonRule found = null;

                if (model.Mode == ModelMode.Create)
                {
                    //если объект создается, Id = Id версии Устава,
                    //значит ищем CommonRule с таким же Name
                    found = DbContext.Set <CommonRule>()
                            .FirstOrDefault(c => c.Name == model.Name &&
                                            c.TypiconVersion.TypiconId == model.Id &&
                                            c.TypiconVersion.BDate == null &&
                                            c.TypiconVersion.EDate == null);
                }
                else
                {
                    //Edit
                    //сначала находим сам редактируемый объект
                    found = DbContext.Set <CommonRule>().FirstOrDefault(c => c.Id == model.Id);

                    if (found?.Name == model.Name)
                    {
                        //если значения DaysFromEaster найденного объекта и редактируемой модели равны,
                        //значит ошибки нет
                        found = null;
                    }
                    else if (found != null)
                    {
                        //ищем дальше
                        found = DbContext.Set <CommonRule>()
                                .FirstOrDefault(c => c.TypiconVersionId == found.TypiconVersionId &&
                                                c.Name == model.Name);
                    }
                }
                if (found != null)
                {
                    errors.Add(new ValidationResult("В Уставе уже есть Общее Правило с заданным Наименованием", new List <string>()
                    {
                        "Name"
                    }));
                }
            }

            if (string.IsNullOrEmpty(model.RuleDefinition))
            {
                errors.Add(new ValidationResult($"Правило для последовательности обязательно для заполнения", new List <string>()
                {
                    "RuleDefinition"
                }));
            }

            return(errors);
        }