public Dictionary <IEmployeePresentationData, double> Calculate(ISchedule schedule) { Dictionary <IEmployeePresentationData, double> output = new Dictionary <IEmployeePresentationData, double>(); foreach (IEmployee employee in schedule.Employees) { int i = 0; double numberOfHours = 0; schedule.IterateOverAllDays((date) => { IWorkingOption planForDay = employee.WorkingPlan[i++]; // This is a night if (planForDay.Symbol == "N") { // This is not a holiday but the next day is if (!HolidayChecker.IsHoliday(date) && HolidayChecker.IsHoliday(date.AddDays(1))) { numberOfHours += HoursFoNightFromNotHolidayToHoliday; } // This is a holiday else if (HolidayChecker.IsHoliday(date)) { numberOfHours += HoursForHolidayNight; } } }); output.Add(employee, numberOfHours); } return(output); }
private void FillTimeFields(IWorkingOption plan) { // Format numbers with leading zero StartingHourTextBox.Text = plan.StartingHour.ToString("HH"); StartingMinuteTextBox.Text = plan.StartingHour.ToString("mm"); WorkingTimeHourTextBox.Text = plan.WorkingTime.ToString("hh"); WorkingTimeMinuteTextBox.Text = plan.WorkingTime.ToString("mm"); }
public void GetWorkingPlanForEmployees(List <IEmployee> employees, List <WorkingPlan> plans, ISchedule schedule) { foreach (IEmployee employee in employees) { List <IWorkingOption> workingPlan = (from p in plans where p.EmployeeID == employee.Id && p.ScheduleID == schedule.Id select p.WorkingOptions).Single(); // Fill in output schedule with plans for each day int i = 0; schedule.IterateOverAllDays((day) => { IWorkingOption planForDay = workingPlan[i++]; schedule.ChangeWorkDay(employee.Id, day, planForDay.Symbol, planForDay.StartingHour, planForDay.WorkingTime); }); } }
public EditPlanForDayWindow(string employeeFirstName, string employeeLastName, int employeeId, DateTime date) { InitializeComponent(); // Fill the header with employee and date information EmployeeNameTextBlock.Text = $"{employeeFirstName} {employeeLastName}"; DateTextBlock.Text = date.ToString("dd.MM.yyyy"); // Fill fields with current values if already modified IWorkingOption plan = GlobalAccess.Schedule.PlanForDay(employeeId, date); string symbol = plan.Symbol; if (symbol != WorkingOptionModel.DefaultSymbol) { SymbolTextBox.Text = symbol; FillTimeFields(plan); } this.date = date; this.employeeId = employeeId; }
public Dictionary <IEmployeePresentationData, List <double> > Calculate(ISchedule schedule) { Dictionary <IEmployeePresentationData, List <double> > output = new Dictionary <IEmployeePresentationData, List <double> >(); foreach (IEmployee employee in schedule.Employees) { List <double> workingTimes = new List <double>(); double workingTimeForWeek = 0; int numberOfDays = employee.WorkingPlan.Count; for (int i = 0; i < numberOfDays; i++) { IWorkingOption planForDay = employee.WorkingPlan[i]; workingTimeForWeek += planForDay.WorkingTime.TotalHours; if (i % 7 == 6 || i == numberOfDays - 1) { workingTimes.Add(workingTimeForWeek); workingTimeForWeek = 0; } } output.Add(employee, workingTimes); } return(output); }
public void AddWorkingOptionForDay(int scheduleID, int employeeID, DateTime date, IWorkingOption workingOption) { CheckInputStrings(SymbolPattern, workingOption.Symbol); ISchedulePresentationData schedule = GetScheduleFromId(scheduleID); int indexOfDate = schedule.GetIndexOfDate(date); List <WorkingPlan> workingPlans = GetWorkingPlans(); foreach (WorkingPlan plan in workingPlans) { if (plan.ScheduleID == scheduleID && plan.EmployeeID == employeeID) { for (int i = 0; i < plan.WorkingOptions.Count; i++) { if (i == indexOfDate) { plan.WorkingOptions[i] = workingOption; break; } } } } SaveWorkingPlans(workingPlans); }