public ScheduledHorizontalScaleForecastWorker( IDeployment deployment, IOperation operation, Guid subscriptionId, string certificateThumbprint, string serviceName, string deploymentSlot, HorizontalScale[] horizontalScales, ScheduleDay[] scheduleDays, bool treatWarningsAsError, string mode, int pollingIntervalInMinutes) : base(GetWorkerId(serviceName, deploymentSlot)) { this.deployment = deployment; this.operation = operation; this.subscriptionId = subscriptionId; this.certificateThumbprint = certificateThumbprint; this.serviceName = serviceName; this.deploymentSlot = deploymentSlot; this.horizontalScales = horizontalScales; this.scheduleDays = scheduleDays; this.treatWarningsAsError = treatWarningsAsError; this.mode = mode; this.pollingIntervalInMinutes = pollingIntervalInMinutes; }
public DeploymentCreateForecastWorker( IDeployment deployment, IOperation operation, Guid subscriptionId, string certificateThumbprint, string serviceName, string deploymentSlot, ScheduleDay[] scheduleDays, string deploymentName, Uri packageUrl, string label, string configurationFilePath, bool startDeployment, bool treatWarningsAsError, int pollingIntervalInMinutes) : base(GetWorkerId(serviceName, deploymentSlot)) { this.deployment = deployment; this.operation = operation; this.subscriptionId = subscriptionId; this.certificateThumbprint = certificateThumbprint; this.serviceName = serviceName; this.deploymentSlot = deploymentSlot; this.scheduleDays = scheduleDays; this.deploymentName = deploymentName; this.packageUrl = packageUrl; this.label = label; this.configurationFilePath = configurationFilePath; this.startDeployment = startDeployment; this.treatWarningsAsError = treatWarningsAsError; this.pollingIntervalInMinutes = pollingIntervalInMinutes; }
/// <summary> /// Modify Cleaning Schedule. /// See http://www.neatorobotics.com/programmers-manual/table-of-robot-application-commands/detailed-command-descriptions/#SetSchedule for more info. /// </summary> /// <param name="day">Day of the week to schedule cleaning for.</param> /// <param name="hour">Hour value 0..23</param> /// <param name="minute">Minutes value 0..59</param> /// <returns> /// TODO: Find out what it returns. /// </returns> public Response SetSchedule(ScheduleDay day, int hour, int minute) { if (hour < 0 || hour > 23) { throw new ArgumentOutOfRangeException("hour", hour, "Hours set must be within range 0..23."); } if (minute < 0 || minute > 59) { throw new ArgumentOutOfRangeException("minute", minute, "Minutes set must be within range 0..59."); } return this.neato.Connection.SendCommand("SetSchedule " + day + " " + hour + " " + minute + "HOUSE"); }
public BlobContainerDeleteForecastWorker( IBlobService blobService, string storageAccountName, string[] containerNames, ScheduleDay[] scheduleDays, int pollingIntervalInMinutes) : base(GetWorkerId(storageAccountName)) { this.blobService = blobService; this.storageAccountName = storageAccountName; this.containerNames = containerNames; this.scheduleDays = scheduleDays; this.pollingIntervalInMinutes = pollingIntervalInMinutes; }
public TableDeleteForecastWorker( ITableService tableService, string storageAccountName, string[] tableNames, ScheduleDay[] scheduleDays, int pollingIntervalInMinutes) : base(GetWorkerId(storageAccountName)) { this.tableService = tableService; this.storageAccountName = storageAccountName; this.tableNames = tableNames; this.scheduleDays = scheduleDays; this.pollingIntervalInMinutes = pollingIntervalInMinutes; }
/// <summary> /// Sets the current day, hour and minute for the scheduler clock. /// See http://www.neatorobotics.com/programmers-manual/table-of-robot-application-commands/detailed-command-descriptions/#SetTime for more info. /// </summary> /// <param name="day">Day of week.</param> /// <param name="hour">Hour value 0..23</param> /// <param name="minute">Minutes value 0..59</param> /// <param name="sec">Seconds value 0..59</param> public void SetTime(ScheduleDay day, int hour, int minute, int sec) { if (hour < 0 || hour > 23) { throw new ArgumentOutOfRangeException("hour", hour, "Hours set must be within range 0..23."); } if (minute < 0 || minute > 59) { throw new ArgumentOutOfRangeException("minute", minute, "Minutes set must be within range 0..59."); } if (sec < 0 || sec > 59) { throw new ArgumentOutOfRangeException("sec", sec, "Seconds set must be within range 0..59."); } this.neato.Connection.SendCommand("SetTime " + (int)day + " " + hour + " " + minute + " " + sec, true); }
public DeploymentDeleteForecastWorker( IDeployment deployment, IOperation operation, Guid subscriptionId, string certificateThumbprint, string serviceName, string deploymentSlot, ScheduleDay[] scheduleDays, int pollingIntervalInMinutes) : base(GetWorkerId(serviceName, deploymentSlot)) { this.deployment = deployment; this.operation = operation; this.subscriptionId = subscriptionId; this.certificateThumbprint = certificateThumbprint; this.serviceName = serviceName; this.deploymentSlot = deploymentSlot; this.scheduleDays = scheduleDays; this.pollingIntervalInMinutes = pollingIntervalInMinutes; }
public static ScheduleDay ToLadybugTools_ScheduleDay(this Profile profile) { if (profile == null) { return(null); } string uniqueName = Core.LadybugTools.Query.UniqueName(profile); if (string.IsNullOrWhiteSpace(uniqueName)) { return(null); } uniqueName = Core.LadybugTools.Query.UniqueName(typeof(ScheduleDay), uniqueName); List <double> values = new List <double>(); for (int i = 0; i < 24; i++) { values.Add(profile[i]); } Dictionary <Core.Range <int>, double> dictionary = Core.Query.RangeDictionary(values); values = new List <double>(); List <List <int> > times = new List <List <int> >(); foreach (KeyValuePair <Core.Range <int>, double> keyValuePair in dictionary) { values.Add(keyValuePair.Value); times.Add(new List <int>() { keyValuePair.Key.Min, 0 }); } ScheduleDay result = new ScheduleDay(uniqueName, values, profile.Name, times); return(result); }
public static Profile ToSAM(this ScheduleDay scheduleDay) { if (scheduleDay == null) { return(null); } List <double> values = scheduleDay.Values; if (values == null) { return(null); } Profile result = new Profile(scheduleDay.Identifier, scheduleDay.Type); if (values.Count == 1) { result.Add(new Core.Range <int>(0, 23), values[0]); } else { List <List <int> > times = scheduleDay.Times; if (times.Count == values.Count) { for (int i = 1; i < times.Count; i++) { int min = times[i - 1][0]; int max = times[i][0]; result.Add(new Core.Range <int>(min, max - 1), values[i - 1]); } int index = times.Count - 1; result.Add(new Core.Range <int>(times[index][0], 23), values[index]); } } return(result); }
public void scheduleGames_SingleLine() { const String SINGLE_LINE = "MLG-TXG* PTB-TBM* DTB-OKM* SDG-LAM*"; ScheduleDay day = new ScheduleDay(); day.addGames(SINGLE_LINE); String result1 = day.getTeamsGameToday("MLG"); Assert.IsTrue(result1.Equals("at TXG<br>")); String result2 = day.getTeamsGameToday("TXG"); Assert.IsTrue(result2.Equals("vs MLG<br>")); String result3 = day.getTeamsGameToday("SDG"); Assert.IsTrue(result3.Equals("at LAM<br>")); String result4 = day.getTeamsGameToday("LAM"); Assert.IsTrue(result4.Equals("vs SDG<br>")); }
private void setDayOff(object sender, RoutedEventArgs e) { ScheduleDay sd = ((FrameworkElement)sender).DataContext as ScheduleDay; if (sd.dayOff) { sd.EntryOne = ""; sd.exitOne = ""; sd.entryTwo = ""; sd.exitTwo = ""; sd.entryThree = ""; sd.exitThree = ""; sd.entryTolerance = ""; sd.exitTolerance = ""; sd.workload = ""; sd.endOfficeHour = ""; sd.dayOff = false; } else { sd.EntryOne = "FOLGA"; sd.exitOne = "FOLGA"; sd.entryTwo = "FOLGA"; sd.exitTwo = "FOLGA"; sd.entryThree = "FOLGA"; sd.exitThree = "FOLGA"; sd.entryTolerance = "FOLGA"; sd.exitTolerance = "FOLGA"; sd.workload = "FOLGA"; sd.endOfficeHour = "FOLGA"; sd.dayOff = true; sd.compensation = false; sd.automaticDayOff = false; sd.neutral = false; } GDScheduleDays.Items.Refresh(); }
public AnimeListData GetAiringSchedule(ScheduleDay day) { List <CoreAnimeEntry> list = new List <CoreAnimeEntry>(); var ret = AnimeListParser.Parse(m_malScheduleLink); ret.Animes.ForEach(x => { if (DateTime.TryParse(x.Aired, out DateTime res)) { if (day == ScheduleDay.Any || (int)day == (int)res.DayOfWeek) { list.Add(x); } } else if (day == ScheduleDay.Unknown) { list.Add(x); } }); ret.Animes = list; return(ret); }
public async Task <IActionResult> Create(CreateViewModel input) { if (this.ModelState.IsValid) { var shiftDay = new ScheduleDay { Name = input.Name, WorkingMode = input.WorkingMode, Begins = input.Begins.Length > 5 ? null : input.Begins, CreatedFrom = "Dxcv Gdfgh Ydfgh", Duration = input.Duration == 0 ? null : input.Duration, IncludingRest = input.IncludingRest == 0 ? null : input.IncludingRest, ScheduleId = input.ScheduleId, }; await this.scheduleDayRepository.AddAsync(shiftDay); await this.scheduleDayRepository.SaveChangesAsync(); return(this.RedirectToAction("Index", "ScheduleDays", new { id = shiftDay.ScheduleId })); } return(View()); }
private void repeatFirstScheduleDay(object sender, RoutedEventArgs e) { ScheduleDay firstSd = (ScheduleDay)GDScheduleDays.Items[0]; foreach (ScheduleDay sd in GDScheduleDays.ItemsSource) { sd.EntryOne = firstSd.EntryOne; sd.exitOne = firstSd.exitOne; sd.entryTwo = firstSd.entryTwo; sd.exitTwo = firstSd.exitTwo; sd.entryThree = firstSd.entryThree; sd.exitThree = firstSd.exitThree; sd.entryTolerance = firstSd.entryTolerance; sd.exitTolerance = firstSd.exitTolerance; sd.workload = firstSd.workload; sd.endOfficeHour = firstSd.endOfficeHour; sd.neutral = firstSd.neutral; sd.compensation = firstSd.compensation; sd.automaticDayOff = firstSd.automaticDayOff; } GDScheduleDays.Items.Refresh(); updateWeekWorload(); }
private static ScheduleDay[] GetScheduleDaysFromScheduleConfiguration(ScheduleDefinitionConfiguration scheduleConfiguration) { ScheduleDay[] scheduleDays = new ScheduleDay[scheduleConfiguration.Days.Count]; for (int i = 0; i < scheduleConfiguration.Days.Count; i++) { scheduleDays[i] = new ScheduleDay { DayOfWeek = scheduleConfiguration.Days[i].DayOfWeek, EndTime = scheduleConfiguration.Days[i].EndTime, StartTime = scheduleConfiguration.Days[i].StartTime }; } return scheduleDays; }
public static ScheduleRuleset ToLadybugTools(this Profile profile, ProfileType profileType = ProfileType.Undefined) { if (profile == null) { return(null); } string uniqueName = Core.LadybugTools.Query.UniqueName(profile); if (string.IsNullOrWhiteSpace(uniqueName)) { return(null); } //TODO: Add more sophisticated Method to create ScheduleRulesetAbridged List <Profile> profiles = profile.GetProfiles()?.ToList(); if (profiles == null) { profiles = new List <Profile>(); } if (profiles.Count == 0) { profiles.Add(profile); } profiles.RemoveAll(x => x == null); if (profiles.Count == 0) { return(null); } Dictionary <System.Guid, ScheduleDay> dictionary_ScheduleDay = new Dictionary <System.Guid, ScheduleDay>(); foreach (Profile profile_Temp in profiles) { System.Guid guid = profile_Temp.Guid; if (dictionary_ScheduleDay.ContainsKey(guid)) { continue; } ScheduleDay scheduleDay = profile_Temp.ToLadybugTools_ScheduleDay(); if (scheduleDay == null) { continue; } dictionary_ScheduleDay[guid] = scheduleDay; } if (dictionary_ScheduleDay == null || dictionary_ScheduleDay.Count == 0) { return(null); } int index = 0; while (profiles.Count < 7) { profiles.Add(profiles[index]); index++; } Dictionary <System.Guid, ScheduleRuleAbridged> dictionary_ScheduleRuleAbridged = new Dictionary <System.Guid, ScheduleRuleAbridged>(); for (int i = 0; i < 7; i++) { System.Guid guid = profiles[i].Guid; if (!dictionary_ScheduleDay.ContainsKey(guid)) { continue; } ScheduleDay scheduleDay = dictionary_ScheduleDay[guid]; ScheduleRuleAbridged scheduleRuleAbridged; if (!dictionary_ScheduleRuleAbridged.TryGetValue(guid, out scheduleRuleAbridged)) { scheduleRuleAbridged = new ScheduleRuleAbridged(scheduleDay.Identifier); dictionary_ScheduleRuleAbridged[guid] = scheduleRuleAbridged; } switch (i) { case 0: scheduleRuleAbridged.ApplyMonday = true; break; case 1: scheduleRuleAbridged.ApplyTuesday = true; break; case 2: scheduleRuleAbridged.ApplyWednesday = true; break; case 3: scheduleRuleAbridged.ApplyThursday = true; break; case 4: scheduleRuleAbridged.ApplyFriday = true; break; case 5: scheduleRuleAbridged.ApplySaturday = true; break; case 6: scheduleRuleAbridged.ApplySunday = true; break; } } List <ScheduleDay> scheduleDays = dictionary_ScheduleDay.Values.ToList(); List <ScheduleRuleAbridged> scheduleRuleAbridgedes = dictionary_ScheduleRuleAbridged.Values.ToList(); ScheduleRuleset result = new ScheduleRuleset( identifier: uniqueName, daySchedules: scheduleDays, defaultDaySchedule: scheduleDays.First().Identifier, displayName: profile.Name, userData: null, scheduleRules: scheduleRuleAbridgedes); return(result); }
public virtual List <ScheduleGame> PlayDay(ScheduleDay day, Random random) { return(PlayGames(day.Games, random)); }
public int Insert(ScheduleDay scheduleDay) { int bigId = (int)_scheduleDayService.InsertBigIdentity(scheduleDay); return(bigId); }
public static void ExportToFile(ScheduleDay day, string file) { //string json = JsonSerializer.ToString(day); string json = JsonSerializer.Serialize(day, day.GetType()); }
public static void ReadXls(string FileName) { //ScheduleController.CheckFile(); ScheduleController.Unit(); ScheduleController.AddUniversity("мисис"); ScheduleController.AddFaculty("мисис", FileName); HSSFWorkbook hssfwb; using (FileStream file = new FileStream(@"" + FileName + ".xls", FileMode.Open, FileAccess.Read)) { hssfwb = new HSSFWorkbook(file); } for (int course = 1; course < 7; course++) { if (hssfwb.GetSheet(course + " курс") == null) { break; } ScheduleController.AddCourse("мисис", FileName, course.ToString()); ISheet sheet = hssfwb.GetSheet(course + " курс"); int group = 4; //int myFlag = 0; while (sheet.GetRow(1).GetCell(group - 1) != null) { if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "1") { ScheduleController.AddGroup("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 1 подгруппа"); } else if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "2") { if (sheet.GetRow(0).GetCell(group - 1).ToString() == "") { ScheduleController.AddGroup("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 3).StringCellValue + " 2 подгруппа"); } else { ScheduleController.AddGroup("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 2 подгруппа"); } } else { ScheduleController.AddGroup("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue); } ScheduleWeek week1 = new ScheduleWeek(); ScheduleWeek week2 = new ScheduleWeek(); week1.Week = 1; week1.Day = new List <ScheduleDay>(); week2.Week = 2; week2.Day = new List <ScheduleDay>(); for (int dayofweek = 3; dayofweek < 100; dayofweek += 14) { ScheduleDay day1 = new ScheduleDay(); ScheduleDay day2 = new ScheduleDay(); day1.Day = dayofweek / 14 + 1; day1.Lesson = new List <Lesson>(); day2.Day = dayofweek / 14 + 1; day2.Lesson = new List <Lesson>(); for (int para = dayofweek; para < dayofweek + 14; para += 2) { if (sheet.GetRow(para - 1).GetCell(group - 1) != null) { if (sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue != "") { Lesson a = new Lesson() { Name = sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue, Time = sheet.GetRow(para - 1).GetCell(2).StringCellValue, Room = sheet.GetRow(para - 1).GetCell(group).StringCellValue, Teacher = "", Number = ((para - dayofweek) / 2 + 1).ToString() }; day1.Lesson.Add(a); } } if (sheet.GetRow(para).GetCell(group - 1) != null) { if (sheet.GetRow(para).GetCell(group - 1).StringCellValue != "") { day2.Lesson.Add(new Lesson() { Name = sheet.GetRow(para).GetCell(group - 1).StringCellValue, Time = sheet.GetRow(para - 1).GetCell(2).StringCellValue, Room = sheet.GetRow(para).GetCell(group).StringCellValue, Teacher = "", Number = ((para - dayofweek) / 2 + 1).ToString() }); } } } week1.Day.Add(day1); week2.Day.Add(day2); } if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "1") { ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 1 подгруппа", week1); ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 1 подгруппа", week2); } else if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "2") { if (sheet.GetRow(0).GetCell(group - 1).ToString() == "") { ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 3).StringCellValue + " 2 подгруппа", week1); ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 3).StringCellValue + " 2 подгруппа", week2); } else { ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 2 подгруппа", week1); ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 2 подгруппа", week2); } } else { ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue, week1); ScheduleController.AddScheduleWeek("мисис", FileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue, week2); } group += 2; } } }
public void UpdateScheduleDay(ScheduleDay day) { db.Entry(day).State = EntityState.Modified; }
/// <summary> /// Clears the scheduled clean for the specified day. /// </summary> /// <param name="day">Day to clear cleaning from.</param> public void RemoveCleanSchedule(ScheduleDay day) { this.neato.Connection.SendCommand("SetSchedule " + day + " 0 0 NONE"); }
public void ReadXlsx(string fileName) { //Schedule.AddUniversity("РХТУ им.Менделеева"); XSSFWorkbook scheduleWorkbook; using (FileStream file = new FileStream(@"Schedule Files\Mendeleev\" + fileName + ".xlsx", FileMode.Open, FileAccess.Read)) { scheduleWorkbook = new XSSFWorkbook(file); } int sheetCount = scheduleWorkbook.NumberOfSheets; for (int sheetNumber = 0; sheetNumber < sheetCount; sheetNumber++) { ISheet sheet = scheduleWorkbook.GetSheetAt(sheetNumber); try { if (sheet.GetRow(0).GetCell(1).StringCellValue == "") { break; } } catch { break; } int row = 3; int cell = 10; while (sheet.GetRow(row - 1).GetCell(cell + 1) != null) // перебор всех групп { if (sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue == "") { break; } //Schedule.AddFacility("РХТУ им.Менделеева", //GetFacility(sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue.Split('-')[0])); //Schedule.AddCourse("РХТУ им.Менделеева", // GetFacility(sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue.Split('-')[0]), // fileName[0].ToString()); //Schedule.AddGroup("РХТУ им.Менделеева", // GetFacility(sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue.Split('-')[0]), // fileName[0].ToString(), // sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue,2); ScheduleWeek week1 = new ScheduleWeek(); ScheduleWeek week2 = new ScheduleWeek(); week1.Week = 2; week1.Days = new List <ScheduleDay>(); //номера недель отличаются от мисис week2.Week = 1; week2.Days = new List <ScheduleDay>(); for (int weekDay = 1; weekDay <= 6; weekDay++) //перебор всех дней недели { ScheduleDay day1 = new ScheduleDay(); ScheduleDay day2 = new ScheduleDay(); day1.Day = weekDay; day1.Lessons = new List <Lesson>(); day2.Day = weekDay; day2.Lessons = new List <Lesson>(); bool isFind = true; //определяет, найдены ли все куски склеенной ячейки string startTime = String.Empty; string endTime = String.Empty; int rowBufer = 0; for (int lessonIndex = 0; lessonIndex < 10; lessonIndex++) //перебор всех пар в дне { if (sheet.GetRow(row).GetCell(cell) == null) { continue; } if (weekDay == 6 && lessonIndex > 5) //в суббту { continue; } if (isFind) //если вся ячейка собрана { rowBufer = row; startTime = sheet.GetRow(row).GetCell(1).StringCellValue; endTime = sheet.GetRow(row).GetCell(1).StringCellValue; try { if (sheet.GetRow(row + 1).GetCell(cell + 1).IsMergedCell && sheet.GetRow(row + 1).GetCell(cell + 1).StringCellValue == "") //если снизу находится нижняя часть ячейки, то она объединенная { isFind = false; } else if (sheet.GetRow(row).GetCell(cell + 1).StringCellValue != "") { AddDay(sheet, row, cell, GetTime(startTime, endTime), GetLessonNumber(GetTime(startTime, startTime)), day1, day2, true); } } catch { continue; } } else //продолжается поиск всех частей сборной ячейки { endTime = sheet.GetRow(row).GetCell(1).StringCellValue; try { if (!sheet.GetRow(row + 1).GetCell(cell + 1).IsMergedCell || (sheet.GetRow(row + 1).GetCell(cell + 1).IsMergedCell && sheet.GetRow(row + 1).GetCell(cell + 1).StringCellValue != "") || lessonIndex == 9) //если снизу находится часть объединения ячеек или блок кончился, то можно запоминать последнее время и сохранять { isFind = true; AddDay(sheet, rowBufer, cell, GetTime(startTime, endTime), GetLessonNumber(GetTime(startTime, startTime)), day1, day2); } } catch { continue; } } row++; } week1.Days.Add(day1); week2.Days.Add(day2); } row = 3; Schedule.AddScheduleWeek("РХТУ им.Менделеева", GetFacility(sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue.Split('-')[0]), fileName[0].ToString(), sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue, 2, week1); Schedule.AddScheduleWeek("РХТУ им.Менделеева", GetFacility(sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue.Split('-')[0]), fileName[0].ToString(), sheet.GetRow(row - 1).GetCell(cell + 1).StringCellValue, 2, week2); cell += 4; } } }
public void ScheduledPropertyPage_OnLoad(object sender, EventArgs e) { this.textScheduleName.Text = adapterConfiguration.Name; this.checkSuspendMessage.Checked = adapterConfiguration.SuspendMessage; if (adapterConfiguration.Schedule != null) { this.dateStartDate.Value = adapterConfiguration.Schedule.StartDate; this.dateStartTime.Value = adapterConfiguration.Schedule.StartTime; this.comboScheduleType.SelectedItem = adapterConfiguration.Schedule.Type; switch (adapterConfiguration.Schedule.Type) { case ScheduleType.Daily: //set Daily schedule properties DaySchedule daySchedule = adapterConfiguration.Schedule as DaySchedule; this.updownDayInterval.Value = Convert.ToDecimal(daySchedule.Interval); //if (this.updownDayInterval.Value == 0) --- to be removed if (daySchedule.ScheduledDays != ScheduleDay.None) { ScheduleDay days = daySchedule.ScheduledDays; if ((days & ScheduleDay.Sunday) > 0) { checkDaySunday.Checked = true; } if ((days & ScheduleDay.Monday) > 0) { checkDayMonday.Checked = true; } if ((days & ScheduleDay.Tuesday) > 0) { checkDayTuesday.Checked = true; } if ((days & ScheduleDay.Wednesday) > 0) { checkDayWednesday.Checked = true; } if ((days & ScheduleDay.Thursday) > 0) { checkDayThursday.Checked = true; } if ((days & ScheduleDay.Friday) > 0) { checkDayFriday.Checked = true; } if ((days & ScheduleDay.Saturday) > 0) { checkDaySaturday.Checked = true; } //radioDayInterval.Checked = false; --- to be removed radioSelectDays.Checked = true; } else { radioDayInterval.Checked = true; } break; case ScheduleType.Weekly: //set Weekly schedule properties WeekSchedule weekSchedule = adapterConfiguration.Schedule as WeekSchedule; this.updownWeekInterval.Value = weekSchedule.Interval; ScheduleDay weekDays = weekSchedule.ScheduledDays; if ((weekDays & ScheduleDay.Sunday) > 0) { checkWeekSunday.Checked = true; } if ((weekDays & ScheduleDay.Monday) > 0) { checkWeekMonday.Checked = true; } if ((weekDays & ScheduleDay.Tuesday) > 0) { checkWeekTuesday.Checked = true; } if ((weekDays & ScheduleDay.Wednesday) > 0) { checkWeekWednesday.Checked = true; } if ((weekDays & ScheduleDay.Thursday) > 0) { checkWeekThursday.Checked = true; } if ((weekDays & ScheduleDay.Friday) > 0) { checkWeekFriday.Checked = true; } if ((weekDays & ScheduleDay.Saturday) > 0) { checkWeekSaturday.Checked = true; } break; case ScheduleType.Monthly: //set Monthly schedule properties MonthSchedule monthSchedule = adapterConfiguration.Schedule as MonthSchedule; this.updownDayofMonth.Value = monthSchedule.Day; if (this.updownDayofMonth.Value == 0) { this.comboOrdinal.SelectedItem = monthSchedule.Ordinal; this.comboWeekday.SelectedItem = monthSchedule.WeekDay; radioDayofMonth.Checked = false; } else { radioDayofMonth.Checked = true; } ScheduleMonth months = monthSchedule.ScheduledMonths; if ((months & ScheduleMonth.January) > 0) { checkJanuary.Checked = true; } if ((months & ScheduleMonth.February) > 0) { checkFebruary.Checked = true; } if ((months & ScheduleMonth.March) > 0) { checkMarch.Checked = true; } if ((months & ScheduleMonth.April) > 0) { checkApril.Checked = true; } if ((months & ScheduleMonth.May) > 0) { checkMay.Checked = true; } if ((months & ScheduleMonth.June) > 0) { checkJune.Checked = true; } if ((months & ScheduleMonth.July) > 0) { checkJuly.Checked = true; } if ((months & ScheduleMonth.August) > 0) { checkAugust.Checked = true; } if ((months & ScheduleMonth.September) > 0) { checkSeptember.Checked = true; } if ((months & ScheduleMonth.October) > 0) { checkOctober.Checked = true; } if ((months & ScheduleMonth.November) > 0) { checkNovember.Checked = true; } if ((months & ScheduleMonth.December) > 0) { checkDecember.Checked = true; } break; case ScheduleType.TimeSpan: //set Timespan schedule properties TimeSpanSchedule timeSchedule = adapterConfiguration.Schedule as TimeSpanSchedule; int timeinseconds = timeSchedule.Interval; if (timeinseconds % 3600 == 0) { this.updownTimeInterval.Value = (timeinseconds / 3600); this.comboTimeUnits.SelectedItem = ScheduleTimeUnit.Hours; } else if (timeinseconds % 60 == 0) { this.updownTimeInterval.Value = (timeinseconds / 60); this.comboTimeUnits.SelectedItem = ScheduleTimeUnit.Minutes; } else { this.updownTimeInterval.Value = timeinseconds; this.comboTimeUnits.SelectedItem = ScheduleTimeUnit.Seconds; } break; default: break; } } if (adapterConfiguration.Task != null) { this.taskType = adapterConfiguration.Task.TaskType; this.textTaskClass.Text = adapterConfiguration.Task.TaskType.AssemblyQualifiedName; this.propertyGridTask.SelectedObject = adapterConfiguration.Task.TaskParameters; } }
public void IsDayValid(ScheduleDay day, bool expected) { var counts = new ScheduleDayValidator(day); StrictEqual(expected, counts.IsValid); }
public static void BuildTestSchedule() { string dateFormat = "yyyyMMdd"; int channelID = 1; string status = "In Planning"; const int secondsInHour = 3600; ScheduleDay day = new ScheduleDay(IdGenerator.GetNextID(), channelID, DateTime.ParseExact("20200501", dateFormat, null), status); day.AddEvent( new ScheduleEvent( IdGenerator.GetNextID(), new TimeValue(secondsInHour * 6), new TimeValue(secondsInHour * 2), DateTime.ParseExact("20200501", dateFormat, null), channelID, "Morning Show")); day.AddEvent( new ScheduleEvent( IdGenerator.GetNextID(), new TimeValue(secondsInHour * 10), new TimeValue(secondsInHour * 2), DateTime.ParseExact("20200501", dateFormat, null), channelID, "Lazy Morning Show")); day.AddEvent( new ScheduleEvent( IdGenerator.GetNextID(), new TimeValue(secondsInHour * 8), new TimeValue(secondsInHour * 2), DateTime.ParseExact("20200501", dateFormat, null), channelID, "Normal People Morning Show")); foreach (ScheduleEvent e in day.Events) { e.AddSubElement( new ScheduleElement[] { new ProgramPart(IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(25 * 60)), new ScheduleBreak( IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(5 * 60), subElements: new ScheduleAvail[] { new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Billboard, TimeValue.Zero, new TimeValue(20)), new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Commercial, TimeValue.Zero, new TimeValue(5 * 60 - 20)) } ), new ProgramPart(IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(25 * 60)), new ScheduleBreak( IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(5 * 60), subElements: new ScheduleAvail[] { new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Billboard, TimeValue.Zero, new TimeValue(30)), new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Commercial, TimeValue.Zero, new TimeValue(5 * 60 - 30)) } ), new ProgramPart(IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(25 * 60)), new ScheduleBreak( IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(5 * 60), subElements: new ScheduleAvail[] { new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Billboard, TimeValue.Zero, new TimeValue(30)), new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Commercial, TimeValue.Zero, new TimeValue(2 * 60 - 30)), new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Commercial, TimeValue.Zero, new TimeValue(3 * 60)) } ), new ProgramPart(IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(25 * 60)), new ScheduleBreak( IdGenerator.GetNextID(), TimeValue.Zero, new TimeValue(5 * 60), subElements: new ScheduleAvail[] { new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Billboard, TimeValue.Zero, new TimeValue(30)), new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Commercial, TimeValue.Zero, new TimeValue(2 * 60 - 30)), new ScheduleAvail(IdGenerator.GetNextID(), SchduleAvailType.Commercial, TimeValue.Zero, new TimeValue(3 * 60)) } ) } ); } ConsoleVisualizer.PrintDay(day); }
private void LoadMonthlySchedule() { tabPages.SelectedTab = tabMonthly; _dayofmonth.Value = Convert.ToDecimal(Schedule.IfExistsExtractInt(ConfigXml, "/schedule/dayofmonth", 0)); if (_dayofmonth.Value == 0) { ScheduleOrdinal ordinal = Schedule.ExtractScheduleOrdinal(ConfigXml, "/schedule/ordinal", false); int index = ordinalDropDown.Items.IndexOf(ordinal.ToString()); ordinalDropDown.SelectedIndex = index; ScheduleDay weekDay = Schedule.ExtractScheduleDay(ConfigXml, "/schedule/weekday", false); string strWeekday = weekDay.ToString(); if (strWeekday == "All") { strWeekday = "Day"; } index = weekdayDropDown.Items.IndexOf(strWeekday); weekdayDropDown.SelectedIndex = index; radioDayofMonth.Checked = false; } else { radioDayofMonth.Checked = true; } ScheduleMonth months = Schedule.ExtractScheduleMonth(ConfigXml, "/schedule/months", false); if ((months & ScheduleMonth.February) > 0) { monthFebruary.Checked = true; } if ((months & ScheduleMonth.March) > 0) { monthMarch.Checked = true; } if ((months & ScheduleMonth.April) > 0) { monthApril.Checked = true; } if ((months & ScheduleMonth.May) > 0) { monthMay.Checked = true; } if ((months & ScheduleMonth.June) > 0) { monthJune.Checked = true; } if ((months & ScheduleMonth.July) > 0) { monthJuly.Checked = true; } if ((months & ScheduleMonth.August) > 0) { monthAugust.Checked = true; } if ((months & ScheduleMonth.September) > 0) { monthSeptember.Checked = true; } if ((months & ScheduleMonth.October) > 0) { monthOctober.Checked = true; } if ((months & ScheduleMonth.November) > 0) { monthNovember.Checked = true; } if ((months & ScheduleMonth.December) > 0) { monthDecember.Checked = true; } }
public void Copy(ScheduleDay scheduleDay) { First.Copy(scheduleDay.First); Second.Copy(scheduleDay.Second); Third.Copy(scheduleDay.Third); }
public void ReadXlsx(string fileName) { //schedule.CheckFile(); //Schedule.AddUniversity("НИТУ МИСиС"); //Schedule.AddFacility("НИТУ МИСиС", fileName); XSSFWorkbook hssfwb; using (FileStream file = new FileStream(@"Schedule Files\Misis\" + fileName + ".xlsx", FileMode.Open, FileAccess.Read)) { hssfwb = new XSSFWorkbook(file); } for (int course = 1; course < 9; course++) { if (hssfwb.GetSheet(course + " курс") == null) { break; } //Schedule.AddCourse("НИТУ МИСиС", fileName, course.ToString()); ISheet sheet = hssfwb.GetSheet(course + " курс"); int group = 4; //int myFlag = 0; while (sheet.GetRow(1).GetCell(group - 1) != null) { //if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "1") //{ // Schedule.AddGroup("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 1 подгруппа",2); //} //else if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "2") //{ // if (sheet.GetRow(0).GetCell(group - 1).ToString() == "") // Schedule.AddGroup("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 3).StringCellValue + " 2 подгруппа",2); // else // Schedule.AddGroup("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 2 подгруппа",2); //} //else //{ // Schedule.AddGroup("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue,2); //} ScheduleWeek week1 = new ScheduleWeek(); ScheduleWeek week2 = new ScheduleWeek(); week1.Week = 1; week1.Days = new List <ScheduleDay>(); week2.Week = 2; week2.Days = new List <ScheduleDay>(); for (int dayofweek = 3; dayofweek < 100; dayofweek += 14) { ScheduleDay day1 = new ScheduleDay(); ScheduleDay day2 = new ScheduleDay(); day1.Day = dayofweek / 14 + 1; day1.Lessons = new List <Lesson>(); day2.Day = dayofweek / 14 + 1; day2.Lessons = new List <Lesson>(); for (int para = dayofweek; para < dayofweek + 14; para += 2) { if (sheet.GetRow(para - 1).GetCell(group - 1) != null) { if (sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue != "") { try { if (sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue == "") { continue; } Lesson a = new Lesson() { Name = GetName(sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue), Time = sheet.GetRow(para - 1).GetCell(2).StringCellValue, Room = sheet.GetRow(para - 1).GetCell(group).StringCellValue, Teacher = GetTeacher(sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue), Type = GetType(sheet.GetRow(para - 1).GetCell(group - 1).StringCellValue), Number = ((para - dayofweek) / 2 + 1).ToString() }; day1.Lessons.Add(a); } catch { continue; } } } if (sheet.GetRow(para).GetCell(group - 1) != null) { if (sheet.GetRow(para).GetCell(group - 1).StringCellValue != "") { day2.Lessons.Add(new Lesson() { Name = sheet.GetRow(para).GetCell(group - 1).StringCellValue, Time = sheet.GetRow(para - 1).GetCell(2).StringCellValue, Room = sheet.GetRow(para).GetCell(group).StringCellValue, Teacher = GetTeacher(sheet.GetRow(para).GetCell(group - 1).StringCellValue), Type = GetType(sheet.GetRow(para).GetCell(group - 1).StringCellValue), Number = ((para - dayofweek) / 2 + 1).ToString() }); } } } week1.Days.Add(day1); week2.Days.Add(day2); } if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "1") { Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 1 подгруппа", 2, week1); Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 1 подгруппа", 2, week2); } else if (sheet.GetRow(1).GetCell(group - 1).NumericCellValue.ToString() == "2") { if (sheet.GetRow(0).GetCell(group - 1).ToString() == "") { Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 3).StringCellValue + " 2 подгруппа", 2, week1); Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 3).StringCellValue + " 2 подгруппа", 2, week2); } else { Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 2 подгруппа", 2, week1); Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue + " 2 подгруппа", 2, week2); } } else { Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue, 2, week1); Schedule.AddScheduleWeek("НИТУ МИСиС", fileName, course.ToString(), sheet.GetRow(0).GetCell(group - 1).StringCellValue, 2, week2); } group += 2; } } }
public ScheduleDay CreateScheduleDay(ScheduleDay day) { var scd = db.ScheduleDays.Add(day); return(scd); }
public void calculateHours(DailyMarking dm) { setFieldsByMarkings(dm); List <DateTime> recessDates = recessControl.getAllRecessDates(); ScheduleDay scheduleDay = scheduleControl.getScheduleDay(dm.employee.schedule, MarkingUtil.getDayKey(dm.date.DayOfWeek)); Boolean usualDay = true; string entryTolerance = "0"; string exitTolerance = "0"; TimeSpan standartHoursTS = TimeSpan.Parse("00:00"); TimeSpan faultHoursTS = TimeSpan.Parse("00:00"); TimeSpan extraHoursTS = TimeSpan.Parse("00:00"); TimeSpan workloadTS = TimeSpan.Parse("00:00"); if (scheduleDay.workload != null && !"".Equals(scheduleDay.workload)) { if (absenceControl.getEmployeeInAbsence(dm.employee, dm.date)) { if (!MarkingUtil.testRestrictionModification("AFASTADO", dm)) { dm.entryOne = "AFASTADO"; dm.exitOne = "AFASTADO"; dm.entryTwo = "AFASTADO"; dm.exitTwo = "AFASTADO"; dm.entryThree = "AFASTADO"; dm.exitThree = "AFASTADO"; return; } else { usualDay = false; } } if (recessDates.Contains(dm.date)) { if (!MarkingUtil.testRestrictionModification("FERIADO", dm)) { dm.entryOne = "FERIADO"; dm.exitOne = "FERIADO"; dm.entryTwo = "FERIADO"; dm.exitTwo = "FERIADO"; dm.entryThree = "FERIADO"; dm.exitThree = "FERIADO"; return; } else { usualDay = false; } } if ("FOLGA".Equals(scheduleDay.workload)) { if (!MarkingUtil.testRestrictionModification("FOLGA", dm)) { dm.entryOne = "FOLGA"; dm.exitOne = "FOLGA"; dm.entryTwo = "FOLGA"; dm.exitTwo = "FOLGA"; dm.entryThree = "FOLGA"; dm.exitThree = "FOLGA"; return; } else { usualDay = false; } } if (usualDay) { workloadTS = TimeSpan.Parse(scheduleDay.workload); entryTolerance = scheduleDay.entryTolerance; exitTolerance = scheduleDay.exitTolerance; } if (dm.entryOne != null && dm.exitOne != null) { standartHoursTS += TimeSpan.Parse(dm.exitOne) - TimeSpan.Parse(dm.entryOne); } if (dm.entryTwo != null && dm.exitTwo != null) { standartHoursTS += TimeSpan.Parse(dm.exitTwo) - TimeSpan.Parse(dm.entryTwo); } if (dm.entryThree != null && dm.exitThree != null) { standartHoursTS += TimeSpan.Parse(dm.exitThree) - TimeSpan.Parse(dm.entryThree); } if (standartHoursTS != TimeSpan.Parse("00:00")) { if (scheduleDay.compensation) { if (standartHoursTS.CompareTo(workloadTS) > 0) { TimeSpan extra = standartHoursTS - workloadTS; if (extra.TotalMinutes > Convert.ToInt16(entryTolerance)) { extraHoursTS = extra; } else { standartHoursTS = workloadTS; } } else { TimeSpan fault = workloadTS - standartHoursTS; if (fault.TotalMinutes > Convert.ToInt16(exitTolerance)) { faultHoursTS = workloadTS - standartHoursTS; } else { standartHoursTS = workloadTS; } } } else { if (standartHoursTS.CompareTo(workloadTS) > 0) { extraHoursTS = standartHoursTS - workloadTS; } else { faultHoursTS = workloadTS - standartHoursTS; } } } else { if (scheduleDay.automaticDayOff) { dm.entryOne = "FOLGA"; dm.exitOne = "FOLGA"; dm.entryTwo = "FOLGA"; dm.exitTwo = "FOLGA"; dm.entryThree = "FOLGA"; dm.exitThree = "FOLGA"; standartHoursTS = TimeSpan.Parse("00:00"); faultHoursTS = TimeSpan.Parse("00:00"); extraHoursTS = TimeSpan.Parse("00:00"); workloadTS = TimeSpan.Parse("00:00"); return; } } dm.standartHours = standartHoursTS.ToString(@"hh\:mm"); dm.faultHours = faultHoursTS.ToString(@"hh\:mm"); dm.extraHours = extraHoursTS.ToString(@"hh\:mm"); dm.workload = workloadTS.ToString(@"hh\:mm"); } }
public void Execute(ScheduleDay day) { throw new NotImplementedException(); }
private Table GetDayTable(ScheduleDay day, List <Table> templateTables) { Table dayTable = new Table(); try { //в зависимости от того, какой знак дня - берем для заполнения шаблона соответствующую таблицу в templateTables Table dayTemplateTable = templateTables[day.SignNumber + 1] ?? templateTables[1]; TableRow tr = (TableRow)dayTemplateTable.ChildElements[2].Clone(); TableCell tdDayofweek = (TableCell)tr.ChildElements[2]; TableCell tdName = (TableCell)tr.ChildElements[3]; string sDayofweek = day.Date.ToString("dddd").ToUpper(); string sName = day.Name; //TODO: реализовать функционал bool bIsNameBold = false;//(dayNode.SelectSingleNode("name").Attributes["isbold"] != null); SetTextToCell(tdDayofweek, sDayofweek, false, false); SetTextToCell(tdName, sName, bIsNameBold, false); dayTable.AppendChild(tr); tr = (TableRow)dayTemplateTable.ChildElements[3].Clone(); TableCell tdDate = (TableCell)tr.ChildElements[2]; string sDate = day.Date.ToString("dd MMMM yyyy г."); SetTextToCell(tdDate, sDate, false, false); dayTable.AppendChild(tr); foreach (WorshipRuleViewModel service in day.Schedule) { tr = (TableRow)dayTemplateTable.ChildElements[4].Clone(); TableCell tdTime = (TableCell)tr.ChildElements[2]; TableCell tdSName = (TableCell)tr.ChildElements[3]; string sTime = service.Time.ToString(); string sSName = service.Name; bool bIsTimeBold = false; //(serviceNode.Attributes["istimebold"] != null); bool bIsTimeRed = false; //(serviceNode.Attributes["istimered"] != null); bool bIsServiceNameBold = false; //(serviceNode.Attributes["isnamebold"] != null); bool bIsServiceNameRed = false; //(serviceNode.Attributes["isnamered"] != null); SetTextToCell(tdTime, sTime, bIsTimeBold, bIsTimeRed); SetTextToCell(tdSName, sSName, bIsServiceNameBold, bIsServiceNameRed); //additionalName if (!string.IsNullOrEmpty(service.AdditionalName)) { AppendTextToCell(tdSName, service.AdditionalName, true, false); } //tr.ChildElements[1].InnerXml = dayNode.SelectSingleNode("time").InnerText; //tr.ChildElements[2].InnerXml = dayNode.SelectSingleNode("name").InnerText; dayTable.AppendChild(tr); } } catch (IndexOutOfRangeException) { } return(dayTable); }
/// <summary> /// Get the Cleaning Schedule. (24 hour clock format) /// See http://www.neatorobotics.com/programmers-manual/table-of-robot-application-commands/detailed-command-descriptions/#GetSchedule for more info. /// </summary> /// <param name="flag">Day of the week to get schedule for.</param> /// <returns> /// Cleaning schedule for specified day. /// </returns> public Response GetSchedule(ScheduleDay flag) { // TODO: Implement. "GetSchedule Day 0" or "GetSchedule 0" ? return(this.neato.Connection.SendCommand("GetSchedule " + (int)flag)); }
/// <summary> /// 加载单日时刻表 /// </summary> /// <param name="programScheduleTime"></param> private void LoadScheduleDay(ProgramScheduleTime programScheduleTime) { DateTime dtNow = DateTime.Now; DateTime dtStart, dtEnd; ScheduleDayProgram dayProgram = null; Canvas canvasLayOut = null; ScheduleDay scheduleDay = programScheduleTime.scheduleDay; foreach (var dayProgramItem in scheduleDay.ProgramList) //查找具体时刻表里面符合时间范围的节目 { string tmp = dtNow.ToShortDateString() + " " + dayProgramItem.start_time; //开始时间 DateTime.TryParse(tmp, out dtStart); tmp = dtNow.ToShortDateString() + " " + dayProgramItem.end_time; //结束时间 DateTime.TryParse(tmp, out dtEnd); if (dtNow >= dtStart && dtNow <= dtEnd) { dayProgram = dayProgramItem; _logWrite.WriteLog($"查找到ScheduleDayProgram对象id={dayProgram.id}"); break; } } if (dayProgram != null)//查找到正确的时刻 { ProgramInfo programInfo = _programInfoService.GetCompositeById(dayProgram.program_id); if (programInfo != null) { _logWrite.WriteLog($"开始加载节目信息={programInfo.id} {programInfo.program_name}"); mainWindow.Dispatcher.Invoke(new Action(() => { canvasLayOut = new Canvas(); mainWindow.Width = programInfo.w; //窗体尺寸-宽 mainWindow.Height = programInfo.h; //窗体尺寸-高 canvasLayOut.Width = programInfo.w; canvasLayOut.Height = programInfo.h; })); this.PresentUIElement = canvasLayOut; foreach (var region in programInfo.RegionList)//区块列表 { if (!RegionManagerDic.ContainsKey(region.id)) { ProgramRegionPlayManager regioManager = new ProgramRegionPlayManager(canvasLayOut, region, _mediaInfoService, _logWrite); regioManager.PlayStart(); RegionManagerDic.Add(region.id, regioManager); } } mainWindow.Dispatcher.Invoke(new Action(() => { mainWindow.Content = canvasLayOut;//画布赋值给窗体 })); } else { _logWrite.WriteLog($"未查找到ProgramInfo对象,对象id={dayProgram.program_id}"); } } else { _logWrite.WriteLog("未查找到ScheduleDayProgram对象"); } }
private void AddDay(ISheet sheet, int row, int cell, string time, int lessonNumber, ScheduleDay day1, ScheduleDay day2, bool onlyOne = false) { if (onlyOne) { string roomx = String.Empty; try //определение, цифра ли кабинет или слово { roomx = sheet.GetRow(row).GetCell(cell).StringCellValue; } catch { roomx = sheet.GetRow(row).GetCell(cell).NumericCellValue.ToString(); } string namex = sheet.GetRow(row).GetCell(cell + 1).StringCellValue; string lessonTypex = sheet.GetRow(row).GetCell(cell + 2).StringCellValue; string fullNamex = String.Empty; IColor colorx = sheet.GetRow(row).GetCell(cell).CellStyle.FillBackgroundColorColor; if (colorx != null && !namex.Contains("Физическая культура")) { fullNamex = namex + " (пара в Тушино)"; } else { fullNamex = namex; } Lesson ax = new Lesson() { Name = fullNamex, Number = lessonNumber.ToString(), Time = time, Room = roomx, Type = lessonTypex, Teacher = null }; if (ax.Name == "") { return; } day1.Lessons.Add(ax); day2.Lessons.Add(ax); return; } string room = String.Empty; try //определение, цифра ли кабинет или слово { room = sheet.GetRow(row).GetCell(cell).StringCellValue; } catch { room = sheet.GetRow(row).GetCell(cell).NumericCellValue.ToString(); } string name = sheet.GetRow(row).GetCell(cell + 1).StringCellValue; string lessonType = sheet.GetRow(row).GetCell(cell + 2).StringCellValue; string name1 = StringSeparator(name, ')')[0]; string name2 = StringSeparator(name, ')')[1]; string lessonType1 = String.Empty; string lessonType2 = String.Empty; string room1 = String.Empty; string room2 = String.Empty; if (room.Contains('/')) { room1 = StringSeparator(room, '/')[0]; room2 = StringSeparator(room, '/')[1]; } else { room1 = StringSeparator(room, ' ')[0]; room2 = StringSeparator(room, ' ')[1]; } if (name2 != "") { if (lessonType.Contains('/')) { lessonType1 = StringSeparator(lessonType, '/')[0]; lessonType2 = StringSeparator(lessonType, '/')[1]; } else { lessonType1 = StringSeparator(lessonType, ' ')[0]; lessonType2 = StringSeparator(lessonType, ' ')[1]; } if (lessonType2 == "") { lessonType2 = sheet.GetRow(row + 1).GetCell(cell + 2).StringCellValue; } if (room2 == "") { try //определение, цифра ли кабинет или слово { room2 = sheet.GetRow(row + 1).GetCell(cell).StringCellValue; } catch { room2 = sheet.GetRow(row + 1).GetCell(cell).NumericCellValue.ToString(); } } } else { if (room2 == "") { try //определение, цифра ли кабинет или слово { room2 = sheet.GetRow(row + 1).GetCell(cell).StringCellValue; } catch { room2 = sheet.GetRow(row + 1).GetCell(cell).NumericCellValue.ToString(); } if (room2 == "0" || room2 == "") { room1 = room; room2 = room; } } lessonType1 = lessonType; lessonType2 = lessonType; } string fullName1 = String.Empty; string fullName2 = String.Empty; IColor color = sheet.GetRow(row).GetCell(cell).CellStyle.FillForegroundColorColor; if (color?.RGB != null && color.RGB[0] == 204 && color.RGB[1] == 255 && color.RGB[2] == 204) { fullName1 = name1 + " (пара в Тушино)"; fullName2 = name2 + " (пара в Тушино)"; } else { fullName1 = name1; fullName2 = name2; } Lesson a = new Lesson() { Name = fullName1, Number = lessonNumber.ToString(), Time = time, Room = room1, Type = lessonType1, Teacher = null }; if (a.Name == "") { return; } if (name1.Contains("(1")) { day1.Lessons.Add(a); } else if (name1.Contains("(2")) { day2.Lessons.Add(a); } else { day1.Lessons.Add(a); if (room2 != "") { Lesson x = new Lesson() { Name = fullName1, Number = lessonNumber.ToString(), Time = time, Room = room2, Type = lessonType1, Teacher = null }; day2.Lessons.Add(x); } else { day2.Lessons.Add(a); } return; } Lesson b = null; if (name2 != String.Empty) { b = new Lesson() { Name = fullName2, Number = lessonNumber.ToString(), Time = time, Room = room2, Type = lessonType2, Teacher = null }; if (b.Name == "") { return; } if (name2.Contains("(1")) { if (room1 == "") { Lesson x = new Lesson() { Name = fullName2, Number = lessonNumber.ToString(), Time = time, Room = room2, Type = lessonType2, Teacher = null }; day1.Lessons.Add(x); } else { day1.Lessons.Add(b); } } else if (name2.Contains("(2")) { if (room2 == "") { Lesson x = new Lesson() { Name = fullName2, Number = lessonNumber.ToString(), Time = time, Room = room1, Type = lessonType2, Teacher = null }; day2.Lessons.Add(x); } else { day2.Lessons.Add(b); } } } }
public IActionResult EditHandle(ScheduleDay scheduleDay) { string [] idRes = Convert.ToString(HttpContext.Request.Form["programIdRes"]).Split(','); string [] nameIdRes = Convert.ToString(HttpContext.Request.Form["programNameIdRes"]).Split(',');//将program的id和name组合起来,此处为program_id string [] startRes = Convert.ToString(HttpContext.Request.Form["programStartRes"]).Split(','); string [] endRes = Convert.ToString(HttpContext.Request.Form["programEndRes"]).Split(','); scheduleDay.create_time = DateTime.Now.ToLocalTime(); var scheduleDayJson = JsonConvert.SerializeObject(scheduleDay); //获取ScheduleDay,避免标题重复 var scheduleDayStr = HttpHelper.HttpGet(url_schedule_day); List <ScheduleDay> scheduleDaySearch = JsonConvert.DeserializeObject <List <ScheduleDay> >(scheduleDayStr); List <ScheduleDay> res = scheduleDaySearch.Where(s => s.schedule_name == scheduleDay.schedule_name && s.id != scheduleDay.id).ToList(); if (scheduleDay.id > 0) { if (res.Count > 0) { return(Json("Repeat")); } else { string scheduleDayUrl = url_schedule_day + "?id=" + scheduleDay.id; string jsonStr = HttpHelper.HttpGet(scheduleDayUrl); List <ScheduleDay> scheduleDays = JsonConvert.DeserializeObject <List <ScheduleDay> >(jsonStr); //更新ScheduleDay的schedule_name,其他保持不变 ScheduleDay schedule = new ScheduleDay(); schedule.id = scheduleDays[0].id; //不变 schedule.schedule_name = scheduleDay.schedule_name; //修改 schedule.group_id = scheduleDays[0].group_id; //不变 schedule.user_id = scheduleDays[0].user_id; //不变 schedule.create_time = scheduleDays[0].create_time; //不变 var scheduleJson = JsonConvert.SerializeObject(schedule); bool result = Convert.ToBoolean(HttpHelper.HttpPut(url_schedule_day, scheduleJson)); if (result) { //获取ScheduleDayProgram,做新增、更新或删除操作 var scheduleDayProgramStr = HttpHelper.HttpGet(url_schedule_day_program); List <ScheduleDayProgram> scheduleDayProgram1 = JsonConvert.DeserializeObject <List <ScheduleDayProgram> >(scheduleDayProgramStr); //获取schedule_day下所有的program List <ScheduleDayProgram> scheduleDayProgramSearch = scheduleDayProgram1.Where(s => s.schedule_id == scheduleDay.id).ToList(); List <ScheduleDayProgram> programIndex = new List <ScheduleDayProgram>(); //用于删除 List <ScheduleDayProgram> programDelete = scheduleDayProgramSearch; bool flag = true; if (idRes.Length > 1) { for (int i = 0; i < idRes.Length; i++) { if (idRes[i].Contains("program")) { ScheduleDayProgram scheduleDayProgram = new ScheduleDayProgram(); scheduleDayProgram.schedule_id = scheduleDay.id; scheduleDayProgram.program_id = Convert.ToInt32(nameIdRes[i]); scheduleDayProgram.start_time = startRes[i]; scheduleDayProgram.end_time = endRes[i]; var scheduleDayProgramJson = JsonConvert.SerializeObject(scheduleDayProgram); int schedule_day_program_id = Convert.ToInt32(HttpHelper.HttpPost(url_schedule_day_program, scheduleDayProgramJson)); if (schedule_day_program_id <= 0) { flag = false; } } else { programIndex = scheduleDayProgramSearch.Where(s => s.id == Convert.ToInt32(idRes[i])).ToList(); //修改 if (programIndex.Count > 0) { //将修改后的元素从查询出来的scheduleDayProgram中删除 programDelete.RemoveAll(s => s.id == programIndex[0].id); ScheduleDayProgram scheduleDayProgram = new ScheduleDayProgram(); scheduleDayProgram.id = programIndex[0].id; //保持不变 scheduleDayProgram.schedule_id = programIndex[0].schedule_id; //保持不变 scheduleDayProgram.program_id = programIndex[0].program_id; //保持不变 scheduleDayProgram.start_time = startRes[i]; scheduleDayProgram.end_time = endRes[i]; var scheduleDayProgramJson = JsonConvert.SerializeObject(scheduleDayProgram); bool res1 = Convert.ToBoolean(HttpHelper.HttpPut(url_schedule_day_program, scheduleDayProgramJson)); if (!res1) { flag = false; } } } } } //删除 if (programDelete.Count > 0) { for (int x = 0; x < programDelete.Count; x++) { string urls = url_schedule_day_program + "?id=" + programDelete[x].id; bool resultDelete = Convert.ToBoolean(HttpHelper.HttpDel(urls)); if (!resultDelete) { flag = false; } } } if (flag) { return(Json("Success")); } else { return(Json("Fail")); } } else { return(Json("Fail")); } } } else { if (res.Count > 0) { return(Json("Repeat")); } else { int schedule_id = Convert.ToInt32(HttpHelper.HttpPost(url_schedule_day, scheduleDayJson)); if (schedule_id > 0) { if (idRes.Length > 1) { bool flag = true; for (int i = 0; i < idRes.Length; i++) { ScheduleDayProgram scheduleDayProgram = new ScheduleDayProgram(); scheduleDayProgram.schedule_id = schedule_id; scheduleDayProgram.program_id = Convert.ToInt32(nameIdRes[i]); scheduleDayProgram.start_time = startRes[i]; scheduleDayProgram.end_time = endRes[i]; var scheduleDayProgramJson = JsonConvert.SerializeObject(scheduleDayProgram); int schedule_day_program_id = Convert.ToInt32(HttpHelper.HttpPost(url_schedule_day_program, scheduleDayProgramJson)); if (schedule_day_program_id <= 0) { flag = false; } } if (flag) { return(Json("Success")); } else { return(Json("Fail")); } } } else { return(Json("Fail")); } } return(Json("Success")); } }
public bool Apply() { if (!Validate()) { return(false); } this.adapterConfiguration.Name = this.textScheduleName.Text; this.adapterConfiguration.Uri = string.Format("schedule://{0}/{1}", this.comboScheduleType.SelectedItem, this.textScheduleName.Text); this.adapterConfiguration.SuspendMessage = this.checkSuspendMessage.Checked; #region Schedule Schedule schedule = null; switch ((ScheduleType)this.comboScheduleType.SelectedItem) { case ScheduleType.TimeSpan: schedule = new TimeSpanSchedule(); schedule.StartDate = this.dateStartDate.Value; schedule.StartTime = this.dateStartTime.Value; int interval = 0; switch ((ScheduleTimeUnit)this.comboTimeUnits.SelectedItem) { case ScheduleTimeUnit.Seconds: interval = Convert.ToInt32(this.updownTimeInterval.Value); break; case ScheduleTimeUnit.Minutes: interval = Convert.ToInt32(this.updownTimeInterval.Value * 60); break; case ScheduleTimeUnit.Hours: interval = Convert.ToInt32(this.updownTimeInterval.Value * 3600); break; default: interval = 3600; break; } ((TimeSpanSchedule)schedule).Interval = interval; break; case ScheduleType.Daily: schedule = new DaySchedule(); schedule.StartDate = this.dateStartDate.Value; schedule.StartTime = this.dateStartTime.Value; if (radioDayInterval.Checked) { ((DaySchedule)schedule).Interval = Convert.ToInt32(this.updownDayInterval.Value); ((DaySchedule)schedule).ScheduledDays = ScheduleDay.None; } else { ScheduleDay days = ScheduleDay.None; if (checkDaySunday.Checked) { days |= ScheduleDay.Sunday; } if (checkDayMonday.Checked) { days |= ScheduleDay.Monday; } if (checkDayTuesday.Checked) { days |= ScheduleDay.Tuesday; } if (checkDayWednesday.Checked) { days |= ScheduleDay.Wednesday; } if (checkDayThursday.Checked) { days |= ScheduleDay.Thursday; } if (checkDayFriday.Checked) { days |= ScheduleDay.Friday; } if (checkDaySaturday.Checked) { days |= ScheduleDay.Saturday; } ((DaySchedule)schedule).ScheduledDays = days; ((DaySchedule)schedule).Interval = 0; } break; case ScheduleType.Weekly: schedule = new WeekSchedule(); schedule.StartDate = this.dateStartDate.Value; schedule.StartTime = this.dateStartTime.Value; ((WeekSchedule)schedule).Interval = Convert.ToInt32(this.updownWeekInterval.Value); ScheduleDay weekDays = ScheduleDay.None; if (checkWeekSunday.Checked) { weekDays |= ScheduleDay.Sunday; } if (checkWeekMonday.Checked) { weekDays |= ScheduleDay.Monday; } if (checkWeekTuesday.Checked) { weekDays |= ScheduleDay.Tuesday; } if (checkWeekWednesday.Checked) { weekDays |= ScheduleDay.Wednesday; } if (checkWeekThursday.Checked) { weekDays |= ScheduleDay.Thursday; } if (checkWeekFriday.Checked) { weekDays |= ScheduleDay.Friday; } if (checkWeekSaturday.Checked) { weekDays |= ScheduleDay.Saturday; } ((WeekSchedule)schedule).ScheduledDays = weekDays; break; case ScheduleType.Monthly: schedule = new MonthSchedule(); schedule.StartDate = this.dateStartDate.Value; schedule.StartTime = this.dateStartTime.Value; if (radioDayofMonth.Checked) { ((MonthSchedule)schedule).Day = Convert.ToInt32(this.updownDayofMonth.Value); } else { ((MonthSchedule)schedule).Ordinal = (ScheduleOrdinal)this.comboOrdinal.SelectedItem; ((MonthSchedule)schedule).WeekDay = (ScheduleDay)this.comboWeekday.SelectedItem; } ScheduleMonth months = ScheduleMonth.None; if (checkJanuary.Checked) { months |= ScheduleMonth.January; } if (checkFebruary.Checked) { months |= ScheduleMonth.February; } if (checkMarch.Checked) { months |= ScheduleMonth.March; } if (checkApril.Checked) { months |= ScheduleMonth.April; } if (checkMay.Checked) { months |= ScheduleMonth.May; } if (checkJune.Checked) { months |= ScheduleMonth.June; } if (checkJuly.Checked) { months |= ScheduleMonth.July; } if (checkAugust.Checked) { months |= ScheduleMonth.August; } if (checkSeptember.Checked) { months |= ScheduleMonth.September; } if (checkOctober.Checked) { months |= ScheduleMonth.October; } if (checkNovember.Checked) { months |= ScheduleMonth.November; } if (checkDecember.Checked) { months |= ScheduleMonth.December; } ((MonthSchedule)schedule).ScheduledMonths = months; break; default: break; } adapterConfiguration.Schedule = schedule; #endregion #region Task Task task = new Task(); task.TaskType = this.taskType; task.TaskParameters = propertyGridTask.SelectedObject; this.adapterConfiguration.Task = task; #endregion return(true); }
/// <summary> /// Get the Cleaning Schedule. (24 hour clock format) /// See http://www.neatorobotics.com/programmers-manual/table-of-robot-application-commands/detailed-command-descriptions/#GetSchedule for more info. /// </summary> /// <param name="flag">Day of the week to get schedule for.</param> /// <returns> /// Cleaning schedule for specified day. /// </returns> public Response GetSchedule(ScheduleDay flag) { // TODO: Implement. "GetSchedule Day 0" or "GetSchedule 0" ? return this.neato.Connection.SendCommand("GetSchedule " + (int)flag); }