private async Task <HttpStatusCode> SyncDateListAsync() { string?url = gitHubConfig.Value.DateListUrl; var dateListService = covid19Services["dateTable"]; if (url is null) { throw new ConfigurationErrorsException(); } await foreach (var dateList in dataCollector.GetDataAsync <IEnumerable <ItemDateDto> >(url, SerializerKind.Json)) { foreach (var item in dateList) { var dateItem = new ItemDate { Id = NormalizeDate(item.Data), PartitionKey = "covid19" }; var response = await dateListService.UpdateDataAsync(dateItem, dateItem.PartitionKey); if ((int)response > 299) { return(response); } } } return(HttpStatusCode.OK); }
public void Save() { try { //Pega os dados que serão salvos quadradoDados = quadrado.GetDados(); //Gera o arquivo onde vamos escrever os dados no caminho especificado file = File.Create(Application.persistentDataPath + "/Save.cafe"); Debug.Log(Application.persistentDataPath); //Serializa os dados em formato binário e escreve no arquivo bf.Serialize(file, quadradoDados); } catch (Exception e) { //Imprime mensagem de erro no console Debug.Log(e.Message); } finally { //Fecha o caminho para o arquivo se ele não estiver vazio. Não fazer isso pode causar vazamento de memória (Memory Leak) if (file != null) { file.Close(); } } }
public void Load() { try { //Abre o arquivo no caminho especificado file = File.Open(Application.persistentDataPath + "/Save.cafe", FileMode.Open); //Desserializa os dados no arquivo quadradoDados = (ItemDate)bf.Deserialize(file); //Muda os dados do quadrado de acordo com os dados salvos quadrado.SetDados(quadradoDados); } catch (Exception e) { //Imprime mensagem de erro no console Debug.Log(e.Message); } finally { //Fecha o caminho para o arquivo se ele não estiver vazio. Não fazer isso pode causar vazamento de memória (Memory Leak) if (file != null) { file.Close(); } } }
public Result <IQueryable <MenologyDayWorshipModel> > Handle([NotNull] MenologyDayWorshipQuery query) { ItemDate date = (query.Date != null) ? new ItemDate(query.Date.Value.Month, query.Date.Value.Day) : new ItemDate(); var days = DbContext.Set <MenologyDay>() .Include(c => c.DayWorships) .ThenInclude(c => c.WorshipName) .ThenInclude(c => c.Items) .Include(c => c.DayWorships) .ThenInclude(c => c.WorshipShortName) .ThenInclude(c => c.Items) .Where(c => c.LeapDate.Month == date.Month && c.LeapDate.Day == date.Day) .ToList(); var result = days.SelectMany(day => day.DayWorships, (day, worship) => new MenologyDayWorshipModel() { WorshipId = worship.Id, Date = (day.Date != null) ? day.Date.ToString() : string.Empty, LeapDate = (day.LeapDate != null) ? day.LeapDate.ToString() : string.Empty, IsCelebrating = worship.IsCelebrating, Name = worship.WorshipName.ToString(query.Language), ShortName = worship.WorshipShortName.ToString(query.Language), UseFullName = worship.UseFullName }); return(Result.Ok(result.AsQueryable())); }
private MenologyDay FindParent(DateTime?leapDate) { //MenologyDay ItemDate date = (leapDate != null) ? new ItemDate(leapDate.Value.Month, leapDate.Value.Day) : new ItemDate(); return(DbContext.Set <MenologyDay>() .FirstOrDefault(c => c.LeapDate.Day == date.Day && c.LeapDate.Month == date.Month)); }
public void UpdateItem(ImageSource image, double picSize, string imgName, string title, string description, DateTimeOffset date, bool?isChecked) { this.image = (image == null ? new BitmapImage(new Uri("Assets/pic_5.jpg")) : image); this.Title = title; this.Description = description; this.ItemDate = date; this.picSize = picSize; this.isChecked = isChecked; this.imgName = imgName; itemDateToString = ItemDate.ToString(); }
public TodoItem(TodoItem item) { this.id = item.id; this.picSize = item.picSize; this.Title = item.Title; this.Description = item.Description; this.ItemDate = item.ItemDate; this.isChecked = item.isChecked; this.imgName = item.imgName; itemDateToString = ItemDate.ToString(); }
public TodoItem(string id, ImageSource _image, double picSize, string imgName, string title, string description, DateTimeOffset itemDate, bool?isChecked = false) { this.id = id; this.image = ((_image == null) ? new BitmapImage(new Uri("ms-appx:///Assets/pic_6.jpg")) :_image); this.picSize = picSize; this.Title = title; this.Description = description; this.ItemDate = itemDate; this.isChecked = isChecked; this.imgName = imgName; itemDateToString = ItemDate.ToString(); }
public EveryYearJobScheduler(int month, int day, int hours, int minutes) { _date = new ItemDate(month, day); if (!_date.IsValid) { throw new ArgumentOutOfRangeException("Неверное заполнение даты."); } _time = new ItemTime(hours, minutes); if (!_time.IsValid) { throw new ArgumentOutOfRangeException("Неверное заполнение времени."); } }
private void EditParent(DayWorship worship, DateTime?leapDate) { //MenologyDay ItemDate date = (leapDate != null) ? new ItemDate(leapDate.Value.Month, leapDate.Value.Day) : new ItemDate(); var parent = worship.Parent as MenologyDay; if (parent.LeapDate.ToString() != date.ToString()) { //значит ищем MenologyDay и задаем его как Parent для worship var newParent = DbContext.Set <MenologyDay>() .FirstOrDefault(c => c.LeapDate.Day == date.Day && c.LeapDate.Month == date.Month); worship.Parent = newParent; } }
private void MigrateMenologyDaysAndRules(TypiconVersion typiconEntity) { Console.WriteLine("MigrateMenologyDaysAndRules()"); Timer timer = new Timer(); timer.Start(); //TypiconFolderEntity folder = new TypiconFolderEntity() { Name = "Минея" }; //typiconEntity.RulesFolder.AddFolder(folder); //TypiconFolderEntity childFolder = new TypiconFolderEntity() { Name = "Минея 1" }; //folder.AddFolder(childFolder); string folderRulePath = Path.Combine(FOLDER_PATH, TYPICON_NAME, "Menology"); FileReader fileRuleReader = new FileReader(folderRulePath); MenologyDay menologyDay = null; MenologyRule menologyRule = null; MigrationDayWorshipFactory factory = new MigrationDayWorshipFactory(FOLDER_PATH); foreach (ScheduleDBDataSet.MineinikRow mineinikRow in _sh.DataSet.Mineinik.Rows) { factory.Initialize(mineinikRow); DayWorship dayWorship = factory.Create(); ItemDate d = (!mineinikRow.IsDateBNull()) ? new ItemDate(mineinikRow.DateB.Month, mineinikRow.DateB.Day) : new ItemDate(); //menologyDay /* Чтобы лишний раз не обращаться к БД, * смотрим, не один и тот же MenologyDay, что и предыдущая строка из Access */ //if (menologyDay == null || !menologyDay.DateB.Expression.Equals(d.Expression)) menologyDay = _dbContext.Set <MenologyDay>().FirstOrDefault(c => c.LeapDate.Day == d.Day && c.LeapDate.Month == d.Month); if (menologyDay == null) { //нет - создаем новый день menologyDay = new MenologyDay() { //Name = mineinikRow.Name, //DayName = XmlHelper.CreateItemTextCollection( // new CreateItemTextRequest() { Text = mineinikRow.Name, Name = "Name" }), Date = (mineinikRow.IsDateNull()) ? new ItemDate() : new ItemDate(mineinikRow.Date.Month, mineinikRow.Date.Day), LeapDate = (mineinikRow.IsDateBNull()) ? new ItemDate() : new ItemDate(mineinikRow.DateB.Month, mineinikRow.DateB.Day), }; _dbContext.Set <MenologyDay>().Add(menologyDay); } menologyDay.AppendDayService(dayWorship); //menologyRule /*смотрим, есть ли уже такой объект с заявленной датой * если дата пустая - т.е. праздник переходящий - значит */ if (!d.IsEmpty) { menologyRule = typiconEntity.GetMenologyRule(mineinikRow.DateB); } if (menologyRule == null || d.IsEmpty) { menologyRule = new MenologyRule() { //Name = menologyDay.Name, Date = new ItemDate(menologyDay.Date), LeapDate = new ItemDate(menologyDay.LeapDate), TypiconVersionId = typiconEntity.Id, //Owner = typiconEntity, //IsAddition = true, Template = typiconEntity.Signs.First(c => c.SignName.FirstOrDefault(DEFAULT_LANGUAGE).Text == mineinikRow.ServiceSignsRow.Name), }; menologyRule.DayRuleWorships.Add(new DayRuleWorship() { DayRule = menologyRule, DayWorship = dayWorship, Order = 1 }); typiconEntity.MenologyRules.Add(menologyRule); string n = (!mineinikRow.IsDateBNull()) ? menologyDay.LeapDate.Expression : menologyRule.GetNameByLanguage(DEFAULT_LANGUAGE); //берем xml-правило из файла menologyRule.RuleDefinition = fileRuleReader.Read(n); menologyRule.ModRuleDefinition = fileRuleReader.Read(n, "mod"); } else { int lastOrder = menologyRule.DayRuleWorships.Max(c => c.Order); menologyRule.DayRuleWorships.Add(new DayRuleWorship() { DayRule = menologyRule, DayWorship = dayWorship, Order = lastOrder + 1 }); } } timer.Stop(); Console.WriteLine(timer.GetStringValue()); }
/// <summary> /// Vrati data ku konrketnemu casovemu itemu /// </summary> /// <param name="date">Casovy item definujuci den a mesiac</param> /// <returns>Data z pozadovaneho dna a mesiaa alebo null</returns> public static ItemData GetItemData(ItemDate date) { if (_itemCollection.ContainsKey(date)) { //vratime polozku dat return _itemCollection[date]; } //data nie su dostupne return null; }
private void MigrateMenologyDaysAndRules(TypiconEntity typiconEntity) { Console.WriteLine("MigrateMenologyDaysAndRules()"); Timer timer = new Timer(); timer.Start(); //TypiconFolderEntity folder = new TypiconFolderEntity() { Name = "Минея" }; //typiconEntity.RulesFolder.AddFolder(folder); //TypiconFolderEntity childFolder = new TypiconFolderEntity() { Name = "Минея 1" }; //folder.AddFolder(childFolder); string folderRulePath = Path.Combine(Properties.Settings.Default.FolderPath, typiconEntity.Name, "Menology"); FileReader fileRuleReader = new FileReader(folderRulePath); MenologyDay menologyDay = null; MenologyRule menologyRule = null; MigrationDayWorshipFactory factory = new MigrationDayWorshipFactory(Properties.Settings.Default.FolderPath); foreach (ScheduleDBDataSet.MineinikRow mineinikRow in _sh.DataSet.Mineinik.Rows) { factory.Initialize(mineinikRow); DayWorship dayWorship = factory.Create(); ItemDate d = (!mineinikRow.IsDateBNull()) ? new ItemDate(mineinikRow.DateB.Month, mineinikRow.DateB.Day) : new ItemDate(); //menologyDay /* Чтобы лишний раз не обращаться к БД, * смотрим, не один и тот же MenologyDay, что и предыдущая строка из Access */ //if (menologyDay == null || !menologyDay.DateB.Expression.Equals(d.Expression)) menologyDay = _unitOfWork.Repository <MenologyDay>().Get(c => c.DateB.Expression.Equals(d.Expression)); if (menologyDay == null) { //нет - создаем новый день menologyDay = new MenologyDay() { //Name = mineinikRow.Name, //DayName = XmlHelper.CreateItemTextCollection( // new CreateItemTextRequest() { Text = mineinikRow.Name, Name = "Name" }), Date = (mineinikRow.IsDateNull()) ? new ItemDate() : new ItemDate(mineinikRow.Date.Month, mineinikRow.Date.Day), DateB = (mineinikRow.IsDateBNull()) ? new ItemDate() : new ItemDate(mineinikRow.DateB.Month, mineinikRow.DateB.Day), }; _unitOfWork.Repository <MenologyDay>().Insert(menologyDay); } menologyDay.AppendDayService(dayWorship); //menologyRule /*смотрим, есть ли уже такой объект с заявленной датой * если дата пустая - т.е. праздник переходящий - значит */ if (!d.IsEmpty) { menologyRule = typiconEntity.GetMenologyRule(mineinikRow.DateB); } if (menologyRule == null || d.IsEmpty) { menologyRule = new MenologyRule() { //Name = menologyDay.Name, Date = menologyDay.Date, DateB = menologyDay.DateB, Owner = typiconEntity, //IsAddition = true, Template = typiconEntity.Signs.First(c => c.SignName["cs-ru"] == mineinikRow.ServiceSignsRow.Name), }; menologyRule.DayRuleWorships.Add(new DayRuleWorship() { DayRule = menologyRule, DayWorship = dayWorship }); typiconEntity.MenologyRules.Add(menologyRule); //берем xml-правило из файла menologyRule.RuleDefinition = (!mineinikRow.IsDateBNull()) ? fileRuleReader.Read(menologyDay.DateB.Expression) : fileRuleReader.Read(menologyRule.Name); } else { menologyRule.DayRuleWorships.Add(new DayRuleWorship() { DayRule = menologyRule, DayWorship = dayWorship }); } } timer.Stop(); Console.WriteLine(timer.GetStringValue()); }
//public virtual MenologyDay Day { get; set; } public MenologyRule() { Date = new ItemDate(); DateB = new ItemDate(); }
public MenologyRule() { Date = new ItemDate(); LeapDate = new ItemDate(); }
public void SetDados(ItemDate _itemDate) { Id = _itemDate.id; valorVenda = _itemDate.valorVenda; qualidadeItem = _itemDate.qualidadeItem; }