コード例 #1
0
        public override bool Execute(ICustomInterpreted element)
        {
            bool result = false;

            var dayRule = GetDayRule(element);

            if (dayRule != null)
            {
                //приоритет
                int?priority = (element as ModifyDay).Priority;

                if (priority == null)
                {
                    priority = dayRule.Template.Priority;
                }

                PrintDayTemplate printTemplate = null;

                //ссылка на печатный шаблон
                if ((element as ModifyDay).SignNumber != null)
                {
                    printTemplate = _dbContext.GetPrintDayTemplate(_typiconVersionId, (int)(element as ModifyDay).SignNumber);
                }

                var request = CreateRequest(dayRule, element as ModifyDay, (int)priority, printTemplate);

                _modifiedYear.AddModifiedRule(request);

                result = true;
            }

            return(result);
        }
コード例 #2
0
        public override bool IsTypeAuthorized(ICustomInterpreted t)
        {
            if (t is IAsAdditionElement elemToMatch)
            {
                return(Element.IsMatch(elemToMatch) != AsAdditionMatchingResult.Fail);
            }

            return(false);
        }
コード例 #3
0
        //public override bool IsAuthorized<U>()
        //{
        //    bool result = base.IsAuthorized<U>();

        //    foreach (var type in AuthorizedTypes)
        //    {
        //        result ^= type.IsInterface && typeof(U).GetInterface(type.Name) != null;
        //    }

        //    return result;
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="element">Существует ограничение на то, чтобы элемент был наследником класса RuleElement</param>
        /// <returns></returns>
        public override bool Execute(ICustomInterpreted element)
        {
            if (element is RuleElementBase && element is T r)
            {
                executingResult.Add(r);

                return(true);
            }
            return(false);
        }
コード例 #4
0
        /// <summary>
        /// нельзя этот метод вызывать - будет отрабатывать неккоректно
        /// </summary>
        /// <typeparam name="U"></typeparam>
        /// <returns></returns>
        //public override bool IsAuthorized<U>()
        //{
        //    throw new InvalidOperationException();
        //}

        public override bool Execute(ICustomInterpreted t)
        {
            if (t is IAsAdditionElement elemToMatch &&
                Element.IsMatch(elemToMatch) == AsAdditionMatchingResult.Success &&
                Condition(elemToMatch))
            {
                return(base.Execute(t));
            }

            return(false);
        }
コード例 #5
0
        public override bool Execute(ICustomInterpreted element)
        {
            if (element is WorshipRule w)
            {
                GetResult().Add(new WorshipRuleViewModel(w));

                return(true);
            }

            return(false);
        }
コード例 #6
0
        public override bool IsTypeAuthorized(ICustomInterpreted t)
        {
            bool result = base.IsTypeAuthorized(t);

            foreach (var type in AuthorizedTypes)
            {
                result ^= type.IsInterface && t.GetType().GetInterface(type.Name) != null;
            }

            return(result);
        }
コード例 #7
0
        public override bool Execute(ICustomInterpreted element)
        {
            if (element is WorshipRule w)
            {
                //задаем актуальную коллекцию
                ActualWorshipMode = w.Mode;
                ActualWorshipCollection.Add(new OutputWorshipModel(w));

                return(true);
            }

            return(false);
        }
