private void MigrateTriodionDaysAndRules(TypiconVersion typiconEntity) { Console.WriteLine("MigrateTriodionDaysAndRules()"); Timer timer = new Timer(); timer.Start(); //TypiconFolderEntity folder = new TypiconFolderEntity() { Name = "Триодь" }; //typiconEntity.RulesFolder.AddFolder(folder); foreach (ScheduleDBDataSet.TriodionRow row in _sh.DataSet.Triodion.Rows) { //CreateItemTextRequest req = new CreateItemTextRequest(); //req.Text = row.Name; //req.Name = "Name1"; //req.Style.IsBold = row.IsNameBold; //ItemTextCollection itemTextCol = XmlHelper.CreateItemTextCollection(req); DayWorship dayWorship = new DayWorship() { WorshipName = new ItemTextStyled() }; dayWorship.WorshipName.IsBold = row.IsNameBold; dayWorship.WorshipName.AddOrUpdate(DEFAULT_LANGUAGE, row.Name); //DayWorship dayWorship = new DayWorship() //{ // WorshipName = new ItemFakeText() { StringExpression = row.Name } //}; TriodionDay day = new TriodionDay() { //Name = row.Name, //DayName = itemTextCol, DaysFromEaster = (int)row.DayFromEaster, }; day.AppendDayService(dayWorship); //day.Sign = _dbContext.Set<Sign>().Get(c => c.Id == row.SignID); _dbContext.Set <TriodionDay>().Add(day); string folderPath = Path.Combine(FOLDER_PATH, TYPICON_NAME, "Triodion"); FileReader fileReader = new FileReader(folderPath); TriodionRule rule = new TriodionRule() { //Name = day.Name, DaysFromEaster = day.DaysFromEaster, TypiconVersionId = typiconEntity.Id, //Owner = typiconEntity, //IsAddition = true, Template = typiconEntity.Signs.First(c => c.SignName.FirstOrDefault(DEFAULT_LANGUAGE).Text == row.ServiceSignsRow.Name), RuleDefinition = fileReader.Read(row.DayFromEaster.ToString()), ModRuleDefinition = fileReader.Read(row.DayFromEaster.ToString(), "mod") }; rule.DayRuleWorships = new List <DayRuleWorship>() { new DayRuleWorship() { DayRule = rule, DayWorship = dayWorship, Order = 1 } }; //folder.AddRule(rule); typiconEntity.TriodionRules.Add(rule); } timer.Stop(); Console.WriteLine(timer.GetStringValue()); //_unitOfWork.Commit(); }
private void MigrateTriodionDaysAndRules(TypiconEntity typiconEntity) { Console.WriteLine("MigrateTriodionDaysAndRules()"); Timer timer = new Timer(); timer.Start(); //TypiconFolderEntity folder = new TypiconFolderEntity() { Name = "Триодь" }; //typiconEntity.RulesFolder.AddFolder(folder); foreach (ScheduleDBDataSet.TriodionRow row in _sh.DataSet.Triodion.Rows) { //CreateItemTextRequest req = new CreateItemTextRequest(); //req.Text = row.Name; //req.Name = "Name1"; //req.Style.IsBold = row.IsNameBold; //ItemTextCollection itemTextCol = XmlHelper.CreateItemTextCollection(req); DayWorship dayWorship = new DayWorship() { WorshipName = new ItemTextStyled() }; dayWorship.WorshipName.Style.IsBold = row.IsNameBold; dayWorship.WorshipName.AddElement("cs-ru", row.Name); //DayWorship dayWorship = new DayWorship() //{ // WorshipName = new ItemFakeText() { StringExpression = row.Name } //}; TriodionDay day = new TriodionDay() { //Name = row.Name, //DayName = itemTextCol, DaysFromEaster = (int)row.DayFromEaster, }; day.AppendDayService(dayWorship); //day.Sign = _unitOfWork.Repository<Sign>().Get(c => c.Id == row.SignID); _unitOfWork.Repository <TriodionDay>().Insert(day); string folderPath = Path.Combine(Properties.Settings.Default.FolderPath, typiconEntity.Name, "Triodion"); FileReader fileReader = new FileReader(folderPath); TriodionRule rule = new TriodionRule() { //Name = day.Name, DaysFromEaster = day.DaysFromEaster, Owner = typiconEntity, //IsAddition = true, Template = typiconEntity.Signs.First(c => c.SignName["cs-ru"] == row.ServiceSignsRow.Name), RuleDefinition = fileReader.Read(row.DayFromEaster.ToString()), }; rule.DayRuleWorships = new List <DayRuleWorship>() { new DayRuleWorship() { DayRule = rule, DayWorship = dayWorship } }; //folder.AddRule(rule); typiconEntity.TriodionRules.Add(rule); } timer.Stop(); Console.WriteLine(timer.GetStringValue()); //_unitOfWork.Commit(); }