コード例 #1
0
        // ***DS.snippet.0.start
        string DoWork(string signerEmail, string signerName, string ccEmail,
                      string ccName, string accessToken, string basePath,
                      string accountId, string templateId)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // accessToken
            // basePath
            // accountId
            // templateId

            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi       envelopesApi = new EnvelopesApi(config);
            EnvelopeDefinition envelope     = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId);
            EnvelopeSummary    result       = envelopesApi.CreateEnvelope(accountId, envelope);

            return(result.EnvelopeId);
        }
コード例 #2
0
        public void JwtCreateEmbeddedSigningViewTest()
        {
            JwtRequestSignatureOnDocumentTest();

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient);

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = testConfig.ReturnUrl,
                ClientUserId         = "1234", // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName             = testConfig.RecipientName,
                Email = testConfig.RecipientEmail
            };

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(testConfig.AccountId, testConfig.EnvelopeId, viewOptions);

            Assert.IsNotNull(recipientView);

            Assert.IsNotNull(recipientView.Url);
        }
        public IActionResult Create()
        {
            // Check the token with minimal buffer time.
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation
                // so it could be restarted automatically.
                // But since it should be rare to have a token issue here,
                // we'll make the user re-enter the form data after
                // authentication.
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1: Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  //represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; //represents your {ACCOUNT_ID}
            var envelopeId  = RequestItemsService.EnvelopeId;

            // Step 2: Construct your API headers
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

            // Step 3: Call the eSignature REST API
            EnvelopesApi     envelopesApi = new EnvelopesApi(config);
            EnvelopeFormData results      = envelopesApi.GetFormData(accountId, envelopeId);

            ViewBag.h1          = "Get envelope tab data information";
            ViewBag.message     = "Results from the Envelopes::get method:";
            ViewBag.Locals.Json = JsonConvert.SerializeObject(results, Formatting.Indented);
            return(View("example_done"));
        }
コード例 #4
0
        public void EmbeddedConsoleTest()
        {
            try
            {
                // create draft envelope structure
                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                envDef.EmailSubject = "EmbeddedConsoleTest";

                // call login to authenticate and get default accountId
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();

                // create the Draft envelope on the DocuSign Service
                EnvelopesApi    envelopesApi = new EnvelopesApi();
                EnvelopeSummary envSummary   = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envSummary);
                Assert.IsNotNull(envSummary.EnvelopeId);

                // Start the embedded sending session
                ReturnUrlRequest urlRequest = new ReturnUrlRequest();
                urlRequest.ReturnUrl = TestConfig.DefaultReturnUrl;

                // Adding the envelopeId start sthe console with the envelope open
                ConsoleViewRequest consoleViewRequest = new ConsoleViewRequest();
                consoleViewRequest.EnvelopeId = envSummary.EnvelopeId;
                ViewUrl viewUrl = envelopesApi.CreateConsoleView(TestConfig.AccountId, consoleViewRequest);

                // Start the embedded signing session.
                System.Diagnostics.Process.Start(viewUrl.Url);
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
コード例 #5
0
        public static ViewUrl getRecipientUrl(EnvelopesApi envelopesApi, string accountId, EnvelopeDefinition envDef, string envelopeId, TemplateRole templateRole)
        {
            // set the url where you want the recipient to go once they are done signing
            // - this can be used by your app to watch the URL and detect when signing has completed (or was canceled)
            var returnUrl = new RecipientViewRequest();

            //Get Config settings from App.config
            DocuSignConfig configSettings = new DocuSignConfig();

            returnUrl.ReturnUrl = configSettings.LOCAL_RETURN_URL + "pop/" + envelopeId;

            returnUrl.AuthenticationMethod = "email";

            // recipient information must match embedded recipient info we provided
            returnUrl.UserName     = templateRole.Name;
            returnUrl.Email        = templateRole.Email;
            returnUrl.ClientUserId = templateRole.ClientUserId;

            RecipientViewRequest recipipentViewRequest = new RecipientViewRequest();
            ViewUrl viewUrl = new ViewUrl();

            viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, returnUrl);
            return(viewUrl);
        }
コード例 #6
0
        public EnvelopeSummary SendDocument(int personType, string clientName, string clientEmail, string brokerName, string brokerEmail, string recipientSubject, string recipientBodyMessage)
        {
            var accountId = Credentials.AccountId;

            Template = new DocuSignTemplate(accountId, personType, clientName, clientEmail, brokerName, brokerEmail);

            var templateId    = Template.TemplateId;
            var templateRoles = Template.TemplateRoles;

            // create a new envelope which we will use to send the signature request
            var envelope = new EnvelopeDefinition
            {
                EmailSubject  = recipientSubject,
                EmailBlurb    = recipientBodyMessage,
                TemplateId    = templateId,
                TemplateRoles = templateRoles,
                Status        = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi = new EnvelopesApi();

            return(envelopesApi.CreateEnvelope(accountId, envelope));
        }
コード例 #7
0
        // ***DS.snippet.0.start
        private string DoWork(string signerEmail, string signerName, string ccEmail,
                              string ccName, string accessToken, string basePath,
                              string accountId, string item, string quantity, string dsReturnUrl)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // item
            // quantity
            // accessToken
            // basePath
            // accountId
            // dsReturnUrl
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi envelopesApi = new EnvelopesApi(config);

            // Step 1. Make the envelope request body
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, item, quantity);

            // Step 2. call Envelopes::create API method
            // Exceptions will be caught by the calling function
            EnvelopeSummary results    = envelopesApi.CreateEnvelope(accountId, envelope);
            String          envelopeId = results.EnvelopeId;

            Console.WriteLine("Envelope was created. EnvelopeId " + envelopeId);

            // Step 3. create the recipient view, the Signing Ceremony
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName, dsReturnUrl);
            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            return(results1.Url);
        }
コード例 #8
0
        /// <summary>
        /// Gets a list of all the documents for a specific envelope
        /// </summary>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="envelopeId">The required envelopeId</param>
        /// <returns>An object containing information about all the documents in the envelopes</returns>
        public static EnvelopeDocuments GetDocuments(string accessToken, string basePath, string accountId, string envelopeId)
        {
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            EnvelopesApi            envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeDocumentsResult results      = envelopesApi.ListDocuments(accountId, envelopeId);

            List <EnvelopeDocItem> envelopeDocItems = new List <EnvelopeDocItem>
            {
                new EnvelopeDocItem {
                    Name = "Combined", Type = "content", DocumentId = "combined"
                },
                new EnvelopeDocItem {
                    Name = "Zip archive", Type = "zip", DocumentId = "archive"
                }
            };

            foreach (EnvelopeDocument doc in results.EnvelopeDocuments)
            {
                envelopeDocItems.Add(new EnvelopeDocItem
                {
                    DocumentId = doc.DocumentId,
                    Name       = doc.DocumentId == "certificate" ? "Certificate of completion" : doc.Name,
                    Type       = doc.Type
                });
            }

            EnvelopeDocuments envelopeDocuments = new EnvelopeDocuments
            {
                EnvelopeId = envelopeId,
                Documents  = envelopeDocItems
            };

            return(envelopeDocuments);
        }
コード例 #9
0
        private void SendPersonalEnvelope(DocuSignApiConfiguration loginInfo,
                                          List <FieldDTO> rolesList, List <FieldDTO> fieldList, string curTemplateId, string[] names)
        {
            var          templatesApi = new TemplatesApi(loginInfo.Configuration);
            EnvelopesApi envelopesApi = new EnvelopesApi(loginInfo.Configuration);

            var template = templatesApi.ListTemplates(loginInfo.AccountId).EnvelopeTemplates.Where(x => x.Name.Contains("Personnel")).FirstOrDefault();



            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "Test message from Fr8";
            envDef.TemplateId   = template.TemplateId;


            envDef.Status = "created";

            var summ = envelopesApi.CreateEnvelope(loginInfo.AccountId, envDef);

            var recipients         = envelopesApi.ListRecipients(loginInfo.AccountId, summ.EnvelopeId);
            var recipientId        = recipients.Signers[0].RecipientId;
            var documentId         = envelopesApi.ListDocuments(loginInfo.AccountId, summ.EnvelopeId).EnvelopeDocuments[0].DocumentId;
            var tabs               = envelopesApi.ListTabs(loginInfo.AccountId, summ.EnvelopeId, recipientId);
            var templateRecepients = templatesApi.ListRecipients(loginInfo.AccountId, curTemplateId);

            tabs.SignHereTabs.FirstOrDefault().RecipientId = recipientId;
            envelopesApi.UpdateTabs(loginInfo.AccountId, summ.EnvelopeId, recipientId, tabs);
            tabs.SignHereTabs = null;


            tabs.TextTabs     = new List <Text>();
            tabs.CheckboxTabs = new List <Checkbox>();

            int i = 0;


            foreach (var person in names)
            {
                var textTab1 = JsonConvert.DeserializeObject <Text>(Tab1);
                var checkBox = JsonConvert.DeserializeObject <Checkbox>(checkBox1);
                var textTab2 = JsonConvert.DeserializeObject <Text>(Tab2);

                textTab1.YPosition = UpdateHeight(textTab1.YPosition, i);
                checkBox.YPosition = UpdateHeight(checkBox.YPosition, i);
                textTab2.YPosition = UpdateHeight(textTab2.YPosition, i);
                textTab1.Value     = person;
                textTab1.TabId     = "";
                checkBox.TabId     = "";
                textTab2.TabId     = "";

                textTab1.Name     = "Name " + i;
                textTab1.TabLabel = textTab1.Name;
                checkBox.Name     = "Present " + i;
                checkBox.TabLabel = checkBox.Name;
                textTab2.Name     = "Zombies " + i;
                textTab2.TabLabel = textTab2.Name;

                textTab1.RecipientId = recipientId;
                checkBox.RecipientId = recipientId;
                textTab2.RecipientId = recipientId;

                tabs.TextTabs.Add(textTab1);
                tabs.TextTabs.Add(textTab2);
                tabs.CheckboxTabs.Add(checkBox);

                i++;
            }

            foreach (var recepient in recipients.Signers)
            {
                var    corresponding_template_recipient = templateRecepients.Signers.Where(a => a.RoutingOrder == recepient.RoutingOrder).FirstOrDefault();
                var    related_fields = rolesList.Where(a => a.Tags.Contains("recipientId:" + corresponding_template_recipient.RecipientId));
                string new_email      = related_fields.Where(a => a.Key.Contains("role email")).FirstOrDefault().Value;
                string new_name       = related_fields.Where(a => a.Key.Contains("role name")).FirstOrDefault().Value;
                recepient.Name  = string.IsNullOrEmpty(new_name) ? recepient.Name : new_name;
                recepient.Email = string.IsNullOrEmpty(new_email) ? recepient.Email : new_email;
            }

            envelopesApi.UpdateRecipients(loginInfo.AccountId, summ.EnvelopeId, recipients);

            envelopesApi.CreateTabs(loginInfo.AccountId, summ.EnvelopeId, recipientId, tabs);
            // sending an envelope
            envelopesApi.Update(loginInfo.AccountId, summ.EnvelopeId, new Envelope()
            {
                Status = "sent"
            });
        }
