private void tsbCreateClearShedule_Click(object sender, EventArgs e) { if (!CheckInputData) { return; } CreateSheduleForm frmShedule = new CreateSheduleForm(false, new DateTime(DateTime.Now.Year, 9, 1), new DateTime(DateTime.Now.Year, 12, 31)); if (frmShedule.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } Schedule = new ScheduleWeeks(Rooms, GetSetting(getWeeksInSem(frmShedule.FirstDaySem, frmShedule.LastDaySem)), frmShedule.FirstDaySem, frmShedule.LastDaySem); UpdateTableShedule(); WatchTriggerStateChange(true); if (dgvSchedule.ColumnCount <= 0) { cmbView.Enabled = false; } else { cmbView.Enabled = true; } curSheduleType = scheduleType.leesons; }
public static void NextRun(string schedule, DateTime current, out DateTime nextRun) { if (schedule.Trim() == string.Empty || schedule.Trim() == Constants.TimerScheduleWhenPublished) { nextRun = new DateTime(3000, 1, 1); return; } schedule = TrimEndAndEnsureDoubleDigits(schedule); string[] scheduleParts = schedule.Split(' '); scheduleType schType = scheduleType.Invalid; List <string> hoursInSchedule; List <string> daysInSchedule; List <string> weekdaysInSchedule; string ordinalInSchedule; ValidateAndSeparateScheduleParts(scheduleParts, out schType, out hoursInSchedule, out daysInSchedule, out weekdaysInSchedule, out ordinalInSchedule); TimeSpan ts = new TimeSpan(0, 0, 0, 0); switch (schType) { case scheduleType.TimeOnly: // daily at the same hours CalculateNextTimeSpan(current, hoursInSchedule.ToArray(), out ts); break; case scheduleType.TimeDays: // on those days of the month at those hours CalculateNextDayOfMonthSpan(current, hoursInSchedule.ToArray(), daysInSchedule.ToArray(), out ts); break; case scheduleType.TimeOrdinalWeekday: // on the nth weekday of the month CalculateNextWeekdayOfMonthSpan(current, hoursInSchedule.ToArray(), ordinalInSchedule, weekdaysInSchedule[0], out nextRun); return; case scheduleType.TimeWeekdays: // on those days of the week at those hours CalculateNextWeekDaySpan(current, hoursInSchedule.ToArray(), weekdaysInSchedule.ToArray(), out ts); break; } if (!schType.Equals(scheduleType.Invalid)) { nextRun = current.Add(ts); } else { nextRun = new DateTime(3000, 1, 1); } }
public static bool ValidateSchedule(string schedule) { if (schedule == string.Empty) { return(true); } schedule = TrimEndAndEnsureDoubleDigits(schedule); List <string> hoursInSchedule; List <string> daysInSchedule; List <string> weekdaysInSchedule; string ordinalInSchedule; string[] scheduleParts = schedule.Split(' '); scheduleType schType = scheduleType.Invalid; ValidateAndSeparateScheduleParts(scheduleParts, out schType, out hoursInSchedule, out daysInSchedule, out weekdaysInSchedule, out ordinalInSchedule); return(!schType.Equals(scheduleType.Invalid)); }
private void tsiCreate_Exam_Click(object sender, EventArgs e) { if (!CheckInputData) { return; } CreateSheduleForm frmShedule = new CreateSheduleForm(true, new DateTime(DateTime.Now.Year + 2, 1, 1), new DateTime(DateTime.Now.Year + 2, 1, 31)); if (frmShedule.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } SettingShedule settingBuf1 = GetSetting(getWeeksInSem(frmShedule.FirstDaySem, frmShedule.LastDaySem)); settingBuf1.CountLessonsOfDay = 1; settingBuf1.FirstLessonsOfWeekDay = 1; settingBuf1.FirstLessonsOfWeekEnd = 1; settingBuf1.LastLessonsOfWeekDay = 1; settingBuf1.LastLessonsOfWeekEnd = 1; settingBuf1.MaxCountLessonsOfWeekDay = 1; settingBuf1.MaxCountLessonsOfWeekEnd = 1; Schedule = new ScheduleWeeks(Rooms, settingBuf1, frmShedule.FirstDaySem, frmShedule.LastDaySem); UpdateTableShedule(); WatchTriggerStateChange(true); if (dgvSchedule.ColumnCount <= 0) { cmbView.Enabled = false; } else { cmbView.Enabled = true; } curSheduleType = scheduleType.exams; }
private void tsbCreateShedule_Click(object sender, EventArgs e) { if (!CheckInputData) { return; } CreateSheduleForm frmShedule = new CreateSheduleForm(false, new DateTime(DateTime.Now.Year, 9, 1), new DateTime(DateTime.Now.Year, 12, 31)); if (frmShedule.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } ScheduleGenerator reactor = new ScheduleGenerator(EducationAdapter, Rooms, GetSetting(getWeeksInSem(frmShedule.FirstDaySem, frmShedule.LastDaySem)), frmShedule.FirstDaySem, frmShedule.LastDaySem, Schedule == null ? new Employments() : Schedule.Employments); Schedule = reactor.Generate(); UpdateTableShedule(); UpdateDistributeList(reactor.Results); WatchTriggerStateChange(false); if (dgvSchedule.ColumnCount <= 0) { cmbView.Enabled = false; } else { cmbView.Enabled = true; } curSheduleType = scheduleType.leesons; }
private static void ValidateAndSeparateScheduleParts(string[] scheduleParts, out scheduleType schType, out List <string> hoursInSchedule, out List <string> daysInSchedule, out List <string> weekdaysInSchedule, out string ordinalInSchedule) { bool foundHours = false; bool foundOrdinal = false; bool foundMonthDay = false; bool foundWeekDay = false; hoursInSchedule = new List <string>(); daysInSchedule = new List <string>(); weekdaysInSchedule = new List <string>(); ordinalInSchedule = null; schType = scheduleType.Invalid; int numParts = scheduleParts.Length; for (int i = 0; i < numParts; i++) { string currentPart = scheduleParts[i]; if (IsHour(currentPart)) { if (!foundOrdinal && !foundMonthDay && !foundWeekDay) { foundHours = true; hoursInSchedule.Add(currentPart); schType = scheduleType.TimeOnly; continue; } else { schType = scheduleType.Invalid; break; } } if (foundHours) { if (IsOrdinal(currentPart)) { if (!foundOrdinal && !foundMonthDay && !foundWeekDay) { foundOrdinal = true; ordinalInSchedule = "_" + currentPart; continue; } else { schType = scheduleType.Invalid; break; } } if (IsDayOfWeek(currentPart)) { if (!foundMonthDay) { weekdaysInSchedule.Add(currentPart); if (foundOrdinal && !foundWeekDay) { schType = scheduleType.TimeOrdinalWeekday; } else if (!foundOrdinal) { schType = scheduleType.TimeWeekdays; } else { schType = scheduleType.Invalid; break; } foundWeekDay = true; continue; } else { schType = scheduleType.Invalid; break; } } if (IsDayOfMonth(currentPart)) { if (!foundOrdinal && !foundWeekDay) { foundMonthDay = true; daysInSchedule.Add(currentPart); schType = scheduleType.TimeDays; } else { schType = scheduleType.Invalid; break; } } } else { schType = scheduleType.Invalid; break; } } }
public LessonForm(scheduleType type) { InitializeComponent(); Type = type; this.Load += new EventHandler(LessonForm_Load); }