public IActionResult OnGet(string id)
 {
     try
     {
         SignStorageObject = SignStorageObjectFinder.Find(id);
     }
     catch (Exception Error)
     {
         GeneralError = ErrorHelper.GetError(Error);
     }
     return(Page());
 }
 public FileResult OnGet(string id, string file)
 {
     try
     {
         SignStorageObject     signStorageObject     = SignStorageObjectFinder.Find(id);
         DocumentStorageObject documentStorageObject = getDocumentStorageObject(signStorageObject, file);
         var response = new FileContentResult(documentStorageObject.SignedDocument, "application/octet-stream")
         {
             FileDownloadName = documentStorageObject.FileName
         };
         return(response);
     }
     catch (Exception Error)
     {
         GeneralError = ErrorHelper.GetError(Error);
         return(null);
     }
 }
示例#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());
        }