Beispiel #1
0
 internal void ConvertEntity(Lib.Model.Attachment finder)
 {
     this.BusinessID      = finder.BusinessID;
     this.BusinessType    = finder.BusinessType;
     this.CreateDate      = finder.CreateDate;
     this.CreateLoginName = finder.CreatorLoginName;
     this.CreateName      = finder.CreatorName;
     this.FileCode        = finder.AttachmentPath;
     this.FileName        = finder.Name;
     this.FileSize        = finder.FileSize;
     this.Name            = finder.FileName;
     this.IsUseV1         = finder.IsUseV1;
     this.ID = Guid.Parse(finder.ID);
 }
Beispiel #2
0
        /// <summary>
        /// 通用上传文件方法
        /// </summary>
        /// <param name="businessId"></param>
        /// <param name="action"></param>
        /// <param name="fileName"></param>
        /// <param name="fileStream"></param>
        /// <returns></returns>
        public Lib.Model.Attachment CommonUpload(string businessId, string action, string fileName, Stream fileStream)
        {
            fileStream.Seek(0, SeekOrigin.Begin);
            var userInfo   = WebHelper.GetCurrentUser();;
            var fileCode   = FileUploadHelper.UploadFile(fileStream, fileName);
            var attachment = new Lib.Model.Attachment();

            attachment.ID                = Guid.NewGuid().ToString();
            attachment.Name              = fileName;
            attachment.AttachmentPath    = fileCode;
            attachment.BusinessID        = businessId;
            attachment.BusinessType      = action;
            attachment.IsUseV1           = false;
            attachment.CreateDate        = DateTime.Now;
            attachment.CreatorLoginName  = userInfo.LoginName;
            attachment.CreatorName       = userInfo.CNName;
            attachment.IsDeleted         = false;
            attachment.ModifierLoginName = userInfo.LoginName;
            attachment.ModifierName      = userInfo.CNName;
            attachment.ModifyTime        = DateTime.Now;
            attachment.FileSize          = FileUploadHelper.GetContentLength(fileStream.Length);
            return(attachment);
        }