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;
            }
        }
예제 #2
0
        private async Task <List <ListItem> > GetFinalActionListItems()
        {
            var templates = await HubCommunicator.GetActivityTemplates(ActivityCategories.ForwardId, true);

            return(templates.OrderBy(x => x.Label).Select(x => new ListItem {
                Key = x.Label, Value = x.Id.ToString()
            }).ToList());
        }
        private async Task <Crate> PackAvailableHandlers()
        {
            var templates = await HubCommunicator.GetActivityTemplates(true);

            var taggedTemplates = templates.Where(x => x.Tags != null && x.Tags.Contains("Notifier"));

            return(Crate.FromContent("AvailableHandlers", new KeyValueListCM(taggedTemplates.Select(x => new KeyValueDTO(x.Label, x.Id.ToString())))));
        }
        private async Task <List <ListItem> > GetDataSourceListItems(string tag)
        {
            var curActivityTemplates = await HubCommunicator.GetActivityTemplates(tag);

            return(curActivityTemplates.Select(at => new ListItem()
            {
                Key = at.Label, Value = at.Name
            }).ToList());
        }
        private async Task <ActivityPayload> ConfigureSecondChildActivity(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 loopActivity = context.SolutionActivity.ChildrenActivities
                                   .OfType <ActivityPayload>()
                                   .SingleOrDefault(x => x.ActivityTemplate.Name == "Loop" && x.Ordering == 2);

                if (loopActivity == null)
                {
                    throw new ApplicationException("Invalid solution structure, no Loop activity found.");
                }

                loopActivity = await HubCommunicator.ConfigureChildActivity(context.SolutionActivity, loopActivity);

                var crateChooser     = ActivityConfigurator.GetControl <CrateChooser>(loopActivity, "Available_Crates");
                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 sendDocuSignEnvelope = parentActivity.ChildrenActivities
                                       .OfType <ActivityPayload>()
                                       .Single(x => x.ActivityTemplate.Name == "Send_DocuSign_Envelope" &&
                                               x.Ordering == activityIndex
                                               );

            sendDocuSignEnvelope.CrateStorage = new CrateStorage();
            sendDocuSignEnvelope = await HubCommunicator.ConfigureChildActivity(parentActivity, sendDocuSignEnvelope);

            ActivityConfigurator.SetControlValue(
                sendDocuSignEnvelope,
                "target_docusign_template",
                _docuSignTemplate.ListItems
                .FirstOrDefault(a => a.Key == _docuSignTemplate.selectedKey)
                );

            sendDocuSignEnvelope = await HubCommunicator.ConfigureChildActivity(parentActivity, sendDocuSignEnvelope);

            return(sendDocuSignEnvelope);
        }
