protected void Page_Load(object sender, EventArgs e)
        {
            if (!LoggedIn())
            {
                Response.Redirect("LogIn.aspx");
            }
            if (Page.IsPostBack && Request.Form["__EVENTTARGET"] != logoutCtrlName)
            {
                // Construct the envelope basics
                DocuSignAPI.Envelope envelope = new DocuSignAPI.Envelope();
                envelope.Subject    = Request.Form["subject"];
                envelope.EmailBlurb = Request.Form["emailBlurb"];
                envelope.AccountId  = Session["APIAccountId"].ToString();

                // Construct the recipients, documents and tabs
                envelope.Recipients = ConstructRecipients();
                envelope.Documents  = GetDocuments();
                envelope.Tabs       = AddTabs(envelope.Recipients.Length);
                envelope            = ProcessOptions(envelope);

                if (Request.Form["SendNow"] != null)
                {
                    //we want to send the form ASAP
                    SendNow(envelope);
                }

                else
                {
                    //edit before sending -- embedded sending
                    EmbedSending(envelope);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!LoggedIn())
            {
                Response.Redirect("LogIn.aspx");
            }
                if (Page.IsPostBack && Request.Form["__EVENTTARGET"] != logoutCtrlName)
                {
                    // Construct the envelope basics
                    DocuSignAPI.Envelope envelope = new DocuSignAPI.Envelope();
                    envelope.Subject = Request.Form["subject"];
                    envelope.EmailBlurb = Request.Form["emailBlurb"];
                    envelope.AccountId = Session["APIAccountId"].ToString();

                    // Construct the recipients, documents and tabs
                    envelope.Recipients = ConstructRecipients();
                    envelope.Documents = GetDocuments();
                    envelope.Tabs = AddTabs(envelope.Recipients.Length);
                    envelope = ProcessOptions(envelope);

                    if (Request.Form["SendNow"] != null)
                    {
                        //we want to send the form ASAP
                        SendNow(envelope);
                    }

                    else
                    {
                        //edit before sending -- embedded sending
                        EmbedSending(envelope);
                    }
                }
        }
        private DocuSignAPI.Envelope ProcessOptions(DocuSignAPI.Envelope envelope)
        {
            if (Request.Form["markup"] != null)
            {
                // Allow recipients to mark up the envelope
                envelope.AllowMarkup          = true;
                envelope.AllowMarkupSpecified = true;
            }

            if (Request.Form["enablepaper"] != null)
            {
                // Allow recipients to sign on paper (called wet signing)
                envelope.EnableWetSign          = true;
                envelope.EnableWetSignSpecified = true;
            }

            if (!String.IsNullOrEmpty(Request.Form["reminders"]))
            {
                // Set any reminders
                DateTime remind     = Convert.ToDateTime(Request.Form["reminders"]);
                int      difference = (remind - DateTime.Today).Days;

                if (envelope.Notification == null)
                {
                    envelope.Notification = new DocuSignAPI.Notification();
                }
                envelope.Notification.Reminders = new DocuSignAPI.Reminders();
                envelope.Notification.Reminders.ReminderEnabled   = true;
                envelope.Notification.Reminders.ReminderDelay     = difference.ToString();
                envelope.Notification.Reminders.ReminderFrequency = "2";
            }

            if (!String.IsNullOrEmpty(Request.Form["expiration"]))
            {
                // Set any expirations
                DateTime expire     = Convert.ToDateTime(Request.Form["expiration"]);
                int      difference = (expire - DateTime.Today).Days;

                if (envelope.Notification == null)
                {
                    envelope.Notification = new DocuSignAPI.Notification();
                }

                envelope.Notification.Expirations = new DocuSignAPI.Expirations();
                envelope.Notification.Expirations.ExpireEnabled = true;
                envelope.Notification.Expirations.ExpireAfter   = difference.ToString();
                envelope.Notification.Expirations.ExpireWarn    = (difference - 2).ToString();
            }

            return(envelope);
        }
        protected void CreateAndSend()
        {
            DocuSignAPI.EnvelopeStatus status = null;
            buttonTable.Visible = false;

            // Construct the envelope basics
            DocuSignAPI.Envelope envelope = new DocuSignAPI.Envelope();
            envelope.Subject = "DocuSign API SDK Example";
            envelope.EmailBlurb = "This envelope demonstrates embedded signing";
            envelope.AccountId = Session["APIAccountId"].ToString();

            // Create the recipient(s)
            envelope.Recipients = ConstructRecipients();

            // Add the document to the envelope
            DocuSignAPI.Document stockDocument = new DocuSignAPI.Document();
            stockDocument.PDFBytes = Resources.DocuSign_Demo__111_PDF;
            stockDocument.Name = "Demo Document";
            stockDocument.ID = "1";
            stockDocument.FileExtension = "pdf";

            envelope.Documents = new DocuSignAPI.Document[] { stockDocument };

            // Add the tabs to the envelope
            envelope.Tabs = AddTabs(envelope.Recipients.Length);

            DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy();
            try
            {
                // Send the envelope and temporarily store the status in the session
                status = client.CreateAndSendEnvelope(envelope);
                if (status.SentSpecified)
                {
                    Session["EnvelopeStatus"] = status;
                    base.AddEnvelopeID(status.EnvelopeID);

                    // Start the first signer
                    SignFirst(status);
                }
            }
            catch (Exception ex)
            {
                base.GoToErrorPage(ex.Message);
            }
        }
예제 #5
0
        protected void CreateAndSend()
        {
            DocuSignAPI.EnvelopeStatus status = null;
            buttonTable.Visible = false;

            // Construct the envelope basics
            DocuSignAPI.Envelope envelope = new DocuSignAPI.Envelope();
            envelope.Subject    = "DocuSign API SDK Example";
            envelope.EmailBlurb = "This envelope demonstrates embedded signing";
            envelope.AccountId  = Session["APIAccountId"].ToString();

            // Create the recipient(s)
            envelope.Recipients = ConstructRecipients();

            // Add the document to the envelope
            DocuSignAPI.Document stockDocument = new DocuSignAPI.Document();
            stockDocument.PDFBytes      = Resources.DocuSign_Demo__111_PDF;
            stockDocument.Name          = "Demo Document";
            stockDocument.ID            = "1";
            stockDocument.FileExtension = "pdf";

            envelope.Documents = new DocuSignAPI.Document[] { stockDocument };

            // Add the tabs to the envelope
            envelope.Tabs = AddTabs(envelope.Recipients.Length);

            DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy();
            try
            {
                // Send the envelope and temporarily store the status in the session
                status = client.CreateAndSendEnvelope(envelope);
                if (status.SentSpecified)
                {
                    Session["EnvelopeStatus"] = status;
                    base.AddEnvelopeID(status.EnvelopeID);

                    // Start the first signer
                    SignFirst(status);
                }
            }
            catch (Exception ex)
            {
                base.GoToErrorPage(ex.Message);
            }
        }
        protected void SendNow(DocuSignAPI.Envelope envelope)
        {
            DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy();
            try
            {
                // Create and send the envelope in one step
                DocuSignAPI.EnvelopeStatus status = client.CreateAndSendEnvelope(envelope);

                // If we succeeded, go to the status
                if (status.SentSpecified)
                {
                    base.AddEnvelopeID(status.EnvelopeID);
                    Response.Redirect("GetStatusAndDocs.aspx", false);
                }
            }
            catch (Exception ex)
            {
                base.GoToErrorPage(ex.Message);
            }
        }
        protected void EmbedSending(DocuSignAPI.Envelope envelope)
        {
            DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy();
            try
            {
                // Create the envelope (but don't send it!)
                DocuSignAPI.EnvelopeStatus status = client.CreateEnvelope(envelope);
                base.AddEnvelopeID(status.EnvelopeID);

                // If it created successfully, redirect to the embedded host
                if (status.Status == DocuSignAPI.EnvelopeStatusCode.Created)
                {
                    string navURL = String.Format("{0}?envelopeID={1}&accountID={2}&source=Document", "EmbeddedHost.aspx", status.EnvelopeID,
                                                  envelope.AccountId);
                    Response.Redirect(navURL, false);
                }
            }
            catch (Exception ex)
            {
                base.GoToErrorPage(ex.Message);
            }
        }