Exemplo n.º 1
0
        private int CompareRoutes(TaskItem taskItemClicked, string startAddress, string endAddress, DateTime selectedDate)
        {
            RouteItem AC = RouteCalculator.GetRouteItem((Address)startAddress, taskItemClicked.TaskDescription.Citizen.GetAddress(selectedDate));
            RouteItem CB = RouteCalculator.GetRouteItem(taskItemClicked.TaskDescription.Citizen.GetAddress(selectedDate), (Address)endAddress);

            return(AC.Duration.Seconds + CB.Duration.Seconds);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Plans a task. Sets task status = planned, and adjusts rest of the tasks in the employee schedule
        /// </summary>
        /// <param name="targetGroup"></param>
        /// <param name="targetEmployeeSchedule"></param>
        /// <param name="taskToPlan"></param>
        /// <param name="index"></param>
        public void PlanTask(Group targetGroup, EmployeeSchedule targetEmployeeSchedule, TaskItem taskToPlan, int index) // locked? ret så der bruges GetAddress(date) når address er impl. Add methods.
        {
            if (taskToPlan.Locked)
            {
                taskToPlan.State = TaskItem.Status.Unplanned;
                return(false);
            }

            if (index == 0) //first
            {
                targetEmployeeSchedule.TaskItems.Insert(index, taskToPlan);
                taskToPlan.Route = RouteCalculator.GetRouteItem(new Address("Kærvej 2, 7752 Snedsted"), taskToPlan.TaskDescription.Citizen.GetAddress(DateTime.Today));
                taskToPlan.TimePeriod.StartTime = targetEmployeeSchedule.TimePeriod.StartTime;

                for (int i = index + 1; i < targetEmployeeSchedule.TaskItems.Count; i++)
                {
                    AdjustTravelTime(targetEmployeeSchedule.TaskItems[i - 1], targetEmployeeSchedule.TaskItems[i]);
                    if (targetEmployeeSchedule.TaskItems[i].Locked)//ERRORS messes the list up (indexes and placement). TODO
                    {
                        break;
                    }
                    AdjustStartTime(targetEmployeeSchedule.TaskItems[i - 1], targetEmployeeSchedule.TaskItems[i]);
                }
            }
            else if (index == targetEmployeeSchedule.TaskItems.Count)  //last
            {
                targetEmployeeSchedule.TaskItems.Add(taskToPlan);
                AdjustTravelTime(targetEmployeeSchedule.TaskItems[index - 1], taskToPlan);
                AdjustStartTime(targetEmployeeSchedule.TaskItems[index - 1], taskToPlan);
            }

            else
            {
                targetEmployeeSchedule.TaskItems.Insert(index, taskToPlan);

                for (int i = index; i < targetEmployeeSchedule.TaskItems.Count; i++)
                {
                    AdjustTravelTime(targetEmployeeSchedule.TaskItems[i], targetEmployeeSchedule.TaskItems[i + 1]);
                    if (targetEmployeeSchedule.TaskItems[i].Locked)//ERRORS messes the list up (indexes and placement). TODO
                    {
                        break;
                    }
                    AdjustStartTime(targetEmployeeSchedule.TaskItems[i - 1], targetEmployeeSchedule.TaskItems[i]);
                }
            }
            taskToPlan.State = TaskItem.Status.Planned;
            targetEmployeeSchedule.TimePeriod.EndTime = targetEmployeeSchedule.TaskItems.Last <TaskItem>().TimePeriod.EndTime;
            return(true);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Updates travelTime in a task, according to previous task.
 /// </summary>
 /// <param name="previousTask"></param>
 /// <param name="task"></param>
 private void AdjustTravelTime(TaskItem previousTask, TaskItem task)
 {
     task.Route = RouteCalculator.GetRouteItem(previousTask.TaskDescription.Citizen.GetAddress(DateTime.Today), task.TaskDescription.Citizen.GetAddress(DateTime.Today)); // todo date på addresse
 }