protected void EmbedSending(DocuSignAPI.TemplateReference templateReference, DocuSignAPI.EnvelopeInformation envelopeInfo, DocuSignAPI.Recipient[] recipients) { DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); try { // Create the envelope using the specified template, but don't send it (note the last parameter) DocuSignAPI.EnvelopeStatus status = client.CreateEnvelopeFromTemplates(new DocuSignAPI.TemplateReference[] { templateReference }, recipients, envelopeInfo, false); 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=Template", "EmbeddedHost.aspx", status.EnvelopeID, envelopeInfo.AccountId); Response.Redirect(navURL, false); } } catch (Exception ex) { base.GoToErrorPage(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!LoggedIn()) { Response.Redirect("LogIn.aspx"); } if (Request.Form["__EVENTTARGET"] != logoutCtrlName) { DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); string token = null; // Get the information we need from the query string string envelopeID = Request[Keys.EnvelopeId]; string accountID = Request[Keys.AccountId]; // Request the token to edit the envelope try { string retURL = Request.Url.AbsoluteUri.Replace("EmbeddedHost.aspx", "pop.html?source=document"); token = client.RequestSenderToken(envelopeID, accountID, retURL); } catch (Exception ex) { GoToErrorPage(ex.Message); } // Set the source of the iframe to point to DocuSign sendingFrame.Attributes[Keys.Source] = token; } }
protected void SignFirst(DocuSignAPI.EnvelopeStatus status) { // Create the assertion using the current time, password and demo information DocuSignAPI.RequestRecipientTokenAuthenticationAssertion assertion = new DocuSignAPI.RequestRecipientTokenAuthenticationAssertion(); assertion.AssertionID = new Guid().ToString(); assertion.AuthenticationInstant = DateTime.Now; assertion.AuthenticationMethod = DocuSignAPI.RequestRecipientTokenAuthenticationAssertionAuthenticationMethod.Password; assertion.SecurityDomain = "DocuSignSample"; DocuSignAPI.RecipientStatus recipient = status.RecipientStatuses[0]; // Construct the URLs to which the iframe will redirect upon every event DocuSignAPI.RequestRecipientTokenClientURLs urls = new DocuSignAPI.RequestRecipientTokenClientURLs(); String urlBase = Request.Url.AbsoluteUri.Replace("EmbedDocuSign.aspx", "pop.html") + "?source=embed"; urls.OnSigningComplete = urlBase + "&event=SignComplete1"; urls.OnViewingComplete = urlBase + "&event=ViewComplete1"; urls.OnCancel = urlBase + "&event=Cancel1"; urls.OnDecline = urlBase + "&event=Decline1"; urls.OnSessionTimeout = urlBase + "&event=Timeout1"; urls.OnTTLExpired = urlBase + "&event=TTLExpired1"; urls.OnIdCheckFailed = urlBase + "&event=IDCheck1"; urls.OnAccessCodeFailed = urlBase + "&event=AccessCode1"; urls.OnException = urlBase + "&event=Exception1"; DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); String token = null; try { // Request the token for a specific recipient token = client.RequestRecipientToken(status.EnvelopeID, recipient.ClientUserId, recipient.UserName, recipient.Email, assertion, urls); } catch (Exception ex) { base.GoToErrorPage(ex.Message); } // Set the signer message if (_oneSigner) { signerMessage = "Have the signer fill out the Envelope"; } else { signerMessage = "Have the first signer fill out the Envelope"; } messagediv.Visible = true; // Set the source of the iframe to the token hostiframe.Visible = true; hostiframe.Attributes["src"] = token; }
protected void OnTemplateSelect(object src, EventArgs e) { // Request the template and populate the recipient table DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); try { DocuSignAPI.EnvelopeTemplate template = client.RequestTemplate(TemplateTable.Value, false); // Populate the recipient UI AddRecipients(template.Envelope.Recipients); } catch (Exception ex) { GoToErrorPage(ex.Message); } }
protected void DownloadItem(string id) { DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); try { // Download all documents as one pdf DocuSignAPI.EnvelopePDF pdf = client.RequestPDF(id); // Write the output to the browser Response.ContentType = "Application/pdf"; Response.BinaryWrite(pdf.PDFBytes); } catch (Exception ex) { GoToErrorPage(ex.Message); } }
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 StartSigning(string userName, string clientID, string email, string envelopeID) { // Create the assertion using the current time, password and demo information DocuSignAPI.RequestRecipientTokenAuthenticationAssertion assertion = new DocuSignAPI.RequestRecipientTokenAuthenticationAssertion(); assertion.AssertionID = new Guid().ToString(); assertion.AuthenticationInstant = DateTime.Now; assertion.AuthenticationMethod = DocuSignAPI.RequestRecipientTokenAuthenticationAssertionAuthenticationMethod.Password; assertion.SecurityDomain = "DocuSignSample"; // Construct the URLs to which the iframe will redirect upon every event DocuSignAPI.RequestRecipientTokenClientURLs urls = new DocuSignAPI.RequestRecipientTokenClientURLs(); String urlBase = Request.Url.AbsoluteUri.Replace("GetStatusAndDocs.aspx", "pop.html"); urls.OnSigningComplete = urlBase + "?event=SignComplete"; urls.OnViewingComplete = urlBase + "?event=ViewComplete"; urls.OnCancel = urlBase + "?event=Cancel"; urls.OnDecline = urlBase + "?event=Decline"; urls.OnSessionTimeout = urlBase + "?event=Timeout"; urls.OnTTLExpired = urlBase + "?event=TTLExpired"; urls.OnIdCheckFailed = urlBase + "?event=IDCheck"; urls.OnAccessCodeFailed = urlBase + "?event=AccessCode"; urls.OnException = urlBase + "?event=Exception"; DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); String token = null; try { // Request the token for a specific recipient token = client.RequestRecipientToken(envelopeID, clientID, userName, email, assertion, urls); } catch (Exception ex) { base.GoToErrorPage(ex.Message); } // Set the source of the iframe to the token hostiframe.Visible = true; hostiframe.Attributes["src"] = token; }
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 LoadTemplates() { DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); DocuSignAPI.EnvelopeTemplateDefinition[] templates = null; // Load all the template the logged in user has on their account try { templates = client.RequestTemplates(Session[Keys.ApiAccountId].ToString(), true); // Add them to the drop-down select foreach (DocuSignAPI.EnvelopeTemplateDefinition template in templates) { TemplateTable.Items.Add(new ListItem("Template " + template.TemplateID + ": " + template.Name, template.TemplateID)); } } catch (Exception ex) { GoToErrorPage(ex.Message); } }
protected void SendNow(DocuSignAPI.TemplateReference templateReference, DocuSignAPI.EnvelopeInformation envelopeInfo, DocuSignAPI.Recipient[] recipients) { DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); try { // Create the envelope using the specified template, and send it (note the last parameter) DocuSignAPI.EnvelopeStatus status = client.CreateEnvelopeFromTemplates(new DocuSignAPI.TemplateReference[] { templateReference }, recipients, envelopeInfo, true); base.AddEnvelopeID(status.EnvelopeID); if (status.SentSpecified) { 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); } }
protected void GetStatuses() { DocuSignAPI.APIServiceSoapClient client = CreateAPIProxy(); DocuSignAPI.FilteredEnvelopeStatuses statuses = null; try { // Get all the envelope IDs which we have created in this session DocuSignAPI.EnvelopeStatusFilter filter = new DocuSignAPI.EnvelopeStatusFilter(); filter.AccountId = Session["APIAccountID"].ToString(); filter.EnvelopeIds = base.GetEnvelopeIDs(); if (filter.EnvelopeIds.Length > 0) { // Request all the envelope statuses based on that filter statuses = client.RequestStatusesEx(filter); CreateStatusTable(statuses); } } catch (Exception ex) { base.GoToErrorPage(ex.Message); } }