Example #1
0
        public ActionResult SendSignatureRequest()
        {
            string ds_signer1_name  = WebhookLibrary.GetFakeName();
            string ds_signer1_email = WebhookLibrary.GetFakeEmail(ds_signer1_name);
            string ds_cc1_name      = WebhookLibrary.GetFakeName();
            string ds_cc1_email     = WebhookLibrary.GetFakeEmail(ds_cc1_name);
            string webhook_url      = Request.Url.GetLeftPart(UriPartial.Authority) + "/api/Webhook";

            if (WebhookLibrary.AccountId == null)
            {
                return(Content("[\"ok\" => false, \"html\" => \"<h3>Problem</h3><p>Couldn't login to DocuSign: \"]"));
            }

            // The envelope request includes a signer-recipient and their tabs object,
            // and an eventNotification object which sets the parameters for
            // webhook notifications to us from the DocuSign platform
            List <EnvelopeEvent> envelope_events = new List <EnvelopeEvent>();

            EnvelopeEvent envelope_event1 = new EnvelopeEvent();

            envelope_event1.EnvelopeEventStatusCode = "sent";
            envelope_events.Add(envelope_event1);
            EnvelopeEvent envelope_event3 = new EnvelopeEvent();

            envelope_event3.EnvelopeEventStatusCode = "completed";
            envelope_events.Add(envelope_event3);
            EnvelopeEvent envelope_event4 = new EnvelopeEvent();

            envelope_event4.EnvelopeEventStatusCode = "declined";
            envelope_events.Add(envelope_event4);
            EnvelopeEvent envelope_event5 = new EnvelopeEvent();

            envelope_event5.EnvelopeEventStatusCode = "voided";
            envelope_events.Add(envelope_event5);

            List <RecipientEvent> recipient_events = new List <RecipientEvent>();
            RecipientEvent        recipient_event2 = new RecipientEvent();

            recipient_event2.RecipientEventStatusCode = "Delivered";
            recipient_events.Add(recipient_event2);
            RecipientEvent recipient_event3 = new RecipientEvent();

            recipient_event3.RecipientEventStatusCode = "Completed";
            recipient_events.Add(recipient_event3);
            RecipientEvent recipient_event4 = new RecipientEvent();

            recipient_event4.RecipientEventStatusCode = "Declined";
            recipient_events.Add(recipient_event4);

            EventNotification event_notification = new EventNotification();

            event_notification.Url                               = webhook_url;
            event_notification.LoggingEnabled                    = "true";
            event_notification.RequireAcknowledgment             = "true";
            event_notification.UseSoapInterface                  = "false";
            event_notification.IncludeCertificateWithSoap        = "false";
            event_notification.SignMessageWithX509Cert           = "false";
            event_notification.IncludeDocuments                  = "true";
            event_notification.IncludeEnvelopeVoidReason         = "true";
            event_notification.IncludeTimeZone                   = "true";
            event_notification.IncludeSenderAccountAsCustomField = "false";
            event_notification.IncludeDocumentFields             = "true";
            event_notification.IncludeCertificateOfCompletion    = "false";
            event_notification.EnvelopeEvents                    = envelope_events;
            event_notification.RecipientEvents                   = recipient_events;

            Document document = new Document();

            document.DocumentId = "1";
            document.Name       = "NDA.pdf";

            //string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Documents\NDA.pdf");
            Byte[] bytes = System.IO.File.ReadAllBytes(Server.MapPath("~/Documents/NDA.pdf"));
            document.DocumentBase64 = Convert.ToBase64String(bytes);

            SignHere sign_here_tab = new SignHere();

            sign_here_tab.AnchorString  = "signer1sig";
            sign_here_tab.AnchorXOffset = "0";
            sign_here_tab.AnchorYOffset = "0";
            sign_here_tab.AnchorUnits   = "mms";
            sign_here_tab.RecipientId   = "1";
            sign_here_tab.Name          = "Please sign here";
            sign_here_tab.Optional      = "false";
            sign_here_tab.ScaleValue    = 1;
            sign_here_tab.TabLabel      = "signer1sig";

            FullName full_name_tab = new FullName();

            full_name_tab.AnchorString  = "signer1name";
            full_name_tab.AnchorYOffset = "-6";
            full_name_tab.FontSize      = "Size12";
            full_name_tab.RecipientId   = "1";
            full_name_tab.TabLabel      = "Full Name";
            full_name_tab.Name          = "Full Name";

            DocuSign.eSign.Model.Text text_tab = new DocuSign.eSign.Model.Text();
            text_tab.AnchorString  = "signer1company";
            text_tab.AnchorYOffset = "-8";
            text_tab.FontSize      = "Size12";
            text_tab.RecipientId   = "1";
            text_tab.TabLabel      = "Company";
            text_tab.Name          = "Company";
            text_tab.Required      = "false";

            DateSigned date_signed_tab = new DateSigned();

            date_signed_tab.AnchorString  = "signer1date";
            date_signed_tab.AnchorYOffset = "-6";
            date_signed_tab.FontSize      = "Size12";
            date_signed_tab.RecipientId   = "1";
            date_signed_tab.Name          = "Date Signed";
            date_signed_tab.TabLabel      = "Company";

            DocuSign.eSign.Model.Tabs tabs = new DocuSign.eSign.Model.Tabs();
            tabs.SignHereTabs = new List <SignHere>();
            tabs.SignHereTabs.Add(sign_here_tab);
            tabs.FullNameTabs = new List <FullName>();
            tabs.FullNameTabs.Add(full_name_tab);
            tabs.TextTabs = new List <Text>();
            tabs.TextTabs.Add(text_tab);
            tabs.DateSignedTabs = new List <DateSigned>();
            tabs.DateSignedTabs.Add(date_signed_tab);

            Signer signer = new Signer();

            signer.Email        = ds_signer1_email;
            signer.Name         = ds_signer1_name;
            signer.RecipientId  = "1";
            signer.RoutingOrder = "1";
            signer.Tabs         = tabs;

            Signer signer2 = new Signer();

            signer2.Email        = "*****@*****.**";
            signer2.Name         = "Mario Beko";
            signer2.RecipientId  = "3";
            signer2.RoutingOrder = "1";

            CarbonCopy carbon_copy = new CarbonCopy();

            carbon_copy.Email        = ds_cc1_email;
            carbon_copy.Name         = ds_cc1_name;
            carbon_copy.RecipientId  = "2";
            carbon_copy.RoutingOrder = "2";

            Recipients recipients = new Recipients();

            recipients.Signers = new List <Signer>();
            recipients.Signers.Add(signer);
            recipients.Signers.Add(signer2);
            recipients.CarbonCopies = new List <CarbonCopy>();
            recipients.CarbonCopies.Add(carbon_copy);

            EnvelopeDefinition envelope_definition = new EnvelopeDefinition();

            envelope_definition.EmailSubject = "Please sign the " + "NDA.pdf" + " document.URL:" + webhook_url;
            envelope_definition.Documents    = new List <Document>();
            envelope_definition.Documents.Add(document);
            envelope_definition.Recipients        = recipients;
            envelope_definition.EventNotification = event_notification;
            envelope_definition.Status            = "sent";

            EnvelopesApi envelopesApi = new EnvelopesApi(WebhookLibrary.Configuration);

            EnvelopeSummary envelope_summary = envelopesApi.CreateEnvelope(WebhookLibrary.AccountId, envelope_definition, null);

            if (envelope_summary == null || envelope_summary.EnvelopeId == null)
            {
                return(Content("[\"ok\" => false, html => \"<h3>Problem</h3>\" \"<p>Error calling DocuSign</p>\"]"));
            }

            string envelope_id = envelope_summary.EnvelopeId;

            // Create instructions for reading the email
            string html = "<h2>Signature request sent!</h2>" +
                          "<p>Envelope ID: " + envelope_id + "</p>" +
                          "<h2>Next steps</h2>" +
                          "<h3>1. Open the Webhook Event Viewer</h3>" +
                          "<p><a href='" + Request.Url.GetLeftPart(UriPartial.Authority) + "/Webhook010/status?envelope_id=" + envelope_id + "'" +
                          "  class='btn btn-primary' role='button' target='_blank' style='margin-right:1.5em;'>" +
                          "View Events</a> (A new tab/window will be used.)</p>" +
                          "<h3>2. Respond to the Signature Request</h3>";

            string email_access = WebhookLibrary.GetFakeEmailAccess(ds_signer1_email);

            if (email_access != null)
            {
                // A temp account was used for the email
                html += "<p>Respond to the request via your mobile phone by using the QR code: </p>" +
                        "<p>" + WebhookLibrary.GetFakeEmailAccessQRCode(email_access) + "</p>" +
                        "<p> or via <a target='_blank' href='" + email_access + "'>your web browser.</a></p>";
            }
            else
            {
                // A regular email account was used
                html += "<p>Respond to the request via your mobile phone or other mail tool.</p>" +
                        "<p>The email was sent to " + ds_signer1_name + " &lt;" + ds_signer1_email + "&gt;</p>";
            }

            //return Content("['ok'  => true,'envelope_id' => "+envelope_id+",'html' => "+ html+",'js' => [['disable_button' => 'sendbtn']]]");  // js is an array of items
            return(Content(html));
        }
