コード例 #1
0
        public DocuSignResponseModel GetDocument(DocuSignLog log, DocuSignAuthHeader authInformation, string serverPath, string host)
        {
            var docusignResponse = new DocuSignResponseModel();

            var loginInfo = GetLoginInfo(authInformation);

            EnvelopesApi envelopesApi = new EnvelopesApi();

            var document2 = envelopesApi.GetDocument(loginInfo.AccountId, log.EnvelopeID, log.DocumentID);

            var documentUrl = "/documents/signed/signedocument-" + Guid.NewGuid() + ".pdf";

            var filePath = serverPath + documentUrl;

            using (Stream file = File.Create(filePath))
            {
                FileHelpers.CopyStream(document2, file);
            }


            docusignResponse.DocumentUrl = host + "/" + documentUrl;

            docusignResponse.CaseID     = log.CaseID.ToString();
            docusignResponse.DocumentID = log.DocumentID;
            docusignResponse.EnvelopeID = log.EnvelopeID;

            return(docusignResponse);
        }
コード例 #2
0
        public ApiResponse <DocuSignResponseModel> GetDocument(int caseID, string serverPath, string host)
        {
            try
            {
                var docusignLog = repository.Query(r => r.CaseID == caseID).FirstOrDefault();

                if (docusignLog != null)
                {
                    var docusignManager = new DocuSignManager();

                    var authInformation = new DocuSignAuthHeader
                    {
                        Username      = settings.Docusign.UserName,
                        Password      = settings.Docusign.Password,
                        IntegratorKey = settings.Docusign.IntegratorKey
                    };

                    var responseModel = docusignManager.GetDocument(docusignLog, authInformation, serverPath, host);
                    return(new ApiResponse <DocuSignResponseModel>(responseModel));
                }
                throw new ArgumentException("No document found");
            }
            catch (Exception e)
            {
                return(HandleErrorAndReturnStatus <ApiResponse <DocuSignResponseModel> >(e));
            }
        }
コード例 #3
0
        public async Task <ApiResponse <DocuSignResponseModel> > SendDocument(DocumentSignModel model, string serverPath)
        {
            var docusignManager = new DocuSignManager();
            var confirmationUrl = appSettings.Get("docusign:ConfirmationUrl");

            var authInformation = new DocuSignAuthHeader
            {
                Username      = settings.Docusign.UserName,
                Password      = settings.Docusign.Password,
                IntegratorKey = settings.Docusign.IntegratorKey
            };

            var caseModel = caseRepository.Query(c => c.ID == model.CaseID).FirstOrDefault();

            var responseModel = docusignManager.SendDocument(model, caseModel, authInformation, serverPath, confirmationUrl);

            var docusignLog = new DocuSignLog
            {
                CaseID      = model.CaseID,
                DocumentID  = responseModel.DocumentID,
                EnvelopeID  = responseModel.EnvelopeID,
                CreatedDate = DateTime.Now
            };

            repository.Add(docusignLog);
            await repository.SaveChanges();

            return(new ApiResponse <DocuSignResponseModel>(responseModel));
        }
コード例 #4
0
        private LoginAccount GetLoginInfo(DocuSignAuthHeader headerOptions)
        {
            var basePath  = "https://demo.docusign.net/restapi";
            var apiClient = new ApiClient(basePath);

            Configuration.Default.ApiClient = apiClient;

            var authHeader = JsonConvert.SerializeObject(headerOptions);

            if (!Configuration.Default.DefaultHeader.ContainsKey("X-DocuSign-Authentication"))
            {
                Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            }

            var authApi         = new AuthenticationApi();
            var loginInfoResult = authApi.Login();
            var loginInfo       = loginInfoResult.LoginAccounts.First();

            return(loginInfo);
        }
コード例 #5
0
        public DocuSignResponseModel SendDocument(DocumentSignModel model, Case caseModel, DocuSignAuthHeader authInformation, string serverPath)
        {
            var docusignResponse = new DocuSignResponseModel();

            var loginInfo = GetLoginInfo(authInformation);

            var documentModel = SendDocumentAndGetUrl(model, caseModel, loginInfo, serverPath);

            docusignResponse.SignUrl    = documentModel.SignUrl;
            docusignResponse.CaseID     = model.CaseID.ToString();
            docusignResponse.DocumentID = documentModel.DocumentID;
            docusignResponse.EnvelopeID = documentModel.EnvelopeID;

            return(docusignResponse);
        }