public Scheduler(List<Doctor> doctors, SchedulerBean bean) { MaxShiftsPerRotation = bean.MaxPerRotation; MaxShiftsPerLifetime = bean.MaxPerLifetime; MaxSameShifts = bean.MaxSameShifts; MaxConsecutiveShifts = bean.MaxConsecutiveShifts; MaxWeekends = bean.MaxWeekends; CrossCallAllowed = bean.crossCall; Schedule = new List<Slot>(); Rotations = new List<Rotation>(); Doctors = doctors.Select(x => x.Clone()).Cast<Doctor>().ToList(); LoadRotations(bean.rotationsFilename); var startDate = DateTime.Parse(bean.startDate); var endDate = DateTime.Parse(bean.endDate); if (startDate < Rotations.First().startDate || endDate > Rotations.Last().endDate) { throw (new Exception("Start/End dates are outside the range of loaded rotations.")); } BuildCalendar(startDate, endDate); }
private SchedulerBean GetSchedulerConfigParams() { var bean = new SchedulerBean(); if (!int.TryParse(textboxMaxPerRotation.Text, out bean.MaxPerRotation)) { bean.MaxPerRotation = 0; } if (!int.TryParse(textboxMaxPerLifetime.Text, out bean.MaxPerLifetime)) { bean.MaxPerLifetime = 0; } if (!int.TryParse(textBoxMaxSameShifts.Text, out bean.MaxSameShifts)) { bean.MaxSameShifts = 0; } if (!int.TryParse(textboxMaxConsecutive.Text, out bean.MaxConsecutiveShifts)) { bean.MaxConsecutiveShifts = 0; } if (!int.TryParse(textboxMaxWeekends.Text, out bean.MaxWeekends)) { bean.MaxWeekends = 0; } bean.startDate = textboxStartDate.Text; bean.endDate = textboxEndDate.Text; bean.crossCall = checkboxCrossCall.Checked; bean.rotationsFilename = textboxRotationsFilename.Text; return bean; }