//каждую неделю бухгалтер расчитывает зарплату для всех сотрудников и заносит //её значение в ведомость Employment public static void EndWeekHandler(object sender, TimeEventArgs targs) { Dictionary<string, Report> Employment = ((Office)sender).Employment; int numWeek = targs.Week; uint salary; foreach (Employee emp in ((Office)sender).Employees.Where(x => x is HourlyEmployee)) { salary = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 8; j++) { salary += (Employment[emp.Name].DischargeDuties[numWeek, i, j] != Responsibility.None) ? emp.Rate : 0; } } Employment[emp.Name].WeekSalary[numWeek] = salary; } foreach (Employee emp in ((Office)sender).Employees.Where(x => x is FixedEmployee)) { salary = 0; if (!(emp is Director)) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 8; j++) { salary += (Employment[emp.Name].DischargeDuties[numWeek, i, j] != Responsibility.None && Employment[emp.Name].DischargeDuties[numWeek, i, j] != emp.PositionTask.FirstOrDefault()) ? emp.Rate : 0; } } } salary += (emp as FixedEmployee).FixedRate / 4; Employment[emp.Name].WeekSalary[numWeek] = salary; } foreach (Employee emp in ((Office)sender).RemoteEmployees) { salary = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 8; j++) { salary += (Employment[emp.Name].DischargeDuties[numWeek, i, j] != Responsibility.None) ? emp.Rate : 0; } } Employment[emp.Name].WeekSalary[numWeek] = salary; } if (numWeek == 3) { foreach (KeyValuePair<string, Report> pair in ((Office)sender).Employment) { pair.Value.WeekSalary[4] = (uint)pair.Value.WeekSalary.Take(4).Sum(x => x); } } }
public override void HourBegin(object sender, TimeEventArgs targs) { if (!(targs.Week == 3 && targs.Day == 4 && targs.Hour > 5)) { OnJobProceeding(new TaskCurrentTimeArgs { EmpName = Name, CurResp = Responsibility.GivenTask, CurTime = targs }); int taskNumber = rand.Next(3); for (int i = 0; i < taskNumber; i++) { Task task = new Task(); JobReady(new TaskEventArgs(task)); //Запись выданного задания в офисный список выданных заданий ((Office)sender).GivenTasks.Add(task); } } }
//метод, обрабатывающий каждый час работы сотрудника //отправляет данные в Office public virtual void HourBegin(object sender, TimeEventArgs targs) { if (CurrentTasks.Count > 0 || CurrentTaskTime > 0) //если список текущих заданий не пуст, или текущее задание не завершено { if (CurrentTasks.Count > 0 && CurrentTaskTime == 0) { Task nextTask = CurrentTasks.Dequeue(); CurrentTaskTime = nextTask.Volume; CurrentJob = nextTask.Responsibility; } if (CurrentTaskTime > 0) { CurrentTaskTime--; } if (BusyTime > 0) { BusyTime--; } } else { CurrentJob = Responsibility.None; } OnJobProceeding(new TaskCurrentTimeArgs { EmpName = Name, CurResp = CurrentJob, CurTime = targs }); }