コード例 #10
0
        public static File SaveDocument(string envelopeId, string documentId, string documentName, object folderId)
        {
            if (string.IsNullOrEmpty(envelopeId))
            {
                throw new ArgumentNullException("envelopeId");
            }
            if (string.IsNullOrEmpty(documentId))
            {
                throw new ArgumentNullException("documentId");
            }

            var token         = DocuSignToken.GetToken();
            var account       = GetDocuSignAccount(token);
            var configuration = GetConfiguration(account, token);

            using (var fileDao = Global.DaoFactory.GetFileDao())
                using (var folderDao = Global.DaoFactory.GetFolderDao())
                {
                    if (string.IsNullOrEmpty(documentName))
                    {
                        documentName = "new.pdf";
                    }

                    Folder folder;
                    if (folderId == null ||
                        (folder = folderDao.GetFolder(folderId)) == null ||
                        folder.RootFolderType == FolderType.TRASH ||
                        !Global.GetFilesSecurity().CanCreate(folder))
                    {
                        if (Global.FolderMy != null)
                        {
                            folderId = Global.FolderMy;
                        }
                        else
                        {
                            throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
                        }
                    }

                    var file = new File
                    {
                        FolderID = folderId,
                        Comment  = FilesCommonResource.CommentCreateByDocuSign,
                        Title    = FileUtility.ReplaceFileExtension(documentName, ".pdf"),
                    };

                    var envelopesApi = new EnvelopesApi(configuration);
                    Log.Info("DocuSign webhook get stream: " + documentId);
                    using (var stream = envelopesApi.GetDocument(account.AccountId, envelopeId, documentId))
                    {
                        file.ContentLength = stream.Length;
                        file = fileDao.SaveFile(file, stream);
                    }

                    FilesMessageService.Send(file, MessageInitiator.ThirdPartyProvider, MessageAction.DocumentSignComplete, "DocuSign", file.Title);

                    FileMarker.MarkAsNew(file);

                    return(file);
                }
        }
コード例 #11
0
        private static string CreateEnvelope(string accountId, Document document, DocuSignData docuSignData, DocuSign.eSign.Client.Configuration configuration)
        {
            var eventNotification = new EventNotification
            {
                EnvelopeEvents = new List <EnvelopeEvent>
                {
                    //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Sent.ToString()},
                    //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Delivered.ToString()},
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Completed.ToString()
                    },
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Declined.ToString()
                    },
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Voided.ToString()
                    },
                },
                IncludeDocumentFields = "true",
                //RecipientEvents = new List<RecipientEvent>
                //    {
                //        new RecipientEvent {RecipientEventStatusCode = "Sent"},
                //        new RecipientEvent {RecipientEventStatusCode = "Delivered"},
                //        new RecipientEvent {RecipientEventStatusCode = "Completed"},
                //        new RecipientEvent {RecipientEventStatusCode = "Declined"},
                //        new RecipientEvent {RecipientEventStatusCode = "AuthenticationFailed"},
                //        new RecipientEvent {RecipientEventStatusCode = "AutoResponded"},
                //    },
                Url = CommonLinkUtility.GetFullAbsolutePath(DocuSignHandler.Path + "?" + FilesLinkUtility.Action + "=webhook"),
            };

            Global.Logger.Debug("DocuSign hook url: " + eventNotification.Url);

            var signers = new List <Signer>();

            docuSignData.Users.ForEach(uid =>
            {
                try
                {
                    var user = CoreContext.UserManager.GetUsers(uid);
                    signers.Add(new Signer
                    {
                        Email       = user.Email,
                        Name        = user.DisplayUserName(false),
                        RecipientId = user.ID.ToString(),
                    });
                }
                catch (Exception ex)
                {
                    Log.Error("Signer is undefined", ex);
                }
            });

            var envelopeDefinition = new EnvelopeDefinition
            {
                CustomFields = new CustomFields
                {
                    TextCustomFields = new List <TextCustomField>
                    {
                        new TextCustomField {
                            Name = UserField, Value = SecurityContext.CurrentAccount.ID.ToString()
                        },
                    }
                },
                Documents = new List <Document> {
                    document
                },
                EmailBlurb        = docuSignData.Message,
                EmailSubject      = docuSignData.Name,
                EventNotification = eventNotification,
                Recipients        = new Recipients
                {
                    Signers = signers,
                },
                Status = "created",
            };

            var envelopesApi    = new EnvelopesApi(configuration);
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            Global.Logger.Debug("DocuSign createdEnvelope: " + envelopeSummary.EnvelopeId);

            var envelopeId = envelopeSummary.EnvelopeId;
            var url        = envelopesApi.CreateSenderView(accountId, envelopeId, new ReturnUrlRequest
            {
                ReturnUrl = CommonLinkUtility.GetFullAbsolutePath(DocuSignHandler.Path + "?" + FilesLinkUtility.Action + "=redirect")
            });

            Global.Logger.Debug("DocuSign senderView: " + url.Url);

            return(url.Url);
        }
