private async Task <List <StepReport> > RunBuild(Build build) { var tasks = await _taskBuilder.Build(build, _configuration); var stepInvoker = new StepInvoker(); var outputStepReport = new List <StepReport>(); foreach (var step in tasks) { if (!step.Enabled) { continue; } RenderStepText(step); var stepReport = stepInvoker.RunStep(step); outputStepReport.Add(stepReport); if (!step.ContinueOnError && !stepReport.Succeed) { break; } } return(outputStepReport); }
public TaskGrantDto Build() { var autoTask = _autoTaskBuilder.Build(); var otm = _taskBuilder.Build(); _taskGrant.OtmId = otm.Id; _taskGrant.AutoTaskId = autoTask.Id; _testMtbContext.AddModel(_taskGrant); _taskGrant.Otm = otm; _taskGrant.AutoTask = autoTask; return(_taskGrant); }
private ITask MakeTask(object buildConfigTask) { ITaskBuilder taskBuilder = _factory.Task(buildConfigTask.GetType().Name); foreach (PropertyInfo prop in buildConfigTask.GetType().GetProperties()) { taskBuilder.With(prop.Name, prop.GetValue(buildConfigTask)); } ITask task = taskBuilder.Build(); return(task); }
public async Task <TaskDto> DeleteAsync(Guid taskId, CancellationToken cancellationToken) { var task = _taskBuilder.Build(); await Task.Run(() => { task = _tasklistDbContext.Tasks .Where(t => t.Id == taskId) .FirstOrDefault(); if (task == null) { throw new Exception(); } task.Excluido = true; _tasklistDbContext.Tasks.Update(task); _tasklistDbContext.SaveChangesAsync(); }, cancellationToken); return(_mapper.Map <TaskDto>(task)); }
public LuaCreateSteamWorkshopItemTask(ITaskBuilder taskBuilder, LuaTable table) { taskBuilder .With("AppId", Convert.ToUInt32(table["app_id"])) .With("Title", table["title"]) .With("DescriptionFilePath", table["description_file"]) .With("ItemFolderPath", table["item_folder"]) .With("Visibility", table["visibility"]) .With("Language", table["language"]); LuaTable tags = (LuaTable)table["tags"]; HashSet <string> stringTags = tags?.Values.Cast <string>().ToHashSet(); if (stringTags != null) { taskBuilder.With("Tags", stringTags); } Task = taskBuilder.Build(); }
/// <summary> /// Occurs when object should do its action. /// </summary> public void Execute() { if (taskManagerState == TaskManagerState.ClientOnly) { logger.WriteDebug("The server has client algorithm only."); return; } logger.WriteDebug("Searching for new tasks in available queue..."); IReadOnlyCollection <QueueModel> queues = queueManager.GetAvailableQueues(); foreach (QueueModel queueModel in queues) { Int64 queueId = queueModel.Id; Int64 serverId = serverManager.ServerId; TaskRequestSpecification specification = new TaskRequestSpecification(queueId, serverId, maxTasksPerQueue); List <TaskModel> taskModels; bool isReceived = taskDataContext.TryGetAvailableTask(specification, out taskModels); if (isReceived) { foreach (TaskModel taskModel in taskModels) { IRunningTask currentTask = null; try { currentTask = taskBuilder.Build(taskModel); lock (activeTasks) { activeTasks.Add(taskModel.Id, currentTask); } currentTask.OnCompletedEventHandler += OnCompletedEventHandler; currentTask.Execute(); //TODO: Provide global Cancelation Token. logger.WriteDebug("The task {0} has been received.", taskModel); } catch (Exception ex) { string msg = string.Format("There was an error during executing task: {0}.", taskModel); logger.WriteError(ex, msg); RestartTask(taskModel, msg, ex); } } } else { logger.WriteDebug("There is no new task in the storage."); } List <Int64> taskIds; isReceived = taskDataContext.TryGetCancelTasks(queueId, serverId, out taskIds); if (isReceived) { foreach (Int64 taskId in taskIds) { logger.WriteTrace("The task (id = {0}) has been marked for cancelation. Cancelling...", taskId); IRunningTask runningTask; lock (activeTasks) { if (activeTasks.ContainsKey(taskId) == false) { continue; } runningTask = activeTasks[taskId]; } logger.WriteTrace("The task ({0}) is running. Cancelling...", taskId); try { runningTask.Cancel(); } catch (Exception ex) { //TODO: Decide what to do. logger.WriteError("there was an exception during cancelation task.", ex); } logger.WriteTrace("The task has been marked for canceling."); } } else { logger.WriteDebug("There is no task for cancelation."); } } logger.WriteDebug("All tasks have been found if existed."); }
private void ProcessNewTasks(int currentServerId) { if (taskProcessing.Slots > 0) { Queue <IRunningTask> runningTasks = new Queue <IRunningTask>(); using (IUnitOfWork unitOfWork = unitOfWorkFactory.CreateUnitOfWork(contextSettings)) { //TODO: Queues ICollection <TaskInfo> tasks = unitOfWork.ExecuteQuery <TaskInfo>(@" UPDATE TOP (@MaxRows) [DotNetCraftWiseQueue].[dbo].[TaskInfoes] SET [TaskState] = @UpdatedTaskState, [ServerId] = @ServerId OUTPUT inserted.* Where ( [ServerId] = 0 AND [TaskState] = @NewTask AND [QueueName] in (@QueueName) AND [ExecuteAt] <= @ExecuteAt AND [RepeatCrashCount] > 0);" , new DataBaseParameter("@MaxRows", taskProcessing.Slots), new DataBaseParameter("@UpdatedTaskState", TaskStates.Running), new DataBaseParameter("@ServerId", currentServerId), new DataBaseParameter("@NewTask", TaskStates.New), new DataBaseParameter("@ExecuteAt", DateTime.UtcNow), new DataBaseParameter("@QueueName", "default")); foreach (TaskInfo taskInfo in tasks) { try { IRunningTask runningTask = taskBuilder.Build(taskInfo); runningTasks.Enqueue(runningTask); taskInfo.ServerId = currentServerId; taskInfo.TaskState = TaskStates.Running; } catch (Exception ex) { taskInfo.ServerId = currentServerId; taskInfo.TaskState = TaskStates.Failed; } if (taskInfo.ScheduleInfoId > 0) { ScheduleInfo scheduleInfo = scheduleRepository.Get(taskInfo.ScheduleInfoId); Type type = jsonConverter.ConvertFromJson <Type>(scheduleInfo.ScheduleDataType); IScheduleStrategy scheduleStrategy = (IScheduleStrategy)jsonConverter.ConvertFromJson(scheduleInfo.ScheduleData, type); taskInfo.ExecuteAt = scheduleStrategy.GetNextExecutionTime(taskInfo.ExecuteAt, taskInfo.TaskState); } unitOfWork.Update(taskInfo); } if (runningTasks.Count > 0) { unitOfWork.Commit(); } } while (runningTasks.Count > 0) { IRunningTask runningTask = runningTasks.Dequeue(); taskProcessing.RunTask(runningTask); } } }