public void Add(AddTaskHistoryInput input) { if (input == null) { Logger.LogError($"{nameof(input)} should not be null."); return; } var taskHistory = Mapper.Map <Domain.Entities.TaskHistory>(input); DbContext.TaskHistory.Add(taskHistory); DbContext.SaveChanges(); }
private string PushTask(Core.Entities.Task task) { var nodes = _nodeAppService.GetAvailable(task.Os, task.NodeType, task.NodeCount); if (nodes.Count == 0) { // TODO LOG return(null); } var identity = Guid.NewGuid().ToString("N"); var messages = new List <CreateMessageInput>(); foreach (var node in nodes) { var arguments = string.Concat(task.Arguments, task.IsSingle ? " --tid:" : " ", task.Id, task.IsSingle ? " -i:" : " ", identity); var msg = new CreateMessageInput { TaskId = task.Id, ApplicationName = task.ApplicationName, Name = Core.Entities.Message.RunMessageName, NodeId = node.NodeId, Package = task.Package, Arguments = arguments }; messages.Add(msg); } _messageAppService.Create(messages); var taskHistory = new AddTaskHistoryInput { Identity = identity, NodeIds = string.Join("|", nodes.Select(a => a.NodeId)), TaskId = task.Id }; _taskHistoryAppService.Add(taskHistory); return(identity); }