コード例 #12
0
        public ViewUrl GenerateDocument(GBME11Request getData)
        {
            string clientUserId   = "1234";
            var    docuSignClient = new DocuSignClient(this.DocuSignCredentials);
            var    accountId      = docuSignClient.AccountId;

            string RecipientId  = "1";
            string RoutingOrder = "1";
            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email        = getData.RecipientEmail,
                Name         = getData.ApplicantName,
                ClientUserId = clientUserId,
                RecipientId  = RecipientId,
                RoutingOrder = RoutingOrder,
                RoleName     = DocuSignTemplate.TemplateRoleNames.FirstOrDefault()
            };

            // Create the sign here tab (signing field on the document)
            var tabs = new List <Text> {
                new Text {
                    TabLabel = "ApplicantName", Value = getData.ApplicantName
                },
                new Text {
                    TabLabel = "ApplicantDate", Value = getData.ApplicantDate
                },
                new Text {
                    TabLabel = "SignatureDate", Value = getData.SignatureDate
                },

                new Text {
                    TabLabel = "Name", Value = getData.Name
                },
                new Text {
                    TabLabel = "PreviousName", Value = getData.PreviousName
                },

                new Text {
                    TabLabel = "LastName", Value = getData.LastName
                },
                new Text {
                    TabLabel = "FirstName", Value = getData.FirstName
                },
                new Text {
                    TabLabel = "MiddleName", Value = getData.MiddleName
                },
                new Text {
                    TabLabel = "PrvsLastName", Value = getData.PreviousLastName
                },
                new Text {
                    TabLabel = "PrvsFirstName", Value = getData.PreviousFirstName
                },
                new Text {
                    TabLabel = "SSN", Value = "xxxxxxxxx"
                },
                new Text {
                    TabLabel = "DateOfBirth", Value = getData.DateOfBirth
                },
                new Text {
                    TabLabel = "GuamLicense", Value = getData.GuamLicenseNo
                },
                new Text {
                    TabLabel = "ExpirationDate", Value = getData.ExpirationDate
                },
                new Text {
                    TabLabel = "Course1", Value = getData.Course1
                },
                new Text {
                    TabLabel = "Sponsored1", Value = getData.Sponsored1
                },
                new Text {
                    TabLabel = "Attended1", Value = getData.Attended1
                },
                new Text {
                    TabLabel = "Approved1", Value = getData.Approved1
                },
                new Text {
                    TabLabel = "Category1", Value = getData.Category1
                },
                new Text {
                    TabLabel = "CreditHour1", Value = getData.CreditHour1
                },
                new Text {
                    TabLabel = "Course2", Value = getData.Course2
                },
                new Text {
                    TabLabel = "Sponsored2", Value = getData.Sponsored2
                },
                new Text {
                    TabLabel = "Attended2", Value = getData.Attended2
                },
                new Text {
                    TabLabel = "Approved2", Value = getData.Approved2
                },
                new Text {
                    TabLabel = "Category2", Value = getData.Category2
                },
                new Text {
                    TabLabel = "CreditHour2", Value = getData.CreditHour2
                },
                new Text {
                    TabLabel = "Course3", Value = getData.Course3
                },
                new Text {
                    TabLabel = "Sponsored3", Value = getData.Sponsored3
                },
                new Text {
                    TabLabel = "Attended3", Value = getData.Attended3
                },
                new Text {
                    TabLabel = "Approved3", Value = getData.Approved3
                },
                new Text {
                    TabLabel = "Category3", Value = getData.Category3
                },
                new Text {
                    TabLabel = "CreditHour3", Value = getData.CreditHour3
                },
                new Text {
                    TabLabel = "Course4", Value = getData.Course4
                },
                new Text {
                    TabLabel = "Sponsored4", Value = getData.Sponsored4
                },
                new Text {
                    TabLabel = "Attended4", Value = getData.Attended4
                },
                new Text {
                    TabLabel = "Approved4", Value = getData.Approved4
                },
                new Text {
                    TabLabel = "Category4", Value = getData.Category4
                },
                new Text {
                    TabLabel = "CreditHour4", Value = getData.CreditHour4
                },
                new Text {
                    TabLabel = "Course5", Value = getData.Course5
                },
                new Text {
                    TabLabel = "Sponsored5", Value = getData.Sponsored5
                },
                new Text {
                    TabLabel = "Attended5", Value = getData.Attended5
                },
                new Text {
                    TabLabel = "Approved5", Value = getData.Approved5
                },
                new Text {
                    TabLabel = "Category5", Value = getData.Category5
                },
                new Text {
                    TabLabel = "CreditHour5", Value = getData.CreditHour5
                },
                new Text {
                    TabLabel = "Course6", Value = getData.Course6
                },
                new Text {
                    TabLabel = "Sponsored6", Value = getData.Sponsored6
                },
                new Text {
                    TabLabel = "Attended6", Value = getData.Attended6
                },
                new Text {
                    TabLabel = "Approved6", Value = getData.Approved6
                },
                new Text {
                    TabLabel = "Category6", Value = getData.Category6
                },
                new Text {
                    TabLabel = "CreditHour6", Value = getData.CreditHour6
                },
                new Text {
                    TabLabel = "Course7", Value = getData.Course7
                },
                new Text {
                    TabLabel = "Sponsored7", Value = getData.Sponsored7
                },
                new Text {
                    TabLabel = "Attended7", Value = getData.Attended7
                },
                new Text {
                    TabLabel = "Approved7", Value = getData.Approved7
                },
                new Text {
                    TabLabel = "Category7", Value = getData.Category7
                },
                new Text {
                    TabLabel = "CreditHour7", Value = getData.CreditHour7
                },
                new Text {
                    TabLabel = "Course8", Value = getData.Course8
                },
                new Text {
                    TabLabel = "Sponsored8", Value = getData.Sponsored8
                },
                new Text {
                    TabLabel = "Attended8", Value = getData.Attended8
                },
                new Text {
                    TabLabel = "Approved8", Value = getData.Approved8
                },
                new Text {
                    TabLabel = "Category8", Value = getData.Category8
                },
                new Text {
                    TabLabel = "CreditHour8", Value = getData.CreditHour8
                },
                new Text {
                    TabLabel = "Course9", Value = getData.Course9
                },
                new Text {
                    TabLabel = "Sponsored9", Value = getData.Sponsored9
                },
                new Text {
                    TabLabel = "Attended9", Value = getData.Attended9
                },
                new Text {
                    TabLabel = "Approved9", Value = getData.Approved9
                },
                new Text {
                    TabLabel = "Category9", Value = getData.Category9
                },
                new Text {
                    TabLabel = "CreditHour9", Value = getData.CreditHour9
                },
                new Text {
                    TabLabel = "Course10", Value = getData.Course10
                },
                new Text {
                    TabLabel = "Sponsored10", Value = getData.Sponsored10
                },
                new Text {
                    TabLabel = "Attended10", Value = getData.Attended10
                },
                new Text {
                    TabLabel = "Approved10", Value = getData.Approved10
                },
                new Text {
                    TabLabel = "Category10", Value = getData.Category10
                },
                new Text {
                    TabLabel = "CreditHour10", Value = getData.CreditHour10
                },
                new Text {
                    TabLabel = "Course11", Value = getData.Course11
                },
                new Text {
                    TabLabel = "Sponsored11", Value = getData.Sponsored11
                },
                new Text {
                    TabLabel = "Attended11", Value = getData.Attended11
                },
                new Text {
                    TabLabel = "Approved11", Value = getData.Approved11
                },
                new Text {
                    TabLabel = "Category11", Value = getData.Category11
                },
                new Text {
                    TabLabel = "CreditHour11", Value = getData.CreditHour11
                }
            };

            var radiotabs = new List <RadioGroup> {
                new RadioGroup {
                    GroupName = "RadioLicense", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioLicense, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioConvicted", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioConvicted, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioDisciplinary", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioDisciplinary, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioDrugs", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioDrugs, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioJudgements", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioJudgements, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioGeneralinfo", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioGeneralinfo, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioNarcotic", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioNarcotic, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioPhysicalHealth", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioPhysicalHealth, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioPractice", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioPractice, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioPracticeSpecialty", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioPracticeSpecialty, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioResigned", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioResigned, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioStaff", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioStaff, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioVoluntarily", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioVoluntarily, Selected = "true"
                        }
                    }
                },
                new RadioGroup {
                    GroupName = "RadioVoluntarilyResigned", Radios = new List <Radio> {
                        new Radio {
                            Value = getData.RadioVoluntarilyResigned, Selected = "true"
                        }
                    }
                }
            };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                TextTabs = tabs, RadioGroupTabs = radiotabs
            };

            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipient = new Recipients {
                Signers = new List <Signer>(signers)
            };

            var serverTemplates = new List <ServerTemplate> {
                new ServerTemplate {
                    TemplateId = "bba3f36b-cdc2-4afc-a2be-1208b0aa3eb9", Sequence = "1"
                }
            };                                                                                                                                             //// GBME21
            var serverTemplates2 = new List <ServerTemplate> {
                new ServerTemplate {
                    TemplateId = "649b1587-2481-463a-b11f-8e01a68cc120", Sequence = "2"
                }
            };                                                                                                                                              //// GBME11
            var serverTemplates3 = new List <ServerTemplate> {
                new ServerTemplate {
                    TemplateId = "09fece4a-6c0c-496f-b0a2-6bacc2c76a9f", Sequence = "3"
                }
            };                                                                                                                                              //// GBME09
            var inlineTemplates = new List <InlineTemplate> {
                new InlineTemplate {
                    Recipients = recipient, Sequence = "1"
                }
            };
            var inlineTemplates2 = new List <InlineTemplate> {
                new InlineTemplate {
                    Recipients = recipient, Sequence = "2"
                }
            };
            var inlineTemplates3 = new List <InlineTemplate> {
                new InlineTemplate {
                    Recipients = recipient, Sequence = "3"
                }
            };
            var compositeTemplates = new List <CompositeTemplate> {
                new CompositeTemplate {
                    InlineTemplates = inlineTemplates, ServerTemplates = serverTemplates
                },
                new CompositeTemplate {
                    InlineTemplates = inlineTemplates2, ServerTemplates = serverTemplates2
                },
                new CompositeTemplate {
                    InlineTemplates = inlineTemplates3, ServerTemplates = serverTemplates3
                }
            };

            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelope = new EnvelopeDefinition
            {
                EmailSubject       = this.EmailTemplate.Subject,
                EmailBlurb         = this.EmailTemplate.MessageBody,
                CompositeTemplates = compositeTemplates,
                Status             = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi    = new EnvelopesApi();
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope);

            // 3. Create Envelope Recipient View request obj
            string envelopeId = envelopeSummary.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = "http://www.docusign.com/devcenter",
                ClientUserId         = clientUserId,
                UserName             = getData.ApplicantName,
                AuthenticationMethod = "Email",
                Email = getData.RecipientEmail
            };

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

            return(viewUrl);
        }
コード例 #13
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)));
        }
コード例 #14
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);
        }