Example #2
0
        public async Task <Boolean> sendRequestSign(string signerName, string signerEmail, string accountId, string returnUrl, string authHeader, Dictionary <string, SymitarVars> symitarVars, string fileName)
        {
            List <EnvelopeEvent> envelope_events = new List <EnvelopeEvent>();

            EnvelopeEvent envelope_event1 = new EnvelopeEvent();

            envelope_event1.EnvelopeEventStatusCode = "sent";
            envelope_events.Add(envelope_event1);
            EnvelopeEvent envelope_event2 = new EnvelopeEvent();

            envelope_event2.EnvelopeEventStatusCode = "delivered";
            envelope_events.Add(envelope_event2);
            EnvelopeEvent envelope_event3 = new EnvelopeEvent();

            envelope_event3.EnvelopeEventStatusCode = "completed";

            List <RecipientEvent> recipient_events = new List <RecipientEvent>();
            RecipientEvent        recipient_event1 = new RecipientEvent();

            recipient_event1.RecipientEventStatusCode = "Sent";
            recipient_events.Add(recipient_event1);
            RecipientEvent recipient_event2 = new RecipientEvent();

            recipient_event2.RecipientEventStatusCode = "Delivered";
            recipient_events.Add(recipient_event2);
            RecipientEvent recipient_event3 = new RecipientEvent();

            recipient_event3.RecipientEventStatusCode = "Completed";

            EventNotification event_notification = new EventNotification();

            event_notification.Url                               = returnUrl;
            event_notification.LoggingEnabled                    = "true";
            event_notification.RequireAcknowledgment             = "true";
            event_notification.UseSoapInterface                  = "false";
            event_notification.IncludeCertificateWithSoap        = "false";
            event_notification.SignMessageWithX509Cert           = "false";
            event_notification.IncludeDocuments                  = "true";
            event_notification.IncludeEnvelopeVoidReason         = "true";
            event_notification.IncludeTimeZone                   = "true";
            event_notification.IncludeSenderAccountAsCustomField = "true";
            event_notification.IncludeDocumentFields             = "true";
            event_notification.IncludeCertificateOfCompletion    = "true";
            event_notification.EnvelopeEvents                    = envelope_events;
            event_notification.RecipientEvents                   = recipient_events;


            Tabs tabs = new Tabs();

            tabs.TextTabs       = new List <Text>();
            tabs.SignHereTabs   = new List <SignHere>();
            tabs.DateSignedTabs = new List <DateSigned>();
            int index = 1;

            foreach (KeyValuePair <string, SymitarVars> data in symitarVars)
            {
                System.Console.WriteLine(data.Value.FieldLabel);
                System.Console.WriteLine(data.Value.FieldValue);
                if (data.Value.FieldType.ToUpper() != "SETTING" && (data.Value.FieldType != "DocuSignField" || (data.Value.FieldType == "DocuSignField" && !String.IsNullOrWhiteSpace(data.Value.FieldValue))))
                {
                    switch (data.Value.FieldType)
                    {
                    case "DocuSignField":
                        Text text_tab = new Text();
                        text_tab.AnchorString  = "/*" + data.Value.FieldLabel + "*/";
                        text_tab.AnchorYOffset = "-8";
                        text_tab.AnchorXOffset = "0";
                        text_tab.RecipientId   = string.Concat("", index);
                        text_tab.TabLabel      = data.Value.FieldLabel;
                        text_tab.Name          = data.Value.FieldValue;
                        text_tab.Value         = data.Value.FieldValue;
                        // text_tab.Required = data.Value.Required;

                        tabs.TextTabs.Add(text_tab);
                        break;

                    case "SignatureField":
                        SignHere sign_here_tab = new SignHere();
                        sign_here_tab.AnchorString  = "/*" + data.Value.FieldLabel + "*/";
                        sign_here_tab.AnchorXOffset = "0";
                        sign_here_tab.AnchorYOffset = "0";
                        sign_here_tab.Name          = "";
                        sign_here_tab.Optional      = data.Value.Required;
                        sign_here_tab.ScaleValue    = "1";
                        sign_here_tab.TabLabel      = data.Value.FieldLabel;

                        tabs.SignHereTabs.Add(sign_here_tab);
                        break;

                    case "DateSigned":
                        DateSigned date_signed_tab = new DateSigned();
                        date_signed_tab.AnchorString  = "/*" + data.Value.FieldLabel + "*/";
                        date_signed_tab.AnchorYOffset = "-6";
                        date_signed_tab.RecipientId   = string.Concat("", index);
                        date_signed_tab.Name          = "";
                        date_signed_tab.TabLabel      = data.Value.FieldLabel;
                        // date_signed_tab.Required = data.Value.Required;

                        tabs.DateSignedTabs.Add(date_signed_tab);
                        break;

                    default:
                        break;
                        index++;
                    }
                }
            }

            Signer signer = new Signer();

            signer.Email        = signerEmail;
            signer.Name         = signerName;
            signer.RecipientId  = "1";
            signer.RoutingOrder = "1";
            signer.Tabs         = tabs;


            Task <Stream> getS3PDF = S3Data.ReadS3PDF("eSignature/PDFTemplate/" + fileName + ".pdf");
            Stream        newPdf   = await getS3PDF;
            var           bytes    = S3Data.ReadByteStream(newPdf);

            Document document = new Document();

            document.DocumentId = "1";
            document.Name       = fileName;

            // byte[] buffer = System.IO.File.ReadAllBytes("AUTOPYMT2.pdf");
            document.DocumentBase64 = Convert.ToBase64String(bytes);

            Recipients recipients = new Recipients();

            recipients.Signers = new List <Signer>();
            recipients.Signers.Add(signer);

            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();

            envelopeDefinition.EmailSubject = "Please sign the " + "AUTOPYMT.pdf" + " document";
            envelopeDefinition.Documents    = new List <Document>();
            envelopeDefinition.Documents.Add(document);
            envelopeDefinition.Recipients        = recipients;
            envelopeDefinition.EventNotification = event_notification;
            envelopeDefinition.Status            = "sent";

            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);

            EnvelopeSummary envelope_summary = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            if (envelope_summary == null || envelope_summary.EnvelopeId == null)
            {
                return(false);
            }

            // apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            // EnvelopesApi envelopesApi = new EnvelopesApi(WebhookLibrary.Configuration);
            // EnvelopeSummary envelope_summary = envelopesApi.CreateEnvelope(WebhookLibrary.AccountId, envelope_definition, null);

            // string envelope_id = envelope_summary.EnvelopeId;
            Console.WriteLine(envelope_summary);
            return(true);
        }
