public override async Task Run() { var userDefinedFields = Storage.FirstCrateOrDefault <KeyValueListCM>(x => x.Label == UserFieldsAndRolesCrateLabel); if (userDefinedFields == null) { throw new ActivityExecutionException("Activity storage doesn't contain info about DocuSign envelope properties. This may indicate that activity was not properly configured. Try to reconfigure this activity"); } var allFields = userDefinedFields.Content.Values; var roleValues = ActivityUI.RolesFields.Select(x => new { x.Name, Value = x.TextValue }).ToDictionary(x => x.Name, x => x.Value); var fieldValues = ActivityUI.CheckBoxFields.Select(x => new { x.Name, Value = x.Selected.ToString().ToLower() }) .Concat(ActivityUI.DropDownListFields.Select(x => new { x.Name, Value = x.selectedKey })) .Concat(ActivityUI.RadioButtonGroupFields.Select(x => new { x.Name, x.Radios.FirstOrDefault(y => y.Selected)?.Value })) .Concat(ActivityUI.TextFields.Select(x => new { x.Name, Value = x.TextValue })) .ToDictionary(x => x.Name, x => x.Value); var docuSignConfiguration = DocuSignManager.SetUp(AuthorizationToken); var roleFields = allFields.Where(x => x.Tags.Contains(DocuSignConstants.DocuSignSignerTag, StringComparison.InvariantCultureIgnoreCase)).ToList(); foreach (var roleField in roleFields) { roleField.Value = roleValues[roleField.Key]; } var userFields = allFields.Where(x => x.Tags.Contains(DocuSignConstants.DocuSignTabTag)).ToList(); foreach (var userField in userFields) { userField.Value = fieldValues[userField.Key]; } DocuSignManager.SendAnEnvelopeFromTemplate(docuSignConfiguration, roleFields, userFields, SelectedTemplateId); }
public ApiResponse <DocuSignResponseModel> GetDocument(int caseID, string serverPath, string host) { try { var docusignLog = repository.Query(r => r.CaseID == caseID).FirstOrDefault(); if (docusignLog != null) { var docusignManager = new DocuSignManager(); var authInformation = new DocuSignAuthHeader { Username = settings.Docusign.UserName, Password = settings.Docusign.Password, IntegratorKey = settings.Docusign.IntegratorKey }; var responseModel = docusignManager.GetDocument(docusignLog, authInformation, serverPath, host); return(new ApiResponse <DocuSignResponseModel>(responseModel)); } throw new ArgumentException("No document found"); } catch (Exception e) { return(HandleErrorAndReturnStatus <ApiResponse <DocuSignResponseModel> >(e)); } }
private async Task FillDropdowns() { var docusignToken = JsonConvert.DeserializeObject <DocuSignAuthTokenDTO>(AuthorizationToken.Token); if (this["AccountId"] != docusignToken.AccountId) { var configuration = DocuSignManager.SetUp(AuthorizationToken); ActivityUI.TemplateSelector.selectedKey = null; ActivityUI.TemplateSelector.SelectedItem = null; ActivityUI.TemplateSelector.ListItems.Clear(); ActivityUI.TemplateSelector.ListItems.AddRange(DocuSignManager.GetTemplatesList(configuration) .Select(x => new ListItem { Key = x.Key, Value = x.Value })); ActivityUI.NotifierSelector.selectedKey = null; ActivityUI.NotifierSelector.SelectedItem = null; ActivityUI.NotifierSelector.ListItems.Clear(); ActivityUI.NotifierSelector.ListItems.AddRange((await HubCommunicator.GetActivityTemplates(Tags.Notifier, true)) .Select(x => new ListItem { Key = x.Label, Value = x.Id.ToString() })); this["AccountId"] = docusignToken.AccountId; } }
public async Task <ApiResponse <DocuSignResponseModel> > SendDocument(DocumentSignModel model, string serverPath) { var docusignManager = new DocuSignManager(); var confirmationUrl = appSettings.Get("docusign:ConfirmationUrl"); var authInformation = new DocuSignAuthHeader { Username = settings.Docusign.UserName, Password = settings.Docusign.Password, IntegratorKey = settings.Docusign.IntegratorKey }; var caseModel = caseRepository.Query(c => c.ID == model.CaseID).FirstOrDefault(); var responseModel = docusignManager.SendDocument(model, caseModel, authInformation, serverPath, confirmationUrl); var docusignLog = new DocuSignLog { CaseID = model.CaseID, DocumentID = responseModel.DocumentID, EnvelopeID = responseModel.EnvelopeID, CreatedDate = DateTime.Now }; repository.Add(docusignLog); await repository.SaveChanges(); return(new ApiResponse <DocuSignResponseModel>(responseModel)); }
private void SendDocuSignTestEnvelope(DocuSignManager docuSignManager, DocuSignApiConfiguration loginInfo, AuthorizationTokenDO authTokenDO) { var rolesList = new List <KeyValueDTO>() { new KeyValueDTO() { Tags = "recipientId:1", Key = "role name", Value = ToEmail }, new KeyValueDTO() { Tags = "recipientId:1", Key = "role email", Value = ToEmail } }; var fieldsList = new List <KeyValueDTO>() { new KeyValueDTO() { Tags = "recipientId:1", Key = "companyTabs", Value = "test" }, new KeyValueDTO() { Tags = "recipientId:1", Key = "textTabs", Value = "test" }, new KeyValueDTO() { Tags = "recipientId:1", Key = "noteTabs", Value = "test" }, new KeyValueDTO() { Tags = "recipientId:1", Key = "checkboxTabs", Value = "Radio 1" }, new KeyValueDTO() { Tags = "recipientId:1", Key = "listTabs", Value = "1" } }; docuSignManager.SendAnEnvelopeFromTemplate( loginInfo, rolesList, fieldsList, templateId ); }
public override async Task Run() { var loginInfo = DocuSignManager.SetUp(AuthorizationToken); var curTemplateId = ExtractTemplateId(); var fieldList = MapControlsToFields(); var rolesList = MapRoleControlsToFields(); SendAnEnvelope(loginInfo, rolesList, fieldList, curTemplateId); }
private Crate PackAvailableTemplates() { var conf = DocuSignManager.SetUp(AuthorizationToken); var fields = DocuSignManager.GetTemplatesList(conf); var crate = Crate.FromContent("AvailableTemplates", new KeyValueListCM(fields)); return(crate); }
public override async Task Run() { var configuration = DocuSignManager.SetUp(AuthorizationToken); var settings = GetDocusignQuery(); var folderItems = DocuSignFolders.GetFolderItems(configuration, settings); Payload.Add(Crate.FromContent(RunTimeCrateLabel, new DocuSignEnvelopeCM_v3 { Envelopes = folderItems.Select(ConvertFolderItemToDocuSignEnvelope).ToList() })); }
public override async Task Run() { var configuration = DocuSignManager.SetUp(AuthorizationToken); var settings = GetDocusignQuery(); var folderItems = DocuSignFolders.GetFolderItems(configuration, settings); foreach (var item in folderItems) { Payload.Add(Crate.FromContent(RunTimeCrateLabel, MapFolderItemToDocuSignEnvelopeCM(item))); } Success(); }
protected virtual void SendAnEnvelope(DocuSignApiConfiguration loginInfo, List <KeyValueDTO> rolesList, List <KeyValueDTO> fieldList, string curTemplateId) { try { DocuSignManager.SendAnEnvelopeFromTemplate(loginInfo, rolesList, fieldList, curTemplateId); } catch (Exception ex) { RaiseError($"Couldn't send an envelope. {ex}"); return; } Success(); }
private void FillFolderSource(string controlName) { var control = ConfigurationControls.FindByNameNested <DropDownList>(controlName); if (control != null) { var conf = DocuSignManager.SetUp(AuthorizationToken); control.ListItems = DocuSignFolders.GetFolders(conf) .Select(x => new ListItem() { Key = x.Key, Value = x.Value }) .ToList(); } }
private void LoadDocuSignTemplates() { var selectedTemplateId = SelectedTemplateId; var configuratin = DocuSignManager.SetUp(AuthorizationToken); ActivityUI.TemplateSelector.ListItems = DocuSignManager.GetTemplatesList(configuratin) .Select(x => new ListItem { Key = x.Key, Value = x.Value }) .ToList(); if (string.IsNullOrEmpty(selectedTemplateId)) { return; } ActivityUI.TemplateSelector.SelectByValue(selectedTemplateId); }
public override async Task Initialize() { var configuration = DocuSignManager.SetUp(AuthorizationToken); ActivityUI.FolderFilter.ListItems = DocuSignFolders.GetFolders(configuration) .Select(x => new ListItem { Key = x.Key, Value = x.Value }) .ToList(); ActivityUI.FolderFilter.ListItems.Insert(0, new ListItem { Key = "Any Folder", Value = string.Empty }); ActivityUI.StatusFilter.ListItems = DocuSignQuery.Statuses .Select(x => new ListItem { Key = x.Key, Value = x.Value }) .ToList(); CrateSignaller.MarkAvailableAtRuntime <DocuSignEnvelopeCM_v3>(RunTimeCrateLabel, true) .AddFields(GetEnvelopeProperties()); }
public override async Task Run() { //Get template Id var control = GetControl <DropDownList>("Available_Templates"); string selectedDocusignTemplateId = control.Value; if (selectedDocusignTemplateId == null) { RaiseError("No Template was selected at design time", ActivityErrorCode.DESIGN_TIME_DATA_MISSING); return; } var config = DocuSignManager.SetUp(AuthorizationToken); //lets download specified template from user's docusign account var downloadedTemplate = DocuSignManager.DownloadDocuSignTemplate(config, selectedDocusignTemplateId); //and add it to payload var templateCrate = CreateDocuSignTemplateCrateFromDto(downloadedTemplate); Payload.Add(templateCrate); Success(); }
private void AssertEnvelopeContents(Guid docuSignTokenId, string expectedName) { var token = Mapper.Map <AuthorizationToken>(_docuSignTestTools.GetDocuSignAuthToken(docuSignTokenId)); var configuration = new DocuSignManager().SetUp(token); //find the envelope on the Docusign Account var folderItems = DocuSignFolders.GetFolderItems(configuration, new DocuSignQuery() { Status = "sent", SearchText = expectedName }); var envelope = folderItems.FirstOrDefault(); Assert.IsNotNull(envelope, "Cannot find created Envelope in sent folder of DocuSign Account"); var envelopeApi = new EnvelopesApi(configuration.Configuration); //get the recipient that receive this sent envelope var envelopeSigner = envelopeApi.ListRecipients(configuration.AccountId, envelope.EnvelopeId).Signers.FirstOrDefault(); Assert.IsNotNull(envelopeSigner, "Envelope does not contain signer as recipient. Send_DocuSign_Envelope activity failed to provide any signers"); //get the tabs for the envelope that this recipient received var tabs = envelopeApi.ListTabs(configuration.AccountId, envelope.EnvelopeId, envelopeSigner.RecipientId); Assert.IsNotNull(tabs, "Envelope does not contain any tabs. Check for problems in DocuSignManager and HandleTemplateData"); }
protected override void SendAnEnvelope(DocuSignApiConfiguration loginInfo, List <KeyValueDTO> rolesList, List <KeyValueDTO> fieldList, string curTemplateId) { try { var documentSelector = GetControl <CrateChooser>("document_selector"); var fileCrate = documentSelector.GetValue(Payload); if (fileCrate == null) { RaiseError($"New document file wasn't found"); return; } var file_manifest = fileCrate.Get <StandardFileDescriptionCM>(); DocuSignManager.SendAnEnvelopeFromTemplate(loginInfo, rolesList, fieldList, curTemplateId, file_manifest); } catch (Exception ex) { RaiseError($"Couldn't send an envelope. {ex}"); } Success(); }
public async void Test_MonitorAllDocuSignEvents_Plan() { using (var unitOfWork = ObjectFactory.GetInstance <IUnitOfWork>()) { var testAccount = unitOfWork.UserRepository .GetQuery() .SingleOrDefault(x => x.UserName == UserAccountName); var docuSignTerminal = unitOfWork.TerminalRepository .GetQuery() .SingleOrDefault(x => x.Name == TerminalName); if (testAccount == null) { throw new ApplicationException( string.Format("No test account found with UserName = {0}", UserAccountName) ); } if (docuSignTerminal == null) { throw new ApplicationException( string.Format("No terminal found with Name = {0}", TerminalName) ); } await RecreateDefaultAuthToken(unitOfWork, testAccount, docuSignTerminal); var mtDataCountBefore = unitOfWork.MultiTenantObjectRepository .AsQueryable <DocuSignEnvelopeCM_v2>(testAccount.Id).MtCount(); int mtDataCountAfter = mtDataCountBefore; //Set up DS var token = await Authenticate(); var authToken = new AuthorizationToken() { Token = token.Token }; var authTokenDO = new AuthorizationTokenDO() { Token = token.Token }; var docuSignManager = new DocuSignManager(); var loginInfo = docuSignManager.SetUp(authToken); //let's wait 10 seconds to ensure that MADSE plan was created/activated by re-authentication await Task.Delay(MadseCreationPeriod); //send envelope SendDocuSignTestEnvelope(docuSignManager, loginInfo, authTokenDO); var stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.ElapsedMilliseconds <= MaxAwaitPeriod) { await Task.Delay(SingleAwaitPeriod); mtDataCountAfter = unitOfWork.MultiTenantObjectRepository .AsQueryable <DocuSignEnvelopeCM_v2>(testAccount.Id).MtCount(); if (mtDataCountBefore < mtDataCountAfter) { break; } } Assert.IsTrue(mtDataCountBefore < mtDataCountAfter, $"The number of MtData: ({mtDataCountAfter}) records for user {UserAccountName} remained unchanged within {MaxAwaitPeriod} miliseconds."); } }
protected async Task HandleFollowUpConfiguration() { if (Storage.Count == 0) { return; } //update docusign templates list to get if new templates were provided by DS FillDocuSignTemplateSource("target_docusign_template"); // Try to find DocuSignTemplate drop-down. var dropdownControlDTO = ConfigurationControls.FindByName("target_docusign_template"); if (dropdownControlDTO == null) { return; } // Get DocuSign Template Id var docusignTemplateId = dropdownControlDTO.Value; //Abort configuration if templateId is the same that before if (!IsNewTemplateIdChoosen(Storage, docusignTemplateId)) { return; } var conf = DocuSignManager.SetUp(AuthorizationToken); var tabsandfields = DocuSignManager.GetTemplateRecipientsTabsAndDocuSignTabs(conf, docusignTemplateId); var roles = tabsandfields.Item1.Where(a => a.Tags.Contains(DocuSignConstants.DocuSignSignerTag)); Storage.RemoveByLabel("DocuSignTemplateRolesFields"); Storage.Add("DocuSignTemplateRolesFields", new KeyValueListCM(roles)); var envelopeDataDTO = tabsandfields.Item2; var userDefinedFields = tabsandfields.Item1.Where(a => a.Tags.Contains(DocuSignConstants.DocuSignTabTag)); //check for DocuSign default template names and add advisory json var hasDefaultNames = DocuSignManager.DocuSignTemplateDefaultNames(tabsandfields.Item2); if (hasDefaultNames) { var advisoryCrate = Storage.CratesOfType <AdvisoryMessagesCM>().FirstOrDefault(); var currentAdvisoryResults = advisoryCrate == null ? new AdvisoryMessagesCM() : advisoryCrate.Content; var advisory = currentAdvisoryResults.Advisories.FirstOrDefault(x => x.Name == advisoryName); if (advisory == null) { currentAdvisoryResults.Advisories.Add(new AdvisoryMessageDTO { Name = advisoryName, Content = advisoryContent }); } else { advisory.Content = advisoryContent; } Storage.Add(Crate.FromContent("Advisories", currentAdvisoryResults)); } Storage.RemoveByLabel("DocuSignTemplateUserDefinedFields"); Storage.Add("DocuSignTemplateUserDefinedFields", new KeyValueListCM(userDefinedFields.Concat(roles))); //Create TextSource controls for ROLES var rolesMappingBehavior = new TextSourceMappingBehavior(Storage, "RolesMapping", true); rolesMappingBehavior.Clear(); rolesMappingBehavior.Append(roles.Select(x => x.Key).ToList(), "Upstream Terminal-Provided Fields", AvailabilityType.RunTime); //Create Text Source controls for TABS var textSourceFields = new List <string>(); textSourceFields = envelopeDataDTO.Where(x => x.Fr8DisplayType == ControlTypes.TextBox).Select(x => x.Name).ToList(); var mappingBehavior = new TextSourceMappingBehavior( Storage, "Mapping", true ); mappingBehavior.Clear(); mappingBehavior.Append(textSourceFields, "Upstream Terminal-Provided Fields", AvailabilityType.RunTime); //Create TextSource controls for ROLES //Create radio Button Groups var radioButtonGroupBehavior = new RadioButtonGroupMappingBehavior(Storage, "RadioGroupMapping"); radioButtonGroupBehavior.Clear(); foreach (var item in envelopeDataDTO.Where(x => x.Fr8DisplayType == ControlTypes.RadioButtonGroup).ToList()) { var radioButtonGroupDTO = item as DocuSignMultipleOptionsTabDTO; if (radioButtonGroupDTO == null) { continue; } //todo: migrate the string format for label into template radioButtonGroupBehavior.Append(radioButtonGroupDTO.Name, $"For the <strong>{radioButtonGroupDTO.Name}</strong>, use:", radioButtonGroupDTO.Items.Select(x => new RadioButtonOption() { Name = x.Value, Value = x.Value, Selected = x.Selected }).ToList()); } //create checkbox controls var checkBoxMappingBehavior = new CheckBoxMappingBehavior(Storage, "CheckBoxMapping"); checkBoxMappingBehavior.Clear(); foreach (var item in envelopeDataDTO.Where(x => x.Fr8DisplayType == ControlTypes.CheckBox).ToList()) { checkBoxMappingBehavior.Append(item.Name, item.Name); } //create dropdown controls var dropdownListMappingBehavior = new DropDownListMappingBehavior(Storage, "DropDownMapping"); dropdownListMappingBehavior.Clear(); foreach (var item in envelopeDataDTO.Where(x => x.Fr8DisplayType == ControlTypes.DropDownList).ToList()) { var dropDownListDTO = item as DocuSignMultipleOptionsTabDTO; if (dropDownListDTO == null) { continue; } dropdownListMappingBehavior.Append(dropDownListDTO.Name, $"For the <strong>{item.Name}</strong>, use:", dropDownListDTO.Items.Where(x => x.Text != string.Empty || x.Value != string.Empty).Select(x => new ListItem() { Key = string.IsNullOrEmpty(x.Value) ? x.Text : x.Value, Value = string.IsNullOrEmpty(x.Text) ? x.Value : x.Text, Selected = x.Selected, }).ToList()); } }
public override async Task FollowUp() { //Load DocuSign template again in case there are new templates available LoadDocuSignTemplates(); var selectedTemplateId = SelectedTemplateId; //If template selection is cleared we should remove existing template fields if (string.IsNullOrEmpty(selectedTemplateId)) { PreviousSelectedTemplateId = null; ActivityUI.ClearDynamicFields(); Storage.RemoveByLabel(UserFieldsAndRolesCrateLabel); return; } if (selectedTemplateId == PreviousSelectedTemplateId) { return; } ActivityUI.ClearDynamicFields(); PreviousSelectedTemplateId = selectedTemplateId; var docuSignConfiguration = DocuSignManager.SetUp(AuthorizationToken); var tabsAndFields = DocuSignManager.GetTemplateRecipientsTabsAndDocuSignTabs(docuSignConfiguration, selectedTemplateId); var roles = tabsAndFields.Item1.Where(x => x.Tags.Contains(DocuSignConstants.DocuSignSignerTag, StringComparison.InvariantCultureIgnoreCase)).ToArray(); var userDefinedFields = tabsAndFields.Item1.Where(x => x.Tags.Contains(DocuSignConstants.DocuSignTabTag)); var envelopeData = tabsAndFields.Item2.ToLookup(x => x.Fr8DisplayType); //check for DocuSign default template names and add advisory json var hasDefaultNames = DocuSignManager.DocuSignTemplateDefaultNames(tabsAndFields.Item2); if (hasDefaultNames) { var advisoryCrate = Storage.CratesOfType <AdvisoryMessagesCM>().FirstOrDefault(); var currentAdvisoryResults = advisoryCrate == null ? new AdvisoryMessagesCM() : advisoryCrate.Content; var advisory = currentAdvisoryResults.Advisories.FirstOrDefault(x => x.Name == AdvisoryName); if (advisory == null) { currentAdvisoryResults.Advisories.Add(new AdvisoryMessageDTO { Name = AdvisoryName, Content = AdvisoryContent }); } else { advisory.Content = AdvisoryContent; } Storage.Add(Crate.FromContent("Advisories", currentAdvisoryResults)); } //Add TextSource control for every DocuSign role to activity UI ActivityUI.RolesFields.AddRange(roles.Select(x => UiBuilder.CreateSpecificOrUpstreamValueChooser(x.Key, x.Key, requestUpstream: true, specificValue: x.Value))); //Add TextSrouce control for every DocuSign template text field to activity UI ActivityUI.TextFields.AddRange(envelopeData[ControlTypes.TextBox].Select(x => UiBuilder.CreateSpecificOrUpstreamValueChooser(x.Name, x.Name, requestUpstream: true, specificValue: x.Value))); //Add RadioButtonGroup with respective options for every DocuSign template radio selection field to activity UI ActivityUI.RadioButtonGroupFields.AddRange( envelopeData[ControlTypes.RadioButtonGroup] .OfType <DocuSignMultipleOptionsTabDTO>() .Select(x => new RadioButtonGroup { GroupName = x.Name, Name = x.Name, Label = $"For the <strong>{x.Name}</strong>, use:", Radios = x.Items.Select(y => new RadioButtonOption { Name = y.Value, Value = y.Value, Selected = y.Selected }) .ToList() })); //Add CheckBox for every DocuSign template yes/no field to activity UI ActivityUI.CheckBoxFields.AddRange(envelopeData[ControlTypes.CheckBox].Select(x => new CheckBox { Name = x.Name, Label = x.Name, Selected = Convert.ToBoolean(x.Value) })); //Add DropDownList for every DocuSign template list selection field to activity UI ActivityUI.DropDownListFields.AddRange( envelopeData[ControlTypes.DropDownList] .OfType <DocuSignMultipleOptionsTabDTO>() .Select(x => new DropDownList { Name = x.Name, Label = $"For the <strong>{x.Name}</strong>, use:", ListItems = x.Items.Select(y => new ListItem { Key = string.IsNullOrEmpty(y.Value) ? y.Text : y.Value, Value = string.IsNullOrEmpty(y.Text) ? y.Value : y.Text, Selected = y.Selected }) .ToList() })); Storage.ReplaceByLabel(Crate.FromContent(UserFieldsAndRolesCrateLabel, new KeyValueListCM(userDefinedFields.Concat(roles)))); }
public async Task Mail_Merge_Into_DocuSign_EndToEnd_Upstream_Values_From_Google_Check_Tabs() { // //Setup Test // await RevokeTokens(); var terminalGoogleTestTools = new Fr8.Testing.Integration.Tools.Terminals.IntegrationTestTools_terminalGoogle(this); var googleActivityTestTools = new Fr8.Testing.Integration.Tools.Activities.IntegrationTestTools_terminalGoogle(this); var googleAuthTokenId = await terminalGoogleTestTools.ExtractGoogleDefaultToken(); string spreadsheetName = Guid.NewGuid().ToString(); string spreadsheetKeyWord = Guid.NewGuid().ToString(); string worksheetName = "TestSheet"; //create new excel spreadsheet inside google and insert one row of data inside the spreadsheet //spreadsheetKeyWord is an identifier that will help up later in the test to easily identify specific envelope var tableFixtureData = FixtureData.TestStandardTableData(TestEmail, spreadsheetKeyWord); string spreadsheetId = await terminalGoogleTestTools.CreateNewSpreadsheet(googleAuthTokenId, spreadsheetName, worksheetName, tableFixtureData); // // Create solution // var parameters = await _docuSignActivitiesTestTools.CreateAndConfigure_MailMergeIntoDocuSign_Solution("Get_Google_Sheet_Data", "Get Google Sheet Data", "a439cedc-92a8-49ad-ab31-e2ee7964b468", "Fr8 Fromentum Registration Form", false); this.solution = parameters.Item1; var plan = parameters.Item2; var tokenGuid = parameters.Item3; // // configure Get_Google_Sheet_Data activity // var googleSheetActivity = this.solution.ChildrenActivities.Single(a => a.ActivityTemplate.Name.Equals("Get_Google_Sheet_Data", StringComparison.InvariantCultureIgnoreCase)); await googleActivityTestTools.ConfigureGetFromGoogleSheetActivity(googleSheetActivity, spreadsheetName, false, worksheetName); // // configure Loop activity // var loopActivity = this.solution.ChildrenActivities.Single(a => a.ActivityTemplate.Name.Equals("Loop", StringComparison.InvariantCultureIgnoreCase)); var terminalFr8CoreTools = new IntegrationTestTools_terminalFr8(this); loopActivity = await terminalFr8CoreTools.ConfigureLoopActivity(loopActivity, "Standard Table Data", "Table Generated From Google Sheet Data"); // // Configure Send DocuSign Envelope action // // // Initial Configuration // var sendEnvelopeAction = loopActivity.ChildrenActivities.Single(a => a.ActivityTemplate.Name == "Send_DocuSign_Envelope"); crateStorage = Crate.FromDto(sendEnvelopeAction.CrateStorage); var controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First(); var docuSignTemplate = controlsCrate.Content.Controls.OfType <DropDownList>().First(); docuSignTemplate.Value = "a439cedc-92a8-49ad-ab31-e2ee7964b468"; docuSignTemplate.selectedKey = "Fr8 Fromentum Registration Form"; using (var updatableStorage = Crate.GetUpdatableStorage(sendEnvelopeAction)) { updatableStorage.Remove <StandardConfigurationControlsCM>(); updatableStorage.Add(controlsCrate); } sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", sendEnvelopeAction); sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", sendEnvelopeAction); // // Follow-up Configuration // //chosen "Fr8 Fromentum Registration Form" contains 7 specific DocuSign tabs that will be configured with upstream values crateStorage = Crate.FromDto(sendEnvelopeAction.CrateStorage); controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First(); var emailField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Lead role email"); emailField.ValueSource = "upstream"; emailField.Value = "emailaddress"; emailField.selectedKey = "emailaddress"; var emailNameField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Lead role name"); emailNameField.ValueSource = "upstream"; emailNameField.Value = "name"; emailNameField.selectedKey = "name"; var phoneField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Phone (Lead)"); phoneField.ValueSource = "upstream"; phoneField.Value = "phone"; phoneField.selectedKey = "phone"; var titleField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Title (Lead)"); titleField.ValueSource = "upstream"; titleField.Value = "title"; titleField.selectedKey = "title"; var companyField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Company (Lead)"); companyField.ValueSource = "upstream"; companyField.Value = "companyname"; companyField.selectedKey = "companyname"; var radioGroup = controlsCrate.Content.Controls.OfType <RadioButtonGroup>().First(f => f.GroupName == "Registration Type (Lead)"); foreach (var radios in radioGroup.Radios) { //reset all preselected radioButtons radios.Selected = false; } var radioButton = radioGroup.Radios.FirstOrDefault(x => x.Name == "Buy 2, Get 3rd Free"); radioButton.Selected = true; var checkboxField = controlsCrate.Content.Controls.OfType <CheckBox>().First(f => f.Name == "CheckBoxFields_GovernmentEntity? (Lead)"); checkboxField.Selected = true; var dropdownField = controlsCrate.Content.Controls.OfType <DropDownList>().First(f => f.Name == "DropDownListFields_Size of Company (Lead)"); dropdownField.Value = "Medium (51-250)"; dropdownField.selectedKey = "Medium (51-250)"; using (var updatableStorage = Crate.GetUpdatableStorage(sendEnvelopeAction)) { updatableStorage.Remove <StandardConfigurationControlsCM>(); updatableStorage.Add(controlsCrate); } sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", sendEnvelopeAction); crateStorage = Crate.FromDto(sendEnvelopeAction.CrateStorage); controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First(); docuSignTemplate = controlsCrate.Content.Controls.OfType <DropDownList>().First(); Assert.AreEqual("a439cedc-92a8-49ad-ab31-e2ee7964b468", docuSignTemplate.Value, "Selected DocuSign Template did not save on Send DocuSign Envelope action."); Assert.AreEqual("Fr8 Fromentum Registration Form", docuSignTemplate.selectedKey, "Selected DocuSign Template did not save on Send DocuSign Envelope action."); // // Activate and run plan // var container = await HttpPostAsync <string, ContainerDTO>(_baseUrl + "plans/run?planId=" + plan.Id, null); Assert.AreEqual(container.State, State.Completed, "Container state is not equal to completed on Mail_Merge e2e test"); // // Assert // var authorizationTokenDO = _terminalDocuSignTestTools.GetDocuSignAuthToken(tokenGuid); var authorizationToken = new AuthorizationToken() { Token = authorizationTokenDO.Token, }; var configuration = new DocuSignManager().SetUp(authorizationToken); //find the envelope on the Docusign Account var folderItems = DocuSignFolders.GetFolderItems(configuration, new DocuSignQuery() { Status = "sent", SearchText = spreadsheetKeyWord }); var envelope = folderItems.FirstOrDefault(); Assert.IsNotNull(envelope, "Cannot find created Envelope in sent folder of DocuSign Account"); var envelopeApi = new EnvelopesApi(configuration.Configuration); //get the recipient that receive this sent envelope var envelopeSigner = envelopeApi.ListRecipients(configuration.AccountId, envelope.EnvelopeId).Signers.FirstOrDefault(); Assert.IsNotNull(envelopeSigner, "Envelope does not contain signer as recipient. Send_DocuSign_Envelope activity failed to provide any signers"); //get the tabs for the envelope that this recipient received var tabs = envelopeApi.ListTabs(configuration.AccountId, envelope.EnvelopeId, envelopeSigner.RecipientId); Assert.IsNotNull(tabs, "Envelope does not contain any tabs. Check for problems in DocuSignManager and HandleTemplateData"); //check all tabs and their values for received envelope, and compare them to those from the google sheet configured into Mail_Merge_Into_Docusign solution var titleRecipientTab = tabs.TextTabs.FirstOrDefault(x => x.TabLabel == "Title"); Assert.IsNotNull(titleRecipientTab, "Envelope does not contain Title tab. Check for problems in DocuSignManager and HandleTemplateData"); Assert.AreEqual(tableFixtureData.Table[1].Row.FirstOrDefault(x => x.Cell.Key == "title").Cell.Value, titleRecipientTab.Value, "Provided value for Title in document for recipient after finishing mail merge plan is incorrect"); var companyRecipientTab = tabs.TextTabs.FirstOrDefault(x => x.TabLabel == "Company"); Assert.IsNotNull(companyRecipientTab, "Envelope does not contain Company tab. Check for problems in DocuSignManager and HandleTemplateData"); Assert.AreEqual(tableFixtureData.Table[1].Row.FirstOrDefault(x => x.Cell.Key == "companyname").Cell.Value, companyRecipientTab.Value, "Provided value for CompanyName in document for recipient after finishing mail merge plan is incorrect"); var phoneRecipientTab = tabs.TextTabs.FirstOrDefault(x => x.TabLabel == "Phone"); Assert.IsNotNull(phoneRecipientTab, "Envelope does not contain phone tab. Check for problems in DocuSignManager and HandleTemplateData"); Assert.AreEqual(tableFixtureData.Table[1].Row.FirstOrDefault(x => x.Cell.Key == "phone").Cell.Value, phoneRecipientTab.Value, "Provided value for phone in document for recipient after finishing mail merge plan is incorrect"); var listRecipientTab = tabs.ListTabs.FirstOrDefault(x => x.TabLabel == "Size of Company"); Assert.IsNotNull(listRecipientTab, "Envelope does not contain List Tab for Size of Company tab. Check for problems in DocuSignManager and HandleTemplateData"); Assert.AreEqual("Medium (51-250)", listRecipientTab.Value, "Provided value for Size of Company(Lead) in document for recipient after finishing mail merge plan is incorrect"); var checkboxRecipientTab = tabs.CheckboxTabs.FirstOrDefault(x => x.TabLabel == "GovernmentEntity?"); Assert.IsNotNull(checkboxRecipientTab, "Envelope does not contain Checkbox for Goverment Entity tab. Check for problems in DocuSignManager and HandleTemplateData"); Assert.AreEqual("true", checkboxRecipientTab.Selected, "Provided value for GovernmentEntity? in document for recipient after finishing mail merge plan is incorrect"); var radioButtonGroupTab = tabs.RadioGroupTabs.FirstOrDefault(x => x.GroupName == "Registration Type"); Assert.IsNotNull(radioButtonGroupTab, "Envelope does not contain RadioGroup tab for registration. Check for problems in DocuSignManager and HandleTemplateData"); Assert.AreEqual("Buy 2, Get 3rd Free", radioButtonGroupTab.Radios.FirstOrDefault(x => x.Selected == "true").Value, "Provided value for Registration Type in document for recipient after finishing mail merge plan is incorrect"); // Verify that test email has been received EmailAssert.EmailReceived("*****@*****.**", "Test Message from Fr8"); // // Cleanup // //delete spreadsheet await terminalGoogleTestTools.DeleteSpreadSheet(googleAuthTokenId, spreadsheetId); // // Deactivate plan // await HttpPostAsync <string, string>(_baseUrl + "plans/deactivate?planId=" + plan.Id, null); // // Delete plan // //await HttpDeleteAsync(_baseUrl + "plans?id=" + plan.Id); }
public override async Task Run() { DocuSignEnvelopeCM_v2 envelopeStatus = null; var eventCrate = Payload.CratesOfType <EventReportCM>().FirstOrDefault()?.Get <EventReportCM>()?.EventPayload; if (eventCrate != null) { envelopeStatus = eventCrate.CrateContentsOfType <DocuSignEnvelopeCM_v2>().SingleOrDefault(); } if (envelopeStatus == null) { RequestPlanExecutionTermination("Evelope was not found in the payload."); return; } //Create run-time fields var eventFields = CreateDocuSignEventValues(envelopeStatus); //get currently selected option and its value string curSelectedOption, curSelectedValue, curSelectedTemplate; GetTemplateRecipientPickerValue(out curSelectedOption, out curSelectedValue, out curSelectedTemplate); var envelopeId = string.Empty; //retrieve envelope ID based on the selected option and its value if (!string.IsNullOrEmpty(curSelectedOption)) { switch (curSelectedOption) { case "template": //filter the incoming envelope by template value selected by the user var incomingTemplate = string.Join(",", envelopeStatus.Templates.Select(t => t.Name).ToArray()); //Dirty quick fix for FR-2858 if (string.IsNullOrEmpty(incomingTemplate)) { var manager = new DocuSignManager(); var config = manager.SetUp(AuthorizationToken); TemplatesApi api = new TemplatesApi(config.Configuration); var templateslist = api.ListTemplates(config.AccountId); if (templateslist.TotalSetSize == "0") { break; } incomingTemplate = string.Join(",", templateslist.EnvelopeTemplates.Select(a => a.Name).ToArray()); } if (incomingTemplate.Contains(curSelectedTemplate, StringComparison.InvariantCultureIgnoreCase)) { envelopeId = envelopeStatus.EnvelopeId; } else { //this event isn't about us let's stop execution RequestPlanExecutionTermination(); return; } break; case "recipient": string envelopeCurentRecipientEmail = eventFields.FirstOrDefault(a => a.Key == "CurrentRecipientEmail")?.Value; //filter incoming envelope by recipient email address specified by the user if (envelopeCurentRecipientEmail != null) { //if the incoming envelope's recipient is user specified one, get the envelope ID if (envelopeCurentRecipientEmail.Contains(curSelectedValue, StringComparison.InvariantCultureIgnoreCase)) { envelopeId = envelopeStatus.EnvelopeId; } else { //this event isn't about us let's stop execution RequestPlanExecutionTermination(); return; } } break; } } var allFields = new List <KeyValueDTO>(eventFields); if (curSelectedOption == "template") { allFields.AddRange(GetEnvelopeData(envelopeId)); allFields.Add(new KeyValueDTO("TemplateName", curSelectedTemplate)); } Payload.Add(AllFieldsCrateName, new StandardPayloadDataCM(allFields)); Success(); }