Example #1
0
        private void InitializeIoC()
        {
            var container = new RegisterByContainer().Container;

            _unitOfWork = container.GetInstance <IUnitOfWork>();

            _typiconEntityService = container.With(_unitOfWork).GetInstance <ITypiconEntityService>();

            GetTypiconEntityResponse response = _typiconEntityService.GetTypiconEntity(1);// _unitOfWork.Repository<TypiconEntity>().Get(c => c.Name == "Типикон");

            _typiconEntity = response.TypiconEntity;

            _bookStorage = new BookStorage(
                container.With(_unitOfWork).GetInstance <IEvangelionContext>(),
                container.With(_unitOfWork).GetInstance <IApostolContext>(),
                container.With(_unitOfWork).GetInstance <IOldTestamentContext>(),
                container.With(_unitOfWork).GetInstance <IPsalterContext>(),
                container.With(_unitOfWork).GetInstance <IOktoikhContext>(),
                container.With(_unitOfWork).GetInstance <ITheotokionAppContext>(),
                container.With(_unitOfWork).GetInstance <IEasterContext>(),
                container.With(_unitOfWork).GetInstance <IKatavasiaContext>());

            //EasterStorage.Instance.EasterDays = _unitOfWork.Repository<EasterItem>().GetAll().ToList();

            IRuleSerializerRoot serializerRoot = container.With(_bookStorage).GetInstance <IRuleSerializerRoot>();
            var settingsFactory = container.GetInstance <IRuleHandlerSettingsFactory>();

            _scheduleService = container.With(settingsFactory).With(serializerRoot).GetInstance <IScheduleService>();

            _docxTemplateService = container.With(_bookStorage.Oktoikh).GetInstance <IDocxTemplateService>();
        }
 protected override void Validate(IRuleSerializerRoot serializerRoot)
 {
     if (string.IsNullOrEmpty(RuleDefinition))
     {
         AddBrokenConstraint(new BusinessConstraint("Правило должно быть определено.", nameof(RuleDefinition)));
     }
 }
        protected void Validate(IRuleSerializerRoot ruleSerializer)
        {
            if (Typicon == null || TypiconId == 0)
            {
                AddError("Версия Устава должна иметь ссылку на Устав");
            }

            //Signs
            ValidateChildCollection(Signs.Cast <RuleEntity>(), ruleSerializer, ErrorConstants.Sign, ErrorConstants.Signs, "Должен быть определен хотя бы один Знак службы");
            //CommonRules
            ValidateChildCollection(CommonRules.Cast <RuleEntity>(), ruleSerializer, ErrorConstants.CommonRule);
            //MenologyRules
            ValidateMenologyRules(ruleSerializer);
            //TriodionRules
            ValidateChildCollection(TriodionRules.Cast <RuleEntity>(), ruleSerializer, ErrorConstants.TriodionRule);
            //ExplicitAddRules
            ValidateChildCollection(ExplicitAddRules.Cast <RuleEntity>(), ruleSerializer, ErrorConstants.ExplicitAddRule);
            //Kathismas
            ValidateKathismas(ruleSerializer.TypiconSerializer);

            if (ScheduleSettings == null)
            {
                AddError("Версия Устава должна иметь Настройки дней богослужений");
            }
        }
Example #4
0
        private void InitializeIoC()
        {
            var container = new RegisterByContainer().Container;

            var unitOfWork = container.GetInstance <IUnitOfWork>();

            var typiconEntityService = container.With(unitOfWork).GetInstance <ITypiconEntityService>();

            GetTypiconEntityResponse response = typiconEntityService.GetTypiconEntity(1);// _unitOfWork.Repository<TypiconEntity>().Get(c => c.Name == "Типикон");

            typiconEntity = response.TypiconEntity;

            var bookStorage = new BookStorage(
                container.With(unitOfWork).GetInstance <IEvangelionContext>(),
                container.With(unitOfWork).GetInstance <IApostolContext>(),
                container.With(unitOfWork).GetInstance <IOldTestamentContext>(),
                container.With(unitOfWork).GetInstance <IPsalterContext>(),
                container.With(unitOfWork).GetInstance <IOktoikhContext>(),
                container.With(unitOfWork).GetInstance <ITheotokionAppContext>(),
                container.With(unitOfWork).GetInstance <IEasterContext>(),
                container.With(unitOfWork).GetInstance <IKatavasiaContext>());

            IRuleSerializerRoot serializerRoot = container.With(bookStorage).GetInstance <IRuleSerializerRoot>();

            settingsFactory = new CustomRuleSettingsFactory();

            scheduleService = container.With(settingsFactory).With(serializerRoot).GetInstance <IScheduleService>();
        }
        public RuleSerializerContainerBase(IRuleSerializerRoot unitOfWork, IDescriptor descriptor)
        {
            _unitOfWork = unitOfWork ?? throw new ArgumentNullException("unitOfWork");
            _descriptor = descriptor ?? throw new ArgumentNullException("descriptor");

            LoadFactories();
        }
