예제 #1
0
        public async Task DaycareShiftsOfThreeWeeks(Daycare dc, int openingTeam, List <Wish> wishes, int up = 0)
        {
            bool upOrDown = Convert.ToBoolean(up);

            CheckDuplicates(wishes);
            dc.Teams.ForEach(t => TeamShiftsOfWeek(t, openingTeam, dc.Teams.Count, upOrDown));
            openingTeam++;
            if (openingTeam > dc.Teams.Count - 1)
            {
                openingTeam = 0;
            }
            dc.RotateTeamsOneWeek();
            dc.Teams.ForEach(t => TeamShiftsOfWeek(t, openingTeam, dc.Teams.Count, upOrDown));
            openingTeam++;
            if (openingTeam > dc.Teams.Count - 1)
            {
                openingTeam = 0;
            }
            dc.RotateTeamsOneWeek();
            dc.Teams.ForEach(t => TeamShiftsOfWeek(t, openingTeam, dc.Teams.Count, upOrDown));

            foreach (var wish in wishes)
            {
                Switch(dc, wish);
            }
            CheckTeacherSwitches(dc);
        }
예제 #2
0
 private void CheckTeacherSwitches(Daycare dc)
 {
     foreach (var emp in dc.Employees)
     {
         if (emp.Status == StatusEnum.Teacher)
         {
             var counts = GetOpensAndCloses(emp.Shifts, 0, 5, dc.Teams.Count);
             CheckTeacherWeek(emp, counts, dc);
             counts = GetOpensAndCloses(emp.Shifts, 5, 10, dc.Teams.Count);
             CheckTeacherWeek(emp, counts, dc);
             counts = GetOpensAndCloses(emp.Shifts, 10, 15, dc.Teams.Count);
             CheckTeacherWeek(emp, counts, dc);
             CheckPlantimeAvailable(emp, dc);
         }
     }
 }
예제 #3
0
 private void Switch(Daycare dc, Wish wish)
 {
     try
     {
         var team = dc.Teams[wish.Employee.Team];
         AdjustTeamByWish(team, wish, dc.Employees.Count);
         var current = Convert.ToInt32(wish.Employee.Shifts[wish.Day].Shift);
         var wanted  = wish.WantedShift;
         if (current != wanted)
         {
             AdjustDaycareByWish(dc, wish, current);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #4
0
        private void AdjustDaycareByWish(Daycare dc, Wish wish, int current)
        {
            if (current >= dc.Employees.Count / 3 && current <= dc.Employees.Count / 3 * 2 - 1)
            {
                return;
            }
            var shiftList = PossibleShifts(wish.WantedShift, dc.Teams.Count);

            shiftList.Remove(current);
            foreach (var item in shiftList)
            {
                var emp = dc.Employees.Find(e => Convert.ToInt32(e.Shifts[wish.Day].Shift) == item);
                if (!emp.Shifts[wish.Day].Locked)
                {
                    var oldShift = wish.Employee.Shifts[wish.Day].Shift;
                    var newShift = emp.Shifts[wish.Day].Shift;
                    wish.Employee.Shifts[wish.Day].Shift  = newShift;
                    emp.Shifts[wish.Day].Shift            = oldShift;
                    wish.Employee.Shifts[wish.Day].Locked = true;
                    break;
                }
            }
        }