Beispiel #1
0
        /// <summary>
        /// Gets the agreement document.
        /// </summary>
        /// <param name="agreementId">The agreement identifier.</param>
        /// <returns></returns>
        public async Task <EchoSignAgreementDocumentResponse> GetAgreementDocument(string agreementId)
        {
            string path = string.Format("agreements/{0}/combinedDocument?attachSupportingDocuments=true", agreementId);

            string accessToken = await GetAccessToken();

            var httpClient = GetHttpClient(accessToken);

            httpClient.BaseAddress = baseRestUrl;

            byte[] file;

            using (var httpResponse = await httpClient.GetAsync(path)) {
                using (var content = httpResponse.Content) {
                    file = await content.ReadAsByteArrayAsync();
                }
            }

            EchoSignAgreementDocumentResponse response = new EchoSignAgreementDocumentResponse {
                Content  = file,
                MimeType = "application/pdf"
            };

            return(response);
        }
Beispiel #2
0
        private int HandleRestAgreementStatus(Esignature oSignature)
        {
            this.log.Msg("Loading document info for the key '{0}' started...", oSignature.DocumentKey);

            DocumentInfo oResult;
            int          agreementStatus = -1;

            EchoSignAgreementStatusResponse response;

            try {
                response        = this.restClient.GetAgreementStatus(oSignature.DocumentKey).Result;
                agreementStatus = (int)response.status;

                oResult = new DocumentInfo {
                    documentKey = response.agreementId,
                    name        = response.name,
                    message     = response.message,
                    expiration  = response.expiration ?? DateTime.MinValue,
                };
            } catch (Exception e) {
                this.log.Warn(e, "Failed to load document info for the '{0}'.", oSignature.DocumentKey);
                return(-1);
            }             // try

            this.log.Debug("Loading document info result:");
            this.log.Debug("Name: {0}", oResult.name);
            this.log.Debug("Status: {0}", response.status);
            this.log.Debug(
                "Expiration: {0}",
                oResult.expiration.ToString("MMMM d yyyy H:mm:ss", CultureInfo.InvariantCulture)
                );

            oSignature.SetHistoryAndStatus(response.events, response.participantSetInfos);

            EchoSignAgreementDocumentResponse docResponse = this.restClient.GetAgreementDocument(oSignature.DocumentKey).Result;

            var sp = new SpSaveSignedDocument(this.db, this.log)
            {
                EsignatureID    = oSignature.ID,
                StatusID        = agreementStatus,
                DoSaveDoc       = true,
                MimeType        = docResponse.MimeType,
                DocumentContent = docResponse.Content,
                SignerStatuses  = oSignature.SignerStatuses,
                HistoryEvents   = oSignature.HistoryEvents,
            };

            try
            {
                sp.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                this.log.Alert(e, "Failed to save signed document for the key '{0}'.", oSignature.DocumentKey);
            } // try

            this.log.Msg("Loading document info for the key '{0}' complete.", oSignature.DocumentKey);

            return(agreementStatus);
        }         // GetAgreementStatus