public bool checkAccountForTemplate() { bool retval = false; Signing.AccountCredentials creds = base.GetAPICredentials(); Signing.DocuSignWeb.APIServiceSoap api = Signing.Envelope.CreateApiProxy(creds); Signing.DocuSignWeb.RequestTemplatesResponse response; Signing.DocuSignWeb.RequestTemplatesRequest request = new Signing.DocuSignWeb.RequestTemplatesRequest(); request.AccountID = (string)Session["AccountID"]; request.IncludeAdvancedTemplates = true; try { response = api.RequestTemplates(request); foreach (Signing.DocuSignWeb.EnvelopeTemplateDefinition def in response.RequestTemplatesResult) { if (def.Name == "InsuranceCo Auto Insurance Application") { Session["TemplateID"] = def.TemplateID; retval = true; } } } catch (Exception excp) { base.GoToErrorPage(excp.Message); } return(retval); }
public bool uploadTemplateToAccount() { bool retval = false; Signing.AccountCredentials creds = base.GetAPICredentials(); Signing.DocuSignWeb.APIServiceSoap api = Signing.Envelope.CreateApiProxy(creds); string templateXml = System.IO.File.ReadAllText(Server.MapPath("resources/autoInsuranceApplication.dpd")); try{ // upload template Signing.DocuSignWeb.SaveTemplateResult uploadTemplateResponse = api.UploadTemplate(templateXml, (string)Session["AccountID"], false); // so, due to a bug we have to upload a template in the dpd format // and then download it from the server, which will cause it to be converted to the new format // and then upload it again so that we can use it. However, when we try to upload it we'll hit another // bug that prevents us from saving a template without an email address so we'll specify bogus email // and then update to the correct email address when we are ready to send the envelope. Signing.DocuSignWeb.EnvelopeTemplate retrievedTemplate = api.RequestTemplate(uploadTemplateResponse.TemplateID, true); // this is to work around a bug that prevents saving a template when there isn't an email address specified. retrievedTemplate.Envelope.Recipients[0].UserName = "******"; retrievedTemplate.Envelope.Recipients[0].Email = "*****@*****.**"; Signing.DocuSignWeb.SaveTemplateResult saveResult = api.SaveTemplate(retrievedTemplate); Session["TemplateID"] = saveResult.TemplateID; retval = true; } catch (Exception excp) { if (excp.Message.IndexOf("User lacks sufficient permissions") > 0) { // set local error message and stay on page lblTemplateUploadError.Text = "You do not have permissions to upload templates to this account. Please select a different account."; } else { base.GoToErrorPage(excp.Message); } } return(retval); }
public CredentialService.Account[] checkAccountsForTemplatePermissions(CredentialService.LoginResult loginResult) { List <CredentialService.Account> accountsWithTemplatesPermissions = new List <InsuranceCo.CredentialService.Account>(); Signing.AccountCredentials creds = base.GetAPICredentials(); Signing.DocuSignWeb.APIServiceSoap api = Signing.Envelope.CreateApiProxy(creds); Signing.DocuSignWeb.RequestTemplatesResponse response; Signing.DocuSignWeb.RequestTemplatesRequest request = new Signing.DocuSignWeb.RequestTemplatesRequest(); foreach (CredentialService.Account account in loginResult.Accounts) { request.AccountID = account.AccountID; request.IncludeAdvancedTemplates = true; try{ response = api.RequestTemplates(request); accountsWithTemplatesPermissions.Add(account); } catch (Exception excp) { // nada } } return(accountsWithTemplatesPermissions.ToArray()); }