public async Task <IActionResult> Create([FromBody] CreateTaskModel model) { try { if (TaskTypes.IsReserved(model.TypeId)) { return(Error(HttpStatusCode.BadRequest, "Tasks of this type cannot be created manually.")); } var user = await GetLoggedInUser(); var accessResponse = await GetPermissionsForTasksPerson(model.AssignedToId, true); if (accessResponse.CanAccess || accessResponse.IsOwner) { model.AssignedById = user.Id.Value; await _taskService.Create(model); return(Ok()); } return(Error(HttpStatusCode.Forbidden, "You do not have permission to create tasks for this person.")); } catch (Exception e) { return(HandleException(e)); } }
public static INPCTask CreateTaskFromTypeAndParameters(TaskTypes taskType, string parameter) { switch (taskType) { case TaskTypes.GoToObject: return(new GoToObjectTask(parameter)); case TaskTypes.GoToPosition: return(new GoToLocationTask(parameter)); case TaskTypes.WaitForDuration: return(new WaitForDurationTask(parameter)); case TaskTypes.GoToRoom: return(new GoToRoomTask(parameter)); case TaskTypes.KillClosestAgent: return(new KillClosestAgentTask()); case TaskTypes.RoamPassively: return(new RoamBetweenRoomsRandomlyTask()); default: return(null); } }
public async Task <IActionResult> Create([FromForm] CreateTaskModel model) { return(await ProcessAsync(async() => { if (TaskTypes.IsReserved(model.TypeId)) { return BadRequest("This task type cannot be created manually."); } var user = await UserService.GetUserByPrincipal(User); var canCreate = await AuthoriseCreate(model.AssignedToId, user.Id); if (canCreate) { var task = new TaskModel { AssignedToId = model.AssignedToId, AssignedById = user.Id, Title = model.Title, Description = model.Description, DueDate = model.DueDate, CreatedDate = DateTime.Now, TypeId = model.TypeId, Completed = false }; await _taskService.Create(task); return Ok("Task created successfully."); } return Forbid(); })); }
public IHttpActionResult PutTaskTypes(int id, TaskTypes taskTypes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != taskTypes.Id) { return(BadRequest()); } db.Entry(taskTypes).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TaskTypesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static ITask CreateTask(TaskTypes taskType, List <IOption> options) { if (taskType == TaskTypes.DeleteByAttribute) { return(new DeleteByAttribute(options)); } else if (taskType == TaskTypes.DeleteBySize) { return(new DeleteBySize(options)); } else if (taskType == TaskTypes.RenameFile) { return(new RenameFile(options)); } else if (taskType == TaskTypes.SetCreateDate) { return(new SetCreateDate(options)); } else if (taskType == TaskTypes.ModifyDateTaken) { return(new SetDateTaken(options)); } else if (taskType == TaskTypes.ModifyDateTakenFromFileName) { return(new SetDateTakenFromFileName(options)); } throw new NotImplementedException(); }
private void ProceedTask() { if (taskType != TaskTypes.None) { switch (taskType) { case TaskTypes.Add: if (!langPack.languages.ContainsKey(taskKey)) { langPack.languages.Add(taskKey, new Language("")); SaveChanges(); } break; case TaskTypes.Remove: if (langPack.languages.ContainsKey(taskKey) && langPack.languages.Count > 1) { langPack.languages.Remove(taskKey); SaveChanges(); } break; } taskType = TaskTypes.None; taskKey = ""; } }
//move a list of selected units private bool OnSelectedUnitsAction(Vector3 targetPosition, TaskTypes taskType) { List <Unit> selectedUnits = selected.GetEntitiesList(EntityTypes.unit, false, true).Cast <Unit>().ToList(); //get selected units from player faction if (selectedUnits.Count == 0) //do not proceed if no units are selected { return(false); } if (taskType == TaskTypes.attack) //if this is an attack task type { gameMgr.AttackMgr.LaunchTerrainAttack(selectedUnits, targetPosition, true); //only check for launching terrain attack return(true); } //if this is a movemen task or it's no assigned task type but terrain attack is not launched if (taskType == TaskTypes.movement || (taskType == TaskTypes.none && !gameMgr.AttackMgr.LaunchTerrainAttack(selectedUnits, targetPosition))) { gameMgr.MvtMgr.Move(selectedUnits, targetPosition, 0.0f, null, InputMode.movement, true); //move selected units return(true); } return(false); }
//for local player only, not for NPC factions public bool CanAddTask(TaskLauncher TaskComp, int TaskID, TaskTypes TaskType) { //Always check that the health is above the minimal limit to launch tasks and that the building was built (to max health) at least once: if (TaskComp.GetTaskHolderHealth() < TaskComp.MinTaskHealth) { UIMgr.ShowPlayerMessage("Health is too low to launch task!", UIManager.MessageTypes.Error); AudioManager.PlayAudio(GameMgr.GeneralAudioSource.gameObject, TaskComp.DeclinedTaskAudio, false); //Declined task audio. return(false); } else if (TaskComp.MaxTasks <= TaskComp.TasksQueue.Count) { //Notify the player that the maximum amount of tasks for this building has been reached UIMgr.ShowPlayerMessage("Maximum building tasks has been reached", UIManager.MessageTypes.Error); AudioManager.PlayAudio(GameMgr.GeneralAudioSource.gameObject, TaskComp.DeclinedTaskAudio, false); //Declined task audio. return(false); } //Do we have enough resources for this task? if (TaskType == TaskManager.TaskTypes.TaskUpgrade) { //upgrade task: //Make sure there are enough resources if (ResourceMgr.CheckResources(TaskComp.TasksList[TaskID].UnitCreationSettings.Upgrades[TaskComp.TasksList[TaskID].CurrentUpgradeLevel].UpgradeResources, GameManager.PlayerFactionID, 1.0f) == false) { UIMgr.ShowPlayerMessage("Not enough resources to launch upgrade task!", UIManager.MessageTypes.Error); AudioManager.PlayAudio(GameMgr.GeneralAudioSource.gameObject, TaskComp.DeclinedTaskAudio, false); //Declined task audio. return(false); } } else { if (ResourceMgr.CheckResources(TaskComp.TasksList[TaskID].RequiredResources, GameManager.PlayerFactionID, 1) == false) { UIMgr.ShowPlayerMessage("Not enough resources to launch task!", UIManager.MessageTypes.Error); AudioManager.PlayAudio(GameMgr.GeneralAudioSource.gameObject, TaskComp.DeclinedTaskAudio, false); //Declined task audio. return(false); } if (TaskType == TaskManager.TaskTypes.CreateUnit) { //create unit task if (GameMgr.Factions[GameManager.PlayerFactionID].CurrentPopulation >= GameMgr.Factions[GameManager.PlayerFactionID].MaxPopulation) { //Inform the player that there's no more room for new units. UIMgr.ShowPlayerMessage("Maximum population has been reached!", UIManager.MessageTypes.Error); AudioManager.PlayAudio(GameMgr.GeneralAudioSource.gameObject, TaskComp.DeclinedTaskAudio, false); //Declined task audio. return(false); } //if there's population slots but the local faction already hit the limit with this faction else if (GameMgr.Factions[GameManager.PlayerFactionID].FactionMgr.HasReachedLimit(TaskComp.TasksList[TaskID].UnitCreationSettings.Prefabs[0].Code)) { //inform the player that he can't create this unit UIMgr.ShowPlayerMessage("This unit has reached its creation limit", UIManager.MessageTypes.Error); AudioManager.PlayAudio(GameMgr.GeneralAudioSource.gameObject, TaskComp.DeclinedTaskAudio, false); //Declined task audio. return(false); } } } return(true); }
public TaskListForm(WorkItemStore wis, string project, TaskTypes type) : this() { this.wis = wis; this.project = project; this.type = type; this.Text = string.Format("Select {0}", type); }
public ViewResult New() { //12.29.17 - BTo - Needed. Otherwise View will return a Model.IsValid = false var model = new TaskTypes(); model.TaskTypeId = 0; return(View("TaskTypeForm", model)); }
private Vector2 customCursorHotspot = Vector2.zero; //if your cursors use a different hotspot, assign it here public void Init() { AwaitingTaskType = TaskTypes.none; if (defaultCursorSprite != null) //if there's a default texture for the cursor { Cursor.SetCursor(defaultCursorSprite.texture, customCursorHotspot, CursorMode.Auto); } }
//set the awaiting task unit component type public void SetAwaitingTaskType(TaskTypes type, Sprite icon) { AwaitingTaskType = type; //set the new task type if (changeCursorTexture == true && icon != null) { //if it is allowed to change the mouse texture //change it: Cursor.SetCursor(icon.texture, customCursorHotspot, CursorMode.Auto); } }
private static Task Create(string taskTypeName, string json) { Type taskType; if (!TaskTypes.TryGetValue(taskTypeName, out taskType)) { throw new Exception("Unknown task type '" + taskTypeName + "'."); } return(Create(taskType, json)); }
public void removeTask(TaskTypes task) { taskList.Remove(task); updateUI(); if (taskList.Count < 1) { addTask(); } }
private static bool IsAccept(FilterEventArgs e, TaskTypes type) { var task = (IHydraTask)e.Item; if (e.Item == null) { return(false); } return(task.Type == type); }
//generates a new task from enum TaskTypes, based on rng protected override TaskTypes generateTask() { int newTask = Random.Range(10, 13); TaskTypes generatedTask = (TaskTypes)System.Enum.Parse(typeof(TaskTypes), newTask.ToString()); //Ensure bike task does not get generated if bikeNPC is not at start point if (!CityBikeNPC.atInitialPoint && generatedTask.Equals(TaskTypes.Bike)) { generatedTask = GetNonBikeTask(); } return(generatedTask); }
public AddTaskViewModel(Calendar calendar) { TaskStatuses.AddRange(calendar.TaskStatuses); TaskTypes.AddRange(calendar.TaskTypes); Model.CalendarId = calendar.Id; Model.PlannedStart = DateTime.Now; Model.PlannedEnd = DateTime.Now; Ok = ReactiveCommand.CreateFromObservable(() => CloseWindowInteraction.CloseWindow.Handle(true)); Cancel = ReactiveCommand.CreateFromObservable(() => CloseWindowInteraction.CloseWindow.Handle(false)); }
public BaseTask(double estimation, TaskTypes type, string title, string description, User taskOwner, User taskCreator, TaskStatuses status = TaskStatuses.Backlog) { Estimation = estimation; Title = title; Description = description; Id = Guid.NewGuid().ToString(); this.taskCreator = taskCreator; _creationDate = DateTime.Now; UpdatedDate = DateTime.Now; Status = status; TaskOwner = taskOwner; }
public BaseTask(double estimation, TaskTypes type, string title, string discription, User taskCreator, State statuse = State.BackLog) { Estimation = estimation; Type = type; Title = title; Discription = discription; Id = Guid.NewGuid().ToString(); updateDate = DateTime.Now; _createdDate = DateTime.Now; Creator = taskCreator; Statuse = statuse; }
public IHttpActionResult PostTaskTypes(TaskTypes taskTypes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TaskTypes.Add(taskTypes); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = taskTypes.Id }, taskTypes)); }
public BaseTask(double estimation, TaskTypes type, string title, string description, User creator, Status status = Status.BackLog) { Estimation = estimation; Type = type; Title = title; Description = description; Id = Guid.NewGuid().ToString(); _createdDate = DateTime.Now; UpdatedDate = DateTime.Now; taskCreator = creator; this.status = status; }
public BaseTask(double estmation, TaskTypes task, string title, string discription, User taskCreator, Statuses status = Statuses.BackLog) { Estmation = estmation; Task = task; Title = title; Discription = discription; Id = Guid.NewGuid().ToString(); _createdDate = DateTime.Now; UpdatedDate = DateTime.Now; _creator = taskCreator; Status = status; }
public Task(bool isCompleted, bool isLevelTask, ObjectsDescription[] associatedWith, string taskDescription, int taskIndex, int taskCompletionAward, TaskTypes taskType, TaskCategory taskCategory, float countLimit) { IsCompleted = isCompleted; IsLevelTask = isLevelTask; AssociatedWith = associatedWith; TaskIndex = taskIndex; TaskCompletionAward = taskCompletionAward; TaskDescription = taskDescription; CurrTaskCategory = taskCategory; CurrTaskType = taskType; CountLimit = countLimit; CurrentCount = 0; }
private TaskTypes GetNonBikeTask() { int newTask = Random.Range(10, 13); TaskTypes generatedTask = (TaskTypes)System.Enum.Parse(typeof(TaskTypes), newTask.ToString()); //Ensure bike task does not get generated while (generatedTask.Equals(TaskTypes.Bike)) { newTask = Random.Range(10, 13); generatedTask = (TaskTypes)System.Enum.Parse(typeof(TaskTypes), newTask.ToString()); } return(generatedTask); }
public IHttpActionResult DeleteTaskTypes(int id) { TaskTypes taskTypes = db.TaskTypes.Find(id); if (taskTypes == null) { return(NotFound()); } db.TaskTypes.Remove(taskTypes); db.SaveChanges(); return(Ok(taskTypes)); }
private void ActivateTask() { Transform targetLocation = null; //Reset known status of zones fullJoyZones.Clear(); fullInteractionZones.Clear(); //Determine target location switch (taskQueueToday.Peek()) { case TaskTypes.Sleep: targetLocation = sleepZone; currentTask = TaskTypes.Sleep; break; case TaskTypes.Eat: targetLocation = restZone; currentTask = TaskTypes.Eat; break; case TaskTypes.Work: targetLocation = workZone; currentTask = TaskTypes.Work; break; case TaskTypes.Joy: targetLocation = FindJoyLocation(); currentTask = TaskTypes.Joy; break; case TaskTypes.Social: targetLocation = FindInteractionLocation(); currentTask = TaskTypes.Social; break; default: break; } //Set tomorrows schedule and remove current task from list taskQueueTomorrow.Enqueue(taskQueueToday.Dequeue()); taskQueueTimeHourTomorrow.Enqueue(taskQueueTimeHourToday.Dequeue()); taskQueueTimeMinuteTomorrow.Enqueue(taskQueueTimeMinuteToday.Dequeue()); if (targetLocation != null) { SetTarget(targetLocation); } }
// Add a task to the task list protected void addTask() { TaskTypes task = generateTask(); while (taskList.Contains(task)) { task = generateTask(); } taskList.Add(task); updateUI(); tasks[task].setupTask(); generateTaskTime(); }
public static TaskType ByType(this IQueryable<TaskType> qry, TaskTypes type) { var r = qry.Where(x => x.Name == type.ToString()).SingleOrDefault(); if( r == null) { r = new TaskType { Name = type.ToString(), Type = type }; r.Save(); } return r; }
public static bool IsRegularTask(TaskTypes task) { switch (task) { case TaskTypes.FixComms: case TaskTypes.FixLights: case TaskTypes.ResetReactor: case TaskTypes.ResetSeismic: case TaskTypes.RestoreOxy: return(false); default: return(true); } }
/// <summary> /// Find TaskType by it's Enum type /// </summary> /// <param name="dc"></param> /// <param name="type"></param> /// <returns></returns> public Domain.TaskType Find(DataContext dc, TaskTypes type) { var result = All(dc).Where(t => t.Name == type.ToString()).SingleOrDefault(); if (result == null) { result = new Domain.TaskType { Name = type.ToString(), Type = type }; result.Save(); } return result; }
public static bool IsSabotage(this TaskTypes TaskType) { switch (TaskType) { case TaskTypes.FixLights: case TaskTypes.RestoreOxy: case TaskTypes.ResetReactor: case TaskTypes.ResetSeismic: case TaskTypes.FixComms: return(true); default: return(false); } }
// Interact with a particular plot public override ItemTypes OnInteract() { // If there is no plant, plant a dirt pile and set the next interaction text to water if (hasPlant == false) { this.transform.Find("Dirt_Pile").gameObject.SetActive(true); if (GameSettings.sounds == true) { diggingSound.Play(); } hasPlant = true; can.fill(); InteractText = "Press J to Water"; } // If it's not watered, water the plot to grow the plant else if (!watered) { watered = true; this.transform.Find("plant").gameObject.SetActive(true); if (GameSettings.sounds == true) { wateringSound.Play(); } TaskTypes task = TaskTypes.Tree; // Grow the correct type of plant if (plotType == ItemTypes.CarrotSeeds) { task = TaskTypes.Carrot; } else if (plotType == ItemTypes.PotatoSeeds) { task = TaskTypes.Potato; } else if (plotType == ItemTypes.TomatoSeeds) { task = TaskTypes.Tomato; } // Grant score, and complete the task scoring = FindObjectOfType <OutdoorScoreController>(); scoring.taskScored(OutdoorScoreController.Tasks.PLANT); controller.taskComplete(task); } // Remove items from the player after interaction return(ItemTypes.NONE); }
/// <summary> /// Find TaskType by it's Enum type /// </summary> /// <param name="dc"></param> /// <param name="type"></param> /// <returns></returns> public Domain.TaskType Find(DataContext dc, TaskTypes type) { var result = All(dc).Where(t => t.Name == type.ToString()).SingleOrDefault(); if (result == null) { result = new Domain.TaskType { Name = type.ToString(), Type = type }; result.Save(); } return(result); }
/// <summary> /// tlačidlo OK /// </summary> private void btnOk_Click(object sender, RoutedEventArgs e) { //Kontrola, či bol zvolený typ úlohy if (rbLinear.IsChecked == false && rbKnapsack.IsChecked == false) { MessageBox.Show("Nebol zvoleny typ úlohy.", "Chyba!", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Priradenie typu úlohy do premennej if (rbLinear.IsChecked == true) { myTaskType = TaskTypes.Linear; } if (rbKnapsack.IsChecked == true) { myTaskType = TaskTypes.Knapsack; } DialogResult = true; Close(); }
public static bool IsFormDisabled(TaskTypes? taskType = null) { long merchantID = CurrentMerchantID; long contractId = ContractID; if (merchantID <= 0) { return true; } var tasktyp = HttpContext.Current.Request["TaskType"] ?? ""; if (tasktyp == "0") { return false; } if (taskType.HasValue) { var apiMethod = string.Format("merchants/merchantinfo/{0}?tasktypeId={1}", merchantID, (long)taskType); var model = BaseApiData.GetAPIResult<MerchantModel>(apiMethod, () => new MerchantModel()) ?? new MerchantModel(); HttpContext.Current.Items["MerchantInfo"] = model; return model.TaskStatusId != (long)StatusTypes.Assigned; } return false; }
private static bool IsAccept(FilterEventArgs e, TaskTypes type) { var task = (IHydraTask)e.Item; if (e.Item == null) return false; return task.Type == type; }
public TaskListForm(WorkItemStore wis, string project, TaskTypes type, bool showClosed) : this(wis, project, type) { checkBoxClosed.Checked = showClosed; }
public static TaskType Find(DataContext dc, TaskTypes type) { return Repository.Find(dc, type); }
public static TaskType Find(TaskTypes type) { return Find(null, type); }
/// <summary> /// Verifies DC Voltage /// </summary> void preTest(TaskTypes next_task) { // Start the running watch _stopwatch_running.Restart(); // Disable the app setEnablement(false, false); // Init the status text box runStatus_Init(); // Clear output status textBoxOutputStatus.Clear(); // Clear tool strip toolStripTimingStatusLabel.Text = ""; statusStrip.Update(); setRunStatus("Start Pre-test", Color.Black, Color.White); updateOutputStatus("Start Pre-test".PadBoth(80, '-')); // Clear the error _pretest_error_msg = null; // Init the meter object if (Properties.Settings.Default.Meter_Manual_Measurement) _meter = null; else _meter = new MultiMeter(Properties.Settings.Default.Meter_COM_Port_Name); _relay_ctrl.OpenIfClosed(); _relay_ctrl.WriteLine(Relay_Lines.Ember, false); _relay_ctrl.WriteLine(Relay_Lines.Load, false); _relay_ctrl.WriteLine(Relay_Lines.Power, true); Thread.Sleep(1000); if (getSelectedBoardType() == BoardTypes.Honeycomb) { _relay_ctrl.WriteLine(4, false); } relaysShowSetttings(); if (!Properties.Settings.Default.PrePost_Test_Enabled) { pretest_done(next_task); return; } Tests pretest = new Tests(); pretest.Status_Event += _pretest_Status_Event; pretest.MultiMeter = _meter; pretest.RelayController = _relay_ctrl; _task_uut = new Task(() => pretest.Verify_Voltage(3.3 - 0.33, 3.3 + 0.33)); _task_uut.ContinueWith((t) => pretest_done_handler(next_task), TaskContinuationOptions.OnlyOnRanToCompletion); _task_uut.ContinueWith((t) => pretest_exception_handler(t, next_task), TaskContinuationOptions.OnlyOnFaulted); _task_uut.Start(); }
/// <summary> /// Pretest done handler /// </summary> void pretest_done(TaskTypes next_task) { // Check PASS or FAIL if (_pretest_error_msg == null) { updateRunStatus("PASS", Color.White, Color.Green); // Should be safe to connect Ember _relay_ctrl.OpenIfClosed(); _relay_ctrl.WriteLine(Relay_Lines.Power, false); Thread.Sleep(500); if (next_task == TaskTypes.Test || next_task == TaskTypes.Calibrate) { openTelnet(); } _relay_ctrl.WriteLine(Relay_Lines.Ember, true); _relay_ctrl.WriteLine(Relay_Lines.Power, true); Thread.Sleep(1000); } else { closeTelnet(); try { power_off(); } catch (Exception ex) { updateOutputStatus("Power off exception:" + ex.Message); } if (_meter != null) _meter.CloseSerialPort(); updateRunStatus("FAIL", Color.White, Color.Red); updateOutputStatus(_pretest_error_msg); setEnablement(true, false); } _stopwatch_running.Stop(); string elapsedTime = string.Format("Elapsed time {0:00} seconds", _stopwatch_running.Elapsed.TotalSeconds); updateOutputStatus(elapsedTime); updateOutputStatus("End Pre-test".PadBoth(80, '-')); if (_pretest_error_msg != null) { setEnablement(true, false); return; } try { // Start the running stopwatch _stopwatch_running.Restart(); // Run the next task switch (next_task) { case TaskTypes.Code: _coding_error_msg = null; try { code(); } catch (Exception ex) { _coding_error_msg = ex.Message + "\r\n" + ex.StackTrace; coding_done(); } break; case TaskTypes.Calibrate: _calibration_error_msg = null; try { calibrate(); } catch (Exception ex) { _calibration_error_msg = ex.Message; calibration_done(); } break; case TaskTypes.Test: if (getSelectedBoardType() == BoardTypes.Honeycomb) { _test_error_msg = null; try { hct_Run_Tests(); } catch (Exception ex) { _test_error_msg = ex.Message; hct_done(); } } break; case TaskTypes.Recode: recode(); break; } } catch (Exception ex) { switch (next_task) { case TaskTypes.Code: _coding_error_msg = ex.Message; coding_done(); break; case TaskTypes.Calibrate: _calibration_error_msg = ex.Message; calibration_done(); break; case TaskTypes.Recode: power_off(); break; } } }
/// <summary> /// Handles when pretest is done /// </summary> /// <param name="task"></param> void pretest_done_handler(TaskTypes next_task) { pretest_done(next_task); }
public BasicTask(TaskTypes type) { m_Type = type; }
/// <summary> /// Handles when pretest throws an error /// </summary> /// <param name="task"></param> void pretest_exception_handler(Task task, TaskTypes next_task) { var exception = task.Exception; string errmsg = exception.InnerException.Message; _pretest_error_msg = errmsg; pretest_done(next_task); }