Пример #1
0
        public IActionResult GetDocument(string filed_document_guid)
        {
            var    doc      = _FileDocumentService.Get(new Guid(filed_document_guid));
            var    owner    = _PersonnelService.Get(doc.PERSONNEL_OWNER);
            string filepath = Path.Combine(_HostingEnvironment.WebRootPath, "Templates\\" + doc.PDF_FILENAME);


            using (MemoryStream ms = new MemoryStream())
            {
                PDFStampTemplates.Stamp(filepath, ms, owner);
                return(new FileStreamResult(new MemoryStream(ms.ToArray()), "application/pdf"));
            }
        }
Пример #2
0
        public IActionResult RequestSignature(string id)
        {
            var doc   = _FileDocumentService.Get(new Guid(id));
            var owner = _PersonnelService.Get(doc.PERSONNEL_OWNER);

            string Username       = "******";
            string Password       = "******";
            string IntegrationKey = "a9d661a1-c751-40fa-9fc5-4b1a5865b08b";
            string filepath       = Path.Combine(_HostingEnvironment.WebRootPath, "Templates\\" + doc.PDF_FILENAME);

            string basePath = "https://demo.docusign.net/restapi";

            ApiClient apiClient = new ApiClient(basePath);

            Configuration.Default.ApiClient = apiClient;

            string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegrationKey + "\"}";

            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            AuthenticationApi authApi   = new AuthenticationApi();
            LoginInformation  loginInfo = authApi.Login();
            string            accountID = loginInfo.LoginAccounts[0].AccountId;
            MemoryStream      ms        = new MemoryStream();

            PDFStampTemplates.Stamp(filepath, ms, owner);
            byte[] fileBytes = ms.ToArray();
            ms.Dispose();
            EnvelopeDefinition enDef = new EnvelopeDefinition();

            enDef.EmailSubject = "[C# DocuSign Sig Request]";

            DocuSign.eSign.Model.Document document = new DocuSign.eSign.Model.Document();
            document.DocumentBase64 = Convert.ToBase64String(fileBytes);
            document.Name           = doc.DOCUMENT_NAME;
            document.DocumentId     = "1";

            enDef.Documents = new List <DocuSign.eSign.Model.Document>();
            enDef.Documents.Add(document);

            Signer signer = new Signer();

            signer.Email        = "*****@*****.**";
            signer.Name         = "Mitchell";
            signer.RecipientId  = "1";
            signer.ClientUserId = owner.PERSONNEL_ID.ToString();

            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List <SignHere>();
            SignHere signHere = new SignHere();

            signHere.DocumentId  = "1";
            signHere.PageNumber  = "1";
            signHere.RecipientId = "1";
            signHere.XPosition   = "300";
            signHere.YPosition   = "170";
            signer.Tabs.SignHereTabs.Add(signHere);

            enDef.Recipients         = new Recipients();
            enDef.Recipients.Signers = new List <Signer>();
            enDef.Recipients.Signers.Add(signer);
            enDef.Status = "sent";

            EnvelopesApi    envelopesApi    = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountID, enDef);

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = "https://localhost:44372/api/Signed/?id=" + doc.FILLED_DOCUMENT_GUID,
                ClientUserId         = doc.PERSONNEL_OWNER.ToString(),
                AuthenticationMethod = "email",
                UserName             = enDef.Recipients.Signers[0].Name,
                Email = enDef.Recipients.Signers[0].Email
            };
            ViewUrl recipientView = envelopesApi.CreateRecipientView(accountID, envelopeSummary.EnvelopeId, viewOptions);

            Console.WriteLine("ViewUrl:\n{0}", JsonConvert.SerializeObject(recipientView));

            //System.Diagnostics.Process.Start(recipientView.Url);

            return(Redirect(recipientView.Url));
        }