コード例 #1
0
 /// <inheritdoc />
 public Task <SigningUrlResponse> GetAgreementSigningUrl(int?creditDataId, string agreementId)
 {
     using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"{_apiEndpointVer}/agreements/{agreementId}/signingUrls"))
     {
         try
         {
             var                responseMessage    = _client.SendAsync(requestMessage).Result;
             string             response           = responseMessage.Content.ReadAsStringAsync().Result;
             SigningUrlResponse signingUrlResponse = JsonConvert.DeserializeObject <SigningUrlResponse>(response);
             return(Task.FromResult(signingUrlResponse));
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
 }
コード例 #2
0
        public SigningDocumentResponse SendDocumentForSignature([FromUri] string filename, string creditDataId, string recipientEmail, string agreementName)
        {
            var httpRequest = HttpContext.Current.Request;
            var postedFile  = httpRequest.Files[0];

            var fileStream = postedFile.InputStream;

            byte[] fileByte;

            using (BinaryReader br = new BinaryReader(fileStream))
            {
                fileByte = br.ReadBytes((int)fileStream.Length);
            }

            int creditId = Convert.ToInt32(creditDataId);

            this.RefreshToken(creditId);
            var transientDocument          = this.PostDocument(creditId, filename, fileByte);
            var agreement                  = this.CreateAgreement(creditId, transientDocument.transientDocumentId, recipientEmail, agreementName);
            SigningUrlResponse signingUrls = new SigningUrlResponse();
            int interval        = 1500;  //1.5 sec
            var timeOutSettings = repository.GetKeyValue("RequestTimeout");
            int timeout         = 10000; // default 10 sec

            if (timeOutSettings != null)
            {
                timeout = Convert.ToInt32(timeOutSettings) * 1000;
            }


            int retries = 5;

            retries = timeout / interval;
            int i = 1;

            while (signingUrls.signingUrlSetInfos == null && i <= retries)
            {
                i++;
                signingUrls = this.GetSigningUrl(creditId, agreement.id);
                if (signingUrls.signingUrlSetInfos == null)
                {
                    Thread.Sleep(interval);
                }
            }

            var adobeSigningUrl = string.Empty;

            if (signingUrls.signingUrlSetInfos != null)
            {
                adobeSigningUrl = signingUrls.signingUrlSetInfos[0].signingUrls[0].esignUrl;
            }
            else
            {
                this.CancelAgreement(creditId, agreement.id);
            }

            return(new SigningDocumentResponse
            {
                agreementId = agreement.id,
                signingUrl = adobeSigningUrl
            });
        }