Ejemplo n.º 1
0
        public async Task <List <AttachmentDto> > GetAttachmentDtoHistoryProject(Guid projectId, Guid?historyId = null)
        {
            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                if (historyId != null)
                {
                    return(await _attachmentRepository.GetAll()
                           .Include(i => i.ProcessHistory)
                           .OrderByDescending(o => o.CreatedDate)
                           .Where(w => w.ProjectId == projectId && w.ItemId == historyId.GetValueOrDefault() && w.Source == Source.Project)
                           .Select(e => new AttachmentDto()
                    {
                        FileName = e.FileName,
                        Id = e.Id,
                        FileExt = e.FileExt,
                        CreatedBy = e.CreatedBy,
                        CreatedDate = e.CreatedDate,
                        Source = e.Source
                    }).ToListAsync());
                }

                return(await _attachmentRepository.GetAll()
                       .Include(i => i.ProcessHistory)
                       .OrderByDescending(o => o.CreatedDate)
                       .Where(w => w.ProjectId == projectId && w.ProjectId != w.ItemId && w.Source == Source.Project)
                       .Select(e => new AttachmentDto()
                {
                    FileName = e.FileName,
                    Id = e.Id,
                    FileExt = e.FileExt,
                    CreatedBy = e.CreatedBy,
                    CreatedDate = e.CreatedDate,
                    Source = e.Source
                }).ToListAsync());
            }
        }
        /// <summary>
        /// 通过外键获取附件列表
        /// </summary>
        /// <param name="fkid"></param>
        /// <returns></returns>
        public List <MultimediaOutput> GetAllList(ModuleInfoInput input)
        {
            var att   = _iAttachmentRepository.GetAll().Where(q => q.FKey == input.FKey);
            var query = _iMultimediaTypeRepository.Query(q => q.GroupJoin(att, m => m.Id, a => a.TypeCode, (m, a) => new { m, a }));
            var ret   = query.Where(q => q.m.ModuleType == input.ModuleType).ToList();
            List <MultimediaOutput> list = new List <MultimediaOutput>();

            if (ret.Count > 0)
            {
                ret.ForEach((x) =>
                {
                    MultimediaOutput output = new MultimediaOutput();
                    List <MultimediaAttachmentInput> mlist = new List <MultimediaAttachmentInput>();
                    if (x.a.Count() > 0)
                    {
                        foreach (var tb in x.a)
                        {
                            MultimediaAttachmentInput mul = new MultimediaAttachmentInput();
                            mul.Id           = tb.Id;
                            mul.FKey         = tb.FKey;
                            mul.PhysicalName = tb.PhysicalName;
                            mul.LogicName    = tb.LogicName;
                            mul.PhysicalPath = tb.PhysicalPath;
                            mul.HttpPath     = tb.HttpPath;
                            mul.FileSize     = tb.FileSize;
                            mul.Extension    = tb.Extension;
                            mul.TypeCode     = tb.TypeCode;
                            mlist.Add(mul);
                        }
                    }
                    output.Id         = x.m.Id;
                    output.Name       = x.m.Name;
                    output.ModuleType = x.m.ModuleType;
                    output.Children   = mlist;
                    list.Add(output);
                });
            }
            return(list);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get all attachments
 /// </summary>
 /// <returns></returns>
 public ICollection <AttachmentDomain> GetAllAttachments()
 {
     return(_attachmentRepository.GetAll());
 }
Ejemplo n.º 4
0
        public async Task <SendMessageResponse> UpdateProcessTaskAssign(TaskItemAssignDto dto)
        {
            SendMessageResponse sendMessage = new SendMessageResponse();

            try
            {
                using (var scope = _dbContextScopeFactory.Create())
                {
                    List <AttachmentDto> attachmentDtos = dto.Attachments.ToList();
                    dto.Attachments = null;
                    TaskItemAssign entity = _objectRepository.GetAll().Where(e => e.Id == dto.Id).FirstOrDefault();
                    if (entity != null)
                    {
                        TaskItem taskEntity = _taskItemRepository.GetAll().Where(e => e.Id == entity.TaskItemId).FirstOrDefault();
                        if (!dto.IsFullControl && taskEntity.AssignBy != dto.ModifiedBy && entity.AssignTo != dto.ModifiedBy)
                        {
                            sendMessage = SendMessageResponse.CreateFailedResponse("AccessDenied");
                            return(sendMessage);
                        }
                        if (DateTime.TryParseExact(dto.ExtendDateText, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime extendDate))
                        {
                            dto.ExtendDate = extendDate;
                        }
                        else
                        {
                            dto.ExtendDate = null;
                        }
                        entity.AppraiseProcess = dto.AppraiseProcess;
                        entity.AppraiseStatus  = dto.AppraiseStatus;
                        entity.FinishedDate    = dto.FinishedDate;
                        entity.FromDate        = dto.FromDate;
                        entity.IsDeleted       = dto.IsDeleted;
                        entity.ModifiedDate    = dto.ModifiedDate;
                        entity.Problem         = dto.Problem;
                        entity.Solution        = dto.Solution;
                        entity.ToDate          = dto.ToDate;
                        if (entity.AssignTo == dto.ModifiedBy && !dto.IsAssignBy)
                        {
                            switch (dto.ActionText)
                            {
                            case "Process":
                                dto.TaskItemStatusId = TaskItemStatusId.InProcess;
                                dto.ActionId         = ActionId.Process;
                                entity.PercentFinish = dto.PercentFinish;
                                break;

                            case "Report":
                                if (taskEntity.IsReport == false)
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.Finished;
                                    dto.ActionId         = ActionId.Finish;
                                }
                                else
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.Report;
                                    dto.ActionId         = ActionId.Report;
                                }
                                entity.PercentFinish = dto.PercentFinish;
                                break;

                            case "Extend":
                                entity.IsExtend      = true;
                                entity.ExtendDate    = dto.ExtendDate;
                                dto.ActionId         = ActionId.Extend;
                                entity.PercentFinish = dto.PercentFinish;

                                break;

                            case "ReturnReport":
                                dto.TaskItemStatusId = TaskItemStatusId.ReportReturn;
                                dto.ActionId         = ActionId.Return;
                                break;

                            default:
                                break;
                            }
                            if (entity.TaskType != TaskType.Primary)
                            {
                                dto.TaskItemStatusId = TaskItemStatusId.Read;
                            }
                            entity.LastResult = dto.Description;
                            //entity.IsExtend = dto.IsExtend;
                            //entity.ExtendDate = dto.ExtendDate;
                        }
                        if (taskEntity.AssignBy == dto.ModifiedBy && dto.IsAssignBy)
                        {
                            switch (dto.ActionText)
                            {
                            case "Appraise":
                                dto.ActionId = ActionId.Appraise;

                                if (entity.TaskItemStatusId == TaskItemStatusId.Extend)
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.InProcess;
                                }
                                else if (entity.TaskItemStatusId == TaskItemStatusId.Report)
                                {
                                    dto.TaskItemStatusId         = TaskItemStatusId.Finished;
                                    entity.AppraisePercentFinish = dto.AppraisePercentFinish;
                                    entity.PercentFinish         = dto.AppraisePercentFinish;
                                    dto.ActionId = ActionId.Finish;
                                }
                                else if (entity.TaskItemStatusId == TaskItemStatusId.ReportReturn)
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.Cancel;
                                }
                                break;

                            case "Return":
                                dto.TaskItemStatusId         = TaskItemStatusId.InProcess;
                                entity.AppraisePercentFinish = dto.AppraisePercentFinish;
                                entity.PercentFinish         = dto.AppraisePercentFinish;
                                dto.ActionId = ActionId.Return;
                                break;

                            case "AppraiseExtend":
                                entity.ExtendDate = dto.ExtendDate;
                                taskEntity.ToDate = dto.ExtendDate;
                                entity.IsExtend   = false;
                                dto.ActionId      = ActionId.Appraise;
                                break;

                            case "ReturnExtend":
                                entity.ExtendDate = null;
                                entity.IsExtend   = false;
                                dto.ActionId      = ActionId.Return;
                                break;

                            default:
                                break;
                            }
                            entity.AppraiseResult = dto.Description;
                        }

                        entity.TaskItemStatusId = dto.TaskItemStatusId;
                        TaskItemProcessHistory taskAssignHistory = new TaskItemProcessHistory
                        {
                            Id               = Guid.NewGuid(),
                            ProjectId        = entity.ProjectId,
                            ActionId         = dto.ActionId,
                            CreatedBy        = dto.ModifiedBy,
                            PercentFinish    = entity.PercentFinish,
                            CreatedDate      = dto.ModifiedDate,
                            TaskItemId       = entity.TaskItemId,
                            TaskItemAssignId = entity.Id,
                            TaskItemStatusId = entity.TaskItemStatusId,
                            ProcessResult    = dto.Description
                        };
                        if (entity.TaskType == TaskType.Primary || dto.IsAssignBy)
                        {
                            //TaskItemProcessHistory taskHistory = new TaskItemProcessHistory
                            //{
                            //    Id = Guid.NewGuid(),
                            //    ProjectId = entity.ProjectId,
                            //    ActionId = dto.ActionId,
                            //    CreatedBy = dto.ModifiedBy,
                            //    PercentFinish = dto.PercentFinish,
                            //    CreatedDate = dto.ModifiedDate,
                            //    TaskItemId = entity.TaskItemId,
                            //    TaskItemStatusId = entity.TaskItemStatusId,
                            //    ProcessResult = dto.Description
                            //};
                            taskEntity.TaskItemStatusId = entity.TaskItemStatusId;
                            taskEntity.PercentFinish    = entity.PercentFinish;
                            //_taskItemProcessHistoryRepository.Add(taskHistory);
                        }

                        _objectRepository.Modify(entity);
                        //_taskItemRepository.Modify(taskEntity);
                        _taskItemProcessHistoryRepository.Add(taskAssignHistory);
                        foreach (AttachmentDto attachDto in attachmentDtos)
                        {
                            attachDto.ProjectId = entity.ProjectId;
                            attachDto.ItemId    = entity.Id;
                            Attachment attach = _mapper.Map <Attachment>(attachDto);
                            _attachmentRepository.Add(attach);
                        }
                        if (dto.AttachDelIds != null)
                        {
                            if (dto.AttachDelIds.Any())
                            {
                                List <Attachment> attachDels = _attachmentRepository.GetAll().Where(e => dto.AttachDelIds.Contains(e.Id)).ToList();
                                _attachmentRepository.DeleteRange(attachDels);
                            }
                        }
                        await scope.SaveChangesAsync();

                        var param = new List <SqlParameter>();
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.UniqueIdentifier,
                            ParameterName = "@ProjectId",
                            IsNullable    = false,
                            Value         = dto.ProjectId
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.UniqueIdentifier,
                            ParameterName = "@TaskId",
                            IsNullable    = false,
                            Value         = taskEntity.Id
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.DateTime,
                            ParameterName = "@FromDate",
                            IsNullable    = false,
                            Value         = taskEntity.FromDate
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.DateTime,
                            ParameterName = "@ToDate",
                            IsNullable    = false,
                            Value         = taskEntity.ToDate
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.Bit,
                            ParameterName = "@IsUpdateStatus",
                            IsNullable    = true,
                            Value         = 1
                        });
                        await _objectRepository.SqlQueryAsync(typeof(ProjectDto), "[dbo].[SP_UPDATE_TASK_RANGE_DATE] @ProjectId, @TaskId, @FromDate, @ToDate, @IsUpdateStatus", param.ToArray());
                    }
                }
                sendMessage = SendMessageResponse.CreateSuccessResponse(string.Empty);
                return(sendMessage);
            }
            catch (Exception ex)
            {
                _loggerServices.WriteError(ex.ToString());
                sendMessage = SendMessageResponse.CreateFailedResponse(string.Empty);
                return(sendMessage);
            }
        }