コード例 #15
0
        public IActionResult SetProfile(RecipientModel signer1, RecipientModel carbonCopy1, RecipientModel signer2, RecipientModel carbonCopy2)
        {
            // Check the minimal buffer time.
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be
                // restarted automatically. But since it should be rare to have a token issue
                // here, we'll make the user re-enter the form data after authentication.
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1. Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            // Step 2. Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            var bulkEnvelopesApi = new BulkEnvelopesApi(apiClient);

            // Construct request body
            var sendingList = this.MakeBulkSendList(signer1, carbonCopy1, signer2, carbonCopy2);

            try
            {
                // Step 3. Submit a bulk list
                var createBulkListResult = bulkEnvelopesApi.CreateBulkSendList(accountId, sendingList);


                // Step 4. Create an envelope
                var envelopeDefinition = new EnvelopeDefinition
                {
                    Documents = new List <Document>
                    {
                        new Document
                        {
                            DocumentBase64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(Config.docDocx)),
                            Name           = "Battle Plan",
                            FileExtension  = "docx",
                            DocumentId     = "1"
                        }
                    },
                    EnvelopeIdStamping = "true",
                    EmailSubject       = "Please sign this document sent from the C# SDK",
                    Status             = "created"
                };

                var envelopesApi    = new EnvelopesApi(apiClient);
                var envelopeResults = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

                // Step 5. Attach your bulk list ID to the envelope
                // Add an envelope custom field set to the value of your listId (EnvelopeCustomFields::create)
                // This Custom Field is used for tracking your Bulk Send via the Envelopes::Get method

                var fields = new CustomFields
                {
                    ListCustomFields = new List <ListCustomField> {
                    },

                    TextCustomFields = new List <TextCustomField>
                    {
                        new TextCustomField
                        {
                            Name     = "mailingListId",
                            Required = "false",
                            Show     = "false",
                            Value    = createBulkListResult.ListId //Adding the BULK_LIST_ID as an Envelope Custom Field
                        }
                    }
                };
                envelopesApi.CreateCustomFields(accountId, envelopeResults.EnvelopeId, fields);

                // Step 6. Add placeholder recipients.
                // These will be replaced by the details provided in the Bulk List uploaded during Step 3
                // Note: The name / email format used is:
                // Name: Multi Bulk Recipients::{rolename}
                // Email: MultiBulkRecipients-{rolename}@docusign.com

                var recipients = new Recipients
                {
                    Signers = new List <Signer>
                    {
                        new Signer
                        {
                            Name           = "Multi Bulk Recipient::signer",
                            Email          = "*****@*****.**",
                            RoleName       = "signer",
                            RoutingOrder   = "1",
                            Status         = "sent",
                            DeliveryMethod = "Email",
                            RecipientId    = "1",
                            RecipientType  = "signer"
                        },
                        new Signer
                        {
                            Name           = "Multi Bulk Recipient::cc",
                            Email          = "*****@*****.**",
                            RoleName       = "cc",
                            RoutingOrder   = "1",
                            Status         = "sent",
                            DeliveryMethod = "Email",
                            RecipientId    = "2",
                            RecipientType  = "cc"
                        }
                    }
                };
                envelopesApi.CreateRecipient(accountId, envelopeResults.EnvelopeId, recipients);


                //Step 7. Initiate bulk send

                var bulkRequestResult = bulkEnvelopesApi.CreateBulkSendRequest(accountId, createBulkListResult.ListId,
                                                                               new BulkSendRequest
                {
                    EnvelopeOrTemplateId =
                        envelopeResults.EnvelopeId
                });

                //Wait until all requests sent. For 2000 recipients, it can take about 1h.
                System.Threading.Thread.Sleep(5000);


                Console.WriteLine("Bulk Batch ID: " + bulkRequestResult.BatchId);

                // Step 8. Confirm successful batch send
                var status = bulkEnvelopesApi.GetBulkSendBatchStatus(accountId, bulkRequestResult.BatchId);

                ViewBag.h1      = "Bulk send envelope was successfully performed!";
                ViewBag.message = $@"Bulk request queued to {status.Queued} user lists.";
            }
            catch (Exception ex)
            {
                ViewBag.h1      = "Bulk send envelope failed.";
                ViewBag.message = $@"Bulk request failed to send. Reason: {ex}.";
            }

            return(View("example_done"));
        }
コード例 #16
0
        public void JwtBulkEnvelopesApiTest()
        {
            #region Envelope Creation - with BulkRecipient Flag
            // the document (file) we want signed
            const string SignTest1File = @"../../docs/SignTest1.pdf";

            // Read a file from disk to use as a document.
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";
            // doc.FileExtension = System.IO.Path.GetExtension(SignTest1File);

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.RecipientId     = "1";
            signer.IsBulkRecipient = "true";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            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   = "100";
            signHere.YPosition   = "100";
            signHere.ScaleValue  = ".5";
            signer.Tabs.SignHereTabs.Add(signHere);

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


            TemplateTabs templateTabs = new TemplateTabs();
            templateTabs.DateTabs = new List <Date>();

            Tabs tabs = new Tabs();
            tabs.DateTabs = new List <Date>();

            SignerAttachment signerAttachment = new SignerAttachment();
            signerAttachment.ScaleValue = "";

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "created";

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi(testConfig.ApiClient.Configuration);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(testConfig.AccountId, envDef);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
            #endregion
            var response = MockBulkRecipientsSummaryResponse();

            // update the status of the enve
            Envelope envelope = new Envelope();
            envelope.Status = "sent";

            envelopesApi.Update(testConfig.AccountId, testConfig.EnvelopeId, envelope);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.BulkRecipientsUri);
            Assert.IsNotNull(response.BulkRecipientsCount);
        }
コード例 #17
0
 public void Init()
 {
     instance = new EnvelopesApi();
 }
コード例 #18
0
        public ViewUrl GenerateDocument(GBME9Request getData)
        {
            string clientUserId   = "1234";
            var    docuSignClient = new DocuSignClient(this.DocuSignCredentials);
            var    accountId      = docuSignClient.AccountId;

            string signerEmail  = getData.RecipientEmail;
            string signerName   = "";
            string RecipientId  = "1";
            string RoutingOrder = "1";
            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                ClientUserId = clientUserId,
                RecipientId  = RecipientId,
                RoutingOrder = RoutingOrder,
                RoleName     = DocuSignTemplate.TemplateRoleNames.FirstOrDefault()
            };

            // Create the sign here tab (signing field on the document)
            var tabs = new List <Text> {
                new Text {
                    TabLabel = "LastName", Value = getData.LastName
                },
                new Text {
                    TabLabel = "FirstName", Value = getData.FirstName
                },
                new Text {
                    TabLabel = "MiddleName", Value = getData.MiddleName
                },
                new Text {
                    TabLabel = "PrvsLastName", Value = getData.PreviousLastName
                },
                new Text {
                    TabLabel = "PrvsFirstName", Value = getData.PreviousFirstName
                },
                new Text {
                    TabLabel = "SSN", Value = "xxxxxxxxx"
                },
                new Text {
                    TabLabel = "DateOfBirth", Value = getData.DateOfBirth
                },
                new Text {
                    TabLabel = "GuamLicense", Value = getData.GuamLicenseNo
                },
                new Text {
                    TabLabel = "ExpirationDate", Value = getData.ExpirationDate
                },
                new Text {
                    TabLabel = "Course1", Value = getData.Course1
                },
                new Text {
                    TabLabel = "Sponsored1", Value = getData.Sponsored1
                },
                new Text {
                    TabLabel = "Attended1", Value = getData.Attended1
                },
                new Text {
                    TabLabel = "Approved1", Value = getData.Approved1
                },
                new Text {
                    TabLabel = "Category1", Value = getData.Category1
                },
                new Text {
                    TabLabel = "CreditHour1", Value = getData.CreditHour1
                },
                new Text {
                    TabLabel = "Course2", Value = getData.Course2
                },
                new Text {
                    TabLabel = "Sponsored2", Value = getData.Sponsored2
                },
                new Text {
                    TabLabel = "Attended2", Value = getData.Attended2
                },
                new Text {
                    TabLabel = "Approved2", Value = getData.Approved2
                },
                new Text {
                    TabLabel = "Category2", Value = getData.Category2
                },
                new Text {
                    TabLabel = "CreditHour2", Value = getData.CreditHour2
                },
                new Text {
                    TabLabel = "Course3", Value = getData.Course3
                },
                new Text {
                    TabLabel = "Sponsored3", Value = getData.Sponsored3
                },
                new Text {
                    TabLabel = "Attended3", Value = getData.Attended3
                },
                new Text {
                    TabLabel = "Approved3", Value = getData.Approved3
                },
                new Text {
                    TabLabel = "Category3", Value = getData.Category3
                },
                new Text {
                    TabLabel = "CreditHour3", Value = getData.CreditHour3
                },
                new Text {
                    TabLabel = "Course4", Value = getData.Course4
                },
                new Text {
                    TabLabel = "Sponsored4", Value = getData.Sponsored4
                },
                new Text {
                    TabLabel = "Attended4", Value = getData.Attended4
                },
                new Text {
                    TabLabel = "Approved4", Value = getData.Approved4
                },
                new Text {
                    TabLabel = "Category4", Value = getData.Category4
                },
                new Text {
                    TabLabel = "CreditHour4", Value = getData.CreditHour4
                },
                new Text {
                    TabLabel = "Course5", Value = getData.Course5
                },
                new Text {
                    TabLabel = "Sponsored5", Value = getData.Sponsored5
                },
                new Text {
                    TabLabel = "Attended5", Value = getData.Attended5
                },
                new Text {
                    TabLabel = "Approved5", Value = getData.Approved5
                },
                new Text {
                    TabLabel = "Category5", Value = getData.Category5
                },
                new Text {
                    TabLabel = "CreditHour5", Value = getData.CreditHour5
                },
                new Text {
                    TabLabel = "Course6", Value = getData.Course6
                },
                new Text {
                    TabLabel = "Sponsored6", Value = getData.Sponsored6
                },
                new Text {
                    TabLabel = "Attended6", Value = getData.Attended6
                },
                new Text {
                    TabLabel = "Approved6", Value = getData.Approved6
                },
                new Text {
                    TabLabel = "Category6", Value = getData.Category6
                },
                new Text {
                    TabLabel = "CreditHour6", Value = getData.CreditHour6
                },
                new Text {
                    TabLabel = "Course7", Value = getData.Course7
                },
                new Text {
                    TabLabel = "Sponsored7", Value = getData.Sponsored7
                },
                new Text {
                    TabLabel = "Attended7", Value = getData.Attended7
                },
                new Text {
                    TabLabel = "Approved7", Value = getData.Approved7
                },
                new Text {
                    TabLabel = "Category7", Value = getData.Category7
                },
                new Text {
                    TabLabel = "CreditHour7", Value = getData.CreditHour7
                },
                new Text {
                    TabLabel = "Course8", Value = getData.Course8
                },
                new Text {
                    TabLabel = "Sponsored8", Value = getData.Sponsored8
                },
                new Text {
                    TabLabel = "Attended8", Value = getData.Attended8
                },
                new Text {
                    TabLabel = "Approved8", Value = getData.Approved8
                },
                new Text {
                    TabLabel = "Category8", Value = getData.Category8
                },
                new Text {
                    TabLabel = "CreditHour8", Value = getData.CreditHour8
                },
                new Text {
                    TabLabel = "Course9", Value = getData.Course9
                },
                new Text {
                    TabLabel = "Sponsored9", Value = getData.Sponsored9
                },
                new Text {
                    TabLabel = "Attended9", Value = getData.Attended9
                },
                new Text {
                    TabLabel = "Approved9", Value = getData.Approved9
                },
                new Text {
                    TabLabel = "Category9", Value = getData.Category9
                },
                new Text {
                    TabLabel = "CreditHour9", Value = getData.CreditHour9
                },
                new Text {
                    TabLabel = "Course10", Value = getData.Course10
                },
                new Text {
                    TabLabel = "Sponsored10", Value = getData.Sponsored10
                },
                new Text {
                    TabLabel = "Attended10", Value = getData.Attended10
                },
                new Text {
                    TabLabel = "Approved10", Value = getData.Approved10
                },
                new Text {
                    TabLabel = "Category10", Value = getData.Category10
                },
                new Text {
                    TabLabel = "CreditHour10", Value = getData.CreditHour10
                },
                new Text {
                    TabLabel = "Course11", Value = getData.Course11
                },
                new Text {
                    TabLabel = "Sponsored11", Value = getData.Sponsored11
                },
                new Text {
                    TabLabel = "Attended11", Value = getData.Attended11
                },
                new Text {
                    TabLabel = "Approved11", Value = getData.Approved11
                },
                new Text {
                    TabLabel = "Category11", Value = getData.Category11
                },
                new Text {
                    TabLabel = "CreditHour11", Value = getData.CreditHour11
                }
            };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                TextTabs = tabs
            };

            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipient = new Recipients {
                Signers = new List <Signer>(signers)
            };

            var serverTemplates = new List <ServerTemplate> {
                new ServerTemplate {
                    TemplateId = DocuSignTemplate.TemplateId, Sequence = "1"
                }
            };
            var inlineTemplates = new List <InlineTemplate> {
                new InlineTemplate {
                    Recipients = recipient, Sequence = "2"
                }
            };
            var compositeTemplates = new List <CompositeTemplate> {
                new CompositeTemplate {
                    InlineTemplates = inlineTemplates, ServerTemplates = serverTemplates
                }
            };

            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelope = new EnvelopeDefinition
            {
                EmailSubject       = this.EmailTemplate.Subject,
                EmailBlurb         = this.EmailTemplate.MessageBody,
                CompositeTemplates = compositeTemplates,
                Status             = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi    = new EnvelopesApi();
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope);

            // 3. Create Envelope Recipient View request obj
            string envelopeId = envelopeSummary.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = "http://www.docusign.com/devcenter",
                ClientUserId         = clientUserId,
                UserName             = signerName,
                AuthenticationMethod = "Email",
                Email = signerEmail
            };

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

            return(viewUrl);
        }