Example #3
0
        public async Task <IActionResult> OnPostAsync([FromRoute] string accessCode, [FromRoute] Guid taxId)
        {
            var tax = await _taxBiz.Get(new BaseCoreModel { Id = taxId });

            var result = await _membershipServiceApi.SystemUserApiService.Get(
                new MembershipService.ApiClient.Models.BaseModel
            {
                Id = tax.Data.User.Id
            });

            var bytesAsync =
                await global::System.IO.File.ReadAllBytesAsync(
                    "/home/ubuntu/Workdir/AccnetEngagement.pdf");

            var documentBase64 = Convert.ToBase64String(bytesAsync);
            var accessToken    = await _docusignHttpClient.GetAccessToken(accessCode);

            var userInfo = await _docusignHttpClient.GetUserInfo(accessToken.Data);

            Document document = new Document
            {
                DocumentBase64 = documentBase64,
                Name           = "test", FileExtension = "pdf", DocumentId = "1"
            };

            Document[] documents = new Document[] { document };

            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email       = userInfo.Data.email, Name = userInfo.Data.name, ClientUserId = userInfo.Data.sub,
                RecipientId = "1", RoutingOrder = "1"
            };

            // Create the sign here tab (signing field on the document)


            var dateSigned = new DocuSign.eSign.Model.DateSigned()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Date Signed Tab", XPosition = "70", YPosition = "120",
                Value      = DateTime.Now.ToString("d")
            };

            var fullName1 = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "69", YPosition = "130",
                Value      = result.Data.Firstname + " " + result.Data.Lastname
            };

            var text = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Text Tab", XPosition = "69", YPosition = "140", Value = result.Data.Address
            };

            var fullName4 = new DocuSign.eSign.Model.Text
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "100", YPosition = "155",
                Value      = result.Data.Gender + " " + result.Data.Firstname + " " + result.Data.Lastname
            };

            var text1 = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Text Tab", XPosition = "370", YPosition = "202", Value = tax.Data.Title
            };
            var text2 = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Text Tab", XPosition = "150", YPosition = "260", Value = tax.Data.Title
            };


            var fullName2 = new DocuSign.eSign.Model.Text
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "240", YPosition = "260",
                Value      = result.Data.Firstname + " " + result.Data.Lastname
            };
            var fullName3 = new DocuSign.eSign.Model.Text
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "430", YPosition = "260",
                Value      = result.Data.Firstname + " " + result.Data.Lastname
            };


            SignHere signHereTab = new SignHere
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Sign Here Tab", XPosition = "400", YPosition = "650"
            };

            SignHere[]   signHereTabs = new SignHere[] { signHereTab };
            DateSigned[] dateSigns    = new DateSigned[] { dateSigned };
            Text[]       texts        = new Text[] { text, text1, text2, fullName1, fullName2, fullName3, fullName4 };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs
            {
                SignHereTabs   = new List <SignHere>(signHereTabs),
                DateSignedTabs = new List <DateSigned>(dateSigns), TextTabs = new List <Text>(texts)
            };
            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipients = new Recipients {
                Signers = new List <Signer>(signers)
            };
            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
            {
                EmailSubject = "Please sign the document",
                Documents    = new List <Document>(documents),
                Recipients   = recipients,
                Status       = "sent"
            };
            // 2. Use the SDK to create and send the envelope
            var apiClient = new DocuSign.eSign.Client.ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken.Data);
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient.Configuration);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            // 3. Create Envelope Recipient View request obj
            string envelopeId = results.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = returnUrl, ClientUserId = userInfo.Data.sub,
                AuthenticationMethod = "none",
                UserName             = userInfo.Data.name, Email = userInfo.Data.email
            };

            // 4. Use the SDK to obtain a Recipient View URL
            ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, viewOptions);

            return(Ok(Result <string> .Successful(viewUrl.Url)));
        }
Example #4
0
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string documentBase64)
        {
            var envelopeDefinition = new EnvelopeDefinition()
            {
                EmailSubject = "Please sign this document"
            };

            var doc = new Document()
            {
                DocumentBase64 = documentBase64,
                Name           = $"Contract_{signerName}",
                FileExtension  = "pdf",
                DocumentId     = "3"
            };

            envelopeDefinition.Documents = new List <Document> {
                doc
            };
            var signer = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                ClientUserId = signerClientId,
                RecipientId  = "1",
            };

            var signHere = new SignHere
            {
                AnchorString = "/signature/",
                AnchorUnits  = "pixels"
            };

            var dateSigned = new DateSigned
            {
                AnchorString = "/datesigned/",
                AnchorUnits  = "pixels"
            };

            var placeSigned = new Text
            {
                AnchorString = "/placesigned/",
                AnchorUnits  = "pixels",
                Width        = "100"
            };

            var signerTabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere
                },
                DateSignedTabs = new List <DateSigned> {
                    dateSigned
                },
                TextTabs = new List <Text> {
                    placeSigned
                }
            };

            signer.Tabs = signerTabs;

            var recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer
                }
            };

            var envelope_events = new List <EnvelopeEvent>()
            {
                new EnvelopeEvent
                {
                    EnvelopeEventStatusCode = "completed"
                }
            };

            var event_notification = new EventNotification
            {
                Url                               = "https://auditqualification.azurewebsite.com/Docusign/connectwebhook",
                LoggingEnabled                    = "true",
                RequireAcknowledgment             = "true",
                UseSoapInterface                  = "false",
                IncludeCertificateWithSoap        = "false",
                SignMessageWithX509Cert           = "false",
                IncludeDocuments                  = "true",
                IncludeEnvelopeVoidReason         = "true",
                IncludeTimeZone                   = "true",
                IncludeSenderAccountAsCustomField = "true",
                IncludeDocumentFields             = "true",
                IncludeCertificateOfCompletion    = "true",
                EnvelopeEvents                    = envelope_events
            };

            envelopeDefinition.EventNotification = event_notification;
            envelopeDefinition.Recipients        = recipients;

            envelopeDefinition.Status = "sent";

            return(envelopeDefinition);
        }
