private async Task <ActivityPayload> CreateProcessingActivity(ReconfigurationContext context)
        {
            var loopActivity = await HubCommunicator.AddAndConfigureChildActivity(context.SolutionActivity, await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Loop"), "Loop", "Loop", 2);

            var loopConfigControls  = ActivityConfigurator.GetConfigurationControls(loopActivity);
            var crateChooser        = loopConfigControls.Controls.OfType <CrateChooser>().Single();
            var firstActivity       = context.SolutionActivity.ChildrenActivities.OrderBy(x => x.Ordering).First();
            var firstActivityCrates = firstActivity.CrateStorage.CrateContentsOfType <CrateDescriptionCM>().FirstOrDefault();

            crateChooser.CrateDescriptions = firstActivityCrates?.CrateDescriptions;

            var tableDescription = crateChooser.CrateDescriptions?.FirstOrDefault(x => x.ManifestId == (int)MT.StandardTableData);

            if (tableDescription != null)
            {
                tableDescription.Selected = true;
            }

            var solutionActivityUi         = new ActivityUi().ClonePropertiesFrom(context.SolutionActivity.CrateStorage.FirstCrate <StandardConfigurationControlsCM>().Content) as ActivityUi;
            var mailSenderActivityTemplate = await HubCommunicator.GetActivityTemplate(Guid.Parse(solutionActivityUi.MailSenderActivitySelector.Value));

            var sendEmailActivity = await HubCommunicator.AddAndConfigureChildActivity(loopActivity, mailSenderActivityTemplate, order : 1);

            return(loopActivity);
        }
        private async Task <ActivityPayload> CreateSecondChildActivity(ReconfigurationContext context)
        {
            var curActivityTemplates = (await HubCommunicator.GetActivityTemplates(null, true))
                                       .ToList();

            var             selectedReceiver = curActivityTemplates.Single(x => x.Name == _dataSourceValue);
            ActivityPayload parentActivity;
            int             activityIndex;

            if (DoesActivityTemplateGenerateTableData(selectedReceiver))
            {
                var loopAT = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Loop");

                var loopActivity = await HubCommunicator.AddAndConfigureChildActivity(context.SolutionActivity, loopAT, "Loop", "Loop", 2);

                var crateChooser        = ActivityConfigurator.GetControl <CrateChooser>(loopActivity, "Available_Crates");
                var firstActivity       = context.SolutionActivity.ChildrenActivities.OrderBy(x => x.Ordering).First();
                var firstActivityCrates = firstActivity.CrateStorage.CrateContentsOfType <CrateDescriptionCM>().FirstOrDefault();

                crateChooser.CrateDescriptions = firstActivityCrates?.CrateDescriptions;

                var tableDescription = crateChooser.CrateDescriptions?.FirstOrDefault(c => c.ManifestId == (int)MT.StandardTableData);
                if (tableDescription != null)
                {
                    tableDescription.Selected = true;
                }

                parentActivity = loopActivity;
                activityIndex  = 1;
            }
            else
            {
                parentActivity = context.SolutionActivity;
                activityIndex  = 2;
            }

            var sendDocusignEnvelopeAT = await HubCommunicator.GetActivityTemplate("terminalDocuSign", "Send_DocuSign_Envelope", activityTemplateVersion : "2");

            var sendDocuSignActivity = await HubCommunicator.AddAndConfigureChildActivity(parentActivity, sendDocusignEnvelopeAT, order : activityIndex);

            // Set docusign template
            ActivityConfigurator.SetControlValue(sendDocuSignActivity, "TemplateSelector",
                                                 _docuSignTemplate.ListItems.FirstOrDefault(a => a.Key == _docuSignTemplate.selectedKey)
                                                 );

            await HubCommunicator.ConfigureChildActivity(parentActivity, sendDocuSignActivity);

            return(activityIndex == 1 ? sendDocuSignActivity : parentActivity);
        }
Exemple #3
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;
        }
        protected async Task GenerateSolutionActivities(string fr8ObjectID)
        {
            var queryFr8WarehouseAT = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Query_Fr8_Warehouse");

            var queryFr8WarehouseAction = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, queryFr8WarehouseAT);

            var crateStorage = queryFr8WarehouseAction.CrateStorage;
            // We insteady of using getConfiguration control used the same GetConfiguration control required actionDO
            var          queryFr8configurationControls = crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().FirstOrDefault();
            var          radioButtonGroup  = queryFr8configurationControls.FindByName <RadioButtonGroup>("QueryPicker");
            DropDownList fr8ObjectDropDown = null;

            if (radioButtonGroup != null &&
                radioButtonGroup.Radios.Count > 0 &&
                radioButtonGroup.Radios[0].Controls.Count > 0)
            {
                fr8ObjectDropDown = radioButtonGroup.Radios[1].Controls[0] as DropDownList;
                radioButtonGroup.Radios[1].Selected = true;
                radioButtonGroup.Radios[0].Selected = false;
            }

            if (fr8ObjectDropDown != null)
            {
                fr8ObjectDropDown.Selected    = true;
                fr8ObjectDropDown.Value       = fr8ObjectID;
                fr8ObjectDropDown.selectedKey = fr8ObjectID;

                FilterPane    upstreamCrateChooser1 = radioButtonGroup.Radios[1].Controls[1] as FilterPane;
                var           queryBuilderControl   = GetControl <QueryBuilder>("QueryBuilder");
                var           criteria      = JsonConvert.DeserializeObject <List <FilterConditionDTO> >(queryBuilderControl.Value);
                FilterDataDTO filterPaneDTO = new FilterDataDTO();
                filterPaneDTO.Conditions       = criteria;
                filterPaneDTO.ExecutionType    = FilterExecutionType.WithFilter;
                upstreamCrateChooser1.Value    = JsonConvert.SerializeObject(filterPaneDTO);
                upstreamCrateChooser1.Selected = true;
            }

            queryFr8WarehouseAction = await HubCommunicator.ConfigureChildActivity(
                ActivityContext.ActivityPayload,
                queryFr8WarehouseAction
                );
        }
        /// <summary>
        /// TODO this part is ugly - why do we load those activities from hub in activity
        /// we already have a code in base class that does this operation with caching
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private async Task <ActivityPayload> CreateFirstChildActivity(ReconfigurationContext context)
        {
            var curActivityTemplates = (await HubCommunicator.GetActivityTemplates(null, true))
                                       .Select(Mapper.Map <ActivityTemplateDO>)
                                       .ToList();

            // Let's check if activity template generates table data
            var selectedReceiver = curActivityTemplates.Single(x => x.Name == _dataSourceValue);

            var selectedReceiverTemplate = await HubCommunicator.GetActivityTemplate(selectedReceiver.Id);

            var dataSourceActivity = await HubCommunicator.AddAndConfigureChildActivity(
                context.SolutionActivity,
                selectedReceiverTemplate,
                order : 1
                );

            context.SolutionActivity.ChildrenActivities.Remove(dataSourceActivity);
            context.SolutionActivity.ChildrenActivities.Insert(0, dataSourceActivity);
            return(dataSourceActivity);
        }