コード例 #19
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string serverpath     = Server.MapPath(".");
            string signerClientId = "1000";

            StreamReader sr = new StreamReader(serverpath + @"\privatekey2.txt");

            DS_PRIVATE_KEY = sr.ReadToEnd();
            sr.Close();

            ApiClient APClient = new ApiClient();

            OAuth.OAuthToken authToken = APClient.RequestJWTUserToken(DS_CLIENT_ID,
                                                                      DS_IMPERSONATED_USER_GUID,
                                                                      DS_AUTH_SERVER,
                                                                      Encoding.UTF8.GetBytes(DS_PRIVATE_KEY),
                                                                      1);

            AccessToken = authToken.access_token;

            APClient.SetOAuthBasePath(DS_AUTH_SERVER);
            OAuth.UserInfo UserInfoGet = APClient.GetUserInfo(authToken.access_token);

            AccountIDVar = UserInfoGet.Accounts[0].AccountId;
            APClient     = new ApiClient(UserInfoGet.Accounts[0].BaseUri + "/restapi");
            APClient.Configuration.AccessToken = AccessToken;

            TemplatesApi tempAPI  = new TemplatesApi(APClient.Configuration);
            var          template = tempAPI.ListTemplates(AccountIDVar).EnvelopeTemplates.First(x => x.Name == "Steady Property");

            Text LblTxtName = new Text
            {
                TabLabel = "TxtName",
                Value    = TxtName.Text
            };

            Text LblTxtEmail = new Text
            {
                TabLabel = "TxtEmail",
                Value    = TxtEmail.Text
            };

            Text LblTxtDOB = new Text
            {
                TabLabel = "TxtDOB",
                Value    = TxtDOB.Text
            };

            string GenderValue = "";

            GenderValue = RbMale.Checked ? "Male" : "Female";

            Text LblTxtGender = new Text
            {
                TabLabel = "TxtGender",
                Value    = GenderValue
            };

            Text LblTxtPhone = new Text
            {
                TabLabel = "TxtPhone",
                Value    = TxtPhone.Text
            };

            Text LblTxtAddress = new Text
            {
                TabLabel = "TxtAddress",
                Value    = TxtAddress.Text
            };

            Text LblTxtMember = new Text
            {
                TabLabel = "TxtMember",
                Value    = DropMember.Text
            };

            Tabs tabs = new Tabs
            {
                TextTabs = new List <Text> {
                    LblTxtName, LblTxtEmail, LblTxtDOB, LblTxtGender, LblTxtPhone, LblTxtAddress, LblTxtMember
                }
            };

            TemplateRole signer = new TemplateRole
            {
                Email             = TxtEmail.Text,
                Name              = TxtName.Text,
                RoleName          = "Signer1",
                ClientUserId      = signerClientId,
                EmailNotification = new RecipientEmailNotification
                {
                    EmailSubject = "Please sign the membership form",
                    EmailBody    = "Dear " + TxtName.Text + @", <br><br>Please sign the membership form and we will process your application form." +
                                   @"<br>You will recieve email confirmation within 48 hours<br><br>Thank you <br>Steady Property"
                },
                Tabs = tabs                 //Set tab values
            };

            TemplateRole cc = new TemplateRole
            {
                Email             = TxtEmail.Text,
                Name              = TxtName.Text,
                EmailNotification = new RecipientEmailNotification
                {
                    EmailSubject = "Membership registation completed",
                    EmailBody    = "Dear " + TxtName.Text + @", <br><br>We will process your application form." +
                                   @"<br>You will recieve email confirmation within 48 hours<br><br>Thank you <br>Steady Property"
                },
                RoleName = "cc"
            };

            TemplateRole radmin = new TemplateRole
            {
                Email             = "*****@*****.**",
                Name              = "Harry Tim",
                EmailNotification = new RecipientEmailNotification
                {
                    EmailSubject = "New member registraion notification",
                    EmailBody    = "Dear Admin, <br><br>New membership registration for : " + TxtName.Text +
                                   @"<br>Please process it within 48 hours<br><br>Thank you <br>Steady Property"
                },
                RoleName = "admin"
            };

            EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition
            {
                TemplateId    = "5aa70f7a-7a21-496b-9f24-ada8431cf93b",
                Status        = "Sent",
                TemplateRoles = new List <TemplateRole> {
                    signer, cc, radmin
                }
            };

            EnvelopesApi    envelopesApi = new EnvelopesApi(APClient.Configuration);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(AccountIDVar, envelopeAttributes);

            RecipientViewRequest viewRequest = new RecipientViewRequest();

            viewRequest.ReturnUrl = "https://localhost:44387/Confirm.aspx" + "?envelopeid=" + results.EnvelopeId;

            viewRequest.AuthenticationMethod = "none";

            viewRequest.Email        = TxtEmail.Text;
            viewRequest.UserName     = TxtName.Text;
            viewRequest.ClientUserId = signerClientId;

            viewRequest.PingFrequency = "600";             // seconds
            // NOTE: The pings will only be sent if the pingUrl is an HTTPS address
            viewRequest.PingUrl = "https://localhost";     // Optional setting

            ViewUrl results1 = envelopesApi.CreateRecipientView(AccountIDVar, results.EnvelopeId, viewRequest);

            Response.Redirect(results1.Url);
        }
コード例 #20
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                ViewData["results"] = $"Informações não preenchidas";

                return(new PageResult());
            }


            // Constants need to be set:
            string accessToken = config.Value.AccessToken;
            string accountId   = config.Value.AccountId;


            string signerName = EnvelopeInfo.Name;

            string signerEmail = EnvelopeInfo.Email;

            // Send envelope. Signer's request to sign is sent by email.
            // 1. Create envelope request obj
            // 2. Use the SDK to create and send the envelope

            // 1. Create envelope request object
            //    Start with the different components of the request
            //    Create the document object
            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name           = "Lorem Ipsum",
                FileExtension  = "pdf",
                DocumentId     = "1",
            };

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

            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email       = signerEmail, Name = signerName,
                RecipientId = "1", RoutingOrder = "1"
            };

            // Create the sign here tab (signing field on the document)
            SignHere signHereTab = new SignHere
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Sign Here Tab", XPosition = "195", YPosition = "147"
            };

            SignHere[] signHereTabs = new SignHere[] { signHereTab };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                SignHereTabs = new List <SignHere>(signHereTabs)
            };

            // 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 = EnvelopeInfo.AssuntoEmail,
                Documents    = new List <Document>(documents),
                Recipients   = recipients,
                Status       = "sent"
            };

            // 2. Use the SDK to create and send the envelope
            ApiClient apiClient = new ApiClient(basePath);

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

            ViewData["results"] = $"Envelope status: {results.Status}. Envelope ID: {results.EnvelopeId}";

            return(new PageResult());
        }
