public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                try
                {
                    List <MultipartUploadMedia> UploadMedias = GetMultipartUploadMedias();
                    if (ModelState.IsValid)
                    {
                        List <TbsData> TbsDatas = await GetTbsDataAsync <List <TbsData> >(UploadMedias);

                        SignRequestGenerationResponse = await GetSignRequestAsync <SignRequestGenerationResponse>(TbsDatas);

                        // Save new sign-request in database
                        List <DocumentStorageObject> DocumentStorageObjects = DocumentStorageObjectFactory.Create(UploadMedias);
                        SignStorageObject            SignStorageObject      = SignStorageObjectFactory.Create(DocumentStorageObjects, TbsDatas, SignRequestGenerationResponse);
                        SignSupportDatabase.Upsert(SignStorageObject);
                    }
                }
                catch (SignSupportException Error)
                {
                    SignSupportError = Error.SignSupportError;
                }
                catch (Exception Error)
                {
                    GeneralError = ErrorHelper.GetError(Error);
                }
            }
            return(Page());
        }
Exemplo n.º 2
0
 internal static Exception GetSignSupportErrorException(HttpResponseMessage response, byte[] responseBody)
 {
     Console.WriteLine("Response error: {0}", Encoding.UTF8.GetString(responseBody));
     try
     {
         SignSupportError Error = JsonUtil.JsonDeserialize <SignSupportError>(responseBody);
         throw new SignSupportException(Error);
     }
     catch (JsonReaderException e)
     {
         throw new Exception("Error status " + (int)response.StatusCode
                             + " from " + response.RequestMessage.RequestUri.OriginalString, e);
     }
 }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                GeneralError = ErrorHelper.GetError("Failed to complete signing, invalid response!");
                return(Page());
            }
            try
            {
                SignStorageObject     SignStorageObject     = SignStorageObjectFinder.Find(SignResponseData.RelayState);
                SignCompletionRequest SignCompletionRequest = CreateSignCompletionRequest(SignStorageObject);
                string RequestJson = Encoding.UTF8.GetString(JsonUtil.JsonSerialize <SignCompletionRequest>(SignCompletionRequest));

                // Perform complete-signing request for each document
                foreach (var DocumentStorageObject in SignStorageObject.Documents)
                {
                    byte[] OriginalDocument          = DocumentStorageObject.OriginalDocument;
                    MultipartUploadMedia UploadMedia = new MultipartUploadMedia(OriginalDocument, "document", DocumentStorageObject.FileName);
                    byte[] SignedDocumentBytes       = await CompleteDocumentSignatureAsync(UploadMedia, RequestJson);

                    DocumentStorageObject.SignedDocument = SignedDocumentBytes;
                }
                // Store signed documents in database
                SignSupportDatabase.Upsert(SignStorageObject);
                return(Redirect("~/SignResult?id=" + SignResponseData.RelayState));
            }
            catch (SignSupportException Error)
            {
                SignSupportError = Error.SignSupportError;
            }
            catch (Exception Error)
            {
                GeneralError = ErrorHelper.GetError(Error);
            }
            return(Page());
        }
Exemplo n.º 4
0
 public SignSupportException(SignSupportError signSupportError)
 {
     this.SignSupportError = signSupportError;
 }