public string SendDocuSign <T>(T fileId, DocuSignData docuSignData, Dictionary <string, string> requestHeaders) { if (docuSignData == null) { throw new ArgumentNullException("docuSignData"); } var token = DocuSignToken.GetToken(); var account = GetDocuSignAccount(token); var configuration = GetConfiguration(account, token); var document = CreateDocument(fileId, docuSignData.Name, docuSignData.FolderId, out var sourceFile); var url = CreateEnvelope(account.AccountId, document, docuSignData, configuration); FilesMessageService.Send(sourceFile, requestHeaders, MessageAction.DocumentSendToSign, "DocuSign", sourceFile.Title); return(url); }
public static File SaveDocument(string envelopeId, string documentId, string documentName, object folderId) { if (string.IsNullOrEmpty(envelopeId)) { throw new ArgumentNullException("envelopeId"); } if (string.IsNullOrEmpty(documentId)) { throw new ArgumentNullException("documentId"); } var token = DocuSignToken.GetToken(); var account = GetDocuSignAccount(token); var configuration = GetConfiguration(account, token); using (var fileDao = Global.DaoFactory.GetFileDao()) using (var folderDao = Global.DaoFactory.GetFolderDao()) { if (string.IsNullOrEmpty(documentName)) { documentName = "new.pdf"; } Folder folder; if (folderId == null || (folder = folderDao.GetFolder(folderId)) == null || folder.RootFolderType == FolderType.TRASH || !Global.GetFilesSecurity().CanCreate(folder)) { if (Global.FolderMy != null) { folderId = Global.FolderMy; } else { throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create); } } var file = new File { FolderID = folderId, Comment = FilesCommonResource.CommentCreateByDocuSign, Title = FileUtility.ReplaceFileExtension(documentName, ".pdf"), }; var envelopesApi = new EnvelopesApi(configuration); Log.Info("DocuSign webhook get stream: " + documentId); using (var stream = envelopesApi.GetDocument(account.AccountId, envelopeId, documentId)) { file.ContentLength = stream.Length; file = fileDao.SaveFile(file, stream); } FilesMessageService.Send(file, MessageInitiator.ThirdPartyProvider, MessageAction.DocumentSignComplete, "DocuSign", file.Title); FileMarker.MarkAsNew(file); return(file); } }