public void UploadAttachmentAsync(InMemoryMultipartFormDataStreamProvider dataStreamProvider, ResponseBase responseBase, int userID, string defaultPath) { ResponseBase submitIdeaAttachmentResponse = new ResponseBase(); RestAPIIdeaSupportingRequest ideaSupportingRequest = dataStreamProvider.restAPIIdeaSupportingRequest; ideaSupportingRequest.ideaAttachments.ToList().ForEach((ideaAttachment) => { ideaAttachment.IdeaId = ideaSupportingRequest.IdeaId; }); foreach (IdeaAttachmentRequest ideaAttachmentRequest in ideaSupportingRequest.ideaAttachments) { string inputFileName = ideaAttachmentRequest.AttachedFileName; string folderpath = UploadPath(ideaAttachmentRequest, ideaSupportingRequest.IdeaId); logger.Info($"Folder path={folderpath}"); string filepath = Path.Combine(folderpath, inputFileName); if (IsS3Enable) { UploadRequestToS3(folderpath, filepath, ideaAttachmentRequest.stream); } else { SaveAttachments(ideaAttachmentRequest.stream, inputFileName, folderpath); } } }
public SubmitIdeaAttachmentResponse SubmitIdeaAttachment(InMemoryMultipartFormDataStreamProvider provider, int UserID) { SubmitIdeaAttachmentResponse restAPISubmitIdeaResponse = new SubmitIdeaAttachmentResponse() { Status = Success }; RestAPIIdeaSupportingRequest IdeaSupportingRequest = provider.restAPIIdeaSupportingRequest; IdeaSupportingRequest.UserID = UserID; try { attachmentUtils.SubmitIdeaAttachment(restAPISubmitIdeaResponse, IdeaSupportingRequest, UserID); if (restAPISubmitIdeaResponse.ErrorList.Count != 0) { restAPISubmitIdeaResponse.Status = Failure; return(restAPISubmitIdeaResponse); } fileUtil.UploadAttachmentAsync(provider, restAPISubmitIdeaResponse, UserID, provider.DefaultPath); if (restAPISubmitIdeaResponse.ErrorList.Count != 0) { restAPISubmitIdeaResponse.Status = Failure; } } catch (Exception ex) { restAPISubmitIdeaResponse.Status = Failure; throw new Exception(ex.Message, ex); } return(restAPISubmitIdeaResponse); }
public RestAPIUpdateIntellectResponse UpdateIntellectual(InMemoryMultipartFormDataStreamProvider provider, int UserID) { RestAPIUpdateIntellectResponse updateIntellectualResponse = new RestAPIUpdateIntellectResponse() { Status = Success }; UpdateIntellectualRequest updateIntellectual = provider.UpdateIntellectualRequest; updateIntellectual.UserID = UserID; try { if (provider.attachFileCount != 0) { updateIntellectual.IsAttachment = true; updateIntellectual.AttachmentCount = provider.attachFileCount; } ideautils.UpdateIntellectProperty(updateIntellectualResponse, updateIntellectual); if (updateIntellectualResponse.ErrorList.Count != 0) { updateIntellectualResponse.Status = Failure; } if (provider.UpdateIntellectualRequest.files.Count == 0) { return(updateIntellectualResponse); } fileUtil.UploadIntellectualAttachmentAsync(updateIntellectualResponse, provider); if (updateIntellectualResponse.ErrorList.Count != 0) { updateIntellectualResponse.Status = Failure; } } catch (Exception ex) { updateIntellectualResponse.Status = Failure; throw new Exception(ex.Message, ex); } return(updateIntellectualResponse); }
public RestAPIAddIntellectualResponse SubmitIntellectual(InMemoryMultipartFormDataStreamProvider provider, int UserID) { RestAPIAddIntellectualResponse intellectualResponse = new RestAPIAddIntellectualResponse() { Status = Success }; SubmitIntellectualRequest submitIntellectual = provider.SubmitIntellectualrequest; submitIntellectual.UserID = UserID; try { if (provider.attachFileCount != 0) { submitIntellectual.IsAttachment = true; submitIntellectual.AttachmentCount = provider.attachFileCount; } ideautils.SubmitIdeaIntellectual(intellectualResponse, submitIntellectual); if (intellectualResponse.ErrorList.Count != 0) { intellectualResponse.Status = Failure; } if (provider.SubmitIntellectualrequest.files.Count == 0) { return(intellectualResponse); } fileUtil.UploadIntellectualAttachmentAsync(intellectualResponse, provider); if (intellectualResponse.ErrorList.Count != 0) { intellectualResponse.Status = Failure; } } catch (Exception ex) { intellectualResponse.Status = Failure; throw new Exception(ex.Message, ex); } return(intellectualResponse); }
public void UploadIntellectualAttachmentAsync(RestAPIAddIntellectualResponse IntellectualAttachmentResponse, InMemoryMultipartFormDataStreamProvider dataStreamProvider) { SubmitIntellectualRequest submitIntellectual = dataStreamProvider.SubmitIntellectualrequest; dataStreamProvider.SubmitIntellectualrequest.ideaAttachments.ToList().ForEach((ideaAttachment) => { ideaAttachment.IdeaId = submitIntellectual.IdeaId; }); foreach (IdeaAttachmentRequest ideaAttachmentRequest in submitIntellectual.ideaAttachments) { string inputFileName = ideaAttachmentRequest.AttachedFileName; string folderpath = UploadPath(ideaAttachmentRequest, submitIntellectual.IdeaId); string filepath = Path.Combine(folderpath, inputFileName); logger.Info($"IntellectualAttachmentResponse==Folder path={folderpath}"); if (IsS3Enable) { UploadRequestToS3(folderpath, filepath, ideaAttachmentRequest.stream); } else { SaveAttachments(ideaAttachmentRequest.stream, inputFileName, folderpath); } } }
public void UploadIntellectualAttachmentAsync(RestAPIUpdateIntellectResponse IntellectualAttachmentResponse, InMemoryMultipartFormDataStreamProvider dataStreamProvider) { IdeaIntellectualProperty intellectualProperty = null; UpdateIntellectualRequest updateIntellectual = dataStreamProvider.UpdateIntellectualRequest; dataStreamProvider.UpdateIntellectualRequest.ideaAttachments.ToList().ForEach((ideaAttachment) => { ideaAttachment.IdeaId = updateIntellectual.IdeaId; }); DatabaseWrapper.databaseOperation(response, (context, query) => { intellectualProperty = query.GetIdeaIntellectualById(context, updateIntellectual.IntellectualId); } , readOnly: true ); foreach (IdeaAttachmentRequest ideaAttachmentRequest in updateIntellectual.ideaAttachments) { string inputFileName = ideaAttachmentRequest.AttachedFileName; string folderpath = UploadPath(ideaAttachmentRequest, intellectualProperty.IdeaId); string filepath = Path.Combine(folderpath, inputFileName); logger.Info($"IntellectualAttachmentResponse==Folder path={folderpath}"); if (IsS3Enable) { UploadRequestToS3(folderpath, filepath, ideaAttachmentRequest.stream); } else { SaveAttachments(ideaAttachmentRequest.stream, inputFileName, folderpath); } } }