Example #5
0
        public string SendforESign(SendDocumentInfo docDetails, List <FileDetail> fileDetails, string CUName, string CUEmail)
        {
            try
            {
                if (!_canExecuteRequest)
                {
                    throw new Exception("Failed to retrieve Credentials from Credential store");
                }

                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Request Send document");
                }

                string authHeader = "{\"Username\":\"" + _email + "\", \"Password\":\"" + _password + "\", \"IntegratorKey\":\"" + _integratorKey + "\"}";
                DocuSign.eSign.Client.Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

                string accountId = (!string.IsNullOrEmpty(Utility.DocuSignAccountID)) ? Utility.DocuSignAccountID : GetAccountID();

                EnvelopeDefinition envDef = new EnvelopeDefinition();
                envDef.EmailSubject = ConfigurationManager.AppSettings["DocuSignEmailSubject"];
                envDef.EmailBlurb   = ConfigurationManager.AppSettings["DocuSignEmailBody"];
                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Creating document object");
                }

                envDef.Documents = new List <Document>();

                for (int i = 0; i < fileDetails.Count(); i++)
                {
                    Document doc = new Document();
                    doc.DocumentBase64 = fileDetails.ElementAt(i).base64WordDoc;
                    doc.Name           = fileDetails.ElementAt(i).name;
                    doc.DocumentId     = fileDetails.ElementAt(i).id;
                    doc.FileExtension  = "docx";
                    envDef.Documents.Add(doc);
                }

                envDef.Recipients                 = new Recipients();
                envDef.Recipients.Signers         = new List <Signer>();
                envDef.Recipients.InPersonSigners = new List <InPersonSigner>();

                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Creating recipient and sign tabs");
                }

                foreach (var reci in docDetails.SignerDetails)
                {
                    if (docDetails.SignerDetails.ElementAt(0).IsInPerson.ToLower() == "true")
                    {
                        InPersonSigner signer = new InPersonSigner();
                        signer.Tabs = new Tabs();
                        signer.Tabs.SignHereTabs   = new List <SignHere>();
                        signer.Tabs.DateSignedTabs = new List <DateSigned>();
                        signer.Tabs.TextTabs       = new List <Text>();
                        signer.Tabs.DateTabs       = new List <Date>();
                        signer.Tabs.CheckboxTabs   = new List <Checkbox>();

                        //signer.Name = reci.ReciName;
                        //signer.Email = reci.ReciEmail;
                        //signer.RecipientId = reci.ReciId;
                        //signer.RoutingOrder = reci.ReciId;

                        signer.RecipientId         = reci.ReciId;
                        signer.RoutingOrder        = reci.ReciId;
                        signer.InPersonSigningType = "inPersonSigner";
                        signer.SignerName          = reci.ReciName;
                        signer.HostName            = CUName;
                        signer.HostEmail           = CUEmail;
                        //signer.AutoNavigation = "true";
                        //signer.DefaultRecipient = "true";

                        SignHere signHere = new SignHere();
                        signHere.DocumentId               = "1";
                        signHere.RecipientId              = reci.ReciId;
                        signHere.AnchorString             = "member$ign";
                        signHere.AnchorXOffset            = "0";
                        signHere.AnchorYOffset            = "0";
                        signHere.AnchorUnits              = "inches";
                        signHere.AnchorIgnoreIfNotPresent = "false";

                        signer.Tabs.SignHereTabs.Add(signHere);

                        DateSigned signed = new DateSigned();
                        signed.DocumentId               = "1";
                        signed.RecipientId              = reci.ReciId;
                        signed.AnchorString             = "member$date";
                        signed.AnchorXOffset            = "0";
                        signed.AnchorYOffset            = "0";
                        signed.AnchorUnits              = "inches";
                        signed.AnchorIgnoreIfNotPresent = "true";

                        signer.Tabs.DateSignedTabs.Add(signed);

                        for (int j = 1; j <= 16; j++)
                        {
                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = "1";
                            textTab.AnchorString             = "member1$1nput" + j;
                            textTab.TabLabel                 = "OptionalBeneficiaryInfo" + j;
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required                 = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            signer.Tabs.TextTabs.Add(textTab);
                        }


                        for (int k = 1; k <= 8; k++)
                        {
                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = "1";
                            dateTab.AnchorString             = "OBI$D01B$" + k;
                            dateTab.TabLabel                 = "OBIDate" + k;
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            signer.Tabs.DateTabs.Add(dateTab);
                        }

                        for (int c = 1; c <= 5; c++)
                        {
                            Checkbox checkBox = new Checkbox();
                            checkBox.DocumentId               = "1";
                            checkBox.RecipientId              = "1";
                            checkBox.AnchorString             = "cu0$chk" + c;
                            checkBox.TabLabel                 = "MSRCheckBox" + c;
                            checkBox.AnchorXOffset            = "0";
                            checkBox.AnchorYOffset            = "0";
                            checkBox.AnchorUnits              = "inches";
                            checkBox.AnchorIgnoreIfNotPresent = "true";

                            signer.Tabs.CheckboxTabs.Add(checkBox);
                        }

                        envDef.Recipients.InPersonSigners.Add(signer);
                    }
                    else
                    {
                        Signer signer = new Signer();
                        signer.Tabs = new Tabs();
                        signer.Tabs.SignHereTabs   = new List <SignHere>();
                        signer.Tabs.DateSignedTabs = new List <DateSigned>();
                        signer.Tabs.TextTabs       = new List <Text>();
                        signer.Tabs.DateTabs       = new List <Date>();
                        signer.Tabs.CheckboxTabs   = new List <Checkbox>();

                        signer.Name         = reci.ReciName;
                        signer.Email        = reci.ReciEmail;
                        signer.RecipientId  = reci.ReciId;
                        signer.RoutingOrder = reci.ReciId;

                        SignHere signHere = new SignHere();
                        signHere.DocumentId               = "1";
                        signHere.RecipientId              = reci.ReciId;
                        signHere.AnchorString             = "member$ign";
                        signHere.AnchorXOffset            = "0";
                        signHere.AnchorYOffset            = "0";
                        signHere.AnchorUnits              = "inches";
                        signHere.AnchorIgnoreIfNotPresent = "false";

                        signer.Tabs.SignHereTabs.Add(signHere);

                        DateSigned signed = new DateSigned();
                        signed.DocumentId               = "1";
                        signed.RecipientId              = reci.ReciId;
                        signed.AnchorString             = "member$date";
                        signed.AnchorXOffset            = "0";
                        signed.AnchorYOffset            = "0";
                        signed.AnchorUnits              = "inches";
                        signed.AnchorIgnoreIfNotPresent = "true";

                        signer.Tabs.DateSignedTabs.Add(signed);

                        for (int j = 1; j <= 16; j++)
                        {
                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = "1";
                            textTab.AnchorString             = "member1$1nput" + j;
                            textTab.TabLabel                 = "OptionalBeneficiaryInfo" + j;
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required                 = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            signer.Tabs.TextTabs.Add(textTab);
                        }


                        for (int k = 1; k <= 8; k++)
                        {
                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = "1";
                            dateTab.AnchorString             = "OBI$D01B$" + k;
                            dateTab.TabLabel                 = "OBIDate" + k;
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            signer.Tabs.DateTabs.Add(dateTab);
                        }

                        for (int c = 1; c <= 5; c++)
                        {
                            Checkbox checkBox = new Checkbox();
                            checkBox.DocumentId               = "1";
                            checkBox.RecipientId              = "1";
                            checkBox.AnchorString             = "cu0$chk" + c;
                            checkBox.TabLabel                 = "MSRCheckBox" + c;
                            checkBox.AnchorXOffset            = "0";
                            checkBox.AnchorYOffset            = "0";
                            checkBox.AnchorUnits              = "inches";
                            checkBox.AnchorIgnoreIfNotPresent = "true";

                            signer.Tabs.CheckboxTabs.Add(checkBox);
                        }

                        envDef.Recipients.Signers.Add(signer);
                    }
                }

                if (docDetails.JointSignerDetails != null && docDetails.JointSignerDetails.Count > 0)
                {
                    for (int i = 0; i < docDetails.JointSignerDetails.Count; i++)
                    {
                        if (docDetails.JointSignerDetails.ElementAt(i).IsInPerson.ToLower() == "true")
                        {
                            InPersonSigner jointSigner = new InPersonSigner();
                            jointSigner.Tabs = new Tabs();
                            jointSigner.Tabs.SignHereTabs   = new List <SignHere>();
                            jointSigner.Tabs.DateSignedTabs = new List <DateSigned>();
                            jointSigner.Tabs.TextTabs       = new List <Text>();
                            jointSigner.Tabs.DateTabs       = new List <Date>();
                            jointSigner.Tabs.CheckboxTabs   = new List <Checkbox>();

                            //jointSigner.Name = docDetails.JointSignerDetails[i].ReciName;
                            //jointSigner.Email = docDetails.JointSignerDetails[i].ReciEmail;
                            //jointSigner.RecipientId = docDetails.JointSignerDetails[i].ReciId;
                            //jointSigner.RoutingOrder = docDetails.JointSignerDetails[i].ReciId;

                            jointSigner.RecipientId         = docDetails.JointSignerDetails[i].ReciId;
                            jointSigner.RoutingOrder        = docDetails.JointSignerDetails[i].ReciId;
                            jointSigner.InPersonSigningType = "inPersonSigner";
                            jointSigner.SignerName          = docDetails.JointSignerDetails[i].ReciName;
                            jointSigner.HostName            = CUName;
                            jointSigner.HostEmail           = CUEmail;

                            SignHere jointSignerTab = new SignHere();
                            jointSignerTab.DocumentId               = "1";
                            jointSignerTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSignerTab.AnchorString             = "Joint0w$ign" + (i + 1);
                            jointSignerTab.AnchorXOffset            = "0";
                            jointSignerTab.AnchorYOffset            = "0";
                            jointSignerTab.AnchorUnits              = "inches";
                            jointSignerTab.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.SignHereTabs.Add(jointSignerTab);

                            DateSigned jointSigned = new DateSigned();
                            jointSigned.DocumentId               = "1";
                            jointSigned.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSigned.AnchorString             = "Joint0w$date" + (i + 1);
                            jointSigned.AnchorXOffset            = "0";
                            jointSigned.AnchorYOffset            = "0";
                            jointSigned.AnchorUnits              = "inches";
                            jointSigned.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.DateSignedTabs.Add(jointSigned);

                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            textTab.AnchorString             = "joint1$1nput";
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            jointSigner.Tabs.TextTabs.Add(textTab);

                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            dateTab.AnchorString             = "joint$D01B$";
                            dateTab.TabLabel                 = "date1";
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            jointSigner.Tabs.DateTabs.Add(dateTab);

                            for (int c = 1; c <= 5; c++)
                            {
                                Checkbox checkBox = new Checkbox();
                                checkBox.DocumentId               = "1";
                                checkBox.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                                checkBox.AnchorString             = "cu0$chk" + c;
                                checkBox.TabLabel                 = "MSRCheckBox" + c;
                                checkBox.AnchorXOffset            = "0";
                                checkBox.AnchorYOffset            = "0";
                                checkBox.AnchorUnits              = "inches";
                                checkBox.AnchorIgnoreIfNotPresent = "true";

                                jointSigner.Tabs.CheckboxTabs.Add(checkBox);
                            }

                            envDef.Recipients.InPersonSigners.Add(jointSigner);
                        }
                        else
                        {
                            Signer jointSigner = new Signer();
                            jointSigner.Tabs = new Tabs();
                            jointSigner.Tabs.SignHereTabs   = new List <SignHere>();
                            jointSigner.Tabs.DateSignedTabs = new List <DateSigned>();
                            jointSigner.Tabs.TextTabs       = new List <Text>();
                            jointSigner.Tabs.DateTabs       = new List <Date>();
                            jointSigner.Tabs.CheckboxTabs   = new List <Checkbox>();

                            jointSigner.Name         = docDetails.JointSignerDetails[i].ReciName;
                            jointSigner.Email        = docDetails.JointSignerDetails[i].ReciEmail;
                            jointSigner.RecipientId  = docDetails.JointSignerDetails[i].ReciId;
                            jointSigner.RoutingOrder = docDetails.JointSignerDetails[i].ReciId;


                            SignHere jointSignerTab = new SignHere();
                            jointSignerTab.DocumentId               = "1";
                            jointSignerTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSignerTab.AnchorString             = "Joint0w$ign" + (i + 1);
                            jointSignerTab.AnchorXOffset            = "0";
                            jointSignerTab.AnchorYOffset            = "0";
                            jointSignerTab.AnchorUnits              = "inches";
                            jointSignerTab.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.SignHereTabs.Add(jointSignerTab);

                            DateSigned jointSigned = new DateSigned();
                            jointSigned.DocumentId               = "1";
                            jointSigned.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSigned.AnchorString             = "Joint0w$date" + (i + 1);
                            jointSigned.AnchorXOffset            = "0";
                            jointSigned.AnchorYOffset            = "0";
                            jointSigned.AnchorUnits              = "inches";
                            jointSigned.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.DateSignedTabs.Add(jointSigned);

                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            textTab.AnchorString             = "joint1$1nput";
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            jointSigner.Tabs.TextTabs.Add(textTab);

                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            dateTab.AnchorString             = "joint$D01B$";
                            dateTab.TabLabel                 = "date1";
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            jointSigner.Tabs.DateTabs.Add(dateTab);

                            for (int c = 1; c <= 5; c++)
                            {
                                Checkbox checkBox = new Checkbox();
                                checkBox.DocumentId               = "1";
                                checkBox.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                                checkBox.AnchorString             = "cu0$chk" + c;
                                checkBox.TabLabel                 = "MSRCheckBox" + c;
                                checkBox.AnchorXOffset            = "0";
                                checkBox.AnchorYOffset            = "0";
                                checkBox.AnchorUnits              = "inches";
                                checkBox.AnchorIgnoreIfNotPresent = "true";

                                jointSigner.Tabs.CheckboxTabs.Add(checkBox);
                            }

                            envDef.Recipients.Signers.Add(jointSigner);
                        }
                    }
                }


                if (docDetails.CUSignerDetails != null && docDetails.CUSignerDetails.Count > 0)
                {
                    for (int i = 0; i < docDetails.CUSignerDetails.Count; i++)
                    {
                        Signer cuSigner = new Signer();
                        cuSigner.Tabs = new Tabs();
                        cuSigner.Tabs.SignHereTabs   = new List <SignHere>();
                        cuSigner.Tabs.DateSignedTabs = new List <DateSigned>();
                        cuSigner.Tabs.TextTabs       = new List <Text>();
                        cuSigner.Tabs.DateTabs       = new List <Date>();
                        cuSigner.Tabs.CheckboxTabs   = new List <Checkbox>();

                        cuSigner.Name         = docDetails.CUSignerDetails[i].ReciName;
                        cuSigner.Email        = docDetails.CUSignerDetails[i].ReciEmail;
                        cuSigner.RecipientId  = docDetails.CUSignerDetails[i].ReciId;
                        cuSigner.RoutingOrder = docDetails.CUSignerDetails[i].ReciId;


                        SignHere cuSignerTab = new SignHere();
                        cuSignerTab.DocumentId               = "1";
                        cuSignerTab.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        cuSignerTab.AnchorString             = "Cu0w$ign";
                        cuSignerTab.AnchorXOffset            = "0";
                        cuSignerTab.AnchorYOffset            = "0";
                        cuSignerTab.AnchorUnits              = "inches";
                        cuSignerTab.AnchorIgnoreIfNotPresent = "true";

                        cuSigner.Tabs.SignHereTabs.Add(cuSignerTab);

                        DateSigned cuSigned = new DateSigned();
                        cuSigned.DocumentId               = "1";
                        cuSigned.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        cuSigned.AnchorString             = "Cu0w$date";
                        cuSigned.AnchorXOffset            = "0";
                        cuSigned.AnchorYOffset            = "0";
                        cuSigned.AnchorUnits              = "inches";
                        cuSigned.AnchorIgnoreIfNotPresent = "true";

                        cuSigner.Tabs.DateSignedTabs.Add(cuSigned);
                        for (int j = 1; j <= 6; j++)
                        {
                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                            textTab.AnchorString             = "cu1$1nput" + j;
                            textTab.TabLabel                 = "cuOfficialSec" + j;
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required                 = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            cuSigner.Tabs.TextTabs.Add(textTab);
                        }

                        for (int k = 1; k <= 3; k++)
                        {
                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                            dateTab.AnchorString             = "cu$D01B$" + k;
                            dateTab.TabLabel                 = "cuDate" + k;
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            cuSigner.Tabs.DateTabs.Add(dateTab);
                        }

                        Text textTab1 = new Text();
                        textTab1.DocumentId               = "1";
                        textTab1.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        textTab1.AnchorString             = "benComment$1nput";
                        textTab1.TabLabel                 = "BenComment";
                        textTab1.AnchorXOffset            = "0";
                        textTab1.AnchorYOffset            = "-3";
                        textTab1.AnchorUnits              = "pixels";
                        textTab1.AnchorIgnoreIfNotPresent = "true";
                        textTab1.AnchorMatchWholeWord     = "true";
                        textTab1.Required                 = "false";
                        textTab1.Width    = "75";
                        textTab1.Height   = "15";
                        textTab1.FontSize = "Size10";
                        textTab1.Font     = "TimesNewRoman";
                        cuSigner.Tabs.TextTabs.Add(textTab1);

                        Text textTab2 = new Text();
                        textTab2.DocumentId               = "1";
                        textTab2.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        textTab2.AnchorString             = "RetailComment$1nput";
                        textTab2.TabLabel                 = "RetailComment";
                        textTab2.AnchorXOffset            = "0";
                        textTab2.AnchorYOffset            = "-3";
                        textTab2.AnchorUnits              = "pixels";
                        textTab2.AnchorIgnoreIfNotPresent = "true";
                        textTab2.AnchorMatchWholeWord     = "true";
                        textTab2.Required                 = "false";
                        textTab2.Width    = "75";
                        textTab2.Height   = "15";
                        textTab2.FontSize = "Size10";
                        textTab2.Font     = "TimesNewRoman";

                        cuSigner.Tabs.TextTabs.Add(textTab2);

                        Text textTab3 = new Text();
                        textTab3.DocumentId               = "1";
                        textTab3.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        textTab3.AnchorString             = "Retailemployeeinfo$1nput";
                        textTab3.TabLabel                 = "Retailemployeeinfo";
                        textTab3.AnchorXOffset            = "0";
                        textTab3.AnchorYOffset            = "-3";
                        textTab3.AnchorUnits              = "pixels";
                        textTab3.AnchorIgnoreIfNotPresent = "true";
                        textTab3.AnchorMatchWholeWord     = "true";
                        textTab3.Required                 = "false";
                        textTab3.Width    = "75";
                        textTab3.Height   = "15";
                        textTab3.FontSize = "Size10";
                        textTab3.Font     = "TimesNewRoman";

                        cuSigner.Tabs.TextTabs.Add(textTab3);

                        for (int c = 1; c <= 5; c++)
                        {
                            Checkbox checkBox = new Checkbox();
                            checkBox.DocumentId               = "1";
                            checkBox.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                            checkBox.AnchorString             = "cu0$chk" + c;
                            checkBox.TabLabel                 = "MSRCheckBox" + c;
                            checkBox.AnchorXOffset            = "0";
                            checkBox.AnchorYOffset            = "0";
                            checkBox.AnchorUnits              = "inches";
                            checkBox.AnchorIgnoreIfNotPresent = "true";

                            cuSigner.Tabs.CheckboxTabs.Add(checkBox);
                        }

                        envDef.Recipients.Signers.Add(cuSigner);
                    }
                }

                envDef.Status = "sent";
                envDef.EnforceSignerVisibility = "true";

                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Sending Create and send envelope request");
                }

                EnvelopesApi    envelopesApi    = new EnvelopesApi();
                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

                return(envelopeSummary.EnvelopeId);
            }
            catch (Exception ex)
            {
                Utility.LogAction("sending document to DocuSign failed with exception: " + ex.Message);
                throw;
            }
        }
