public override async Task Run()
        {
            if (string.IsNullOrEmpty(ActivityUI.FileNameTextBox.Value))
            {
                RaiseError("No file name was given on design time", ActivityErrorCode.DESIGN_TIME_DATA_MISSING);
                return;
            }

            //we should upload this file to our file storage
            var userSelectedFileManifest = Payload.CrateContentsOfType <StandardFileDescriptionCM>().FirstOrDefault();

            if (userSelectedFileManifest == null)
            {
                RaiseError("No StandardFileDescriptionCM Crate was found", ActivityErrorCode.PAYLOAD_DATA_MISSING);
            }

            var fileContents = userSelectedFileManifest.TextRepresentation;

            using (var stream = GenerateStreamFromString(fileContents))
            {
                //TODO what to do with this fileDO??
                var fileDO = await HubCommunicator.SaveFile(ActivityUI.FileNameTextBox.Value, stream);
            }
            Success();
        }
        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));
        }
        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);
        }
 protected async Task <ActivityPayload> AddAndConfigureChildActivity(Guid parentActivityId, ActivityTemplateDTO activityTemplate, string name = null, string label = null, int?order = null)
 {
     //assign missing properties
     label = string.IsNullOrEmpty(label) ? activityTemplate.Label : label;
     name  = string.IsNullOrEmpty(name) ? activityTemplate.Label : label;
     return(await HubCommunicator.CreateAndConfigureActivity(activityTemplate.Id, name, order, parentActivityId));
 }
        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;
            }
        }
        private async Task ConfigureSetDelayActivity(List <ActivityTemplateDTO> activityTemplates)
        {
            var template = activityTemplates.Single(x => x.Terminal.Name == "terminalFr8Core" && x.Name == "Set_Delay" && x.Version == "1");
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, template, order : 2);

            ActivityConfigurator.SetControlValue(activity, "Delay_Duration", ActivityUI.TimePeriod.Value);
        }
        public override async Task Run()
        {
            Payload.Add(Crate.FromContent(RunTimeCrateLabel,
                                          new StandardPayloadDataCM(
                                              new KeyValueDTO("DelayTime", GetDelayDescription(GetControl <Duration>("Delay_Duration"))))));
            //find our action state in operations crate
            var delayState = OperationalState.CallStack.GetLocalData <string>("Delay");

            //extract ActivityResponse type from result
            if (delayState == "suspended")
            {
                //this is second time we are being called. this means alarm has triggered
                Success();
                return;
            }

            //get user selected design time duration
            var delayDuration = GetUserDefinedDelayDuration();
            var alarmDTO      = CreateAlarm(delayDuration);
            //post to hub to create an alarm
            await HubCommunicator.CreateAlarm(alarmDTO);

            OperationalState.CallStack.StoreLocalData("Delay", "suspended");

            RequestPlanExecutionSuspension();
        }
        public override async Task FollowUp()
        {
            var control        = GetControl <TextSource>("EnvelopeIdSelector");
            var envelope_crate = CrateSignaller.MarkAvailableAtRuntime <DocuSignEnvelopeCM_v2>(AllFieldsCrateName, false);

            var availlable_crates = await HubCommunicator.GetCratesByDirection(this.ActivityId, CrateDirection.Upstream);
        }
        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));
        }
        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 <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())))));
        }
Exemple #12
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 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);
        }
        /// <summary>
        /// Returns list of FieldDTO from upper crate from ConnectToSql action.
        /// </summary>
        private async Task <List <KeyValueDTO> > ExtractColumnDefinitions()
        {
            var upstreamCrates = await HubCommunicator.GetCratesByDirection <KeyValueListCM>(ActivityId, CrateDirection.Upstream);

            var tablesDefinitionCrate = upstreamCrates?.FirstOrDefault(x => x.Label == "Sql Table Definitions");
            var tablesDefinition      = tablesDefinitionCrate?.Content;

            return(tablesDefinition?.Values);
        }
        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);
        }
