private async Task <ActivityPayload> ConfigureFilterDataActivity(List <ActivityTemplateDTO> activityTemplates)
        {
            var template = activityTemplates.Single(x => x.Terminal.Name == "terminalFr8Core" && x.Name == "Test_Incoming_Data" && x.Version == "1");
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, template, order : 4);

            var crateStorage    = activity.CrateStorage;
            var configControlCM = crateStorage
                                  .CrateContentsOfType <StandardConfigurationControlsCM>()
                                  .First();
            var filterPane = (FilterPane)configControlCM.Controls.First(x => x.Name == "Selected_Filter");

            string field_name = ActivityUI.SentToSpecificRecipientOption.Selected ? "RecipientStatus" : "Status";

            var conditions = new List <FilterConditionDTO>
            {
                new FilterConditionDTO {
                    Field = field_name, Operator = "neq", Value = ActivityUI.RecipientEventSelector.Value
                }
            };

            filterPane.Value = JsonConvert.SerializeObject(new FilterDataDTO
            {
                ExecutionType = FilterExecutionType.WithFilter,
                Conditions    = conditions
            });

            return(await HubCommunicator.ConfigureActivity(activity));
        }
        private async Task <ActivityPayload> ConfigureQueryFr8Activity(List <ActivityTemplateDTO> activityTemplates)
        {
            var template = activityTemplates.Single(x => x.Terminal.Name == "terminalFr8Core" && x.Name == "Get_Data_From_Fr8_Warehouse" && x.Version == "1");
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, template, order : 3);

            var crateStorage    = activity.CrateStorage;
            var configControlCM = ActivityConfigurator.GetConfigurationControls(activity);
            var objectList      = (DropDownList)configControlCM.Controls.First(x => x.Name == "AvailableObjects");
            var selectedObject  = objectList.ListItems.Where(a => a.Key == (ActivityUI.BasedOnTemplateOption.Selected ? MT.DocuSignEnvelope_v2.GetEnumDisplayName() : MT.DocuSignRecipient.GetEnumDisplayName())).FirstOrDefault();

            if (selectedObject == null)
            {
                return(activity);
            }
            objectList.SelectByKey(selectedObject.Key);
            var queryBuilder = (QueryBuilder)configControlCM.Controls.First(c => c.Name == "QueryBuilder");
            var conditions   = new List <FilterConditionDTO>();

            if (ActivityUI.SentToSpecificRecipientOption.Selected)
            {
                conditions.Add(new FilterConditionDTO {
                    Field = "RecipientEmail", Operator = "eq", Value = ActivityUI.SpecificRecipientEmailText.Value
                });
            }

            conditions.Add(new FilterConditionDTO {
                Field = "EnvelopeId", Operator = "eq", Value = "FromPayload"
            });

            queryBuilder.Value = JsonConvert.SerializeObject(conditions);

            return(await HubCommunicator.ConfigureActivity(activity));
        }
        protected async Task <ActivityPayload> ConfigureChildActivity(ActivityPayload parent, ActivityPayload child)
        {
            var result = await HubCommunicator.ConfigureActivity(child);

            parent.ChildrenActivities.Remove(child);
            parent.ChildrenActivities.Add(result);
            return(result);
        }
        private async Task ConfigureBuildMessageActivity(List <ActivityTemplateDTO> activityTemplates)
        {
            var template = activityTemplates.Single(x => x.Terminal.Name == "terminalFr8Core" && x.Name == "Build_Message" && x.Version == "1");
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload.RootPlanNodeId.Value, template, order : 2);

            ActivityConfigurator.SetControlValue(activity, "Body", MessageBody);
            ActivityConfigurator.SetControlValue(activity, "Name", "NotificationMessage");
            await HubCommunicator.ConfigureActivity(activity);
        }
