/// <summary> /// Given an event, the list of shifts in the event is printed to a new sheet in the excel resource file. /// </summary> /// <param name="e"></param> private void PrintShiftList(Event e) { try { CurrentWorkSheet = CurrentWorkBook.Sheets["Shifts"]; } catch (System.Runtime.InteropServices.COMException) { CurrentWorkSheet = excel.Worksheets.Add(); CurrentWorkSheet.Name = "Shifts"; } int i = 1; foreach (Task t in e.GetTaskList()) { foreach (Shift s in t.Shifts) { CurrentWorkSheet.Cells[1][i].Value2 = s.Task.Name; CurrentWorkSheet.Cells[2][i].Value2 = s.Start.ToString(); CurrentWorkSheet.Cells[3][i].Value2 = s.End.ToString(); CurrentWorkSheet.Cells[4][i].Value2 = s.NoOfWorkersNeededOnShift.ToString(); i++; } } }
/// <summary> /// PlanGenerationHandler /// The function produces an event object which contains the resources found in the resource file /// and generates a plan from the resources. /// </summary> public void PlanGenerationHandler() { Event e = new Event(filename); EventShiftPlanGenerator.ErrorLogger.ClearLog(); //CreateWorkerList(); foreach (Task t in CreateTaskList()) { e.addTask(t); } PrintShiftList(e); //save the changes CurrentWorkBook.Close(true); }