Example #6
0
        protected RuleSerializerContainerBase(IRuleSerializerRoot serializerRoot, IDescriptor descriptor)
        {
            SerializerRoot = serializerRoot ?? throw new ArgumentNullException(nameof(serializerRoot));
            Descriptor     = descriptor ?? throw new ArgumentNullException(nameof(descriptor));

            LoadFactories();
        }
Example #7
0
 public CustomScheduleDataCalculator(IRuleSerializerRoot ruleSerializer
                                     , IRuleHandlerSettingsFactory settingsFactor
                                     , IScheduleDataCalculator decoratee)
 {
     RuleSerializer = ruleSerializer ?? throw new ArgumentNullException(nameof(ruleSerializer));
     Decoratee      = decoratee ?? throw new ArgumentNullException(nameof(decoratee));
 }
 public YmnosRuleSerializer(IRuleSerializerRoot root) : base(root)
 {
     ElementNames = new string[] {
         RuleConstants.YmnosRuleNode,
         RuleConstants.YmnosRuleDoxastichonNode
     };
 }
Example #9
0
 public ApostichaRuleSerializer(IRuleSerializerRoot root) : base(root)
 {
     ElementNames = new string[] {
         RuleConstants.ApostichaRuleNode,
         RuleConstants.LitiRuleNode
     };
 }
Example #10
0
        public OdiViewModelFactory(IRuleHandler handler, IRuleSerializerRoot serializer, Action <OutputSectionModelCollection> appendModelAction)
        {
            this.handler           = handler ?? throw new ArgumentNullException("IRuleHandler in OdiViewModelHandler");
            this.appendModelAction = appendModelAction ?? throw new ArgumentNullException("Action<ElementViewModel> in OdiViewModelHandler");
            this.serializer        = serializer ?? throw new ArgumentNullException("IRuleSerializerRoot in OdiViewModelHandler");

            choruses = serializer.GetCommonRuleChildren <TextHolder>(handler.Settings.TypiconVersionId, CommonRuleConstants.KanonasChorusRule);
        }
 public ValidateJobHandlerBase(TypiconDBContext dbContext
                               , IJobRepository jobs
                               , IRuleSerializerRoot serializer)
 {
     DbContext  = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     Jobs       = jobs ?? throw new ArgumentNullException(nameof(jobs));
     Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
 }
Example #12
0
        protected override void Validate(IRuleSerializerRoot serializerRoot)
        {
            base.Validate(serializerRoot);

            if (DayRuleWorships.Count > 1)
            {
                AddBrokenConstraint(new BusinessConstraint("В коллекции Текстов служб не должно быть более одного Текста служб", "TriodionRule"));
            }
        }
Example #13
0
        protected override void Validate(IRuleSerializerRoot serializerRoot)
        {
            base.Validate(serializerRoot);

            if (Template == null || TemplateId < 1)
            {
                AddBrokenConstraint(new BusinessConstraint("Шаблон для Правила должен быть определен", "TypiconRule"));
            }
        }
Example #14
0
        protected override void Validate(IRuleSerializerRoot serializerRoot)
        {
            base.Validate(serializerRoot);

            if (DayRuleWorships.Count == 0)
            {
                AddBrokenConstraint(new BusinessConstraint("В коллекции Текстов служб должен быть определен хотя бы один элемент", "DayRule"));
            }
        }
Example #15
0
        /// <summary>
        /// Возвращает ItemText из Правила, представляющего из себя коллекцию TextHolder, согласно индекса
        /// </summary>
        /// <param name="serializer"></param>
        /// <param name="typiconId"></param>
        /// <param name="name"></param>
        /// <param name="language"></param>
        /// <param name="index">Номер TextHolder-ы в коллекции Правил</param>
        /// <returns></returns>
        public static ItemText GetCommonRuleIndexedItemText(this IRuleSerializerRoot serializer, int typiconId, string name, int index)
        {
            ItemText result = null;

            if (serializer.GetCommonRuleChildren(typiconId, name).ElementAtOrDefault(index) is TextHolder t && t.Paragraphs?.Count > 0)
            {
                result = new ItemText(t.Paragraphs[0]);
            }
            return(result);
        }
