public string TaskCreate(ulong SequenceId, Packs Package, CONST.LaunchMode LaunchMode, TaskFileDescription[] InputFiles, TaskFileDescription[] OutputFiles, string[] ParamKeys, string[] ParamValues) { lock (_taskServiceLock) { Task task = new Task(SequenceId, Package, LaunchMode, InputFiles, OutputFiles); if (ParamKeys != null && ParamKeys.Length > 0) { if (ParamKeys.Length != ParamValues.Length) throw new Exception("Param keys and values lengths must be equal!"); int length = ParamKeys.Length; for (int i = 0; i < length; i++) task.Params[ParamKeys[i]] = ParamValues[i]; } Log.Debug(String.Format( "Цепочка {0}: создана задача {1}", SequenceId, task.TaskId )); task.Save(); return task.TaskId; } }
public void TaskFail(string TaskId) { lock (_taskServiceLock) { try { Task task = Task.Load(TaskId); task.Fail(); task.Save(); var sequenceService = new SequenceService(); sequenceService.StepFinishedCallback(task.SequenceId); } catch (Exception e) { Log.Error(String.Format( "Задача {2}, возникло исключение при завершении со статусом Fail\n{0}\n{1}", e.Message, e.StackTrace, TaskId )); } } }
public void TaskAbort(string TaskId) { lock (_taskServiceLock) { try { Task task = Task.Load(TaskId); task.Abort(); task.Save(); var sequenceService = new SequenceService(); sequenceService.StepFinishedCallback(task.SequenceId); } catch (Exception e) { Log.Error(String.Format( "Задача {2}, возникло исключение при попытке принудительного завершения\n{0}\n{1}", e.Message, e.StackTrace, TaskId )); } } }
public void TaskRun(string TaskId) { lock (_taskServiceLock) { try { Task task = Task.Load(TaskId); Log.Stats("T_task_start", task.SequenceId, task.TaskId, DateTime.Now); if (task.AssignedTo == null || String.IsNullOrEmpty(task.AssignedTo.ClusterName)) { DateTime timeBefore = DateTime.Now; task.AutoAssign(); Log.Stats("T_assign", task.SequenceId, task.TaskId, DateTime.Now - timeBefore); } if (!task.Time.Estimated.HasValue) { throw new Exception("Could not assign task to any cluster!"); } task.Run(); task.Save(); } catch (Exception e) { Log.Error(String.Format( "Задача {0}, ошибка при запуске: {1}\n{2}", TaskId, e.Message, e.StackTrace )); TaskFail(TaskId); } } }