コード例 #21
0
        public IActionResult Create(string signerEmail, string signerName, string ccEmail, string ccName)
        {
            // Check the token with minimal buffer time
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be
                // restarted automatically. But since it should be rare to have a token issue
                // here, we'll make the user re-enter the form data after authentication
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            // The envelope will be sent first to the signer; after it is signed,
            // a copy is sent to the cc person
            //
            // Read files from a local directory
            // The reads could raise an exception if the file is not available!
            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1: Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            // Step 3: Create Tabs and CustomFields
            // Set the values for the fields in the template
            // List item
            List colorPicker = new List
            {
                Value      = "green",
                DocumentId = "1",
                PageNumber = "1",
                TabLabel   = "list"
            };

            // Checkboxes
            Checkbox ckAuthorization = new Checkbox
            {
                TabLabel = "ckAuthorization",
                Selected = "true"
            };
            Checkbox ckAgreement = new Checkbox
            {
                TabLabel = "ckAgreement",
                Selected = "true"
            };

            RadioGroup radioGroup = new RadioGroup
            {
                GroupName = "radio1",
                // You only need to provide the readio entry for the entry you're selecting
                Radios = new List <Radio> {
                    new Radio {
                        Value = "white", Selected = "true"
                    }
                }
            };

            Text includedOnTemplate = new Text
            {
                TabLabel = "text",
                Value    = "Jabberywocky!"
            };

            // We can also add a new tab (field) to the ones already in the template
            Text addedField = new Text
            {
                DocumentId = "1",
                PageNumber = "1",
                XPosition  = "280",
                YPosition  = "172",
                Font       = "helvetica",
                FontSize   = "size14",
                TabLabel   = "added text field",
                Height     = "23",
                Width      = "84",
                Required   = "false",
                Bold       = "true",
                Value      = signerName,
                Locked     = "false",
                TabId      = "name"
            };

            // Add the tabs model (including the SignHere tab) to the signer.
            // The Tabs object wants arrays of the different field/tab types
            // Tabs are set per recipient/signer
            Tabs tabs = new Tabs
            {
                CheckboxTabs = new List <Checkbox> {
                    ckAuthorization, ckAgreement
                },
                RadioGroupTabs = new List <RadioGroup> {
                    radioGroup
                },
                TextTabs = new List <Text> {
                    includedOnTemplate, addedField
                },
                ListTabs = new List <List> {
                    colorPicker
                }
            };

            // Create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            TemplateRole signer = new TemplateRole
            {
                Email        = signerEmail,
                Name         = signerName,
                RoleName     = "signer",
                ClientUserId = signerClientId, // Change the signer to be embedded
                Tabs         = tabs            //Set tab values
            };

            TemplateRole cc = new TemplateRole
            {
                Email    = ccEmail,
                Name     = ccName,
                RoleName = "cc"
            };

            // Create an envelope custom field to save our application's
            // data about the envelope
            TextCustomField customField = new TextCustomField
            {
                Name     = "app metadata item",
                Required = "false",
                Show     = "true", // Yes, include in the CoC
                Value    = "1234567"
            };

            CustomFields cf = new CustomFields
            {
                TextCustomFields = new List <TextCustomField> {
                    customField
                }
            };

            // Step 4: Create the envelope definition
            EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition
            {
                // Uses the template ID received from example 08
                TemplateId = RequestItemsService.TemplateId,
                Status     = "Sent",
                // Add the TemplateRole objects to utilize a pre-defined
                // document and signing/routing order on an envelope.
                // Template role names need to match what is available on
                // the correlated templateID or else an error will occur
                TemplateRoles = new List <TemplateRole> {
                    signer, cc
                },
                CustomFields = cf
            };

            // Step 5: Call the eSignature REST API
            var             envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelopeAttributes);

            // Step 6: Create the View Request
            RequestItemsService.EnvelopeId = results.EnvelopeId;
            RecipientViewRequest viewRequest = new RecipientViewRequest();

            // Set the URL where you want the recipient to go once they are done signing;
            // this should typically be a callback route somewhere in your app.
            // The query parameter is included as an example of how
            // to save/recover state information during the redirect to
            // the DocuSign signing ceremony. It's usually better to use
            // the session mechanism of your web framework. Query parameters
            // can be changed/spoofed very easily
            viewRequest.ReturnUrl = dsReturnUrl + "?state=123";

            // How has your app authenticated the user? In addition to your app's authentication,
            // you can include authentication steps from DocuSign; e.g., SMS authentication
            viewRequest.AuthenticationMethod = "none";

            // Recipient information must match the embedded recipient info
            // that we used to create the envelope
            viewRequest.Email        = signerEmail;
            viewRequest.UserName     = signerName;
            viewRequest.ClientUserId = signerClientId;

            // DocuSign recommends that you redirect to DocuSign for the
            // signing ceremony. There are multiple ways to save state.
            // To maintain your application's session, use the PingUrl
            // parameter. It causes the DocuSign Signing Ceremony web page
            // (not the DocuSign server) to send pings via AJAX to your app
            viewRequest.PingFrequency = "600"; // seconds
                                               // NOTE: The pings will only be sent if the pingUrl is an HTTPS address
            viewRequest.PingUrl = dsPingUrl;   // Optional setting

            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, results.EnvelopeId, viewRequest);
            //***********
            // Don't use an iframe with embedded signing requests!
            //***********
            // State can be stored/recovered using the framework's session or a
            // query parameter on the return URL (see the makeRecipientViewRequest method)
            string redirectUrl = results1.Url;

            return(Redirect(redirectUrl));
        }
コード例 #22
0
        public void GenerateDocument(string name, string email, int LastInsertID)
        {
            var docuSignClient = new ESignClient(this.ESignCredentials);
            var accountId      = docuSignClient.AccountId;

            // assign recipient to template role by setting name, email, and role name.  Note that the
            // template role name must match the placeholder role name saved in your account template.
            var templateRoles = this.DocuSignTemplate.TemplateRoleNames.Select(m => new TemplateRole
            {
                Email    = email,
                Name     = name,
                RoleName = m
            }).ToList();

            // create a new envelope which we will use to send the signature request
            var envelope = new EnvelopeDefinition
            {
                EmailSubject  = this.EmailTemplate.Subject,
                EmailBlurb    = this.EmailTemplate.MessageBody,
                TemplateId    = this.DocuSignTemplate.TemplateId,
                TemplateRoles = templateRoles,
                Status        = "sent"
            };
            //Added by MK - START

            FileStream fs = new FileStream(@"C:/Users/ue/Desktop/LIC/MoneyPack -1.pdf", FileMode.Open, FileAccess.Read);

            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, data.Length);
            //string base64 = Convert.ToBase64String(data);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = this.EmailTemplate.Subject;

            // Add a document to the envelope
            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(data);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the document
            Signer signer = new Signer();

            signer.Email       = email;
            signer.Name        = name;
            signer.RecipientId = "1";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            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   = "100";
            signHere.YPosition   = "150";
            signer.Tabs.SignHereTabs.Add(signHere);

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

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            //Added by MK - END



            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi = new EnvelopesApi();
            //var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope);
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            if (LastInsertID != 0)
            {
                string mycon;
                mycon = "server=localhost;port=3306;database=esignapp;user=root;password=sql123";
                con   = new MySql.Data.MySqlClient.MySqlConnection();
                con.ConnectionString = mycon;
                con.Open();
                string UpdateFil = "update tbl_envelope set EnvelopeId = '" + envelopeSummary.EnvelopeId + "', EnvelopeStatus = '" + envelopeSummary.Status + "' where id = '" + LastInsertID + "' ";
                MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand(UpdateFil, con);
                cmd2.ExecuteNonQuery();
            }
        }
コード例 #23
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));
        }
コード例 #24
0
        /// <summary>
        /// UploadDocuSignEnvelopeToSharePoint - uploads a COMPLETED DocuSign envelope to a Sharepoint folder named as envelopeID
        /// </summary>
        /// <param name="accountID"></param>
        /// <param name="envelopeID"></param>
        static public void UploadDocuSignEnvelopeToSharePoint(string accountID, string envelopeID)
        {
            string userId             = ConfigurationManager.AppSettings["UserId"];
            string oauthBasePath      = ConfigurationManager.AppSettings["OAuthBasePath"];
            string integratorKey      = ConfigurationManager.AppSettings["IntegratorKey"];
            string privateKeyFilename = AppContext.BaseDirectory + "PrivateKey.txt";
            string host           = ConfigurationManager.AppSettings["Host"];
            int    expiresInHours = 1;

            string siteUrl       = ConfigurationManager.AppSettings["SiteUrl"];
            string targetLibrary = ConfigurationManager.AppSettings["TargetLibrary"];
            string userName      = ConfigurationManager.AppSettings["UserName"];
            string password      = ConfigurationManager.AppSettings["Password"];

            ApiClient apiClient = new ApiClient(host);

            apiClient.ConfigureJwtAuthorizationFlow(integratorKey, userId, oauthBasePath, privateKeyFilename, expiresInHours);

            /////////////////////////////////////////////////////////////////
            // STEP 1: LOGIN API
            /////////////////////////////////////////////////////////////////
            AuthenticationApi authApi   = new AuthenticationApi(apiClient.Configuration);
            LoginInformation  loginInfo = authApi.Login();

            // find the default account for this user
            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true")
                {
                    accountID = loginAcct.AccountId;

                    string[] separatingStrings = { "/v2" };

                    // Update ApiClient with the new base url from login call
                    apiClient = new ApiClient(loginAcct.BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
                    break;
                }
            }

            /////////////////////////////////////////////////////////////////
            // STEP 2: GET DOCUMENTS API
            /////////////////////////////////////////////////////////////////

            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);
            Envelope     envInfo      = envelopesApi.GetEnvelope(accountID, envelopeID);

            if (envInfo.Status.ToLower().CompareTo("completed") == 0)
            {
                // upload all documents for accountID and envelopeID
                MemoryStream docStream = GetAllDocuments(accountID, envelopeID);
                Console.WriteLine("Uploading to SharePoint all documents for envelope {0}", envelopeID);
                string fileName = envInfo.EnvelopeId + ".pdf";
                SharePointOnlineHelper.UploadFileStreamToSharePoint(siteUrl, userName, password, targetLibrary, docStream, fileName, envelopeID, false);

                // upload Certificate of Completion for accountID and envelopeID
                Console.WriteLine("Uploading to SharePoint the Certificate Of Completion for envelope {0}", envelopeID);
                MemoryStream cocStream = GetCertificateOfCompletion(accountID, envelopeID);
                fileName = "COC_" + envInfo.EnvelopeId + ".pdf";
                SharePointOnlineHelper.UploadFileStreamToSharePoint(siteUrl, userName, password, targetLibrary, cocStream, fileName, envelopeID, false);
            }
            else
            {
                Console.WriteLine("Download DocuSign documents can be performed only for COMPLETED envelopes.");
            }
        }