Example #16
0
        /// <summary>
        /// Возвращает строку из Правила, представляющего из себя коллекцию TextHolder, согласно индекса
        /// </summary>
        /// <param name="serializer"></param>
        /// <param name="typiconId"></param>
        /// <param name="name"></param>
        /// <param name="language"></param>
        /// <param name="index">Номер TextHolder-ы в коллекции Правила</param>
        /// <returns></returns>
        public static string GetCommonRuleIndexedString(this IRuleSerializerRoot serializer, int typiconId, string name, string language, int index)
        {
            var result = "";

            if (serializer.GetCommonRuleChildren(typiconId, name).ElementAtOrDefault(index) is TextHolder t && t.Paragraphs?.Count > 0)
            {
                result = t.Paragraphs[0]?.FirstOrDefault(language).Text;
            }
            return(result);
        }
Example #17
0
 public ExecContainerSerializer(IRuleSerializerRoot root) : base(root)
 {
     ElementNames = new string[] {
         RuleConstants.ExecContainerNodeName,
         RuleConstants.ActionNodeName,
         RuleConstants.DefaultNodeName,
         RuleConstants.ThenNodeName,
         RuleConstants.ElseNodeName
     };
 }
Example #18
0
 public WorshipSequenceSerializer(IRuleSerializerRoot root) : base(root)
 {
     ElementNames = new string[] {
         RuleConstants.MikrosEsperinosNode,
         RuleConstants.MegalisEsperinosNode,
         RuleConstants.EsperinosNode,
         RuleConstants.OrthrosNode,
         RuleConstants.LeitourgiaNode
     };
 }
 public TextHolderSerializer(IRuleSerializerRoot root) : base(root)
 {
     ElementNames = new string[] {
         RuleConstants.TextHolderLectorNode,
         RuleConstants.TextHolderChoirNode,
         RuleConstants.TextHolderDeaconNode,
         RuleConstants.TextHolderPriestNode,
         RuleConstants.TextHolderTextNode
     };
 }
 public ExecContainerSerializer(IRuleSerializerRoot root) : base(root)
 {
     ElementNames = new [] {
         //RuleConstants.ExecContainerNodeName,
         RuleConstants.ActionNodeName,
         RuleConstants.DefaultNodeName,
         RuleConstants.ThenNodeName,
         RuleConstants.ElseNodeName,
         RuleConstants.WorshipRuleSequenceNode
     };
 }
Example #21
0
        /// <summary>
        /// Возвращает Правило, либо свое, либо шаблонное
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serializerRoot"></param>
        /// <returns></returns>
        public override T GetModRule <T>(IRuleSerializerRoot serializerRoot)
        {
            T baseRule = base.GetModRule <T>(serializerRoot);

            if ((baseRule == null) && string.IsNullOrEmpty(ModRuleDefinition))
            {
                return((Template != null) ? Template.GetModRule <T>(serializerRoot) : default(T));
            }

            return(baseRule);
        }
Example #22
0
        /// <summary>
        /// Возвращает Правило: либо свое, либо шаблонное
        /// </summary>
        //public override RuleElement Rule
        //{
        //    get
        //    {
        //        if ((base.Rule == null) && string.IsNullOrEmpty(RuleDefinition))
        //        {
        //            return Template.Rule;
        //        }

        //        return base.Rule;//(string.IsNullOrEmpty(RuleDefinition)) ? Template.Rule : null;
        //    }
        //}

        public override T GetRule <T>(IRuleSerializerRoot serializerRoot)
        {
            T baseRule = base.GetRule <T>(serializerRoot);

            if ((baseRule == null) && string.IsNullOrEmpty(RuleDefinition))
            {
                return(Template?.GetRule <T>(serializerRoot));
            }

            return(baseRule);
        }
        //public bool IsPublished => BDate != null && EDate == null;
        //public bool IsDraft => BDate == null && EDate == null;
        #endregion

        #region Validation

        public IReadOnlyCollection <TypiconVersionError> GetBrokenConstraints(IRuleSerializerRoot ruleSerializer)
        {
            if (!IsValidated)
            {
                Errors.Clear();
                Validate(ruleSerializer);
                IsValidated = true;
            }

            return(Errors);
        }
        public OdiViewModelFactory(IRuleHandler handler, IRuleSerializerRoot serializer, Action <ElementViewModel> appendModelAction)
        {
            this.handler           = handler ?? throw new ArgumentNullException("IRuleHandler in OdiViewModelHandler");
            this.appendModelAction = appendModelAction ?? throw new ArgumentNullException("Action<ElementViewModel> in OdiViewModelHandler");
            this.serializer        = serializer ?? throw new ArgumentNullException("IRuleSerializerRoot in OdiViewModelHandler");

            choruses = handler.Settings.Rule.Owner.GetCommonRuleChildren(
                new CommonRuleServiceRequest()
            {
                Key = CommonRuleConstants.KanonasChorusRule, RuleSerializer = serializer
            }).Cast <TextHolder>().ToList();
        }
        public static ScheduleService Create(TypiconDBContext dbContext)
        {
            IRuleSerializerRoot serializerRoot = TestRuleSerializer.Create(dbContext);

            var settingsFactory = new RuleHandlerSettingsFactory(serializerRoot);

            var commandProcessor = CommandProcessorFactory.Create(dbContext);
            var queryProcessor   = DataQueryProcessorFactory.Create(dbContext);

            return(new ScheduleService(new ScheduleDataCalculator(queryProcessor, settingsFactory)
                                       , new ScheduleDayNameComposer(serializerRoot.QueryProcessor)));
        }