示例#5
0
        public override async Task FollowUp()
        {
            var actionUi = new ActivityUi();

            actionUi.ClonePropertiesFrom(ConfigurationControls);

            //don't add child actions until a selection is made
            if (string.IsNullOrEmpty(actionUi.FinalActionsList.Value))
            {
                return;
            }

            //Removing children activities when configuring solution after returning to Solution Introduction
            if (ActivityPayload.ChildrenActivities.Count() > 0)
            {
                ActivityPayload.ChildrenActivities.RemoveAll(a => true);
            }

            // Always use default template for solution
            const string firstTemplateName       = "Monitor_DocuSign_Envelope_Activity";
            var          monitorDocusignTemplate = await HubCommunicator.GetActivityTemplate("terminalDocuSign", firstTemplateName);

            Guid secondActivityTemplateGuid;
            ActivityTemplateDTO secondActivityTemplate;

            if (Guid.TryParse(actionUi.FinalActionsList.Value, out secondActivityTemplateGuid))
            {
                secondActivityTemplate = await HubCommunicator.GetActivityTemplate(Guid.Parse(actionUi.FinalActionsList.Value));
            }
            else
            {
                secondActivityTemplate = await GetActivityTemplateByName(actionUi.FinalActionsList.Value);
            }

            var firstActivity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, monitorDocusignTemplate);

            var secondActivity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, secondActivityTemplate, "Final activity");

            await HubCommunicator.ApplyNewToken(firstActivity.Id, Guid.Parse(AuthorizationToken.Id));

            firstActivity = await HubCommunicator.ConfigureActivity(firstActivity);

            ActivityPayload.ChildrenActivities[0] = firstActivity;

            return;
        }
        private async Task <Guid> ConfigureNotifierActivity(List <ActivityTemplateDTO> activityTemplates, int previousNotifierOrdering)
        {
            var template = activityTemplates.First(x => x.Id == NotifierActivityTemplateId);
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload.RootPlanNodeId.Value, template, order : previousNotifierOrdering);

            if (activity.ActivityTemplate.Name == "Send_Email_Via_SendGrid" && activity.ActivityTemplate.Version == "1")
            {
                //var configControls = ControlHelper.GetConfigurationControls(activity.CrateStorage);
                var emailBodyField = ActivityConfigurator.GetControl <TextSource>(activity, "EmailBody", ControlTypes.TextSource);
                emailBodyField.ValueSource = "upstream";
                emailBodyField.Value       = NotificationMessageLabel;
                emailBodyField.selectedKey = NotificationMessageLabel;
                var emailSubjectField = ActivityConfigurator.GetControl <TextSource>(activity, "EmailSubject", ControlTypes.TextSource);
                emailSubjectField.ValueSource = "specific";
                emailSubjectField.TextValue   = "Fr8 Notification Message";

                await HubCommunicator.ConfigureActivity(activity);
            }
            else if (activity.ActivityTemplate.Name == "Send_Via_Twilio" && activity.ActivityTemplate.Version == "1")
            {
                var emailBodyField = ActivityConfigurator.GetControl <TextSource>(activity, "SMS_Body", ControlTypes.TextSource);
                emailBodyField.ValueSource = "upstream";
                emailBodyField.Value       = NotificationMessageLabel;
                emailBodyField.selectedKey = NotificationMessageLabel;
            }
            else if (activity.ActivityTemplate.Name == "Publish_To_Slack" && activity.ActivityTemplate.Version == "2")
            {
                if (activity.CrateStorage.FirstCrateOrDefault <StandardAuthenticationCM>() == null)
                {
                    var messageField = ActivityConfigurator.GetControl <TextSource>(activity, "MessageSource", ControlTypes.TextSource);
                    messageField.ValueSource  = "upstream";
                    messageField.Value        = NotificationMessageLabel;
                    messageField.selectedKey  = NotificationMessageLabel;
                    messageField.SelectedItem = new FieldDTO {
                        Name = NotificationMessageLabel
                    };
                    activity = await HubCommunicator.ConfigureActivity(activity);
                }
            }
            return(activity.Id);
        }
