Exemplo n.º 1
0
 public void UpdateTaskLogs(TaskLogsDto dto)
 {
     //try
     //{
     //    var entity = Mapper.Map<TaskLogsDto, TaskLogs>(dto);
     //    using (var dbScope = _dbScopeFactory.Create())
     //    {
     //        var db = dbScope.DbContexts.Get<FireProjDbContext>();
     //        db.Update(entity, r => new { r.ModifyBy,r.TaskLogsType,r.LogsDesc,r.BuildId});
     //        db.SaveChanges();
     //    }
     //}
     //catch (Exception ex)
     //{
     //    throw new TipInfoException(ex.Message);
     //}
 }
Exemplo n.º 2
0
        public List <TaskLogsDto> GetTaskLogsByTaskId(int taskId)
        {
            using (var dbScope = _dbScopeFactory.CreateReadOnly())
            {
                var db       = dbScope.DbContexts.Get <FireProjDbContext>();
                var taskInfo = db.TaskInfo.Find(taskId);
                var entitys  = db.TaskLogs.Where(r => r.TaskId == taskId && r.LogType != LogType.Online && r.LogType != LogType.RollBack).ToList();
                if (taskInfo != null && taskInfo.OnlineTaskId.HasValue)
                {
                    var onlineLog = db.TaskLogs.Where(r => r.TaskId == taskInfo.OnlineTaskId.Value && r.LogType == LogType.Online).ToList();
                    entitys.AddRange(onlineLog);
                }
                entitys = entitys.OrderByDescending(t => t.Id).ToList();
                List <TaskLogsDto> data = new List <TaskLogsDto>();
                foreach (var item in entitys)
                {
                    TaskLogsDto taskLogsDto = new TaskLogsDto();
                    taskLogsDto.TaskId      = item.TaskId;
                    taskLogsDto.Stage       = item.Stage;
                    taskLogsDto.Comments    = item.Comments;
                    taskLogsDto.LogType     = item.LogType;
                    taskLogsDto.CreatorId   = item.CreatorId;
                    taskLogsDto.CreatorName = item.CreatorName;
                    taskLogsDto.CreateDate  = item.CreateDate;

                    switch (item.Stage)
                    {
                    case StageEnum.TEST:
                        taskLogsDto.DeployInfoIocDto = !item.DeployInfo.IsNullOrEmpty() ? JsonHelper.FromJson <DeployInfoIocDto>(item.DeployInfo) : new DeployInfoIocDto();
                        var checkUsers = AnalysisObj.AnalysisCheckUser(taskLogsDto.DeployInfoIocDto.CheckUserId);
                        var currUser   = checkUsers.FirstOrDefault(t => t.UserId == item.CreatorId);
                        if (currUser != null)
                        {
                            taskLogsDto.QAStatus = currUser.QAStatus;
                        }
                        taskLogsDto.BuildId      = taskLogsDto.DeployInfoIocDto.BuildId;
                        taskLogsDto.DeployStatus = taskLogsDto.DeployInfoIocDto.DeployStatus;
                        break;

                    case StageEnum.PRE:
                        taskLogsDto.DeployInfoPreDto = !item.DeployInfo.IsNullOrEmpty() ? JsonHelper.FromJson <DeployInfoPreDto>(item.DeployInfo) : new DeployInfoPreDto();
                        var checkUsers1 = AnalysisObj.AnalysisCheckUser(taskLogsDto.DeployInfoPreDto.CheckUserId);
                        var currUser1   = checkUsers1.FirstOrDefault(t => t.UserId == item.CreatorId);
                        if (currUser1 != null)
                        {
                            taskLogsDto.QAStatus = currUser1.QAStatus;
                        }
                        taskLogsDto.BuildId      = taskLogsDto.DeployInfoPreDto.BuildId;
                        taskLogsDto.DeployStatus = taskLogsDto.DeployInfoPreDto.DeployStatus;
                        break;

                    case StageEnum.PRODUCTION:
                        taskLogsDto.DeployInfoOnlineDto = !item.DeployInfo.IsNullOrEmpty() ? JsonHelper.FromJson <DeployInfoOnlineDto>(item.DeployInfo) : new DeployInfoOnlineDto();
                        var checkUsers2 = AnalysisObj.AnalysisCheckUser(taskLogsDto.DeployInfoOnlineDto.CheckUserId);
                        var currUser2   = checkUsers2.FirstOrDefault(t => t.UserId == item.CreatorId);
                        if (currUser2 != null)
                        {
                            taskLogsDto.QAStatus = currUser2.QAStatus;
                        }
                        if (item.LogType == LogType.Online)
                        {
                            var onlineTask = JsonHelper.FromJson <OnlineTaskInfo>(item.DeployInfo);
                            if (onlineTask != null)
                            {
                                taskLogsDto.BuildId      = onlineTask.BuildId;
                                taskLogsDto.DeployStatus = onlineTask.DeployStatus;
                            }
                        }

                        break;

                    default:
                        break;
                    }
                    data.Add(taskLogsDto);
                }
                return(data);
            }
        }