Example #26
0
        /// <summary>
        /// Возвращает коллекцию RuleElement запрашиваемого общего правила.
        /// </summary>
        /// <returns></returns>
        public static IReadOnlyList <RuleElementBase> GetCommonRuleChildren(this IRuleSerializerRoot serializer, int typiconId, string key)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var commonRule = serializer.QueryProcessor.Process(new CommonRuleQuery(typiconId, key));

            var container = commonRule?.GetRule <RootContainer>(serializer);

            return((container != null) ? container.ChildElements : new List <RuleElementBase>());
        }
        private void ValidateMenologyRules(IRuleSerializerRoot ruleSerializer)
        {
            //проверяем наличие Правил для каждого дня високосного года
            EachDayPerYear.Perform(2016, date =>
            {
                if (GetMenologyRule(date) == null)
                {
                    AddError($"Отсутствует определение Правила Минеи для даты --{date.Month}-{date.Day}", ErrorConstants.MenologyRules);
                }
            });

            ValidateChildCollection(MenologyRules.Cast <RuleEntity>(), ruleSerializer, ErrorConstants.MenologyRule);
        }
Example #28
0
        public YmnosGroupViewModel(YmnosGroup group, IRuleHandler handler, IRuleSerializerRoot serializer)
        {
            if (group == null || group.Ymnis == null)
            {
                throw new ArgumentNullException("YmnosGroup");
            }
            _group = group;

            _handler = handler ?? throw new ArgumentNullException("handler");

            Serializer = serializer ?? throw new ArgumentNullException("IRuleSerializerRoot");

            Ihos = group.Ihos;

            if (group.Annotation?.IsEmpty == false)
            {
                Annotation = group.Annotation[handler.Settings.Language];
            }

            //текст "Глас"
            CommonRuleServiceRequest req = new CommonRuleServiceRequest()
            {
                RuleSerializer = Serializer
            };

            req.Key  = CommonRuleConstants.IhosText;
            IhosText = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language);

            //если подобен
            if (group.Prosomoion?.IsEmpty == false)
            {
                req.Key    = CommonRuleConstants.ProsomoionText;
                Prosomoion = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language);

                Prosomoion = string.Format(@"{0}: ""{1}""", Prosomoion, group.Prosomoion[handler.Settings.Language]);
            }
            //самоподобен?
            if (group.Prosomoion?.Self == true)
            {
                req.Key = CommonRuleConstants.SelfText;
                Self    = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language);
            }

            //находим Стих и Хор для дальнешей вставки
            req.Key          = CommonRuleConstants.StihosRule;
            _kindStihosValue = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language);

            req.Key         = CommonRuleConstants.ChoirRule;
            _kindChoirValue = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language);
        }
Example #29
0
        public static ViewModelItem Create(Ymnos ymnos, IRuleHandler handler, IRuleSerializerRoot serializer)
        {
            var kind = Cast(ymnos.Kind);

            return(new ViewModelItem()
            {
                Kind = Cast(ymnos.Kind),
                KindStringValue = GetKindStringValue(kind, handler, serializer),
                Paragraphs = new List <ParagraphViewModel>()
                {
                    ParagraphVMFactory.Create(ymnos.Text, handler.Settings.Language.Name)
                }
            });
        }
        public static OutputSectionModel Create(Ymnos ymnos, int typiconVersionId, IRuleSerializerRoot serializer)
        {
            var kind = Cast(ymnos.Kind);

            return(new OutputSectionModel()
            {
                Kind = Cast(ymnos.Kind),
                KindText = GetKindItemTextValue(kind, typiconVersionId, serializer),
                Paragraphs = new List <ItemTextNoted>()
                {
                    new ItemTextNoted(ymnos.Text)
                }
            });
        }