Exemple #17
0
        private async Task ValidateAndHandleCrateSelection()
        {
            //CrateChooser requests data only on click. So in order to autoselect a single crate - we need to make a request on our own
            var crateChooser = GetControl <CrateChooser>("Available_Crates");

            var upstreamCrates = await HubCommunicator.GetAvailableData(ActivityId, CrateDirection.Upstream, AvailabilityType.RunTime);


            if (crateChooser.CrateDescriptions == null)
            {
                crateChooser.CrateDescriptions = upstreamCrates.AvailableCrates;
            }
            else
            {
                //elements in crate chooser that are not in upstream
                var inCrateChooser = crateChooser.CrateDescriptions
                                     .Where(y => !upstreamCrates.AvailableCrates.Any(z => z.ManifestId == y.ManifestId && z.SourceActivityId == y.SourceActivityId && z.Label == y.Label));
                //elements in upstream that are not in crate chooser
                var inUpstream = upstreamCrates.AvailableCrates
                                 .Where(y => !crateChooser.CrateDescriptions.Any(z => z.ManifestId == y.ManifestId && z.SourceActivityId == y.SourceActivityId && z.Label == y.Label));
                if (inUpstream.Count() > 0 || inCrateChooser.Count() > 0)
                {
                    //check if selected crate is no more available
                    var old_selected = crateChooser.CrateDescriptions.FirstOrDefault(x => x.Selected);
                    if (old_selected != null)
                    {
                        var selected_in_upstream = upstreamCrates.AvailableCrates
                                                   .Where(a => a.Label == old_selected.Label && a.SourceActivityId == old_selected.SourceActivityId && a.ManifestId == old_selected.ManifestId)
                                                   .FirstOrDefault();
                        if (selected_in_upstream != null)
                        {
                            //it is available
                            selected_in_upstream.Selected = true;
                        }
                    }

                    //updated CrateChooser.CrateDescriptions
                    crateChooser.CrateDescriptions = upstreamCrates.AvailableCrates;
                }
            }

            var selected = crateChooser.CrateDescriptions.FirstOrDefault(x => x.Selected);

            if (selected != null)
            {
                SignalRowCrate(selected);
            }
            else
            {
                selected = SelectTheCrateIfThereIsOnlyOne(crateChooser);
                if (selected != null)
                {
                    SignalRowCrate(selected);
                }
            }
        }
        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();
        }
Exemple #19
0
        private async Task <List <ListItem> > GetCurrentUsersFiles()
        {
            var curAccountFileList = await HubCommunicator.GetFiles();

            //TODO where tags == Docusign files
            return(curAccountFileList.Select(c => new ListItem()
            {
                Key = c.OriginalFileName, Value = c.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Exemple #20
0
        public override async Task FollowUp()
        {
            if (ActivityUI.AddChild.Clicked)
            {
                ActivityUI.AddChild.Clicked = false;
                var activityTemplate = await GetActivityTemplateByName(ActivityUI.ActivityToAdd.Value);

                await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, activityTemplate, ActivityPayload.Label + "." + (ActivityPayload.ChildrenActivities.Count + 1), ActivityPayload.Label + "." + (ActivityPayload.ChildrenActivities.Count + 1));
            }
        }
        private async Task <ActivityPayload> ConfigureFirstChildActivity(ReconfigurationContext context)
        {
            var activity = context.SolutionActivity.ChildrenActivities
                           .OfType <ActivityPayload>()
                           .Single(x => x.Ordering == 1);

            activity.CrateStorage = new CrateStorage();
            activity = await HubCommunicator.ConfigureChildActivity(context.SolutionActivity, activity);

            return(activity);
        }
Exemple #22
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();
        }
        private async Task <List <ListItem> > GetCurrentUsersFiles()
        {
            //Leave only XLSX files as activity fails to rewrite XLS files
            var curAccountFileList = (await HubCommunicator.GetFiles()).Where(x => x.OriginalFileName?.EndsWith(".xlsx", StringComparison.InvariantCultureIgnoreCase) ?? true);

            //TODO where tags == Docusign files
            return(curAccountFileList.Select(c => new ListItem()
            {
                Key = c.OriginalFileName, Value = c.Id.ToString(CultureInfo.InvariantCulture)
            }).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;
        }
Exemple #25
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);
        }
 protected async Task PushUserNotification(string type, string subject, string message)
 {
     var notificationMsg = new TerminalNotificationDTO
     {
         Type            = type,
         Subject         = subject,
         Message         = message,
         ActivityName    = MyTemplate.Name,
         ActivityVersion = MyTemplate.Version,
         TerminalName    = MyTemplate.Terminal.Name,
         TerminalVersion = MyTemplate.Terminal.Version
     };
     await HubCommunicator.NotifyUser(notificationMsg);
 }
Exemple #29
0
        private async Task <string> ExtractConnectionString()
        {
            var upstreamCrates = await HubCommunicator.GetCratesByDirection <KeyValueListCM>(ActivityId, CrateDirection.Upstream);

            var connectionStringCrate  = upstreamCrates?.FirstOrDefault(x => x.Label == "Sql Connection String");
            var connectionStringCM     = connectionStringCrate?.Content;
            var connectionStringFields = connectionStringCM?.Values;

            if (connectionStringFields == null || connectionStringFields.Count == 0)
            {
                return(null);
            }
            return(connectionStringFields[0].Key);
        }
        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);
        }