Пример #1
0
        private void StartJob(PlaceState place, ShipTimeAssignment assignee, ScheduledJob job)
        {
            if (!place.Employees.Contains(assignee.AssignedEmployee))
            {
                job.Job.JobWasCompletedUnsuccesfully();

                MessageLog.AddError(string.Format("{0} {1} missed their trip to {2} from {3} at {4}",
                                                  assignee.AssignedEmployee.Name,
                                                  assignee.AssignedEmployee.Id,
                                                  job.Job.To.Name, job.Job.From.Name, assignee.Time.ToString("h':'m''")));
                return;
            }

            var employee = assignee.AssignedEmployee;

            if (employee.AssignedTruck == null)
            {
                MessageLog.AddError(string.Format("{0} {1} does not have a truck to drive to {2} from {3} at {4}",
                                                  assignee.AssignedEmployee.Name,
                                                  assignee.AssignedEmployee.Id,
                                                  job.Job.To.Name, job.Job.From.Name, assignee.Time.ToString("h':'m''")));
                return;
            }

            if (employee.CurrentJob == null)
            {
                employee.CurrentLocation = null;
                place.Employees.Remove(assignee.AssignedEmployee);
                var activeJob = new ActiveJob(job, assignee, Time - TimeSpan.FromMinutes(Time.Minute % 15), employee);
                Money -= activeJob.GasPrice();

                employee.CurrentJob = activeJob;
                ActiveJobs.Add(activeJob);

                MessageLog.AddInfo(string.Format("{0} left {1}, driving to {2}", assignee.AssignedEmployee.Name, job.Job.From.Name, job.Job.To.Name));
            }
        }