public virtual ReturnInfo <bool> Upload(IList <AttachmentInfo> attachments, IList <Stream> streams, BasicUserInfo currUser = null) { ReturnInfo <bool> re = new ReturnInfo <bool>(); AttachmentStreamInfo[] attachmentStreams = new AttachmentStreamInfo[attachments.Count]; for (var i = 0; i < attachments.Count; i++) { attachments[i].FileSize = Convert.ToSingle(streams[i].Length / 1024.00); ValiFile(attachments[i], re); if (re.Failure()) { return(re); } attachmentStreams[i] = new AttachmentStreamInfo() { FileName = attachments[i].FileName, Stream = streams[i] }; } ReturnInfo <IList <string> > returnInfo = AttachmentUploadStore.Upload(currUser, attachmentStreams); if (returnInfo.Failure()) { ReturnInfo <bool> result = new ReturnInfo <bool>(); result.FromBasic(returnInfo); return(result); } for (var i = 0; i < returnInfo.Data.Count; i++) { attachments[i].FileAddress = returnInfo.Data[i]; attachments[i].ExpandName = attachments[i].FileName.FileExpandName(); } return(Add(attachments, currUser: currUser)); }
public virtual ReturnInfo <bool> Upload([DisplayName2("附件"), Model] AttachmentInfo attachment, Stream stream, BasicUserInfo currUser = null) { AttachmentStreamInfo attachmentStream = new AttachmentStreamInfo() { FileName = attachment.FileName, Stream = stream }; ReturnInfo <IList <string> > returnInfo = AttachmentUploadStore.Upload(currUser, attachmentStream); if (returnInfo.Failure()) { ReturnInfo <bool> result = new ReturnInfo <bool>(); result.FromBasic(returnInfo); return(result); } attachment.FileAddress = returnInfo.Data[0]; attachment.ExpandName = attachment.FileName.FileExpandName(); attachment.FileSize = Convert.ToSingle(stream.Length / 1024.00); return(Add(attachment, currUser: currUser)); }