コード例 #1
0
        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;
        }