IEnumerator DequeueTask() { if (taskQueue.Count < 1) { yield break; } OfficerTask task = taskQueue[0]; taskQueue.RemoveAt(0); // check to see if officer can be interrpted, wait if not if ((m_officerState == types.OfficerState.isTravelling_interruptible)) { while (!tripCanBeInterrupted) { yield return(null); } } // interpret the task, then initiate int type = task.GetTaskType(); if (type == 0) // crime { AssignCrime((Crime)task.GetActivity()); } else if (type == 1 || type == 2) // depot or building { GoToLocation((Structure)task.GetLocation()); } }
public bool AddTask(OfficerTaskDTO task) { try { if (task == null) { return(false); } var officer = operationalDataContext.Patrols.Where(p => !p.IsPatrol.Value && p.PatrolCode == task.OfficerMilitaryId).FirstOrDefault(); if (officer == null) { return(false); } var pointString = string.Format("POINT({0} {1})", task.Longitude.ToString(), task.Latitude.ToString()); DbGeography dbGeography = DbGeography.FromText(pointString); var officerTask = new OfficerTask { CreateDate = DateTime.Now, GeoLocation = dbGeography, Latitude = task.Latitude, Longitude = task.Longitude, OfficerMilitaryId = task.OfficerMilitaryId, TaskMessage = task.TaskMessage, TaskTime = task.TaskTime, UserId = task.UserId, IsNoticed = false }; officerTask = operationalDataContext.OfficerTask.Add(officerTask); var officertaskstatus = new OfficerTaskStatus { OfficerTaskId = officerTask.OfficerTaskId, StatusUpdateDate = DateTime.Now, TaskStatusId = 1, Latitude = task.Latitude, Longitude = task.Longitude, GeoLocation = dbGeography, IsNoticed = false }; operationalDataContext.OfficerTaskStatus.Add(officertaskstatus); return(operationalDataContext.SaveChanges() > 0); } catch (Exception ex) { return(false); } }
public void SubmitTask(Crime _crime) { OfficerTask task = new OfficerTask((Activity)_crime); SubmitTask(task); }
public void SubmitTask(Structure _structure) { OfficerTask task = new OfficerTask(_structure); SubmitTask(task); }
public void SubmitTask(OfficerTask _task) { taskQueue.Add(_task); }