コード例 #8
0
        public override bool Execute(ICustomInterpreted element)
        {
            bool result = base.Execute(element);

            if (!result)
            {
                //добавляем элементы, реализующие интерфейс IViewModelElement к последней WorshipRuleViewModel
                if (element is IViewModelElement viewElement)
                {
                    viewElement.CreateViewModel(this, model => ActualWorshipChildElements?.AddRange(model));
                }
            }

            return(result);
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element">Существует ограничение на то, чтобы элемент был наследником класса RuleElement</param>
        /// <returns></returns>
        public override bool Execute(ICustomInterpreted element)
        {
            if (element is T && element is RuleElement r)
            {
                if (_executingResult == null)
                {
                    _executingResult = new ExecContainer();
                }

                _executingResult.ChildElements.Add(r);

                return(true);
            }
            return(false);
        }
コード例 #10
0
        private DayRule GetDayRule(ICustomInterpreted element)
        {
            DayRule result = null;

            if (element is ModifyReplacedDay modifyReplacedDay)
            {
                if (modifyReplacedDay.Kind == KindOfReplacedDay.Menology)
                {
                    result = _dbContext.GetMenologyRule(_typiconVersionId, modifyReplacedDay.DateToReplaceCalculated);
                }
                else
                {
                    result = _dbContext.GetTriodionRule(_typiconVersionId, modifyReplacedDay.DateToReplaceCalculated);
                }
            }
            else if ((element is ModifyDay modifyDay) &&
                     (modifyDay.MoveDateCalculated.Year == _modifiedYear.Year))
            {
                result = ProcessingDayRule;
            }

            return(result);
        }
コード例 #11
0
        public override bool Execute(ICustomInterpreted element)
        {
            bool result = false;

            if (element is ModifyReplacedDay modifyReplacedDay)
            {
                var typiconEntity = _settings.Rule.Owner;

                DayRule ruleToModify;

                if (modifyReplacedDay.Kind == KindOfReplacedDay.Menology)
                {
                    ruleToModify = typiconEntity.GetMenologyRule(modifyReplacedDay.DateToReplaceCalculated);
                }
                else //if ((element as ModifyReplacedDay).Kind == RuleConstants.KindOfReplacedDay.triodion)
                {
                    int daysFromEaster = modifyReplacedDay.EasterContext.GetDaysFromCurrentEaster(modifyReplacedDay.DateToReplaceCalculated);
                    ruleToModify = typiconEntity.GetTriodionRule(daysFromEaster);
                }

                int priority = modifyReplacedDay.Priority;

                if (priority == 0)
                {
                    priority = ruleToModify.Template.Priority;
                }

                var request = CreateRequest(ruleToModify, modifyReplacedDay, priority);

                typiconEntity.AddModifiedRule(request);

                result = true;
            }
            else if ((element is ModifyDay modifyDay) &&
                     (modifyDay.MoveDateCalculated.Year == _yearToModify))
            {
                int priority = modifyDay.Priority;

                //TypiconRule seniorTypiconRule = Rules[0];

                if (priority == 0)
                {
                    priority = /*seniorTypicon*/ _settings.Rule.Template.Priority;
                }

                var request = CreateRequest((DayRule)_settings.Rule, modifyDay, priority);

                _settings.Rule.Owner.AddModifiedRule(request);

                result = true;
            }

            ModificationsRuleRequest CreateRequest(DayRule caller, ModifyDay md, int priority)
            {
                return(new ModificationsRuleRequest()
                {
                    Caller = caller,
                    Date = md.MoveDateCalculated,
                    Priority = priority,
                    ShortName = md.ShortName,
                    AsAddition = md.AsAddition,
                    IsLastName = md.IsLastName,
                    UseFullName = md.UseFullName,
                    SignNumber = md.SignNumber,
                    Filter = md.Filter
                });
            }

            return(result);
        }
コード例 #12
0
 public bool IsTypeAuthorized(ICustomInterpreted t)
 {
     return(IsTypeAuthorized(t.GetType()));
 }
コード例 #13
0
 /// <summary>
 /// Абстрактный метод обработки правила
 /// </summary>
 /// <param name="element"></param>
 public abstract bool Execute(ICustomInterpreted element);
コード例 #14
0
        public override bool Execute(ICustomInterpreted element)
        {
            container.Add(element as RuleElementBase);

            return(true);
        }
コード例 #15
0
 public bool IsTypeAuthorized(ICustomInterpreted t)
 {
     return(true);
 }
コード例 #16
0
 public bool Execute(ICustomInterpreted element)
 {
     return(true);
 }
コード例 #17
0
 public void Execute(ICustomInterpreted element)
 {
     throw new NotImplementedException();
 }