private void SetNotifierActivityBody(ActivityPayload notifierActivity)
        {
            var activityConfigurator = new ActivityConfigurator(notifierActivity);

            if (notifierActivity.ActivityTemplate.Name == "Send_Email_Via_SendGrid")
            {
                var emailBodyField = activityConfigurator.GetControl <TextSource>("EmailBody", ControlTypes.TextSource);
                emailBodyField.ValueSource = "upstream";
                emailBodyField.Value       = "NotificationMessage";
                emailBodyField.selectedKey = "NotificationMessage";
                var emailSubjectField = activityConfigurator.GetControl <TextSource>("EmailSubject", ControlTypes.TextSource);
                emailSubjectField.ValueSource = "specific";
                emailSubjectField.TextValue   = "Fr8 Notification Message";
            }
            else if (notifierActivity.ActivityTemplate.Name == "Send_Via_Twilio")
            {
                var emailBodyField = activityConfigurator.GetControl <TextSource>("SMS_Body", ControlTypes.TextSource);
                emailBodyField.ValueSource = "upstream";
                emailBodyField.Value       = "NotificationMessage";
                emailBodyField.selectedKey = "NotificationMessage";
            }
            else if (notifierActivity.ActivityTemplate.Name == "Publish_To_Slack")
            {
                var messageField = activityConfigurator.GetControl <TextSource>("Select_Message_Field", ControlTypes.TextSource);
                if (messageField == null)
                {
                    //user is not authenticated yet - there is nothing we can do now
                    return;
                }
                messageField.ValueSource = "upstream";
                messageField.Value       = "NotificationMessage";
                messageField.selectedKey = "NotificationMessage";
            }
        }
示例#2
0
        public async Task Run_WhenMessageIsEmpty_ReturnsError()
        {
            var activity         = New <Post_To_Chatter_v2>();
            var executionContext = new ContainerExecutionContext
            {
                PayloadStorage = new CrateStorage(Crate.FromContent(string.Empty, new OperationalStateCM()))
            };
            var activityContext = new ActivityContext
            {
                HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(),
                ActivityPayload = new ActivityPayload
                {
                    CrateStorage = new CrateStorage()
                },
                AuthorizationToken = new AuthorizationToken {
                    Token = Token.Token
                }
            };
            await activity.Configure(activityContext);


            ActivityConfigurator.GetControl <ControlDefinitionDTO>(activityContext.ActivityPayload, "FeedTextSource").Value = null;

            activity = New <Post_To_Chatter_v2>();

            await activity.Run(activityContext, executionContext);

            var operationalState = executionContext.PayloadStorage.FirstCrateContentOrDefault <OperationalStateCM>();

            Assert.AreEqual(ActivityResponse.Error.ToString(), operationalState.CurrentActivityResponse.Type, "Run must fail if message is empty");
        }
示例#3
0
        private void SetSelectedTemplate(ActivityPayload docuSignActivity, DropDownList selectedTemplateDd)
        {
            var actionDdlb = ActivityConfigurator.GetControl <DropDownList>(docuSignActivity, "Available_Templates", ControlTypes.DropDownList);

            actionDdlb.selectedKey = selectedTemplateDd.selectedKey;
            actionDdlb.Value       = selectedTemplateDd.Value;
        }
示例#4
0
        private void SetToConversion(ActivityPayload convertCratesActivity)
        {
            var toDropdown = ActivityConfigurator.GetControl <DropDownList>(convertCratesActivity, "Available_To_Manifests", ControlTypes.DropDownList);

            toDropdown.Value       = ((int)MT.StandardFileHandle).ToString(CultureInfo.InvariantCulture);
            toDropdown.selectedKey = MT.StandardFileHandle.GetEnumDisplayName();
        }
示例#5
0
        private void SetFromConversion(ActivityPayload convertCratesActivity)
        {
            var fromDropdown = ActivityConfigurator.GetControl <DropDownList>(convertCratesActivity, "Available_From_Manifests", ControlTypes.DropDownList);

            fromDropdown.Value       = ((int)MT.DocuSignTemplate).ToString(CultureInfo.InvariantCulture);
            fromDropdown.selectedKey = MT.DocuSignTemplate.GetEnumDisplayName();
        }
        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);
        }
示例#7
0
        private void SetFileDetails(ActivityPayload storeFileActivity, string fileName)
        {
            var fileNameTextbox     = ActivityConfigurator.GetControl <TextBox>(storeFileActivity, "File_Name", ControlTypes.TextBox);
            var fileCrateTextSource = ActivityConfigurator.GetControl <TextSource>(storeFileActivity, "File Crate label", ControlTypes.TextSource);

            fileNameTextbox.Value           = fileName;
            fileCrateTextSource.ValueSource = "specific";
            fileCrateTextSource.TextValue   = "From DocuSignTemplate To StandardFileDescription";
        }
        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);
        }
        private async Task <Guid> ConfigureNotifierActivity(List <ActivityTemplateDTO> activityTemplates, int previousNotifierOrdering)
        {
            var template = activityTemplates.First(x => x.Id == NotifierActivityTemplateId);
            var activity = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload.RootPlanNodeId.Value, template, order : previousNotifierOrdering);

            if (activity.ActivityTemplate.Name == "Send_Email_Via_SendGrid" && activity.ActivityTemplate.Version == "1")
            {
                //var configControls = ControlHelper.GetConfigurationControls(activity.CrateStorage);
                var emailBodyField = ActivityConfigurator.GetControl <TextSource>(activity, "EmailBody", ControlTypes.TextSource);
                emailBodyField.ValueSource = "upstream";
                emailBodyField.Value       = NotificationMessageLabel;
                emailBodyField.selectedKey = NotificationMessageLabel;
                var emailSubjectField = ActivityConfigurator.GetControl <TextSource>(activity, "EmailSubject", ControlTypes.TextSource);
                emailSubjectField.ValueSource = "specific";
                emailSubjectField.TextValue   = "Fr8 Notification Message";

                await HubCommunicator.ConfigureActivity(activity);
            }
            else if (activity.ActivityTemplate.Name == "Send_Via_Twilio" && activity.ActivityTemplate.Version == "1")
            {
                var emailBodyField = ActivityConfigurator.GetControl <TextSource>(activity, "SMS_Body", ControlTypes.TextSource);
                emailBodyField.ValueSource = "upstream";
                emailBodyField.Value       = NotificationMessageLabel;
                emailBodyField.selectedKey = NotificationMessageLabel;
            }
            else if (activity.ActivityTemplate.Name == "Publish_To_Slack" && activity.ActivityTemplate.Version == "2")
            {
                if (activity.CrateStorage.FirstCrateOrDefault <StandardAuthenticationCM>() == null)
                {
                    var messageField = ActivityConfigurator.GetControl <TextSource>(activity, "MessageSource", ControlTypes.TextSource);
                    messageField.ValueSource  = "upstream";
                    messageField.Value        = NotificationMessageLabel;
                    messageField.selectedKey  = NotificationMessageLabel;
                    messageField.SelectedItem = new FieldDTO {
                        Name = NotificationMessageLabel
                    };
                    activity = await HubCommunicator.ConfigureActivity(activity);
                }
            }
            return(activity.Id);
        }