コード例 #25
0
        public async Task <IActionResult> OnPostAsync()
        {
            // Embedded Signing Ceremony
            // 1. Create envelope request obj
            // 2. Use the SDK to create and send the envelope
            // 3. Create Envelope Recipient View request obj
            // 4. Use the SDK to obtain a Recipient View URL
            // 5. Redirect the user's browser to the URL

            // 1. Create envelope request object
            //    Start with the different components of the request
            //    Create the document object
            EmbeddedSigning pageInfo = new EmbeddedSigning
            {
                signerName    = "Tanny Ng",
                signerEmail   = "*****@*****.**",
                signerId      = "1000",
                signerRouting = "1",
                accessToken   = "eyJ0eXAiOiJNVCIsImFsZyI6IlJTMjU2Iiwia2lkIjoiNjgxODVmZjEtNGU1MS00Y2U5LWFmMWMtNjg5ODEyMjAzMzE3In0.AQoAAAABAAUABwCALdLYwezWSAgAgG315gTt1kgCAC5WseC6Pj1BpkJ7B9-e_VQVAAEAAAAYAAkAAAAFAAAAKwAAAC0AAAAvAAAAMQAAADIAAAA4AAAAMwAAADUAAAANACQAAABmMGYyN2YwZS04NTdkLTRhNzEtYTRkYS0zMmNlY2FlM2E5NzgSAAEAAAALAAAAaW50ZXJhY3RpdmUwAIAAodfB7NZINwDkybNa7LwrS5p6OhdY9kFz.LHHS7H4GTayO31-USuesGb--00NMcrOqO0KnzoKMhM55ClXR2vw2OzKShqI3yhIjHc0CyGoyOtNrEW0MN0o8rRZuctb5hNtR9RAtbuNZ-hITpjyL9LBFZWxV91dYAmlgrBAcM2LtrZTWHolkqGLUNQMpD_vI8BqqT3UEO9zBL5OUz4WwSZgBoCmdejMVq-zOq-ALPpD6YoX0HoHiZHVl4_DTwTiJ_lB6I3z72fh3-i6f7iD_kaJyc2nA5jAtRXVGvX_gNUPhA4aDIZ8tJ8TTZW9hbgQ2BkFlwm69xqvRjMUuQlg6xnfW7vlvtI6tQ7GAUlVhQS5KX9FveUDYogidQw"
            };

            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name           = "Petition Sample", FileExtension = "pdf", DocumentId = docId
            };

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

            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email        = pageInfo.signerEmail,
                Name         = pageInfo.signerName,
                ClientUserId = pageInfo.signerId,
                RecipientId  = pageInfo.signerId,
                RoutingOrder = pageInfo.signerRouting
            };

            // Create the sign here tab (signing field on the document)
            SignHere signHereTab = new SignHere
            {
                DocumentId  = docId,
                PageNumber  = "1",
                RecipientId = pageInfo.signerId,
                TabLabel    = "Sign Here Tab",
                XPosition   = "195",
                YPosition   = "147"
            };

            SignHere[] signHereTabs = new SignHere[] { signHereTab };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                SignHereTabs = new List <SignHere>(signHereTabs)
            };
            // 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
            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + pageInfo.accessToken);
            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 = pageInfo.signerId,
                AuthenticationMethod = "none",
                UserName             = pageInfo.signerName, Email = pageInfo.signerEmail
            };

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

            // 5. Redirect the user's browser to the URL
            return(Redirect(viewUrl.Url));
        }
コード例 #26
0
        static void Main(string[] args)
        {
            // Enter your DocuSign credentials
            string Username      = "******";
            string Password      = "******";
            string IntegratorKey = "[INTEGRATOR_KEY]";

            // specify the document (file) we want signed
            string SignTest1File = @"[PATH/TO/DOCUMENT/TEST.PDF]";

            // Enter recipient (signer) name and email address
            string recipientName  = "[SIGNER_NAME]";
            string recipientEmail = "[SIGNER_EMAIL]";

            // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
            string basePath = "https://demo.docusign.net/restapi";

            // instantiate a new api client
            ApiClient apiClient = new ApiClient(basePath);

            // set client in global config so we don't need to pass it to each API object
            Configuration.Default.ApiClient = apiClient;

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

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

            // we will retrieve this from the login() results
            string accountId = null;

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi();
            LoginInformation  loginInfo = authApi.Login();

            // user might be a member of multiple accounts
            accountId = loginInfo.LoginAccounts[0].AccountId;

            Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());

            // Read a file from disk to use as a document
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();

            signer.Name        = recipientName;
            signer.Email       = recipientEmail;
            signer.RecipientId = "1";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            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   = "100";
            signHere.YPosition   = "150";
            signer.Tabs.SignHereTabs.Add(signHere);

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

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            // Use the EnvelopesApi to send the signature request!
            EnvelopesApi    envelopesApi    = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Console.Read();
        }
コード例 #27
0
        /// <summary>
        /// Sends the bulk envelopes
        /// </summary>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="signer1Name"> The signer recipient's name</param>
        /// <param name="signer1Email"> The signer recipient's email</param>
        /// <param name="carbonCopy1Name">The cc recipient's name</param>
        /// <param name="signer1Email"> The cc recipient's email</param>
        /// <param name="signer2Name"> The signers recipient's name</param>
        /// <param name="signer2Email"> The signers recipient's email</param>
        /// <param name="carbonCopy2Name">The cc recipient's name</param>
        /// <param name="signer2Email"> The cc recipient's email</param>
        /// <param name="docDocx">The document</param>
        /// <returns>The status of sending</returns>
        public static BulkEnvelopeStatus GetStatus(string signer1Name, string signer1Email, string carbonCopy1Name, string carbonCopy1Email, string signer2Name, string signer2Email, string carbonCopy2Name, string carbonCopy2Email, string accessToken, string basePath, string accountId, string docDocx, string envelopeIdStamping, string emailSubject)
        {
            // Step 1. Construct your API headers
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

            var bulkEnvelopesApi = new BulkEnvelopesApi(config);

            // Construct request body
            var sendingList = MakeBulkSendList(signer1Name, signer1Email, carbonCopy1Name, carbonCopy1Email, signer2Name, signer2Email, carbonCopy2Name, carbonCopy2Email);


            // Step 2. Submit a bulk list
            var createBulkListResult = bulkEnvelopesApi.CreateBulkSendList(accountId, sendingList);


            // Step 3. Create an envelope
            var envelopeDefinition = new EnvelopeDefinition
            {
                Documents = new List <Document>
                {
                    new Document
                    {
                        DocumentBase64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(docDocx)),
                        Name           = "Battle Plan",
                        FileExtension  = "docx",
                        DocumentId     = "1"
                    }
                },
                EnvelopeIdStamping = envelopeIdStamping,
                EmailSubject       = emailSubject,
                Status             = "created"
            };

            EnvelopesApi envelopesApi    = new EnvelopesApi(config);
            var          envelopeResults = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            // Step 4. Attach your bulk list ID to the envelope
            // Add an envelope custom field set to the value of your listId (EnvelopeCustomFields::create)
            // This Custom Field is used for tracking your Bulk Send via the Envelopes::Get method

            var fields = new CustomFields
            {
                ListCustomFields = new List <ListCustomField> {
                },

                TextCustomFields = new List <TextCustomField>
                {
                    new TextCustomField
                    {
                        Name     = "mailingListId",
                        Required = "false",
                        Show     = "false",
                        Value    = createBulkListResult.ListId  //Adding the BULK_LIST_ID as an Envelope Custom Field
                    }
                }
            };

            envelopesApi.CreateCustomFields(accountId, envelopeResults.EnvelopeId, fields);

            // Step 5. Add placeholder recipients.
            // These will be replaced by the details provided in the Bulk List uploaded during Step 2
            // Note: The name / email format used is:
            // Name: Multi Bulk Recipients::{rolename}
            // Email: MultiBulkRecipients-{rolename}@docusign.com

            var recipients = new Recipients
            {
                Signers = new List <Signer>
                {
                    new Signer
                    {
                        Name           = "Multi Bulk Recipient::signer",
                        Email          = "*****@*****.**",
                        RoleName       = "signer",
                        RoutingOrder   = "1",
                        Status         = "sent",
                        DeliveryMethod = "Email",
                        RecipientId    = "1",
                        RecipientType  = "signer"
                    },
                    new Signer
                    {
                        Name           = "Multi Bulk Recipient::cc",
                        Email          = "*****@*****.**",
                        RoleName       = "cc",
                        RoutingOrder   = "1",
                        Status         = "sent",
                        DeliveryMethod = "Email",
                        RecipientId    = "2",
                        RecipientType  = "cc"
                    }
                }
            };

            envelopesApi.CreateRecipient(accountId, envelopeResults.EnvelopeId, recipients);

            // Step 6. Initiate bulk send
            var bulkRequestResult = bulkEnvelopesApi.CreateBulkSendRequest(accountId, createBulkListResult.ListId, new BulkSendRequest {
                EnvelopeOrTemplateId = envelopeResults.EnvelopeId
            });

            // TODO: instead of waiting 5 seconds, consider using the Asynchrnous method
            System.Threading.Thread.Sleep(5000);

            // Step 7. Confirm successful batch send
            return(bulkEnvelopesApi.Get(accountId, bulkRequestResult.BatchId));
        }