示例#7
0
        public override async Task FollowUp()
        {
            var selectedTemplateField = GetControl <DropDownList>("Available_Templates");

            if (string.IsNullOrEmpty(selectedTemplateField.Value))
            {
                return;
            }

            var destinationFileNameField = GetControl <TextBox>("File_Name");

            if (string.IsNullOrEmpty(destinationFileNameField.Value))
            {
                return;
            }

            var getDocusignTemplate = await HubCommunicator.GetActivityTemplate("terminalDocusign", "Get_DocuSign_Template");

            var convertCratesTemplate = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Convert_Crates");

            var storeFileTemplate = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Store_File");

            var getDocuSignTemplateActivity = await CreateGetDocuSignTemplateActivity(getDocusignTemplate, ActivityPayload);

            var convertCratesActivity = await CreateConvertCratesActivity(convertCratesTemplate, ActivityPayload);

            var storeFileActivity = await CreateStoreFileActivity(storeFileTemplate, ActivityPayload);

            SetSelectedTemplate(getDocuSignTemplateActivity, selectedTemplateField);
            SetFromConversion(convertCratesActivity);
            convertCratesActivity = await HubCommunicator.ConfigureActivity(convertCratesActivity);

            SetToConversion(convertCratesActivity);
            SetFileDetails(storeFileActivity, destinationFileNameField.Value);
            //add child nodes here
            ActivityPayload.ChildrenActivities.Add(getDocuSignTemplateActivity);
            ActivityPayload.ChildrenActivities.Add(convertCratesActivity);
            ActivityPayload.ChildrenActivities.Add(storeFileActivity);
        }
        private async Task <ActivityPayload> ConfigureMonitorActivity(List <ActivityTemplateDTO> activityTemplates)
        {
            var template = activityTemplates.Single(x => x.Terminal.Name == "terminalDocuSign" && x.Name == "Monitor_DocuSign_Envelope_Activity" && x.Version == "1");
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, template, order : 1);

            await HubCommunicator.ApplyNewToken(activity.Id, Guid.Parse(AuthorizationToken.Id));

            activity = await HubCommunicator.ConfigureActivity(activity);

            ActivityConfigurator.SetControlValue(activity, "EnvelopeSent", "true");
            if (ActivityUI.SentToSpecificRecipientOption.Selected)
            {
                ActivityConfigurator.SetControlValue(activity, "TemplateRecipientPicker.recipient.RecipientValue", ActivityUI.SpecificRecipientEmailText.Value);
                ActivityConfigurator.SetControlValue(activity, "TemplateRecipientPicker.recipient", true);
                ActivityConfigurator.SetControlValue(activity, "TemplateRecipientPicker.template", false);
            }
            else if (ActivityUI.BasedOnTemplateOption.Selected)
            {
                ActivityConfigurator.SetControlValue(activity, "TemplateRecipientPicker.template.UpstreamCrate", ActivityUI.TemplateSelector.ListItems.Single(x => x.Key == ActivityUI.TemplateSelector.selectedKey));
                ActivityConfigurator.SetControlValue(activity, "TemplateRecipientPicker.recipient", false);
                ActivityConfigurator.SetControlValue(activity, "TemplateRecipientPicker.template", true);
            }
            return(await HubCommunicator.ConfigureActivity(activity));
        }
        private async Task <ActivityPayload> CreateSalesforceDataActivity(ReconfigurationContext context)
        {
            var getSalesforceDataActivityTemplate = (await HubCommunicator.GetActivityTemplates(null))
                                                    .First(x => x.Name == "Get_Data" && x.Terminal.Name == TerminalName && x.Version == "1");
            var dataSourceActivity = await HubCommunicator.AddAndConfigureChildActivity(
                context.SolutionActivity,
                getSalesforceDataActivityTemplate,
                order : 1);

            if (dataSourceActivity.CrateStorage.Where(a => a.ManifestType.Id == (int)MT.StandardAuthentication).FirstOrDefault() != null)
            {
                await HubCommunicator.ApplyNewToken(dataSourceActivity.Id, Guid.Parse(AuthorizationToken.Id));

                dataSourceActivity = await HubCommunicator.ConfigureActivity(dataSourceActivity);
            }

            //This config call will make SF Get_Data activity to load properties of the selected object (and removes filter)
            CopySolutionUiValuesToSalesforceActivity(context.SolutionActivity, dataSourceActivity);
            dataSourceActivity = await HubCommunicator.ConfigureChildActivity(context.SolutionActivity, dataSourceActivity);

            //This config call will set the proper filter value for the selected object
            CopySolutionUiValuesToSalesforceActivity(context.SolutionActivity, dataSourceActivity);
            return(await HubCommunicator.ConfigureChildActivity(context.SolutionActivity, dataSourceActivity));
        }
        public override async Task FollowUp()
        {
            var specificRecipientOption = ((RadioButtonGroup)ConfigurationControls.Controls[0]).Radios[0];
            var specificTemplateOption  = ((RadioButtonGroup)ConfigurationControls.Controls[0]).Radios[1];
            var howToBeNotifiedDdl      = (DropDownList)ConfigurationControls.FindByName("NotificationHandler");

            //let's don't add child actions to solution until how to be notified option is selected
            //FR-1873
            if (string.IsNullOrEmpty(howToBeNotifiedDdl.Value))
            {
                return;
            }
            var specificRecipient = specificRecipientOption.Controls.Single();

            if (specificRecipientOption.Selected && string.IsNullOrEmpty(specificRecipient.Value))
            {
                return;
            }

            var specificTemplate = specificTemplateOption.Controls.Single();

            if (specificTemplateOption.Selected && string.IsNullOrEmpty(specificTemplate.Value))
            {
                return;
            }

            bool hasChildren = false;

            if (ActivityPayload.ChildrenActivities.Any())
            {
                hasChildren = true;
                ActivityPayload.ChildrenActivities.Clear();
            }

            var monitorDocusignAT = await HubCommunicator.GetActivityTemplate("terminalDocuSign", "Monitor_DocuSign_Envelope_Activity");

            var setDelayAT = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Set_Delay");

            var queryFr8WareHouseAT = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Query_Fr8_Warehouse");

            var testIncomingDataAT = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Test_Incoming_Data");

            var buildMessageAT = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Build_Message");

            //DocuSign
            var tasks = new List <Task>();
            var monitorDocuSignActionTask = HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, monitorDocusignAT, "Monitor Docusign Envelope Activity", "Monitor Docusign Envelope Activity", 1);

            tasks.Add(monitorDocuSignActionTask);
            var setDelayActionTask = HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, setDelayAT, "Set Delay", "Set Delay", 2);

            tasks.Add(setDelayActionTask);
            var queryFr8WarehouseActionTask = HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, queryFr8WareHouseAT, "Query Fr8 Warehouse", "Query Fr8 Warehouse", 3);

            tasks.Add(queryFr8WarehouseActionTask);
            var filterActionTask = HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, testIncomingDataAT, "Test Incoming Data", "Test Incoming Data", 4);

            tasks.Add(filterActionTask);
            Task <ActivityPayload> buildMessageActivityTask = null;

            if (!hasChildren)
            {
                buildMessageActivityTask = HubCommunicator.AddAndConfigureChildActivity((Guid)ActivityPayload.ParentPlanNodeId, buildMessageAT, "Build a Message", "Build a Message", 2);
                tasks.Add(buildMessageActivityTask);
            }

            await Task.WhenAll(tasks);

            var monitorDocuSignAction   = monitorDocuSignActionTask.Result;
            var setDelayAction          = setDelayActionTask.Result;
            var queryFr8WarehouseAction = queryFr8WarehouseActionTask.Result;
            var filterAction            = filterActionTask.Result;

            // var notifierActivity = notifierActivityTask.Result;
            if (specificRecipientOption.Selected)
            {
                ActivityConfigurator.SetControlValue(monitorDocuSignAction, "TemplateRecipientPicker.recipient.RecipientValue", specificRecipientOption.Controls[0].Value);
            }
            else if (specificTemplateOption.Selected)
            {
                var ddlbTemplate = (specificTemplateOption.Controls[0] as DropDownList);
                ActivityConfigurator.SetControlValue(monitorDocuSignAction, "TemplateRecipientPicker.template.UpstreamCrate",
                                                     ddlbTemplate.ListItems.Single(a => a.Key == ddlbTemplate.selectedKey));
            }

            if (buildMessageActivityTask != null)
            {
                var buildMessageActivity = buildMessageActivityTask.Result;

                ActivityConfigurator.SetControlValue(buildMessageActivity, "Body", MessageBody);
                ActivityConfigurator.SetControlValue(buildMessageActivity, "Name", "NotificationMessage");

                buildMessageActivity = await HubCommunicator.ConfigureActivity(buildMessageActivity);
            }

            if (!hasChildren)
            {
                var notifierAT = await HubCommunicator.GetActivityTemplate(Guid.Parse(howToBeNotifiedDdl.Value));

                var notifierActivity = await HubCommunicator.AddAndConfigureChildActivity((Guid)ActivityPayload.ParentPlanNodeId, notifierAT, howToBeNotifiedDdl.selectedKey, howToBeNotifiedDdl.selectedKey, 3);

                SetNotifierActivityBody(notifierActivity);
                await HubCommunicator.ConfigureActivity(notifierActivity);
            }

            ActivityConfigurator.SetControlValue(monitorDocuSignAction, "EnvelopeSent", "true");
            //let's make followup configuration for monitorDocuSignEventAction
            //followup call places EventSubscription crate in storage
            var configureMonitorDocusignTask = HubCommunicator.ConfigureActivity(monitorDocuSignAction);


            var durationControl = (Duration)ConfigurationControls.FindByName("TimePeriod");

            ActivityConfigurator.SetControlValue(setDelayAction, "Delay_Duration", durationControl.Value);
            await SetQueryFr8WarehouseActivityFields(queryFr8WarehouseAction, specificRecipientOption.Controls[0].Value);

            //let's make a followup configuration to fill criteria fields
            var configureQueryMTTask = HubCommunicator.ConfigureActivity(queryFr8WarehouseAction);
            var recipientEventStatus = (DropDownList)ConfigurationControls.FindByName("RecipientEvent");

            SetFilterUsingRunTimeActivityFields(filterAction, recipientEventStatus.Value);

            await Task.WhenAll(configureMonitorDocusignTask, configureQueryMTTask);

            monitorDocuSignAction = configureMonitorDocusignTask.Result;
            ActivityPayload.ChildrenActivities    = ActivityPayload.ChildrenActivities.OrderBy(a => a.Ordering).ToList();
            ActivityPayload.ChildrenActivities[0] = monitorDocuSignAction;
        }