public override async Task FollowUp()
        {
            if (ConfigurationControls.Controls[0].Value != null)
            {
                ActivityContext.ActivityPayload.Label = ConfigurationControls.Controls[0].Value;
            }
            var controlContainer = GetControl <MetaControlContainer>("control_container");

            if (!controlContainer.MetaDescriptions.Any())
            {
                //TODO add error label
                return;
            }

            //user might have pressed submit button on Collection UI
            var collectionControls = GetMetaControls();

            if (collectionControls != null)
            {
                var submitButton = collectionControls.FindByName <Button>("submit_button");
                if (submitButton.Clicked)
                {
                    // Push toast message to front-end

                    if (ActivityContext.ActivityPayload.RootPlanNodeId == null)
                    {
                        throw new Exception($"Activity with id \"{ActivityId}\" has no owner plan");
                    }

                    var flagCrate = Crate.FromContent(RunFromSubmitButtonLabel, new KeyValueListCM());


                    ThreadPool.QueueUserWorkItem(state =>
                    {
                        try
                        {
                            Task.WaitAll(_pushNotificationService.PushUserNotification(MyTemplate, "App Builder Message", "Submitting data..."));
                            Task.WaitAll(HubCommunicator.SaveActivity(ActivityContext.ActivityPayload));
                            Task.WaitAll(HubCommunicator.RunPlan(ActivityContext.ActivityPayload.RootPlanNodeId.Value, new[] { flagCrate }));
                            Task.WaitAll(_pushNotificationService.PushUserNotification(MyTemplate, "App Builder Message", "Your information has been processed."));
                        }
                        catch
                        {
                            UnClickSubmitButton();
                        }
                    });

                    //we need to start the process - run current plan - that we belong to
                    //after running the plan - let's reset button state
                    //so next configure calls will be made with a fresh state
                    UnClickSubmitButton();
                    return;
                }
            }
            PublishCollectionControls();
        }
示例#2
0
        private async Task UpdateMetaControls()
        {
            Storage.RemoveByLabel(CollectionControlsLabel);
            var controls = CreateCollectionControlsCrate();

            AddFileDescriptionToStorage(Storage, controls.Get <StandardConfigurationControlsCM>().Controls.Where(a => a.Type == ControlTypes.FilePicker).ToList());
            Storage.Add(controls);

            await HubCommunicator.SaveActivity(ActivityContext.ActivityPayload, true);

            string launchUrl = GetLaunchUrl();
            await _planService.ConfigureAsApp(ActivityId, launchUrl, ActivityContext.ActivityPayload.Label);

            await _pushNotificationService.PushUserNotification(MyTemplate, "App Builder URL Generated", "This Plan can be launched with the following URL: " + launchUrl);
        }