Exemple #6
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);
        }
Exemple #7
0
        public override async Task FollowUp()
        {
            //Remove child activity if its not specified or add it if is not yet added
            if (string.IsNullOrEmpty(ActivityUI.DataSourceSelector.Value))
            {
                await HubCommunicator.DeleteExistingChildNodesFromActivity(ActivityId);

                ActivityContext.ActivityPayload.ChildrenActivities.Clear();
                PreviousSelectedDataSourceId = null;
                CachedData = null;
            }
            else if (string.IsNullOrEmpty(PreviousSelectedDataSourceId) || PreviousSelectedDataSourceId != ActivityUI.DataSourceSelector.Value)
            {
                var activityTemplate = await HubCommunicator.GetActivityTemplate(Guid.Parse(ActivityUI.DataSourceSelector.Value));

                await HubCommunicator.DeleteExistingChildNodesFromActivity(ActivityId);

                ActivityContext.ActivityPayload.ChildrenActivities.Clear();
                await HubCommunicator.AddAndConfigureChildActivity(ActivityContext.ActivityPayload, activityTemplate, order : 1);

                PreviousSelectedDataSourceId = ActivityUI.DataSourceSelector.Value;
                CachedData = null;
            }
        }
        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;
        }
Exemple #9
0
        public override async Task FollowUp()
        {
            var activityTemplates = (await HubCommunicator.GetActivityTemplates(null, true))
                                    .Select(Mapper.Map <ActivityTemplateDO>)
                                    .ToList();

            try
            {
                var continueClicked = false;
                Storage.Remove <StandardQueryCM>();
                await UpdatePlanName();

                var queryCrate = ExtractQueryCrate(Storage);
                Storage.Add(queryCrate);

                var continueButton = GetControl <Button>("Continue");
                if (continueButton != null)
                {
                    continueClicked = continueButton.Clicked;

                    if (continueButton.Clicked)
                    {
                        continueButton.Clicked = false;
                    }
                }

                if (continueClicked)
                {
                    ActivityPayload.ChildrenActivities.Clear();

                    var queryFr8WarehouseActivityTemplate = activityTemplates
                                                            .FirstOrDefault(x => x.Name == "Query_Fr8_Warehouse");
                    if (queryFr8WarehouseActivityTemplate == null)
                    {
                        return;
                    }

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

                    var queryFr8WarehouseAction = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, queryFr8WarehouseTemplate);

                    var crateStorage = queryFr8WarehouseAction.CrateStorage;

                    var upstreamManifestTypes = crateStorage
                                                .CrateContentsOfType <KeyValueListCM>(x => x.Label == "Upstream Crate ManifestType List")
                                                .FirstOrDefault();

                    var controls = crateStorage
                                   .CrateContentsOfType <StandardConfigurationControlsCM>()
                                   .FirstOrDefault();

                    var radioButtonGroup = controls
                                           .FindByName <RadioButtonGroup>("QueryPicker");

                    UpstreamCrateChooser upstreamCrateChooser = null;
                    if (radioButtonGroup != null &&
                        radioButtonGroup.Radios.Count > 0 &&
                        radioButtonGroup.Radios[0].Controls.Count > 0)
                    {
                        upstreamCrateChooser = radioButtonGroup.Radios[0].Controls[0] as UpstreamCrateChooser;
                    }

                    if (upstreamCrateChooser != null)
                    {
                        if (upstreamManifestTypes != null)
                        {
                            upstreamCrateChooser.SelectedCrates[0].ManifestType.selectedKey = upstreamManifestTypes.Values[0].Key;
                            upstreamCrateChooser.SelectedCrates[0].ManifestType.Value       = upstreamManifestTypes.Values[0].Value;
                        }

                        upstreamCrateChooser.SelectedCrates[0].Label.selectedKey = QueryCrateLabel;
                        upstreamCrateChooser.SelectedCrates[0].Label.Value       = QueryCrateLabel;
                    }

                    queryFr8WarehouseAction = await HubCommunicator.ConfigureChildActivity(
                        ActivityPayload,
                        queryFr8WarehouseAction
                        );

                    Storage.RemoveByManifestId((int)MT.OperationalStatus);
                    var operationalStatus = new OperationalStateCM();
                    operationalStatus.CurrentActivityResponse =
                        ActivityResponseDTO.Create(ActivityResponse.ExecuteClientActivity);
                    operationalStatus.CurrentActivityResponse.Body = "RunImmediately";
                    var operationsCrate = Crate.FromContent("Operational Status", operationalStatus);
                    Storage.Add(operationsCrate);
                }
            }
            catch (Exception)
            {
            }
        }