private static JobConfiguration CreateJobConfiguration() { var jobConfiguration = JobConfiguration.Create() .WithName("Test Name") .WithDescription("Test Description") .WithSsisOwner("Test SSIS Owner") .WithSsisServer("Test SSIS Server") .WithStep(StepConfiguration.Create() .WithName("Test Step Name") .WithId(1) .WithSubSystem(SsisSubSystem.TransactStructuredQueryLanguage) .ExecuteCommand("Test Command") .OnFailure(JobAction.QuitWithFailure) .OnSuccess(JobAction.QuitWithSuccess)) .WithSchedule(ScheduleConfiguration.Create() .WithName("Test Schedule Configuration") .RunOn(FrequencyDay.Monday) .ActivatedFrom(DateTime.Now) .ActivatedUntil(DateTime.Now.AddDays(1)) .StartingAt(TimeSpan.FromSeconds(6))); return jobConfiguration; }
private async Task <ICollection <Schedule> > InitializePopulation(Section section, ScheduleConfiguration scheduleConfiguration, AcademicSemester currentSemester) { ICollection <Schedule> population = new Collection <Schedule>(); var weekDays = await unitOfWork.WeekDays.GetFirstWeekDays(scheduleConfiguration.NumberOfDaysPerWeek); for (int i = 0; i < GeneticAlgorithmConf.POPULATION_SIZE; i++) { var schedule = helper.InitializeScheduleForSection(section, scheduleConfiguration, weekDays.ToList(), currentSemester); population.Add(schedule); } return(population); }
private void CreateSchedule(ScheduleConfiguration scheduleConfiguration) { try { using (var repository = Repository) { var existingSchedule = repository.Schedules.FirstOrDefault(s => s.ConfigId == scheduleConfiguration.ConfigurationId.Id); var scheduleRecurrence = scheduleConfiguration.ScheduleRecurrences.Value.FirstOrDefault(); var defaultDate = new DateTime(2000, 01, 01); if (existingSchedule == null) { if (scheduleRecurrence != null) { var schedRecurrence = GetScheduleRecurrence(scheduleRecurrence); repository.ScheduleRecurrences.Add(schedRecurrence); var dateLastModified = scheduleConfiguration.StandardProperties.DateLastModified != null && scheduleConfiguration.StandardProperties.DateLastModified.Value > defaultDate ? scheduleConfiguration.StandardProperties.DateLastModified.Value : scheduleConfiguration.StandardProperties.DateCreated != null && scheduleConfiguration.StandardProperties.DateCreated.Value > defaultDate ? scheduleConfiguration.StandardProperties.DateCreated.Value : defaultDate; //_logging.TraceMessage(3, "Date Last Modified: " + dateLastModified.ToShortDateString()); var hasKeywords = scheduleConfiguration.Keywords != null && scheduleConfiguration.Keywords.Value != null; var keywords = hasKeywords ? String.Join("|", scheduleConfiguration.Keywords.Value) : String.Empty; var schedule = new Schedule { ConfigId = scheduleConfiguration.ConfigurationId.Id, DisplayName = scheduleConfiguration.ConfigurationId.DisplayName, Description = scheduleConfiguration.Description.Value, IsActive = scheduleConfiguration.IsActive.Value, IsAssignable = hasKeywords && scheduleConfiguration.Keywords.Value.Any(i => i.ToLower() == "wcb"), MarkedForDeletion = false, Profiles = new List <Profile>(), ScheduleRecurrence = schedRecurrence, DateLastModified = dateLastModified, Keywords = keywords, ClosedOnly = hasKeywords && scheduleConfiguration.Keywords.Value.Any(i => i.ToLower() == "closed") }; repository.Schedules.Add(schedule); repository.SaveChanges(); _logging.LogNote("Schedule Created: " + schedule.DisplayName); } } else { existingSchedule.DisplayName = scheduleConfiguration.ConfigurationId.DisplayName; existingSchedule.Description = scheduleConfiguration.Description.Value; existingSchedule.IsActive = scheduleConfiguration.IsActive.Value; existingSchedule.DateLastModified = scheduleConfiguration.StandardProperties.DateLastModified != null && scheduleConfiguration.StandardProperties.DateLastModified.Value > defaultDate ? scheduleConfiguration.StandardProperties.DateLastModified.Value : scheduleConfiguration.StandardProperties.DateCreated != null && scheduleConfiguration.StandardProperties.DateCreated.Value > defaultDate ? scheduleConfiguration.StandardProperties.DateCreated.Value : defaultDate; if (scheduleRecurrence != null) { var schedRecurrence = GetScheduleRecurrence(scheduleRecurrence); if (existingSchedule.ScheduleRecurrence != null && !existingSchedule.ScheduleRecurrence.Equals(schedRecurrence)) { //_logging.TraceMessage(3, String.Format("Schedule {0} Changed.", schedRecurrence.DisplayName)); var existingRecurrence = existingSchedule.ScheduleRecurrence; existingRecurrence.ConfigId = schedRecurrence.ConfigId; existingRecurrence.DisplayName = schedRecurrence.DisplayName; existingRecurrence.IsAllDay = schedRecurrence.IsAllDay; existingRecurrence.IsDaySpan = schedRecurrence.IsDaySpan; existingRecurrence.IsRelative = schedRecurrence.IsRelative; existingRecurrence.Dates = schedRecurrence.Dates; existingRecurrence.Days = schedRecurrence.Days; existingRecurrence.Month = schedRecurrence.Month; existingRecurrence.PatternType = schedRecurrence.PatternType; existingRecurrence.RelativeDayType = schedRecurrence.RelativeDayType; existingRecurrence.RelativeMonthlyType = schedRecurrence.RelativeMonthlyType; existingRecurrence.StartDate = schedRecurrence.StartDate; existingRecurrence.EndDate = schedRecurrence.EndDate; existingRecurrence.StartTime = schedRecurrence.StartTime; existingRecurrence.EndTime = schedRecurrence.EndTime; existingRecurrence.WeeklyStartTime = schedRecurrence.WeeklyStartTime; existingRecurrence.WeeklyEndTime = schedRecurrence.WeeklyEndTime; } } _logging.LogNote("Schedule Created: " + existingSchedule.DisplayName); repository.SaveChanges(); } } } catch (Exception e) { _logging.TraceException(e, "ScheduleConfigurations Error"); } }
/// <summary> /// Initializes a new instance of the <see cref="ExportPostmanAccountService" /> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="scheduleConfiguration">The configuration of the scheduler.</param> /// <param name="exportPostman">Worker that export postman to local.</param> public ExportPostmanAccountService(ILogger <ExportPostmanAccountService> logger, ScheduleConfiguration scheduleConfiguration, ExportPostman exportPostman) { this.logger = logger; this.scheduleConfiguration = scheduleConfiguration; this.exportPostman = exportPostman; }
public Schedule InitializeScheduleForSection(Section section, ScheduleConfiguration scheduleConfiguration, IList <WeekDay> weekDays, AcademicSemester academicSemester) { var schedule = new Schedule(section, scheduleConfiguration, weekDays, academicSemester); foreach (var courseOffering in section.CourseOfferings) { var lecture = courseOffering.Course.Lecture; var tutor = courseOffering.Course.Tutor; var lab = courseOffering.Course.Lab; while (lecture > 0) { var randDay = Helper.GetRandomInteger(scheduleConfiguration.NumberOfDaysPerWeek); var lectureInstructor = GetInstructor(courseOffering, LECTURE_ID); var lectureRoom = GetRoom(courseOffering, LECTURE_ID); var scheduleEntry = CreateScheduleEntry(courseOffering.Course, lectureInstructor, lectureRoom, LECTURE_ID); if (lecture >= GeneticAlgorithmConf.MAX_CONSECUTIVE_LECTURE) { scheduleEntry.Duration = GeneticAlgorithmConf.MAX_CONSECUTIVE_LECTURE; lecture -= schedule.AddScheduleEntry(scheduleEntry, randDay); } else if (lecture > 0) { scheduleEntry.Duration = GeneticAlgorithmConf.MAX_CONSECUTIVE_LECTURE - 1; lecture -= schedule.AddScheduleEntry(scheduleEntry, randDay); } } while (tutor > 0) { var randDay = Helper.GetRandomInteger(scheduleConfiguration.NumberOfDaysPerWeek); var tutorInstructor = GetInstructor(courseOffering, TUTOR_ID); var tutorRoom = GetRoom(courseOffering, TUTOR_ID); var scheduleEntry = CreateScheduleEntry(courseOffering.Course, tutorInstructor, tutorRoom, TUTOR_ID, duration: 1); tutor -= schedule.AddScheduleEntry(scheduleEntry, randDay); } while (lab > 0) { var randDay = Helper.GetRandomInteger(scheduleConfiguration.NumberOfDaysPerWeek); var labInstructor = GetInstructor(courseOffering, LAB_ID); var labRoom = GetRoom(courseOffering, LAB_ID); var scheduleEntry = CreateScheduleEntry(courseOffering.Course, labInstructor, labRoom, LAB_ID); if (lab >= GeneticAlgorithmConf.MAX_CONSECUTIVE_LAB) { scheduleEntry.Duration = GeneticAlgorithmConf.MAX_CONSECUTIVE_LAB; lab -= schedule.AddScheduleEntry(scheduleEntry, randDay); } else if (lab >= (GeneticAlgorithmConf.MAX_CONSECUTIVE_LAB - 1)) { scheduleEntry.Duration = GeneticAlgorithmConf.MAX_CONSECUTIVE_LAB - 1; lab -= schedule.AddScheduleEntry(scheduleEntry, randDay); } } } return(schedule); }
public static Schedule Crossover(this Schedule scheduleA, Schedule scheduleB, ScheduleConfiguration scheduleConfiguration) { // var schedule = Schedule.GetNewScheduleForSection(scheduleA.Section, scheduleConfiguration); // var numberOfDays = scheduleA.TimeTable.Count; // for (int i = 0; i < numberOfDays; i++) // { // if (i % 2 == 0) // { // schedule.TimeTable[i] = scheduleA.TimeTable[i]; // var daySchedule = scheduleA.TimeTable[i].First(); // if (scheduleA.TimeTable[i].Count > 1) // { // daySchedule.AddRange(scheduleA.TimeTable[i].Last()); // } // RemoveScheduleEntries(daySchedule, scheduleB); // } // else // { // schedule.TimeTable[i] = scheduleB.TimeTable[i]; // var daySchedule = scheduleB.TimeTable[i].First(); // if (scheduleB.TimeTable[i].Count > 1) // { // daySchedule.AddRange(scheduleB.TimeTable[i].Last()); // } // RemoveScheduleEntries(daySchedule, scheduleA); // } // } // return schedule; return(scheduleA); }