Пример #1
0
        private void UpdateAttachmentStatusByReinvenstmentType()
        {
            var isHide       = false;
            var typecodeList = new List <string>()
            {
                "ReinCost", "WriteOff"
            };
            var attachmentRequirementIds = AttachmentRequirement.Search(e => e.RefTableName == "MajorLeaseConsInfo" &&
                                                                        typecodeList.Contains(e.TypeCode)).Select(e => e.Id).ToList();
            var attachments = Attachment.Search(e => e.RequirementId.HasValue &&
                                                e.RefTableID == Id.ToString() &&
                                                attachmentRequirementIds.Contains(e.RequirementId.Value)).ToList();

            if (attachments.Any())
            {
                if (ReinvenstmentType.HasValue &&
                    ReinvenstmentType.Value == 2)
                {
                    isHide = true;
                }

                foreach (var attachment in attachments)
                {
                    attachment.IsHide = isHide;
                }

                Attachment.Update(attachments.ToArray());
            }
        }
Пример #2
0
        public static List <Attachment> GetAllAttachmentsIncludeRequire(string refTableName, string projectId, string flowCode, string refTableId = null)
        {
            if (string.IsNullOrEmpty(refTableId))
            {
                refTableId = GetRefTableId(refTableName, projectId);
            }
            //var userRole = ProjectUsers.Get(ClientCookie.UserCode, projectId);
            var attachments = Search(att => att.RefTableName == refTableName && att.RefTableID == refTableId && !att.IsHide).OrderBy(a => a.Sequence).ToList();

            attachments.ForEach(att =>
            {
                if (!string.IsNullOrEmpty(att.Name))
                {
                    att.RequireName = "其他附件";
                    att.FileName    = att.Name.EndsWith(att.Extension, StringComparison.CurrentCultureIgnoreCase) ? att.Name : (att.Name + att.Extension);
                }
            });
            var attachsReq = AttachmentRequirement.Search(ar => ar.FlowCode == flowCode).OrderBy(ar => ar.Sequence).AsNoTracking().ToList().Select(ar =>
            {
                Attachment att;
                if (ar.LinkTo != null && ar.LinkTo != Guid.Empty)
                {
                    var arLinkTo            = AttachmentRequirement.Get(ar.LinkTo.Value);
                    string linkToRefTableId = GetRefTableId(arLinkTo.RefTableName, projectId);
                    att = FirstOrDefault(at => at.RefTableID == linkToRefTableId && at.RefTableName == arLinkTo.RefTableName && at.RequirementId == arLinkTo.Id && !at.IsHide);
                }
                else
                {
                    att = attachments.FirstOrDefault(a => a.RequirementId == ar.Id);
                }
                if (att == null)
                {
                    att = new Attachment();
                    att.RequirementId = ar.Id;
                    att.RefTableName  = refTableName;
                }
                att.RequireName = ar.NameENUS;
                att.Required    = ar.Required;
                if (!string.IsNullOrEmpty(att.Name))
                {
                    att.FileName = att.Name.EndsWith(att.Extension, StringComparison.CurrentCultureIgnoreCase) ? att.Name : (att.Name + att.Extension);
                }
                return(att);
            }).ToList();
            var attachsOptional = attachments.Where(a => !a.RequirementId.HasValue).ToList();

            return(attachsReq.Union(attachsOptional).ToList());
        }