Beispiel #1
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
Beispiel #2
0
        }         // GetAgreementStatus

        private AgreementStatus?HandleSoapAgreementStatus(Esignature oSignature)
        {
            this.log.Msg("Loading document info for the key '{0}' started...", oSignature.DocumentKey);

            DocumentInfo oResult;

            try
            {
                oResult = this.echoSign.getDocumentInfo(this.apiKey, oSignature.DocumentKey);
            }
            catch (Exception e)
            {
                this.log.Warn(e, "Failed to load document info for the '{0}'.", oSignature.DocumentKey);
                return(null);
            } // try

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

            if (oResult.status.HasValue)
            {
                SignedDoc doc = GetDocuments(oSignature);

                oSignature.SetHistoryAndStatus(oResult.events, oResult.participants);

                if (doc.HasValue)
                {
                    var sp = new SpSaveSignedDocument(this.db, this.log)
                    {
                        EsignatureID    = oSignature.ID,
                        StatusID        = (int)oResult.status.Value,
                        DoSaveDoc       = doc.HasValue,
                        MimeType        = doc.MimeType,
                        DocumentContent = doc.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
                }
                else
                {
                    this.log.Debug(
                        "Nothing to save for the key '{0}': no documents received from EchoSign.",
                        oSignature.DocumentKey
                        );
                } // if
            }     // if

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

            return(oResult.status);
        }