コード例 #28
0
        private DocumentModel SendDocumentAndGetUrl(DocumentSignModel model, Case caseModel, LoginAccount loginInfo, string serverPath)
        {
            var amountString = (caseModel.Transaction.Amount / 100d).ToString("C");

            var email = Guid.NewGuid() + "@twilio.com";

            string generatedPdfFilePath = pdfGenerator.GenerateDocument(caseModel.Customer.FirstName + " " + caseModel.Customer.LastName, caseModel.Transaction.Description, amountString, serverPath);

            byte[]             fileBytes = File.ReadAllBytes(generatedPdfFilePath);
            EnvelopeDefinition envDef    = new EnvelopeDefinition {
                EmailSubject = "Owl Finance: Transaction"
            };

            var documentModel = new DocumentModel();

            var documentId = model.CaseID.ToString();

            documentModel.DocumentID = documentId;
            var clientId = caseModel.Customer.ID.ToString();

            // Add a document to the envelope
            Document doc = new Document
            {
                DocumentBase64 = Convert.ToBase64String(fileBytes),
                Name           = "Case" + model.CaseID + ".pdf",
                DocumentId     = documentId
            };

            envDef.Documents = new List <Document> {
                doc
            };

            // Add a recipient to sign the documeent
            Signer signer = new Signer
            {
                Name         = model.SendTo,
                Email        = email,
                RecipientId  = "1",
                ClientUserId = clientId,
                Tabs         = new Tabs {
                    SignHereTabs = new List <SignHere>()
                }
            };

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            SignHere signHere = new SignHere
            {
                DocumentId  = documentId,
                PageNumber  = "1",
                RecipientId = "1",
                XPosition   = "40",
                YPosition   = "175"
            };

            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients {
                Signers = new List <Signer> {
                    signer
                }
            };
            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

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

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl = "https://owlfinance.azurewebsites.net/#/docusign",
                //ReturnUrl = "https://www.docusign.com/devcenter",
                ClientUserId         = clientId,
                AuthenticationMethod = "email",
                UserName             = model.SendTo,
                Email = email
            };
            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(loginInfo.AccountId, envelopeSummary.EnvelopeId,
                                                                     viewOptions);

            documentModel.SignUrl    = recipientView.Url;
            documentModel.EnvelopeID = envelopeSummary.EnvelopeId;
            documentModel.DocumentID = documentId;

            return(documentModel);
        }
コード例 #29
0
        private void JwtRequestSignatureOnDocumentTest(string status = "sent")
        {
            // the document (file) we want signed
            const string SignTest1File = @"../../docs/SignTest1.pdf";

            // Read a file from disk to use as a document.
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();

            signer.Email        = testConfig.RecipientEmail;
            signer.Name         = testConfig.RecipientName;
            signer.RecipientId  = "1";
            signer.ClientUserId = "1234";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            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   = "100";
            signHere.YPosition   = "100";
            signHere.ScaleValue  = ".5";
            signer.Tabs.SignHereTabs.Add(signHere);

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


            TemplateTabs templateTabs = new TemplateTabs();

            templateTabs.DateTabs = new List <Date>();

            Tabs tabs = new Tabs();

            tabs.DateTabs = new List <Date>();

            SignerAttachment signerAttachment = new SignerAttachment();

            signerAttachment.ScaleValue = "";

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = status;

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi(testConfig.ApiClient.Configuration);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary);
            Assert.IsNotNull(envelopeSummary.EnvelopeId);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
コード例 #30
0
        public IActionResult Create(string signerEmail, string signerName)
        {
            // Check the token with minimal buffer time
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be
                // restarted automatically. But since it should be rare to have a token issue
                // here, we'll make the user re-enter the form data after authentication
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            // The envelope will be sent first to the signer; after it is signed,
            // a copy is sent to the cc person
            //
            // Read files from a local directory
            // The reads could raise an exception if the file is not available!
            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1: Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            // Step 2: Construct your API headers
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

            // Step 3: Create Tabs and CustomFields
            SignHere signHere = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            Text textLegal = new Text
            {
                AnchorString  = "/legal/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "-9",
                AnchorXOffset = "5",
                Font          = "helvetica",
                FontSize      = "size11",
                Bold          = "true",
                Value         = signerName,
                Locked        = "false",
                TabId         = "legal_name",
                TabLabel      = "Legal name",
            };

            Text textFamiliar = new Text
            {
                AnchorString  = "/familiar/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "-9",
                AnchorXOffset = "5",
                Font          = "helvetica",
                FontSize      = "size11",
                Bold          = "true",
                Value         = signerName,
                Locked        = "false",
                TabId         = "familiar_name",
                TabLabel      = "Familiar name"
            };

            // The salary is set both as a readable number in the /salary/ text field,
            // and as a pure number in a custom field ('salary') in the envelope
            int salary = 123000;

            Text textSalary = new Text
            {
                AnchorString  = "/salary/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "-9",
                AnchorXOffset = "5",
                Font          = "helvetica",
                FontSize      = "size11",
                Bold          = "true",
                Locked        = "true",
                // Convert number to String: 'C2' sets the string
                // to currency format with two decimal places
                Value    = salary.ToString("C2"),
                TabId    = "salary",
                TabLabel = "Salary"
            };

            TextCustomField salaryCustomField = new TextCustomField
            {
                Name     = "salary",
                Required = "false",
                Show     = "true", // Yes, include in the CoC
                Value    = salary.ToString()
            };

            CustomFields cf = new CustomFields
            {
                TextCustomFields = new List <TextCustomField> {
                    salaryCustomField
                }
            };

            // Create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                RecipientId  = "1",
                RoutingOrder = "1",
                ClientUserId = signerClientId
            };

            // Add the tabs model (including the SignHere tab) to the signer.
            // The Tabs object wants arrays of the different field/tab types
            // Tabs are set per recipient/signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere
                },
                TextTabs = new List <Text> {
                    textLegal, textFamiliar, textSalary
                }
            };

            signer1.Tabs = signer1Tabs;
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                }
            };

            string doc1b64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(Config.tabsDocx));

            // Create document objects, one per document
            Document doc1 = new Document
            {
                DocumentBase64 = doc1b64,
                Name           = "Lorem Ipsum", // Can be different from actual file name
                FileExtension  = "docx",
                DocumentId     = "1"
            };

            // Step 4: Create the envelope definition
            EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition()
            {
                EnvelopeIdStamping = "true",
                EmailSubject       = "Please Sign",
                EmailBlurb         = "Sample text for email body",
                Status             = "Sent",
                Recipients         = recipients,
                CustomFields       = cf,
                Documents          = new List <Document> {
                    doc1
                }
            };

            // Step 5: Call the eSignature REST API
            EnvelopesApi    envelopesApi = new EnvelopesApi(config);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelopeAttributes);

            RequestItemsService.EnvelopeId = results.EnvelopeId;

            // Step 6: Create the View Request
            RecipientViewRequest viewRequest = new RecipientViewRequest();

            // Set the URL where you want the recipient to go once they are done signing;
            // this should typically be a callback route somewhere in your app.
            // The query parameter is included as an example of how
            // to save/recover state information during the redirect to
            // the DocuSign signing ceremony. It's usually better to use
            // the session mechanism of your web framework. Query parameters
            // can be changed/spoofed very easily
            viewRequest.ReturnUrl = dsReturnUrl + "?state=123";

            // How has your app authenticated the user? In addition to your app's authentication,
            // you can include authentication steps from DocuSign; e.g., SMS authentication
            viewRequest.AuthenticationMethod = "none";

            // Recipient information must match the embedded recipient info
            // that we used to create the envelope
            viewRequest.Email        = signerEmail;
            viewRequest.UserName     = signerName;
            viewRequest.ClientUserId = signerClientId;

            // DocuSign recommends that you redirect to DocuSign for the
            // signing ceremony. There are multiple ways to save state.
            // To maintain your application's session, use the PingUrl
            // parameter. It causes the DocuSign Signing Ceremony web page
            // (not the DocuSign server) to send pings via AJAX to your app
            viewRequest.PingFrequency = "600"; // seconds
                                               // NOTE: The pings will only be sent if the pingUrl is an HTTPS address
            viewRequest.PingUrl = dsPingUrl;   // Optional setting

            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, results.EnvelopeId, viewRequest);
            //***********
            // Don't use an iframe with embedded signing requests!
            //***********
            // State can be stored/recovered using the framework's session or a
            // query parameter on the return URL (see the makeRecipientViewRequest method)
            string redirectUrl = results1.Url;

            return(Redirect(redirectUrl));
        }