예제 #6
0
        public override async Task Initialize()
        {
            var activityTemplates = await HubCommunicator.GetActivityTemplates(Tags.TableDataGenerator);

            activityTemplates.Sort((x, y) => x.Name.CompareTo(y.Name));
            ActivityUI.DataSourceSelector.ListItems = activityTemplates
                                                      .Select(x => new ListItem {
                Key = x.Label, Value = x.Id.ToString()
            })
                                                      .ToList();
        }
        public override async Task FollowUp()
        {
            await FillDropdowns();

            if (!ActivityUI.BuildSolutionButton.Clicked)
            {
                return;
            }
            ActivityPayload.ChildrenActivities.Clear();
            //We need to keep the versions we know how to work with. If later these child activities will be upgraded we probably won't be able to configure them properly
            var activityTemplates = await HubCommunicator.GetActivityTemplates();

            var configureMonitorActivityTask = ConfigureMonitorActivity(activityTemplates);
            var configureSetDelayTask        = ConfigureSetDelayActivity(activityTemplates);
            var configureQueryFr8Task        = ConfigureQueryFr8Activity(activityTemplates);
            var configureTestDataTask        = ConfigureFilterDataActivity(activityTemplates);
            await Task.WhenAll(configureMonitorActivityTask, configureSetDelayTask, configureQueryFr8Task, configureTestDataTask);

            //If solution was already built and  we should replace notifier action
            var previousNotifierId         = NotifierActivityId;
            var previousNotifierTemplateId = NotifierActivityTemplateId;
            var isInitialBuild             = previousNotifierId == Guid.Empty;

            if (isInitialBuild)
            {
                await ConfigureBuildMessageActivity(activityTemplates);
            }
            var currentNotifierTemplateId = NotifierActivityTemplateId = Guid.Parse(ActivityUI.NotifierSelector.Value);

            if (isInitialBuild || currentNotifierTemplateId != previousNotifierTemplateId)
            {
                //If it is not initial build we should remove existing notifier from plan
                var previousNotifierOrdering = 3;
                if (!isInitialBuild)
                {
                    var currentPlan      = (await HubCommunicator.GetPlansByActivity(ActivityId.ToString()));
                    var startingSubPlan  = currentPlan.SubPlans.First(x => x.SubPlanId == currentPlan.StartingSubPlanId);
                    var previousNotifier = startingSubPlan.Activities.FirstOrDefault(x => x.Id == previousNotifierId);
                    if (previousNotifier != null)
                    {
                        previousNotifierOrdering = previousNotifier.Ordering;
                        await HubCommunicator.DeleteActivity(previousNotifierId);
                    }
                }
                //And we should add new notifier anyway
                NotifierActivityId = await ConfigureNotifierActivity(activityTemplates, previousNotifierOrdering);
            }
            ;
            ActivityPayload.ChildrenActivities.Sort((x, y) => x.Ordering.CompareTo(y.Ordering));
            ActivityPayload.ChildrenActivities[0] = configureMonitorActivityTask.Result;
            ActivityPayload.ChildrenActivities[2] = configureQueryFr8Task.Result;
        }
예제 #8
0
        protected async Task <ActivityTemplateDTO> GetActivityTemplateByName(string activityTemplateName)
        {
            var allActivityTemplates = await HubCommunicator.GetActivityTemplates();

            var foundActivity = allActivityTemplates.FirstOrDefault(a => a.Name == activityTemplateName);

            if (foundActivity == null)
            {
                throw new Exception($"ActivityTemplate was not found. ActivitiyTemplateName: {activityTemplateName}");
            }

            return(foundActivity);
        }
        public override async Task Initialize()
        {
            ActivityUI.SalesforceObjectSelector.ListItems = _salesforceManager.GetSalesforceObjectTypes().Select(x => new ListItem {
                Key = x.Name, Value = x.Label
            }).ToList();
            var activityTemplates = await HubCommunicator.GetActivityTemplates(Tags.EmailDeliverer, true);

            activityTemplates.Sort((x, y) => x.Name.CompareTo(y.Name));
            ActivityUI.MailSenderActivitySelector.ListItems = activityTemplates
                                                              .Select(x => new ListItem {
                Key = x.Label, Value = x.Id.ToString()
            })
                                                              .ToList();
        }
        protected async Task <ActivityTemplateDTO> GetActivityTemplate(Guid activityTemplateId)
        {
            var allActivityTemplates = await HubCommunicator.GetActivityTemplates();

            var foundActivity = allActivityTemplates.FirstOrDefault(a => a.Id == activityTemplateId);


            if (foundActivity == null)
            {
                throw new Exception($"ActivityTemplate was not found. Id: {activityTemplateId}");
            }

            return(foundActivity);
        }
        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);
        }
        protected async Task <ActivityTemplateDTO> GetActivityTemplate(string terminalName, string activityTemplateName, string activityTemplateVersion = "1", string terminalVersion = "1")
        {
            var allActivityTemplates = await HubCommunicator.GetActivityTemplates();

            var foundActivity = allActivityTemplates.FirstOrDefault(a =>
                                                                    a.Terminal.Name == terminalName && a.Terminal.Version == terminalVersion &&
                                                                    a.Name == activityTemplateName && a.Version == activityTemplateVersion);

            if (foundActivity == null)
            {
                throw new Exception($"ActivityTemplate was not found. TerminalName: {terminalName}\nTerminalVersion: {terminalVersion}\nActivitiyTemplateName: {activityTemplateName}\nActivityTemplateVersion: {activityTemplateVersion}");
            }

            return(foundActivity);
        }
        private async Task <bool> HasSecondChildActivity(ReconfigurationContext context)
        {
            if (context.SolutionActivity.ChildrenActivities == null)
            {
                return(false);
            }

            var curActivityTemplates = (await HubCommunicator.GetActivityTemplates(null, true))
                                       .ToList();

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

            if (DoesActivityTemplateGenerateTableData(selectedReceiver))
            {
                var loopActivity = context.SolutionActivity.ChildrenActivities
                                   .OfType <ActivityPayload>()
                                   .SingleOrDefault(x => x.ActivityTemplate.Name == "Loop" && x.Ordering == 2);

                if (loopActivity == null)
                {
                    return(false);
                }

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

            if (parentActivity.ChildrenActivities.Count != 1)
            {
                return(false);
            }

            var sendDocuSignEnvelope = parentActivity.ChildrenActivities
                                       .OfType <ActivityPayload>()
                                       .SingleOrDefault(x => x.ActivityTemplate.Name == "Send_DocuSign_Envelope" &&
                                                        x.Ordering == activityIndex
                                                        );

            return(sendDocuSignEnvelope != null);
        }
        /// <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);
        }
        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));
        }
