Пример #1
0
        public void O365ConnectorCardMultichoiceInputInits()
        {
            var type       = "multichoiceInput";
            var id         = "bookChoice";
            var isRequired = true;
            var title      = "Books";
            var value      = "No Book Selected";
            var choices    = new List <O365ConnectorCardMultichoiceInputChoice>()
            {
                new O365ConnectorCardMultichoiceInputChoice("C# In Depth"),
                new O365ConnectorCardMultichoiceInputChoice("C# in a Nutshell"),
            };
            var style         = "expanded";
            var isMultiSelect = true;

            var multichoiceInput = new O365ConnectorCardMultichoiceInput(type, id, isRequired, title, value, choices, style, isMultiSelect);

            Assert.NotNull(multichoiceInput);
            Assert.IsType <O365ConnectorCardMultichoiceInput>(multichoiceInput);
            Assert.Equal(id, multichoiceInput.Id);
            Assert.Equal(isRequired, multichoiceInput.IsRequired);
            Assert.Equal(title, multichoiceInput.Title);
            Assert.Equal(value, multichoiceInput.Value);
            Assert.Equal(choices, multichoiceInput.Choices);
            Assert.Equal(2, multichoiceInput.Choices.Count);
            Assert.Equal(style, multichoiceInput.Style);
            Assert.Equal(isMultiSelect, multichoiceInput.IsMultiSelect);
        }
Пример #2
0
        public void O365ConnectorCardMultichoiceInputInitsWithNoArgs()
        {
            var multichoiceInput = new O365ConnectorCardMultichoiceInput();

            Assert.NotNull(multichoiceInput);
            Assert.IsType <O365ConnectorCardMultichoiceInput>(multichoiceInput);
        }
Пример #3
0
        public static Attachment GetFilter(string email)
        {
            var section = new O365ConnectorCardSection("Please select the option below to create Team");

            // "C:\Users\v-washai\Downloads\Picture1.png"
            // var heroImage = new O365ConnectorCardSection(null, null, null, null, null, "");

            var inputs = new List <O365ConnectorCardMultichoiceInputChoice>();

            foreach (var member in MessagesController.GetMemberList(email))
            {
                inputs.Add(new O365ConnectorCardMultichoiceInputChoice(member.Split('@').First(), member));
            }

            var memberSelection = new O365ConnectorCardMultichoiceInput(
                O365ConnectorCardMultichoiceInput.Type,
                "members",
                true,
                "Select Team Members",
                null,
                inputs
                ,
                "compact"
                , true);

            var createCustomTeam = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Create Custom Team",
                "createCustomTeam",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "teamName",
                    true,
                    "Enter Team Name",
                    null,
                    false,
                    null),
                memberSelection
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Create Team",
                    "Custom",
                    @"{""TeamName"":""{{teamName.value}}"", ""Members"":""{{members.value}}""}")
            });

            var createTeamForFlight = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Create Team for Upcoming Flight",
                "flightWiseTeam",
                new List <O365ConnectorCardInputBase>
            {
                new  O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "flight",
                    true,
                    "Select flight",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("783", "783"),
                    new O365ConnectorCardMultichoiceInputChoice("784", "784"),
                    new O365ConnectorCardMultichoiceInputChoice("785", "785")
                },
                    "compact"
                    , false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Create Team",
                    "Flight",
                    @"{""Value"":""{{flight.value}}""}")
            });


            O365ConnectorCard card = new O365ConnectorCard()
            {
                ThemeColor = "#E67A9E",
                Title      = "Welcome to FlightTeamCreationBot.",
                Summary    = "",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    createTeamForFlight,
                    createCustomTeam
                }
            };

            return(card.ToAttachment());
        }
Пример #4
0
        public static Attachment GetWelcomeMessage(string actionId, IList <ChannelAccount> members)
        {
            var section = new O365ConnectorCardSection("Please select the type of notification you want to receive", null, null, null, null);
            var notificationCardAction = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Select Notification",
                "notificationType",
                new List <O365ConnectorCardInputBase>
            {
                new  O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "notificationType",
                    true,
                    "Select Notification",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Weather", "Weather"),
                    new O365ConnectorCardMultichoiceInputChoice("Operations Delay", "OperationsDelay"),
                    new O365ConnectorCardMultichoiceInputChoice("Social Events", "SocialEvents")
                },
                    "compact"
                    , false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Show notification",
                    "notificationType",
                    @"{""Value"":""{{notificationType.value}}"",  ""ActionId"":""" + actionId + @"""  " + (members == null?"":@",""Members"":""{{members.value}}""") + "}")
            });

            if (members != null)
            {
                var memberSelection = new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "members",
                    false,
                    "Select Members",
                    null, new List <O365ConnectorCardMultichoiceInputChoice>()
                    ,
                    "compact"
                    , true);

                memberSelection.Choices.Add(new O365ConnectorCardMultichoiceInputChoice("ALL TEAM", "ALL TEAM"));

                foreach (var member in members)
                {
                    var nameParts = member.Name.Split(' ');
                    var fullName  = string.Empty;
                    for (int i = 0; i < nameParts.Length && i < 2; i++)
                    {
                        if (!string.IsNullOrEmpty(fullName))
                        {
                            fullName += " ";
                        }
                        fullName += nameParts[i].Trim();
                    }

                    memberSelection.Choices.Add(new O365ConnectorCardMultichoiceInputChoice(fullName, member.Id));
                }

                notificationCardAction.Inputs.Add(memberSelection);
            }


            O365ConnectorCard card = new O365ConnectorCard()
            {
                ThemeColor = "#E67A9E",
                Title      = "Welcome to Notification Bot",
                Summary    = "",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    notificationCardAction
                }
            };

            return(card.ToAttachment());
        }