Example #6
0
        public ActionResult SendSignatureRequest()
        {
            string ds_signer1_name  = WebhookLibrary.GetFakeName();
            string ds_signer1_email = WebhookLibrary.GetFakeEmail(ds_signer1_name);
            string ds_cc1_name      = WebhookLibrary.GetFakeName();
            string ds_cc1_email     = WebhookLibrary.GetFakeEmail(ds_cc1_name);

            //string webhook_url = Request.Url.GetLeftPart(UriPartial.Authority) + "/api/Webhook";

            if (WebhookLibrary.AccountId == null)
            {
                return(Content("[\"ok\" => false, \"html\" => \"<h3>Problem</h3><p>Couldn't login to DocuSign: \"]"));
            }

            // The envelope request includes a signer-recipient and their tabs object,
            // and an eventNotification object which sets the parameters for
            // webhook notifications to us from the DocuSign platform
            //List<EnvelopeEvent> envelope_events = new List<EnvelopeEvent>();

            //EnvelopeEvent envelope_event1 = new EnvelopeEvent();
            //envelope_event1.EnvelopeEventStatusCode = "sent";
            //envelope_events.Add(envelope_event1);
            //EnvelopeEvent envelope_event2 = new EnvelopeEvent();
            //envelope_event2.EnvelopeEventStatusCode = "delivered";
            //envelope_events.Add(envelope_event2);
            //EnvelopeEvent envelope_event3 = new EnvelopeEvent();
            //envelope_event3.EnvelopeEventStatusCode = "completed";
            //envelope_events.Add(envelope_event3);
            //EnvelopeEvent envelope_event4 = new EnvelopeEvent();
            //envelope_event4.EnvelopeEventStatusCode = "declined";
            //envelope_events.Add(envelope_event4);
            //EnvelopeEvent envelope_event5 = new EnvelopeEvent();
            //envelope_event5.EnvelopeEventStatusCode = "voided";
            //envelope_events.Add(envelope_event5);

            //List<RecipientEvent> recipient_events = new List<RecipientEvent>();
            //RecipientEvent recipient_event1 = new RecipientEvent();
            //recipient_event1.RecipientEventStatusCode = "Sent";
            //recipient_events.Add(recipient_event1);
            //RecipientEvent recipient_event2 = new RecipientEvent();
            //recipient_event2.RecipientEventStatusCode = "Delivered";
            //recipient_events.Add(recipient_event2);
            //RecipientEvent recipient_event3 = new RecipientEvent();
            //recipient_event3.RecipientEventStatusCode = "Completed";
            //recipient_events.Add(recipient_event3);
            //RecipientEvent recipient_event4 = new RecipientEvent();
            //recipient_event4.RecipientEventStatusCode = "Declined";
            //recipient_events.Add(recipient_event4);
            //RecipientEvent recipient_event5 = new RecipientEvent();
            //recipient_event5.RecipientEventStatusCode = "AuthenticationFailed";
            //recipient_events.Add(recipient_event5);
            //RecipientEvent recipient_event6 = new RecipientEvent();
            //recipient_event6.RecipientEventStatusCode = "AutoResponded";
            //recipient_events.Add(recipient_event6);

            //EventNotification event_notification = new EventNotification();
            //event_notification.Url = webhook_url;
            //event_notification.LoggingEnabled = "true";
            //event_notification.RequireAcknowledgment ="true";
            //event_notification.UseSoapInterface= "false";
            //event_notification.IncludeCertificateWithSoap= "false";
            //event_notification.SignMessageWithX509Cert= "false";
            //event_notification.IncludeDocuments= "true";
            //event_notification.IncludeEnvelopeVoidReason= "true";
            //event_notification.IncludeTimeZone= "true";
            //event_notification.IncludeSenderAccountAsCustomField= "true";
            //event_notification.IncludeDocumentFields= "true";
            //event_notification.IncludeCertificateOfCompletion= "true";
            //event_notification.EnvelopeEvents = envelope_events;
            //event_notification.RecipientEvents = recipient_events;

            Document document1 = new Document();

            document1.DocumentId = "1";
            document1.Name       = "NDA.pdf";
            Byte[] bytes1 = System.IO.File.ReadAllBytes(Server.MapPath("~/Documents/NDA.pdf"));
            document1.DocumentBase64 = Convert.ToBase64String(bytes1);
            document1.FileExtension  = "pdf";

            Document document2 = new Document();

            document2.DocumentId = "2";
            document2.Name       = "House.pdf";
            Byte[] bytes2 = System.IO.File.ReadAllBytes(Server.MapPath("~/Documents/House.pdf"));
            document2.DocumentBase64 = Convert.ToBase64String(bytes2);
            document2.FileExtension  = "pdf";

            Document document3 = new Document();

            document3.DocumentId = "3";
            document3.Name       = "contractor_agreement.docx";
            Byte[] bytes3 = System.IO.File.ReadAllBytes(Server.MapPath("~/Documents/contractor_agreement.docx"));
            document3.DocumentBase64 = Convert.ToBase64String(bytes3);
            document3.FileExtension  = "docx";

            /*
             * The signing fields
             *
             * Invisible (white) Anchor field names for the NDA.pdf document:
             *   * signer1sig
             *   * signer1name
             *   * signer1company
             *   * signer1date
             *
             * Explicitly placed fields are used in the contractor_agreement
             * and on the house diagram
             *
             * Some anchor fields for document 3, the contractor_agreement.docx, use existing
             * content from the document:
             *   * "Client Signature"
             *   * "Client Name"
             *
             * NOTE: Anchor fields search ALL the documents in the envelope for
             * matches to the field's anchor text
             */

            //Anchored for doc 1
            SignHere sign_here_tab1 = new SignHere();

            sign_here_tab1.AnchorString  = "signer1sig";
            sign_here_tab1.AnchorXOffset = "0";
            sign_here_tab1.AnchorYOffset = "0";
            sign_here_tab1.AnchorUnits   = "mms";
            sign_here_tab1.RecipientId   = "1";
            sign_here_tab1.Name          = "Please sign here";
            sign_here_tab1.Optional      = "false";
            sign_here_tab1.ScaleValue    = 1;
            sign_here_tab1.TabLabel      = "signer1sig";

            // Explicit position for doc 2
            SignHere sign_here_tab2 = new SignHere();

            sign_here_tab2.PageNumber  = "1";
            sign_here_tab2.DocumentId  = "2";
            sign_here_tab2.RecipientId = "2";
            sign_here_tab2.XPosition   = "89";
            sign_here_tab2.YPosition   = "40";
            sign_here_tab2.Name        = "Please sign here";
            sign_here_tab2.Optional    = "false";
            sign_here_tab2.ScaleValue  = 1;
            sign_here_tab2.TabLabel    = "signer1_doc2";

            // Anchored for doc 3
            SignHere sign_here_tab3 = new SignHere();

            sign_here_tab3.AnchorString  = "Client Signature";
            sign_here_tab3.AnchorXOffset = "0";
            sign_here_tab3.AnchorYOffset = "-4";
            sign_here_tab3.AnchorUnits   = "mms";
            sign_here_tab3.RecipientId   = "1";
            sign_here_tab3.Name          = "Please sign here";
            sign_here_tab3.Optional      = "false";
            sign_here_tab3.ScaleValue    = 1;
            sign_here_tab3.TabLabel      = "doc3_client_sig";

            // Anchored for doc 1
            FullName full_name_tab = new FullName();

            full_name_tab.AnchorString  = "signer1name";
            full_name_tab.AnchorYOffset = "-6";
            full_name_tab.FontSize      = "Size12";
            full_name_tab.RecipientId   = "1";
            full_name_tab.TabLabel      = "Full Name";
            full_name_tab.Name          = "Full Name";

            // Anchored for doc 1
            DocuSign.eSign.Model.Text text_tab1 = new DocuSign.eSign.Model.Text();
            text_tab1.AnchorString  = "signer1company";
            text_tab1.AnchorYOffset = "-8";
            text_tab1.FontSize      = "Size12";
            text_tab1.RecipientId   = "1";       //Because the same tab label is
            text_tab1.TabLabel      = "Company"; //used, these fields will have duplicate data
            text_tab1.Name          = "Company"; //Note that the account's "Data Population Scope"
            text_tab1.Required      = "true";    //must be set to "Envelope" to enable this feature.

            // Anchored for doc 3
            DocuSign.eSign.Model.Text text_tab2 = new DocuSign.eSign.Model.Text();
            text_tab2.AnchorString  = "Client Name";
            text_tab2.AnchorYOffset = "-38";
            text_tab2.FontSize      = "Size12";
            text_tab2.RecipientId   = "1";
            text_tab2.TabLabel      = "Company";
            text_tab2.Name          = "Company";
            text_tab2.Required      = "true";

            // Anchored for doc 3
            DocuSign.eSign.Model.Text text_tab3 = new DocuSign.eSign.Model.Text();
            text_tab3.DocumentId  = "3";
            text_tab3.PageNumber  = "1";
            text_tab3.RecipientId = "1";
            text_tab3.XPosition   = "145";
            text_tab3.YPosition   = "195";
            text_tab3.FontSize    = "Size10";
            text_tab3.TabLabel    = "Company";
            text_tab3.Name        = "Company";
            text_tab3.Required    = "true";

            // Anchored for doc 1
            DateSigned date_signed_tab1 = new DateSigned();

            date_signed_tab1.AnchorString  = "signer1date";
            date_signed_tab1.AnchorYOffset = "-6";
            date_signed_tab1.FontSize      = "Size12";
            date_signed_tab1.RecipientId   = "1";
            date_signed_tab1.Name          = "Date Signed";
            date_signed_tab1.TabLabel      = "date_signed";

            // Explicit position for doc 2
            DateSigned date_signed_tab2 = new DateSigned();

            date_signed_tab2.DocumentId  = "2";
            date_signed_tab2.PageNumber  = "1";
            date_signed_tab2.RecipientId = "1";
            date_signed_tab2.XPosition   = "89";
            date_signed_tab2.YPosition   = "100";
            date_signed_tab2.FontSize    = "Size12";
            date_signed_tab2.RecipientId = "1";
            date_signed_tab2.Name        = "Date Signed";
            date_signed_tab2.TabLabel    = "doc3_date_signed";

            DocuSign.eSign.Model.Tabs tabs = new DocuSign.eSign.Model.Tabs();
            tabs.SignHereTabs = new List <SignHere>();
            tabs.SignHereTabs.Add(sign_here_tab1);
            tabs.SignHereTabs.Add(sign_here_tab2);
            tabs.SignHereTabs.Add(sign_here_tab3);

            tabs.FullNameTabs = new List <FullName>();
            tabs.FullNameTabs.Add(full_name_tab);

            tabs.TextTabs = new List <Text>();
            tabs.TextTabs.Add(text_tab1);
            tabs.TextTabs.Add(text_tab2);
            tabs.TextTabs.Add(text_tab3);

            tabs.DateSignedTabs = new List <DateSigned>();
            tabs.DateSignedTabs.Add(date_signed_tab1);
            tabs.DateSignedTabs.Add(date_signed_tab2);

            Signer signer = new Signer();

            signer.Email        = ds_signer1_email;
            signer.Name         = ds_signer1_name;
            signer.RecipientId  = "1";
            signer.RoutingOrder = "1";
            signer.Tabs         = tabs;

            CarbonCopy carbon_copy = new CarbonCopy();

            carbon_copy.Email        = ds_cc1_email;
            carbon_copy.Name         = ds_cc1_name;
            carbon_copy.RecipientId  = "2";
            carbon_copy.RoutingOrder = "2";

            Recipients recipients = new Recipients();

            recipients.Signers = new List <Signer>();
            recipients.Signers.Add(signer);
            recipients.CarbonCopies = new List <CarbonCopy>();
            recipients.CarbonCopies.Add(carbon_copy);

            EnvelopeDefinition envelope_definition = new EnvelopeDefinition();

            envelope_definition.EmailSubject = "Please sign the house documentation package";
            envelope_definition.Documents    = new List <Document>();
            envelope_definition.Documents.Add(document1);
            envelope_definition.Documents.Add(document2);
            envelope_definition.Documents.Add(document3);
            envelope_definition.Recipients = recipients;
            //envelope_definition.EventNotification = event_notification;
            envelope_definition.Status = "sent";

            EnvelopesApi envelopesApi = new EnvelopesApi(WebhookLibrary.Configuration);

            EnvelopeSummary envelope_summary = envelopesApi.CreateEnvelope(WebhookLibrary.AccountId, envelope_definition, null);

            if (envelope_summary == null || envelope_summary.EnvelopeId == null)
            {
                return(Content("[\"ok\" => false, html => \"<h3>Problem</h3>\" \"<p>Error calling DocuSign</p>\"]"));
            }

            string envelope_id = envelope_summary.EnvelopeId;

            // Create instructions for reading the email
            string html = "<h2>Signature request sent!</h2>" +
                          "<p>Envelope ID: " + envelope_id + "</p>" +
                          "<p>Signer: " + ds_signer1_name + "</p>" +
                          "<p>CC: " + ds_cc1_name + "</p>" +
                          "<h2>Next steps</h2>" +
                          "<h3>Respond to the Signature Request</h3>";

            string ds_signer1_email_access = WebhookLibrary.GetFakeEmailAccess(ds_signer1_email);

            if (ds_signer1_email_access != null)
            {
                // A temp account was used for the email
                html += "<p>Respond to the request via your mobile phone by using the QR code: </p>" +
                        "<p>" + WebhookLibrary.GetFakeEmailAccessQRCode(ds_signer1_email_access) + "</p>" +
                        "<p> or via <a target='_blank' href='" + ds_signer1_email_access + "'>your web browser.</a></p>";
            }
            else
            {
                // A regular email account was used
                html += "<p>Respond to the request via your mobile phone or other mail tool.</p>" +
                        "<p>The email was sent to " + ds_signer1_name + " &lt;" + ds_signer1_email + "&gt;</p>";
            }

            //return Content("['ok'  => true,'envelope_id' => "+envelope_id+",'html' => "+ html+",'js' => [['disable_button' => 'sendbtn']]]");  // js is an array of items
            return(Content(html));
        }
