public bool Save(CommandLogViewModel obj) { using (_unitOfWork) { _commandLogRepository.Add(_mapper.Map <CommandLog>(obj)); return(_unitOfWork.Commit()); } }
public ResponseBase <EmptyResponse> AddCommandExecuteLog(AddCommandExecuteLogRequest req) { try { //添加执行命令日志 cmdLogRespository.Add(new tb_commandlog() { commanddetailid = req.CommandDetailId, commandendtime = Convert.ToDateTime(req.CommandEndTime), commandparams = req.CommandParams, commandqueueid = req.CommandQueueId, commandstarttime = Convert.ToDateTime(req.CommandStartTime), commandstate = req.ExecuteStatus, logcreatetime = DateTime.Now, msg = req.CommandExecuteLog, nodeid = req.NodeId, totalruntime = int.Parse(req.TotalTime), commandresult = req.CommandResult, }); var cmdqueuemodel = cmdqueuerespository.FindSingle(x => x.id == req.CommandQueueId && x.nodeid == req.NodeId); if (cmdqueuemodel == null) { return(ResponseToClient <EmptyResponse>(ResponesStatus.Failed, "更新命令队列状态失败")); } cmdqueuemodel.commandstate = req.ExecuteStatus; //更新命令队列执行状态 if (req.ExecuteStatus != (int)ExecuteStatus.ExecuteSucess) { //更新命令队列失败次数 cmdqueuemodel.failedcount += 1; } cmdqueuerespository.Update(cmdqueuemodel); //更新命令实体失败次数 return(ResponseToClient <EmptyResponse>(ResponesStatus.Success, "")); } catch (Exception ex) { return(ResponseToClient <EmptyResponse>(ResponesStatus.Exception, JsonConvert.SerializeObject(ex))); } }