public UploadFileResponse UploadAttachFileToTemp(BLL.AttachFilesIAS.AttachFile attachFile, Stream fileStream) { String brokenRuleString = ThrowExceptionIfUploadInvalid(attachFile); if (!String.IsNullOrEmpty(brokenRuleString)) { throw new ApplicationException(brokenRuleString); } UploadFileResponse response = new UploadFileResponse(); using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient()) { String fs_container = String.Format(@"{0}\{1}", TempFileContainer, attachFile.REGISTRATION_ID); String filename = String.Format("{0}{1}", IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(), attachFile.EXTENSION); UploadFileResponse res = svc.UploadFile(new UploadFileRequest() { TargetContainer = fs_container, TargetFileName = filename, FileStream = fileStream }); return(res); //if (response.Code != "0000") // throw new IOException(response.Message); //attachFile.ATTACH_FILE_PATH = response.TargetFullName; } return(response); }
private String ThrowExceptionIfUploadInvalid(BLL.AttachFilesIAS.AttachFile attachFile) { StringBuilder brokenRules = new StringBuilder(); if (attachFile.GetBrokenRules().Count() > 0) { brokenRules.AppendLine(Resources.errorUploadDataBiz_002); foreach (BLL.BusinessRule bussinessRule in attachFile.GetBrokenRules()) { brokenRules.AppendLine(bussinessRule.Rule); } } return(brokenRules.ToString()); }