Beispiel #1
0
 public void docusign(string path, string recipientName, string recipientEmail)
 {
     try {
         ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
         Configuration.Default.ApiClient = apiClient;
         //Verify Account Details
         string accountId = loginApi(credential.UserName, credential.Password);
         // Read a file from disk to use as a document.
         byte[]             fileBytes = System.IO.File.ReadAllBytes(path);
         EnvelopeDefinition envDef    = new EnvelopeDefinition();
         envDef.EmailSubject = "Please sign this doc";
         // Add a document to the envelope
         Document doc = new Document();
         doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
         doc.Name           = Path.GetFileName(path);
         doc.DocumentId     = "1";
         envDef.Documents   = new List <Document>();
         envDef.Documents.Add(doc);
         // Add a recipient to sign the documeent
         DocuSign.eSign.Model.Signer signer = new DocuSign.eSign.Model.Signer();
         signer.Email              = recipientEmail;
         signer.Name               = recipientName;
         signer.RecipientId        = "1";
         envDef.Recipients         = new DocuSign.eSign.Model.Recipients();
         envDef.Recipients.Signers = new List <DocuSign.eSign.Model.Signer>();
         envDef.Recipients.Signers.Add(signer);
         //set envelope status to "sent" to immediately send the signature request
         envDef.Status = "sent";
         // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
         EnvelopesApi    envelopesApi    = new EnvelopesApi();
         EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
         // print the JSON response
         var result = JsonConvert.SerializeObject(envelopeSummary);
         if (result != null)
         {
             Console.WriteLine("Document sent Successfully!");
         }
         else
         {
             Console.WriteLine("Something went wrong!");
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #2
0
        public void docusign(string path, string recipientName, string recipientEmail)
        {
            //Verify Account Details
            string accountId = loginApi(credential.UserName, credential.Password);

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

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "Please Sign for Tone Tone";

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

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = Path.GetFileName(path);
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the documeent
            DocuSign.eSign.Model.Signer signer = new DocuSign.eSign.Model.Signer();
            signer.Email       = recipientEmail;
            signer.Name        = recipientName;
            signer.RecipientId = "1";

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

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

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

            // print the JSON response
            var result = JsonConvert.SerializeObject(envelopeSummary);
        }
Beispiel #3
0
        public void docusign(string path, string recipientName, string recipientEmail)
        {
            try
            {
                ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
                Configuration.Default.ApiClient = apiClient;
                //Verify Account Details
                string accountId = loginApi(credential.UserName, credential.Password);
                // Read a file from disk to use as a document.
                byte[] fileBytes = System.IO.File.ReadAllBytes(path);

                List <EnvelopeEvent> _lstEnvelopeEvents = new List <EnvelopeEvent>();
                _lstEnvelopeEvents.Add(new EnvelopeEvent()
                {
                    EnvelopeEventStatusCode = "sent"
                });
                _lstEnvelopeEvents.Add(new EnvelopeEvent()
                {
                    EnvelopeEventStatusCode = "delivered"
                });
                _lstEnvelopeEvents.Add(new EnvelopeEvent()
                {
                    EnvelopeEventStatusCode = "completed"
                });
                _lstEnvelopeEvents.Add(new EnvelopeEvent()
                {
                    EnvelopeEventStatusCode = "declined"
                });
                _lstEnvelopeEvents.Add(new EnvelopeEvent()
                {
                    EnvelopeEventStatusCode = "voided"
                });


                List <RecipientEvent> _lstRecipientEvents = new List <RecipientEvent>();
                _lstRecipientEvents.Add(new RecipientEvent()
                {
                    RecipientEventStatusCode = "Sent"
                });
                _lstRecipientEvents.Add(new RecipientEvent()
                {
                    RecipientEventStatusCode = "Delivered"
                });
                _lstRecipientEvents.Add(new RecipientEvent()
                {
                    RecipientEventStatusCode = "Completed"
                });
                _lstRecipientEvents.Add(new RecipientEvent()
                {
                    RecipientEventStatusCode = "Declined"
                });
                _lstRecipientEvents.Add(new RecipientEvent()
                {
                    RecipientEventStatusCode = "AuthenticationFailed"
                });
                _lstRecipientEvents.Add(new RecipientEvent()
                {
                    RecipientEventStatusCode = "AutoResponded"
                });


                EventNotification  _eventNotification = new EventNotification();
                EnvelopeDefinition envDef             = new EnvelopeDefinition();

                _eventNotification.Url                               = "https://docusigndemoapp.azurewebsites.net/api/DocusignDemoo/WebhookDocuSignResponse";
                _eventNotification.LoggingEnabled                    = "true";
                _eventNotification.RequireAcknowledgment             = "true";
                _eventNotification.UseSoapInterface                  = "true";
                _eventNotification.IncludeCertificateWithSoap        = "false";
                _eventNotification.SignMessageWithX509Cert           = "false";
                _eventNotification.IncludeDocuments                  = "true";
                _eventNotification.IncludeEnvelopeVoidReason         = "true";
                _eventNotification.IncludeTimeZone                   = "true";
                _eventNotification.IncludeSenderAccountAsCustomField = "true";
                _eventNotification.IncludeDocumentFields             = "true";
                _eventNotification.IncludeCertificateOfCompletion    = "true";
                _eventNotification.EnvelopeEvents                    = _lstEnvelopeEvents;
                _eventNotification.RecipientEvents                   = _lstRecipientEvents;


                envDef.EmailSubject = "Please sign this doc";
                // Add a document to the envelope
                Document doc = new Document();
                doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
                doc.Name           = Path.GetFileName(path);
                doc.DocumentId     = "1";
                envDef.Documents   = new List <Document>();
                envDef.Documents.Add(doc);
                // Add a recipient to sign the documeent
                DocuSign.eSign.Model.Signer signer = new DocuSign.eSign.Model.Signer();
                signer.Email              = recipientEmail;
                signer.Name               = recipientName;
                signer.RecipientId        = "1";
                envDef.Recipients         = new DocuSign.eSign.Model.Recipients();
                envDef.Recipients.Signers = new List <DocuSign.eSign.Model.Signer>();
                envDef.Recipients.Signers.Add(signer);

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

                // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
                EnvelopesApi    envelopesApi    = new EnvelopesApi();
                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef, null);
                // envelopesApi.Update("", "", new EnvelopesApi.UpdateOptions() { "purgeState": "documents_and_metadata_queued" });
                // EnvelopesApi.UpdateOptions obj = new EnvelopesApi.UpdateOptions();

                //envelopesApi.DeleteDocuments(accountId, envelopeSummary.EnvelopeId, envDef);
                if (envelopeSummary != null || envelopeSummary.EnvelopeId == null)
                {
                }
                // print the JSON response
                var result = JsonConvert.SerializeObject(envelopeSummary);
                if (result != null)
                {
                    // Console.WriteLine("Document sent Successfully!");
                    string successMessage = "Document sent Successfully!";
                    ViewBag.SucMessage = successMessage;
                }
                else
                {
                    //Console.WriteLine("Something went wrong!");
                    ViewBag.SucMessage = "Something went wrong!";
                }
            }
            catch (Exception ex)
            {
            }
        }