예제 #16
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)
            {
            }
        }
        public override async Task Initialize()
        {
            var templates = await HubCommunicator.GetActivityTemplates();

            var activityTemplate = templates.Select(x => new ActivityTemplateSummaryDTO
            {
                Name            = x.Name,
                Version         = x.Version,
                TerminalName    = x.Terminal.Name,
                TerminalVersion = x.Terminal.Version
            }).First(x => x.Name == "SimpleActivity");

            ActivityPayload.ChildrenActivities.Add(new ActivityPayload
            {
                Id               = Guid.NewGuid(),
                CrateStorage     = new CrateStorage(),
                ActivityTemplate = activityTemplate,
                //ActivityTemplateId = activityTemplate.Id,
                Label    = "main 1.1",
                Ordering = 1
            });

            ActivityPayload.ChildrenActivities.Add(new ActivityPayload
            {
                Id           = Guid.NewGuid(),
                CrateStorage = new CrateStorage(),
                //ActivityTemplateId = activityTemplate.Id,
                ActivityTemplate   = activityTemplate,
                Label              = "main 1.2",
                Ordering           = 2,
                ChildrenActivities =
                {
                    new ActivityPayload
                    {
                        Id           = Guid.NewGuid(),
                        CrateStorage = new CrateStorage(),
                        //ActivityTemplateId = activityTemplate.Id,
                        ActivityTemplate = activityTemplate,
                        Label            = "main 1.2.1",
                        Ordering         = 1
                    },
                    new ActivityPayload
                    {
                        Id           = Guid.NewGuid(),
                        CrateStorage = new CrateStorage(),
                        //ActivityTemplateId = activityTemplate.Id,
                        ActivityTemplate = activityTemplate,
                        Label            = "main 1.2.2",
                        Ordering         = 2
                    }
                }
            });

            ActivityPayload.ChildrenActivities.Add(new ActivityPayload
            {
                Id           = Guid.NewGuid(),
                CrateStorage = new CrateStorage(),
                //ActivityTemplateId = activityTemplate.Id,
                ActivityTemplate = activityTemplate,
                Label            = "main 1.3",
                Ordering         = 3,
            });
        }
        private async Task <IEnumerable <ActivityTemplateDTO> > FindTemplates(Predicate <ActivityTemplateDTO> query)
        {
            var templates = await HubCommunicator.GetActivityTemplates(true);

            return(templates.Where(x => query(x)));
        }