public DocumentInfo CreateDocument(CreateDocumentInput input, Stream stream) { var documentInfo = Mapper.Map <DocumentInfo>(input); StoreDocumentFile(documentInfo, stream); HandleTifFile(documentInfo.FileType, documentInfo.Path); documentInfo.Key = Guid.NewGuid().ToString(); documentInfo.CreateTime = DateTime.Now; documentInfo.ModifyTime = documentInfo.CreateTime; documentInfo.ModifyUserId = documentInfo.CreateUserID; documentInfo.ModifyUserName = documentInfo.CreateUserName; documentInfo.CurrentVersion = 1; _context.DocumentInfos.Add(documentInfo); _context.SaveChanges(); var historyPath = StoreHistoryFile(stream, documentInfo.FileType); DocumentHistory fileHistory = new DocumentHistory { DocumentInfoId = documentInfo.Id, Version = 1, PreviousVersion = -1, Key = documentInfo.Key, Path = historyPath, UserId = input.CreateUserID, UserName = input.CreateUserName, CreateTime = DateTime.Now }; _context.DocumentHistories.Add(fileHistory); _context.SaveChanges(); return(documentInfo); }
public int ExternalSaveFile(ExternalSaveFileInput input) { CreateDocumentInput createDocumentInput = Mapper.Map <CreateDocumentInput>(input); createDocumentInput.ExternalFlag = true; DocumentInfo info = documentService.CreateDocument(createDocumentInput, input.ExternalFilePath); return(info.Id); }
public DocumentInfo CreateDocument(CreateDocumentInput input, string url) { var req = WebRequest.CreateHttp(url); string authCookie = HttpContext.Current.Session["YFMIS3"] != null ? HttpContext.Current.Session["YFMIS3"].ToString() : ""; req.Headers.Add(HttpRequestHeader.Cookie, "YFMIS3=" + authCookie); var stream = req.GetResponse().GetResponseStream(); var documentInfo = CreateDocument(input, stream); stream.Close(); return(documentInfo); }
public int UploadDesignVolumeProduct(UploadDesignVolumeProductInput input, Stream stream) { CreateDocumentInput createDocumentInput = new CreateDocumentInput { CreateUserID = input.UserID, CreateUserName = input.UserName, FileName = input.FileName, FileType = input.FileType, ExternalFlag = true }; var documentInfo = documentService.CreateDocument(createDocumentInput, stream); return(documentInfo.Id); }
public ShareLinkItem createBookmarkAsDocument(Uri link, String title, String description, List <String> spaceKeys, Bitmap icon) { try { DocumentApi documentApi = new DocumentApi(session.GetApiClient()); LinkV2Record linkRecord = new LinkV2Record(); linkRecord.Link = link.ToString(); linkRecord.Title = title; linkRecord.Text = description; linkRecord.Type = "link"; CreateDocumentInput createDocumentInput = new CreateDocumentInput(linkRecord); CreateDocumentResult createDocumentResult = documentApi.CreateDocument(createDocumentInput); if (createDocumentResult.Hdr.Rc == 0) { DocumentV2Record createdDocument = createDocumentResult.Document; LinkV2Record createdLink = null; if (spaceKeys != null) { SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(createdDocument.Key, shareInput); if (shareResult.Hdr.Rc == 0) { LinkApi linkApi = new LinkApi(session.GetApiClient()); GetLinkResult getLinkResult = linkApi.GetLink(createdDocument.Key); if (getLinkResult.Hdr.Rc == 0) { createdLink = getLinkResult.Link; } else { throw new Exception("Vmoso error getting created link. Rc=" + getLinkResult.Hdr.Rc); } } else { throw new Exception("Vmoso error sharing link. Rc=" + shareResult.Hdr.Rc); } } ShareLinkItem item = new ShareLinkItem(createdLink.Title, createdLink.Text); item.Key = createdLink.Key; item.Link = new Uri(createdLink.Link); item.Record = createdLink; item.SetIcon(icon); List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in createdLink.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } else { throw new Exception("Vmoso error creating link. Rc=" + createDocumentResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Vmoso error creating link", ex); } }
/// <summary> /// create document /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="input">CreateDocument Input</param> /// <returns>Task of ApiResponse (CreateDocumentResult)</returns> public async System.Threading.Tasks.Task <ApiResponse <CreateDocumentResult> > CreateDocumentAsyncWithHttpInfo(CreateDocumentInput input) { // verify the required parameter 'input' is set if (input == null) { throw new ApiException(400, "Missing required parameter 'input' when calling DocumentApi->CreateDocument"); } var localVarPath = "/documentsV2"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (input != null && input.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(input); // http body (model) parameter } else { localVarPostBody = input; // byte array } // authentication (vmoso_auth) required if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("X-CV-Authorization"))) { localVarHeaderParams["X-CV-Authorization"] = Configuration.GetApiKeyWithPrefix("X-CV-Authorization"); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateDocument", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <CreateDocumentResult>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (CreateDocumentResult)Configuration.ApiClient.Deserialize(localVarResponse, typeof(CreateDocumentResult)))); }
/// <summary> /// create document /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="input">CreateDocument Input</param> /// <returns>Task of CreateDocumentResult</returns> public async System.Threading.Tasks.Task <CreateDocumentResult> CreateDocumentAsync(CreateDocumentInput input) { ApiResponse <CreateDocumentResult> localVarResponse = await CreateDocumentAsyncWithHttpInfo(input); return(localVarResponse.Data); }
/// <summary> /// create document /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="input">CreateDocument Input</param> /// <returns>CreateDocumentResult</returns> public CreateDocumentResult CreateDocument(CreateDocumentInput input) { ApiResponse <CreateDocumentResult> localVarResponse = CreateDocumentWithHttpInfo(input); return(localVarResponse.Data); }
public int Upload(UploadInput input) { var userId = HttpContext.Current.Session["UserID"].ToString(); var userName = HttpContext.Current.Session["UserName"].ToString(); UserDto userDto = new UserDto { UserID = userId, UserName = userName }; userService.SaveUser(userDto); PersonalFile personalFile = _context.PersonalFiles.FirstOrDefault(a => a.Id == input.Id); DocumentInfo documentInfo = null; CreateDocumentInput createDocumentInput = new CreateDocumentInput { CreateUserID = userId, CreateUserName = userName, FileName = input.FileName + "." + input.FileType, FileType = input.FileType }; //新建文件 if (input.CreateType == CreateType.newFile.ToString() && (personalFile == null || input.FileType != personalFile.FileType)) { MemoryStream stream = new MemoryStream(); if (input.FileType == FileType.xlsx.ToString()) { stream = new MemoryStream(NPOIHelper.CreateExcelFile()); } documentInfo = documentService.CreateDocument(createDocumentInput, stream); } else if (input.CreateType == CreateType.uploadFile.ToString() && (personalFile == null || HttpContext.Current.Request.Files.Count > 0)) { if (HttpContext.Current.Request.Files.Count == 0) { return(-1); } var uploadFile = HttpContext.Current.Request.Files[0]; createDocumentInput.FileName = uploadFile.FileName; createDocumentInput.FileType = createDocumentInput.FileName.Substring(createDocumentInput.FileName.LastIndexOf('.') + 1); input.FileName = createDocumentInput.FileName.Substring(0, createDocumentInput.FileName.LastIndexOf('.')); if (createDocumentInput.FileType == FileType.doc.ToString() || createDocumentInput.FileType == FileType.docx.ToString()) { input.FileType = FileType.docx.ToString(); } else { input.FileType = FileType.xlsx.ToString(); } documentInfo = documentService.CreateDocument(createDocumentInput, uploadFile.InputStream); } if (personalFile == null) { var createTime = DateTime.Now; personalFile = new PersonalFile { DocumentID = documentInfo.Id, CreateType = input.CreateType, FileName = input.FileName, FileType = input.FileType, CreateUserID = userId, CreateUserName = userName, CreateTime = createTime, ModifyUserID = userId, ModifyUserName = userName, ModifyTime = createTime }; _context.PersonalFiles.Add(personalFile); } else { //personalFile.CreateType = input.CreateType; personalFile.FileName = input.FileName; //personalFile.FileType = input.FileType; documentInfo = _context.DocumentInfos.FirstOrDefault(a => a.Id == personalFile.DocumentID); documentInfo.FileName = input.FileName + "." + personalFile.FileType; } _context.SaveChanges(); var shareUserList = JsonConvert.DeserializeObject <List <FileUserDto> >(input.ShareUserList); fileShareService.AddShareUser(new AddShareUserInput { FileId = personalFile.Id, FileUserDtos = shareUserList }); return(personalFile.Id); }