Example #7
0
        public string SendForESign(List <DocumentField.SendDocumentInfo> docs)
        {
            bool _IsInperson = true;

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "Email subject";
            envDef.EmailBlurb   = "Email blurb";
            envDef.Documents    = new List <Document>();


            #region Adding Doc One

            Document doc1 = new Document();
            doc1.DocumentBase64 = docs[0].FileBase64String;
            doc1.Name           = "document one";
            doc1.DocumentId     = "1";
            doc1.FileExtension  = "docx";
            doc1.Pages          = "1";


            envDef.Documents.Add(doc1);

            #endregion

            #region Addding Doc Two

            Document doc2 = new Document();
            doc2.DocumentBase64 = docs[1].FileBase64String;
            doc2.Name           = "documnet two";
            doc2.DocumentId     = "2";
            doc2.FileExtension  = "docx";
            doc2.Pages          = "1";

            envDef.Documents.Add(doc2);
            #endregion


            envDef.Recipients                 = new Recipients();
            envDef.Recipients.Signers         = new List <Signer>();
            envDef.Recipients.InPersonSigners = new List <InPersonSigner>();
            //envDef.EnforceSignerVisibility = "true";


            // Adding Signers//

            #region ONE SIGNER

            if (!_IsInperson)
            {
                Signer signer = new Signer();
                signer.Tabs = new Tabs();
                signer.Tabs.SignHereTabs   = new List <SignHere>();
                signer.Tabs.CheckboxTabs   = new List <Checkbox>();
                signer.Tabs.DateSignedTabs = new List <DateSigned>();

                signer.Name  = "Signer One";
                signer.Email = ConfigurationManager.AppSettings["Reci1Email"];

                signer.RecipientId  = "1";
                signer.RoutingOrder = "1";

                SignHere signHere = new SignHere();
                signHere.DocumentId               = "1";
                signHere.RecipientId              = "1";
                signHere.AnchorString             = "signhere1";
                signHere.AnchorXOffset            = "0";
                signHere.AnchorYOffset            = "0";
                signHere.AnchorUnits              = "inches";
                signHere.AnchorIgnoreIfNotPresent = "false";
                signer.Tabs.SignHereTabs.Add(signHere);

                DateSigned Datesign = new DateSigned();
                Datesign.DocumentId               = "1";
                Datesign.RecipientId              = "2";
                Datesign.AnchorString             = "DATEHERE1";
                Datesign.AnchorXOffset            = "0";
                Datesign.AnchorYOffset            = "0";
                Datesign.AnchorUnits              = "inches";
                Datesign.AnchorIgnoreIfNotPresent = "true";
                signer.Tabs.DateSignedTabs.Add(Datesign);

                envDef.Recipients.Signers.Add(signer);
            }
            #endregion

            #region IN-PERSON Signer


            //must be a docusign acc with inperson enabled
            //In-person signing mode
            if (_IsInperson)
            {
                #region impsigner1
                InPersonSigner Impsigner = new InPersonSigner();
                Impsigner.Tabs = new Tabs();
                Impsigner.Tabs.SignHereTabs   = new List <SignHere>();
                Impsigner.Tabs.DateSignedTabs = new List <DateSigned>();

                Impsigner.SignerName          = "InpersonSigner one";
                Impsigner.RecipientId         = "1";
                Impsigner.RoutingOrder        = "1";
                Impsigner.InPersonSigningType = "inPersonSigner";
                Impsigner.HostName            = "inperson host";
                Impsigner.HostEmail           = ConfigurationManager.AppSettings["ImpHostEmail"];



                SignHere signHereImp = new SignHere();
                signHereImp.DocumentId               = "1";
                signHereImp.RecipientId              = "1";
                signHereImp.AnchorString             = "SIGNHERE1";
                signHereImp.AnchorXOffset            = "0";
                signHereImp.AnchorYOffset            = "0";
                signHereImp.AnchorUnits              = "inches";
                signHereImp.AnchorIgnoreIfNotPresent = "false";

                Impsigner.Tabs.SignHereTabs.Add(signHereImp);

                DateSigned signed = new DateSigned();
                signed.DocumentId               = "1";
                signed.RecipientId              = "1";
                signed.AnchorString             = "DATEHERE1";
                signed.AnchorXOffset            = "0";
                signed.AnchorYOffset            = "0";
                signed.AnchorUnits              = "inches";
                signed.AnchorIgnoreIfNotPresent = "true";

                Impsigner.Tabs.DateSignedTabs.Add(signed);


                envDef.Recipients.InPersonSigners.Add(Impsigner);
                #endregion

                #region ImpSigner2
                InPersonSigner Impsigner2 = new InPersonSigner();
                Impsigner2.Tabs = new Tabs();
                Impsigner2.Tabs.SignHereTabs   = new List <SignHere>();
                Impsigner2.Tabs.DateSignedTabs = new List <DateSigned>();

                Impsigner2.SignerName          = "InpersonSigner two";
                Impsigner2.RecipientId         = "2";
                Impsigner2.RoutingOrder        = "2";
                Impsigner2.InPersonSigningType = "inPersonSigner";
                Impsigner2.HostName            = "inperson host";
                Impsigner2.HostEmail           = ConfigurationManager.AppSettings["ImpHostEmail"];



                SignHere signHereImp2 = new SignHere();
                signHereImp2.DocumentId               = "2";
                signHereImp2.RecipientId              = "1";
                signHereImp2.AnchorString             = "SIGNHERE2";
                signHereImp2.AnchorXOffset            = "0";
                signHereImp2.AnchorYOffset            = "0";
                signHereImp2.AnchorUnits              = "inches";
                signHereImp2.AnchorIgnoreIfNotPresent = "false";

                Impsigner2.Tabs.SignHereTabs.Add(signHereImp2);

                DateSigned signed2 = new DateSigned();
                signed2.DocumentId               = "1";
                signed2.RecipientId              = "1";
                signed2.AnchorString             = "DATEHERE2";
                signed2.AnchorXOffset            = "0";
                signed2.AnchorYOffset            = "0";
                signed2.AnchorUnits              = "inches";
                signed2.AnchorIgnoreIfNotPresent = "true";

                Impsigner2.Tabs.DateSignedTabs.Add(signed2);


                envDef.Recipients.InPersonSigners.Add(Impsigner2);
            }



            #endregion

            #region Adding ONE Joint Signer

            if (!_IsInperson)
            {
                Signer jointSigner = new Signer();
                jointSigner.Tabs = new Tabs();
                jointSigner.Tabs.SignHereTabs   = new List <SignHere>();
                jointSigner.Tabs.DateSignedTabs = new List <DateSigned>();

                jointSigner.Name         = "Joint Signer 1";
                jointSigner.Email        = ConfigurationManager.AppSettings["Reci2Email"];
                jointSigner.RecipientId  = "2";
                jointSigner.RoutingOrder = "2";

                SignHere jointSignerTab = new SignHere();
                jointSignerTab.DocumentId               = "1";
                jointSignerTab.RecipientId              = "2";
                jointSignerTab.AnchorString             = "SIGNHERE2";
                jointSignerTab.AnchorXOffset            = "0";
                jointSignerTab.AnchorYOffset            = "0";
                jointSignerTab.AnchorUnits              = "inches";
                jointSignerTab.AnchorIgnoreIfNotPresent = "true";

                jointSigner.Tabs.SignHereTabs.Add(jointSignerTab);

                DateSigned JODateSigned = new DateSigned();
                JODateSigned.DocumentId               = "1";
                JODateSigned.RecipientId              = "2";
                JODateSigned.AnchorString             = "DATEHERE2";
                JODateSigned.AnchorXOffset            = "0";
                JODateSigned.AnchorYOffset            = "0";
                JODateSigned.AnchorUnits              = "inches";
                JODateSigned.AnchorIgnoreIfNotPresent = "true";

                jointSigner.Tabs.DateSignedTabs.Add(JODateSigned);

                envDef.Recipients.Signers.Add(jointSigner);
            }
            #endregion


            #region ATTEMP SEND ENVELOPE

            envDef.Status = "sent";

            string       accountId    = GetAccountID();
            EnvelopesApi envelopesApi = new EnvelopesApi();

            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            #endregion

            var    returnEnv = envelopesApi.GetEnvelope(accountId, envelopeSummary.EnvelopeId, null); //sending for e-sign
            string status    = returnEnv.Status;

            return(envelopeSummary.EnvelopeId);
        }