Ejemplo n.º 1
0
        public static O365ConnectorCard CreateSampleO365ConnectorCard()
        {
            var actionCard1 = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Multiple Choice",
                "card-1",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-1",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice 1", "1"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 2", "2"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 3", "3")
                },
                    "expanded",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-2",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice 4", "4"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 5", "5"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 6", "6")
                },
                    "compact",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-3",
                    false,
                    "Pick an option",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice a", "a"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice b", "b"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice c", "c")
                },
                    "expanded",
                    false),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-4",
                    false,
                    "Pick an option",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice x", "x"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice y", "y"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice z", "z")
                },
                    "compact",
                    false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "card-1-btn-1",
                    @"{""list1"":""{{list-1.value}}"", ""list2"":""{{list-2.value}}"", ""list3"":""{{list-3.value}}"", ""list4"":""{{list-4.value}}""}")
            });

            var actionCard2 = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Text Input",
                "card-2",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-1",
                    false,
                    "multiline, no maxLength",
                    null,
                    true,
                    null),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-2",
                    false,
                    "single line, no maxLength",
                    null,
                    false,
                    null),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-3",
                    true,
                    "multiline, max len = 10, isRequired",
                    null,
                    true,
                    10),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-4",
                    true,
                    "single line, max len = 10, isRequired",
                    null,
                    false,
                    10)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "card-2-btn-1",
                    @"{""text1"":""{{text-1.value}}"", ""text2"":""{{text-2.value}}"", ""text3"":""{{text-3.value}}"", ""text4"":""{{text-4.value}}""}")
            });

            var actionCard3 = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Date Input",
                "card-3",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-1",
                    true,
                    "date with time",
                    null,
                    true),
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-2",
                    false,
                    "date only",
                    null,
                    false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "card-3-btn-1",
                    @"{""date1"":""{{date-1.value}}"", ""date2"":""{{date-2.value}}""}")
            });

            var section = new O365ConnectorCardSection(
                "**section title**",
                "section text",
                "activity title",
                "activity subtitle",
                "activity text",
                "http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
                "avatar",
                true,
                new List <O365ConnectorCardFact>
            {
                new O365ConnectorCardFact("Fact name 1", "Fact value 1"),
                new O365ConnectorCardFact("Fact name 2", "Fact value 2"),
            },
                new List <O365ConnectorCardImage>
            {
                new O365ConnectorCardImage
                {
                    Image = "http://connectorsdemo.azurewebsites.net/images/MicrosoftSurface_024_Cafe_OH-06315_VS_R1c.jpg",
                    Title = "image 1"
                },
                new O365ConnectorCardImage
                {
                    Image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Scene_01.jpg",
                    Title = "image 2"
                },
                new O365ConnectorCardImage
                {
                    Image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Anthony_02.jpg",
                    Title = "image 3"
                }
            });

            O365ConnectorCard card = new O365ConnectorCard()
            {
                Summary    = "O365 card summary",
                ThemeColor = "#E67A9E",
                Title      = "card title",
                Text       = "card text",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    actionCard1,
                    actionCard2,
                    actionCard3,
                    new O365ConnectorCardViewAction(
                        O365ConnectorCardViewAction.Type,
                        "View Action",
                        null,
                        new List <string>
                    {
                        "http://microsoft.com"
                    }),
                    new O365ConnectorCardOpenUri(
                        O365ConnectorCardOpenUri.Type,
                        "Open Uri",
                        "open-uri",
                        new List <O365ConnectorCardOpenUriTarget>
                    {
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "default",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "iOS",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "android",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "windows",
                            Uri = "http://microsoft.com"
                        }
                    })
                }
            };

            return(card);
        }
        /// <summary>
        /// this is the default example's content
        /// multiple choice (compact & expanded), text input, date and placing images in card
        /// </summary>
        /// <returns>The result card with actions.</returns>
        ///
        public static Attachment O365ActionableCardDefault()
        {
            #region multi choice examples

            var multichoice = new O365ConnectorCardActionCard(O365ConnectorCardActionCard.Type)
            {
                Name   = "Multiple Choice",
                Id     = "Multiple Choice Card",
                Inputs = new List <O365ConnectorCardInputBase>
                {
                    // multiple choice control with required, multiselect, expanded style
                    new O365ConnectorCardMultichoiceInput(O365ConnectorCardMultichoiceInput.Type)
                    {
                        Id         = "CardsType",
                        IsRequired = true,
                        Title      = "Pick multiple options",
                        Value      = null,
                        Choices    = new List <O365ConnectorCardMultichoiceInputChoice>
                        {
                            new O365ConnectorCardMultichoiceInputChoice("Hero Card", "Hero Card"),
                            new O365ConnectorCardMultichoiceInputChoice("Thumbnail Card", "Thumbnail Card"),
                            new O365ConnectorCardMultichoiceInputChoice("O365 Connector Card", "O365 Connector Card")
                        },
                        Style         = "expanded",
                        IsMultiSelect = true
                    },
                    // multiple choice control with required, multiselect, compact style
                    new O365ConnectorCardMultichoiceInput(O365ConnectorCardMultichoiceInput.Type)
                    {
                        Id         = "Teams",
                        IsRequired = true,
                        Title      = "Pick multiple options",
                        Value      = null,
                        Choices    = new List <O365ConnectorCardMultichoiceInputChoice>
                        {
                            new O365ConnectorCardMultichoiceInputChoice("Bot", "Bot"),
                            new O365ConnectorCardMultichoiceInputChoice("Tab", "Tab"),
                            new O365ConnectorCardMultichoiceInputChoice("Connector", "Connector"),
                            new O365ConnectorCardMultichoiceInputChoice("Compose Extension", "Compose Extension")
                        },
                        Style         = "compact",
                        IsMultiSelect = true
                    },
                    // multiple choice control with single item select, expanded style
                    new O365ConnectorCardMultichoiceInput(O365ConnectorCardMultichoiceInput.Type)
                    {
                        Id         = "Apps",
                        IsRequired = false,
                        Title      = "Pick an App",
                        Value      = null,
                        Choices    = new List <O365ConnectorCardMultichoiceInputChoice>
                        {
                            new O365ConnectorCardMultichoiceInputChoice("VSTS", "VSTS"),
                            new O365ConnectorCardMultichoiceInputChoice("Wiki", "Wiki"),
                            new O365ConnectorCardMultichoiceInputChoice("Github", "Github")
                        },
                        Style         = "expanded",
                        IsMultiSelect = false
                    },
                    // multiple choice control with single item select, compact style
                    new O365ConnectorCardMultichoiceInput(O365ConnectorCardMultichoiceInput.Type)
                    {
                        Id         = "OfficeProduct",
                        IsRequired = false,
                        Title      = "Pick an Office Product",
                        Value      = null,
                        Choices    = new List <O365ConnectorCardMultichoiceInputChoice>
                        {
                            new O365ConnectorCardMultichoiceInputChoice("Outlook", "Outlook"),
                            new O365ConnectorCardMultichoiceInputChoice("MS Teams", "MS Teams"),
                            new O365ConnectorCardMultichoiceInputChoice("Skype", "Skype")
                        },
                        Style         = "compact",
                        IsMultiSelect = false
                    }
                },

                Actions = new List <O365ConnectorCardActionBase>
                {
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type)
                    {
                        Name = "Send",
                        Id   = "multichoice",
                        Body = @"{""CardsType"":""{{CardsType.value}}"", ""Teams"":""{{Teams.value}}"", ""Apps"":""{{Apps.value}}"", ""OfficeProduct"":""{{OfficeProduct.value}}""}"
                    }
                }
            };

            #endregion

            #region text input examples
            var inputCard = new O365ConnectorCardActionCard(O365ConnectorCardActionCard.Type)
            {
                Name   = "Text Input",
                Id     = "Input Card",
                Inputs = new List <O365ConnectorCardInputBase>
                {
                    // text input control with multiline
                    new O365ConnectorCardTextInput(O365ConnectorCardTextInput.Type)
                    {
                        Id          = "text-1",
                        IsRequired  = false,
                        Title       = "multiline, no maxLength",
                        Value       = null,
                        IsMultiline = true,
                        MaxLength   = null
                    },
                    // text input control without multiline
                    new O365ConnectorCardTextInput(O365ConnectorCardTextInput.Type)
                    {
                        Id          = "text-2",
                        IsRequired  = false,
                        Title       = "single line, no maxLength",
                        Value       = null,
                        IsMultiline = false,
                        MaxLength   = null
                    },
                    // text input control with multiline, reuired,
                    // and control the length of input box
                    new O365ConnectorCardTextInput(O365ConnectorCardTextInput.Type)
                    {
                        Id          = "text-3",
                        IsRequired  = true,
                        Title       = "multiline, max len = 10, isRequired",
                        Value       = null,
                        IsMultiline = true,
                        MaxLength   = 10
                    },
                    // text input control without multiline, reuired,
                    // and control the length of input box
                    new O365ConnectorCardTextInput(O365ConnectorCardTextInput.Type)
                    {
                        Id          = "text-4",
                        IsRequired  = true,
                        Title       = "single line, max len = 10, isRequired",
                        Value       = null,
                        IsMultiline = false,
                        MaxLength   = 10
                    }
                },
                Actions = new List <O365ConnectorCardActionBase>
                {
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type)
                    {
                        Name = "Send",
                        Id   = "inputText",
                        Body = @"{""text1"":""{{text-1.value}}"", ""text2"":""{{text-2.value}}"", ""text3"":""{{text-3.value}}"", ""text4"":""{{text-4.value}}""}"
                    }
                }
            };
            #endregion

            #region date/time input examples
            var dateCard = new O365ConnectorCardActionCard(O365ConnectorCardActionCard.Type)
            {
                Name   = "Date Input",
                Id     = "Date Card",
                Inputs = new List <O365ConnectorCardInputBase>
                {
                    // date input control, with date and time, required
                    new O365ConnectorCardDateInput(O365ConnectorCardDateInput.Type)
                    {
                        Id          = "date-1",
                        IsRequired  = true,
                        Title       = "date with time",
                        Value       = null,
                        IncludeTime = true
                    },
                    // date input control, only date, no time, not required
                    new O365ConnectorCardDateInput(O365ConnectorCardDateInput.Type)
                    {
                        Id          = "date-2",
                        IsRequired  = false,
                        Title       = "date only",
                        Value       = null,
                        IncludeTime = false
                    }
                },
                Actions = new List <O365ConnectorCardActionBase>
                {
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type)
                    {
                        Name = "Send",
                        Id   = "dateInput",
                        Body = @"{""date1"":""{{date-1.value}}"", ""date2"":""{{date-2.value}}""}"
                    }
                }
            };
            #endregion

            var section = new O365ConnectorCardSection
            {
                Title             = "**section title**",
                Text              = "section text",
                ActivityTitle     = "activity title",
                ActivitySubtitle  = "activity subtitle",
                ActivityText      = "activity text",
                ActivityImage     = "http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
                ActivityImageType = null,
                Markdown          = true,
                Facts             = new List <O365ConnectorCardFact>
                {
                    new O365ConnectorCardFact
                    {
                        Name  = "Fact name 1",
                        Value = "Fact value 1"
                    },
                    new O365ConnectorCardFact
                    {
                        Name  = "Fact name 2",
                        Value = "Fact value 2"
                    },
                },
                Images = new List <O365ConnectorCardImage>
                {
                    new O365ConnectorCardImage
                    {
                        Image = "http://connectorsdemo.azurewebsites.net/images/MicrosoftSurface_024_Cafe_OH-06315_VS_R1c.jpg",
                        Title = "image 1"
                    },
                    new O365ConnectorCardImage
                    {
                        Image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Scene_01.jpg",
                        Title = "image 2"
                    },
                    new O365ConnectorCardImage
                    {
                        Image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Anthony_02.jpg",
                        Title = "image 3"
                    }
                }
            };

            O365ConnectorCard card = new O365ConnectorCard()
            {
                Summary    = "O365 card summary",
                ThemeColor = "#E67A9E",
                Title      = "card title",
                Text       = "card text",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    multichoice,
                    inputCard,
                    dateCard,
                    new O365ConnectorCardViewAction(O365ConnectorCardViewAction.Type)
                    {
                        Name   = "View Action",
                        Id     = null,
                        Target = new List <string>
                        {
                            "http://microsoft.com"
                        }
                    },
                    new O365ConnectorCardOpenUri(O365ConnectorCardOpenUri.Type)
                    {
                        Name    = "Open Uri",
                        Id      = "open-uri",
                        Targets = new List <O365ConnectorCardOpenUriTarget>
                        {
                            new O365ConnectorCardOpenUriTarget
                            {
                                Os  = "default",
                                Uri = "http://microsoft.com"
                            },
                            new O365ConnectorCardOpenUriTarget
                            {
                                Os  = "iOS",
                                Uri = "http://microsoft.com"
                            },
                            new O365ConnectorCardOpenUriTarget
                            {
                                Os  = "android",
                                Uri = "http://microsoft.com"
                            },
                            new O365ConnectorCardOpenUriTarget
                            {
                                Os  = "windows",
                                Uri = "http://microsoft.com"
                            }
                        }
                    }
                }
            };

            return(card.ToAttachment());
        }
        /// <summary>
        /// Create a sample O365 connector card.
        /// </summary>
        /// <returns>The result card with actions.</returns>
        ///
        private static Attachment CreateSampleO365ConnectorCard()
        {
            #region Multichoice Card
            var multichoiceCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Multiple Choice",
                "Multiple Choice Card",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "CardsType",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Hero Card", "Hero Card"),
                    new O365ConnectorCardMultichoiceInputChoice("Thumbnail Card", "Thumbnail Card"),
                    new O365ConnectorCardMultichoiceInputChoice("O365 Connector Card", "O365 Connector Card")
                },
                    "expanded",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "Teams",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Bot", "Bot"),
                    new O365ConnectorCardMultichoiceInputChoice("Tab", "Tab"),
                    new O365ConnectorCardMultichoiceInputChoice("Connector", "Connector"),
                    new O365ConnectorCardMultichoiceInputChoice("Compose Extension", "Compose Extension")
                },
                    "compact",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "Apps",
                    false,
                    "Pick an App",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("VSTS", "VSTS"),
                    new O365ConnectorCardMultichoiceInputChoice("Wiki", "Wiki"),
                    new O365ConnectorCardMultichoiceInputChoice("Github", "Github")
                },
                    "expanded",
                    false),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "OfficeProduct",
                    false,
                    "Pick an Office Product",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Outlook", "Outlook"),
                    new O365ConnectorCardMultichoiceInputChoice("MS Teams", "MS Teams"),
                    new O365ConnectorCardMultichoiceInputChoice("Skype", "Skype")
                },
                    "compact",
                    false)
            },

                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "multichoice",
                    @"{""CardsType"":""{{CardsType.value}}"", ""Teams"":""{{Teams.value}}"", ""Apps"":""{{Apps.value}}"", ""OfficeProduct"":""{{OfficeProduct.value}}""}")
            });

            #endregion

            #region Input Card
            var inputCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Text Input",
                "Input Card",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-1",
                    false,
                    "multiline, no maxLength",
                    null,
                    true,
                    null),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-2",
                    false,
                    "single line, no maxLength",
                    null,
                    false,
                    null),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-3",
                    true,
                    "multiline, max len = 10, isRequired",
                    null,
                    true,
                    10),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-4",
                    true,
                    "single line, max len = 10, isRequired",
                    null,
                    false,
                    10)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "inputText",
                    @"{""text1"":""{{text-1.value}}"", ""text2"":""{{text-2.value}}"", ""text3"":""{{text-3.value}}"", ""text4"":""{{text-4.value}}""}")
            });
            #endregion

            #region Date Card
            var dateCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Date Input",
                "Date Card",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-1",
                    true,
                    "date with time",
                    null,
                    true),
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-2",
                    false,
                    "date only",
                    null,
                    false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "dateInput",
                    @"{""date1"":""{{date-1.value}}"", ""date2"":""{{date-2.value}}""}")
            });
            #endregion

            var section = new O365ConnectorCardSection(
                "**section title**",
                "section text",
                "activity title",
                "activity subtitle",
                "activity text",
                "http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
                true,
                new List <O365ConnectorCardFact>
            {
                new O365ConnectorCardFact("Fact name 1", "Fact value 1"),
                new O365ConnectorCardFact("Fact name 2", "Fact value 2"),
            },
                new List <O365ConnectorCardImage>
            {
                new O365ConnectorCardImage
                {
                    Image = "http://connectorsdemo.azurewebsites.net/images/MicrosoftSurface_024_Cafe_OH-06315_VS_R1c.jpg",
                    Title = "image 1"
                },
                new O365ConnectorCardImage
                {
                    Image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Scene_01.jpg",
                    Title = "image 2"
                },
                new O365ConnectorCardImage
                {
                    Image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Anthony_02.jpg",
                    Title = "image 3"
                }
            });

            O365ConnectorCard card = new O365ConnectorCard()
            {
                Summary    = "O365 card summary",
                ThemeColor = "#E67A9E",
                Title      = "card title",
                Text       = "card text",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    multichoiceCard,
                    inputCard,
                    dateCard,
                    new O365ConnectorCardViewAction(
                        O365ConnectorCardViewAction.Type,
                        "View Action",
                        null,
                        new List <string>
                    {
                        "http://microsoft.com"
                    }),
                    new O365ConnectorCardOpenUri(
                        O365ConnectorCardOpenUri.Type,
                        "Open Uri",
                        "open-uri",
                        new List <O365ConnectorCardOpenUriTarget>
                    {
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "default",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "iOS",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "android",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "windows",
                            Uri = "http://microsoft.com"
                        }
                    })
                }
            };

            return(card.ToAttachment());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Starts a running log
 /// </summary>
 /// <param name="title">Title of the running log card</param>
 /// <param name="summary">Optional: Summary of log card</param>
 public void BeginRunningLog(string title, string summary = null)
 {
     _card           = new O365ConnectorCard(_moduleName, title, summary);
     _currentSection = null;
 }
        /// <summary>
        /// Actionable cards can have multiple sections, each with its own set of actions.
        /// If a section contains only 1 card action, that is automatically expanded
        /// </summary>
        /// <returns>The result card with actions.</returns>
        ///
        public static Attachment O365ActionableCardMultipleSection()
        {
            #region Section1

            #region Multichoice Card
            // multiple choice control with required, multiselect, compact style
            var multichoiceCardSection1 = new O365ConnectorCardActionCard(O365ConnectorCardActionCard.Type)
            {
                Name   = "Multiple Choice",
                Id     = "Multiple Choice Card",
                Inputs = new List <O365ConnectorCardInputBase>
                {
                    new O365ConnectorCardMultichoiceInput(O365ConnectorCardMultichoiceInput.Type)
                    {
                        Id         = "cardstype",
                        IsRequired = true,
                        Title      = "Pick multiple options",
                        Value      = null,
                        Choices    = new List <O365ConnectorCardMultichoiceInputChoice>
                        {
                            new O365ConnectorCardMultichoiceInputChoice("Hero Card", "Hero Card"),
                            new O365ConnectorCardMultichoiceInputChoice("Thumbnail Card", "Thumbnail Card"),
                            new O365ConnectorCardMultichoiceInputChoice("O365 Connector Card", "O365 Connector Card")
                        },
                        Style         = "compact",
                        IsMultiSelect = true
                    },
                },
                Actions = new List <O365ConnectorCardActionBase>
                {
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type)
                    {
                        Name = "send",
                        Id   = "multichoice",
                        Body = @"{""cardstype"":""{{cardstype.value}}"""
                    }
                }
            };

            #endregion

            var potentialActionSection1 = new List <O365ConnectorCardActionBase>
            {
                multichoiceCardSection1
            };

            var section1 = new O365ConnectorCardSection
            {
                Title             = "Section Title 1",
                Text              = "",
                ActivityTitle     = "",
                ActivitySubtitle  = "",
                ActivityText      = "",
                ActivityImage     = null,
                ActivityImageType = null,
                Markdown          = true,
                Facts             = null,
                Images            = null,
                PotentialAction   = potentialActionSection1
            };
            #endregion

            #region Section2

            #region Input Card
            // text input examples
            var inputCard = new O365ConnectorCardActionCard(O365ConnectorCardActionCard.Type)
            {
                Id   = "Text Input",
                Name = "Input Card",
                // text input control with multiline
                Inputs = new List <O365ConnectorCardInputBase>
                {
                    new O365ConnectorCardTextInput(O365ConnectorCardTextInput.Type)
                    {
                        Id          = "text-1",
                        IsRequired  = false,
                        Title       = "This is the title of text box",
                        Value       = null,
                        IsMultiline = true,
                        MaxLength   = null
                    }
                },
                Actions = new List <O365ConnectorCardActionBase>
                {
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type)
                    {
                        Name = "Send",
                        Id   = "inputText",
                        Body = @"{""text1"":""{{text-1.value}}""}"
                    }
                }
            };
            #endregion

            #region Multichoice Card For Section2
            // multiple choice control with not required, multiselect, compact style
            var multichoiceCardSection2 = new O365ConnectorCardActionCard(O365ConnectorCardActionCard.Type)
            {
                Name   = "Multiple Choice",
                Id     = "Multiple Choice Card",
                Inputs = new List <O365ConnectorCardInputBase>
                {
                    new O365ConnectorCardMultichoiceInput(O365ConnectorCardMultichoiceInput.Type)
                    {
                        Id         = "CardsTypesection1", //please make sure that id of the control must be unique across card to work properly
                        IsRequired = false,
                        Title      = "This is a title of combo box",
                        Value      = null,
                        Choices    = new List <O365ConnectorCardMultichoiceInputChoice>
                        {
                            new O365ConnectorCardMultichoiceInputChoice("Hero Card", "Hero Card"),
                            new O365ConnectorCardMultichoiceInputChoice("Thumbnail Card", "Thumbnail Card"),
                            new O365ConnectorCardMultichoiceInputChoice("O365 Connector Card", "O365 Connector Card")
                        },
                        Style         = "compact",
                        IsMultiSelect = true
                    }
                },
                Actions = new List <O365ConnectorCardActionBase>
                {
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type)
                    {
                        Name = "Send",
                        Id   = "multichoice",
                        Body = @"{""CardsTypesection1"":""{{CardsTypesection1.value}}"""
                    }
                }
            };
            #endregion

            // please always attach new potential action to individual sections
            var potentialActionSection2 = new List <O365ConnectorCardActionBase>
            {
                inputCard,
                multichoiceCardSection2
            };

            var section2 = new O365ConnectorCardSection
            {
                Title             = "Section Title 2",
                Text              = "",
                ActivityTitle     = "",
                ActivitySubtitle  = "",
                ActivityText      = "",
                ActivityImage     = null,
                ActivityImageType = null,
                Markdown          = true,
                Facts             = null,
                Images            = null,
                PotentialAction   = potentialActionSection2
            };
            #endregion

            O365ConnectorCard card = new O365ConnectorCard()
            {
                Title      = "This is Actionable Card Title",
                Summary    = "O365 card summary",
                ThemeColor = "#E67A9E",
                Sections   = new List <O365ConnectorCardSection> {
                    section1, section2
                },
            };

            return(card.ToAttachment());
        }
Ejemplo n.º 6
0
        public void On(Event <LogEventData> evt)
        {
            try
            {
                //If the event level is defined and it is not in the list do not log it
                if ((LogEventLevelList?.Count ?? 0) > 0 && !LogEventLevelList.Contains(evt.Data.Level))
                {
                    return;
                }

                if (TraceMessage)
                {
                    Log
                    .ForContext("Uri", new Uri(TeamsBaseUrl))
                    .Information("Start Processing {Message}", evt.Data.RenderedMessage);
                }

                O365ConnectorCard body = BuildBody(evt);

                var httpClientHandler = new HttpClientHandler();

                if (!string.IsNullOrEmpty(WebProxy))
                {
                    ICredentials credentials = null;
                    if (!string.IsNullOrEmpty(WebProxyUserName))
                    {
                        credentials = new NetworkCredential(WebProxyUserName, WebProxyPassword);
                    }
                    httpClientHandler.Proxy    = new WebProxy(WebProxy, false, null, credentials);
                    httpClientHandler.UseProxy = true;
                }
                else
                {
                    httpClientHandler.UseProxy = false;
                }

                using (var client = new HttpClient(httpClientHandler))
                {
                    client.BaseAddress = new Uri(TeamsBaseUrl);

                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var js = new JsonSerializerSettings();
                    js.NullValueHandling = NullValueHandling.Ignore;

                    var bodyJson = JsonConvert.SerializeObject(body, js);
                    var response = client.PostAsync(
                        "",
                        new StringContent(bodyJson, Encoding.UTF8, "application/json")
                        ).Result;

                    if (!response.IsSuccessStatusCode)
                    {
                        Log
                        .ForContext("Uri", response.RequestMessage.RequestUri)
                        .Error("Could not send Teams message, server replied {StatusCode} {StatusMessage}: {Message}. Request Body: {RequestBody}", Convert.ToInt32(response.StatusCode), response.StatusCode, response.Content.ReadAsStringAsync().Result, bodyJson);
                    }
                    else
                    {
                        if (TraceMessage)
                        {
                            string reponseResult = response.Content.ReadAsStringAsync().Result;
                            Log
                            .ForContext("Uri", response.RequestMessage.RequestUri)
                            .Information("Server replied {StatusCode} {StatusMessage}: {Message}", Convert.ToInt32(response.StatusCode), response.StatusCode, reponseResult);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log
                .ForContext("Uri", new Uri(TeamsBaseUrl))
                .Error(ex, "An error occured while constructing request.");
            }
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles text message input sent by user.
        /// </summary>
        /// <param name="activity">Incoming request from Bot Framework.</param>
        /// <param name="connectorClient">Connector client instance for posting to Bot Framework.</param>
        /// <returns>Task tracking operation.</returns>
        private static async Task HandleTextMessages(Activity activity, ConnectorClient connectorClient)
        {
            if (activity.Text.Contains("GetChannels"))
            {
                Activity replyActivity = activity.CreateReply();
                replyActivity.AddMentionToText(activity.From, MentionTextLocation.PrependText);

                ConversationList channels = connectorClient.GetTeamsConnectorClient().Teams.FetchChannelList(activity.GetChannelData <TeamsChannelData>().Team.Id);

                // Adding to existing text to ensure @Mention text is not replaced.
                replyActivity.Text = replyActivity.Text + " <p>" + string.Join("</p><p>", channels.Conversations.ToList().Select(info => info.Name + " --> " + info.Id));
                await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
            }
            else if (activity.Text.Contains("GetTenantId"))
            {
                Activity replyActivity = activity.CreateReply();
                replyActivity = replyActivity.AddMentionToText(activity.From, MentionTextLocation.PrependText);

                if (!activity.Conversation.IsGroup.GetValueOrDefault())
                {
                    replyActivity = replyActivity.NotifyUser();
                }

                replyActivity.Text += " Tenant ID - " + activity.GetTenantId();
                await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
            }
            else if (activity.Text.Contains("Create1on1"))
            {
                var      response    = connectorClient.Conversations.CreateOrGetDirectConversation(activity.Recipient, activity.From, activity.GetTenantId());
                Activity newActivity = new Activity()
                {
                    Text         = "Hello",
                    Type         = ActivityTypes.Message,
                    Conversation = new ConversationAccount
                    {
                        Id = response.Id
                    },
                };

                await connectorClient.Conversations.SendToConversationAsync(newActivity, response.Id);
            }
            else if (activity.Text.Contains("GetMembers"))
            {
                var           response      = (await connectorClient.Conversations.GetConversationMembersAsync(activity.Conversation.Id)).AsTeamsChannelAccounts();
                StringBuilder stringBuilder = new StringBuilder();
                Activity      replyActivity = activity.CreateReply();
                replyActivity.Text = string.Join("</p><p>", response.ToList().Select(info => info.GivenName + " " + info.Surname + " --> " + info.ObjectId));
                await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
            }
            else if (activity.Text.Contains("TestRetry"))
            {
                for (int i = 0; i < 15; i++)
                {
                    Activity replyActivity = activity.CreateReply();
                    replyActivity.Text = "Message Count " + i;
                    await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
                }
            }
            else if (activity.Text.Contains("O365Card"))
            {
                O365ConnectorCard card          = CreateSampleO365ConnectorCard();
                Activity          replyActivity = activity.CreateReply();
                replyActivity.Attachments = new List <Attachment>();
                Attachment plAttachment = card.ToAttachment();
                replyActivity.Attachments.Add(plAttachment);
                await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
            }
            else if (activity.Text.Contains("Signin"))
            {
                var userId = activity.From.Id;
                if (userIdFacebookTokenCache.ContainsKey(userId))
                {
                    // Use cached token
                    var token = userIdFacebookTokenCache[userId];
                    try
                    {
                        // Send a thumbnail card with user's FB profile
                        var card = await CreateFBProfileCard(token);

                        Activity replyActivity = activity.CreateReply();
                        replyActivity.Text = "Cached credential is found. Use cached token to fetch info.";
                        replyActivity.Attachments.Add(card);
                        await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
                    }
                    catch (Exception)
                    {
                        await SendSigninCard(activity, connectorClient);
                    }
                }
                else
                {
                    // No token cached: issue a new Signin card
                    await SendSigninCard(activity, connectorClient);
                }
            }
            else if (activity.Text.Contains("Signout"))
            {
                var userId = activity.From.Id;
                userIdFacebookTokenCache.Remove(userId);
                Activity replyActivity = activity.CreateReply();
                replyActivity.Text = "Your credential has been removed.";
                await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
            }
            else if (activity.Text.Contains("GetTeamDetails"))
            {
                if (string.IsNullOrEmpty(activity.GetChannelData <TeamsChannelData>()?.Team?.Id))
                {
                    Activity replyActivity = activity.CreateReply();
                    replyActivity.Text = "This call can only be made from a Team.";
                    await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
                }
                else
                {
                    var teamDetails = await connectorClient.GetTeamsConnectorClient().Teams.FetchTeamDetailsAsync(activity.GetChannelData <TeamsChannelData>().Team.Id);

                    Activity replyActivity = activity.CreateReply();
                    replyActivity.Text = "<p>Team Id " + teamDetails.Id + " </p>" +
                                         "<p>Team Name " + teamDetails.Name + " </p>" +
                                         "<p>Team AAD Group Id " + teamDetails.AadGroupId + " </p>";
                    await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
                }
            }
            else
            {
                var accountList = connectorClient.Conversations.GetConversationMembers(activity.Conversation.Id);

                Activity replyActivity = activity.CreateReply();
                replyActivity.Text = "Help " +
                                     "<p>Type GetChannels to get List of Channels. </p>" +
                                     "<p>Type GetTenantId to get Tenant Id </p>" +
                                     "<p>Type Create1on1 to create one on one conversation. </p>" +
                                     "<p>Type GetMembers to get list of members in a conversation (team or direct conversation). </p>" +
                                     "<p>Type TestRetry to get multiple messages from Bot in throttled and retried mechanism. </p>" +
                                     "<p>Type O365Card to get a O365 actionable connector card. </p>" +
                                     "<p>Type Signin to issue a Signin card to sign in a Facebook app. </p>" +
                                     "<p>Type Signout to logout Facebook app and clear cached credentials. </p>" +
                                     "<p>Type GetTeamDetails to get details for the current team. </p>";
                replyActivity = replyActivity.AddMentionToText(activity.From);
                await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(replyActivity);
            }
        }
        public void CardTests_O365ConnectorCard()
        {
            var actionCard1 = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Multiple Choice",
                "card-1",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-1",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice 1", "1"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 2", "2"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 3", "3")
                },
                    "expanded",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-2",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice 4", "4"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 5", "5"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice 6", "6")
                },
                    "compact",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-3",
                    false,
                    "Pick an option",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice a", "a"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice b", "b"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice c", "c")
                },
                    "expanded",
                    false),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "list-4",
                    false,
                    "Pick an option",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Choice x", "x"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice y", "y"),
                    new O365ConnectorCardMultichoiceInputChoice("Choice z", "z")
                },
                    "compact",
                    false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "card-1-btn-1",
                    @"{""list1"":""{{list-1.value}}"", ""list2"":""{{list-2.value}}"", ""list3"":""{{list-3.value}}"", ""list4"":""{{list-4.value}}""}")
            });

            var actionCard2 = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Text Input",
                "card-2",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-1",
                    false,
                    "multiline, no maxLength",
                    null,
                    true,
                    null),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-2",
                    false,
                    "single line, no maxLength",
                    null,
                    false,
                    null),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-3",
                    true,
                    "multiline, max len = 10, isRequired",
                    null,
                    true,
                    10),
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-4",
                    true,
                    "single line, max len = 10, isRequired",
                    null,
                    false,
                    10)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "card-2-btn-1",
                    @"{""text1"":""{{text-1.value}}"", ""text2"":""{{text-2.value}}"", ""text3"":""{{text-3.value}}"", ""text4"":""{{text-4.value}}""}")
            });

            var actionCard3 = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Date Input",
                "card-3",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-1",
                    true,
                    "date with time",
                    null,
                    true),
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-2",
                    false,
                    "date only",
                    null,
                    false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "card-3-btn-1",
                    @"{""date1"":""{{date-1.value}}"", ""date2"":""{{date-2.value}}""}")
            });

            var section = new O365ConnectorCardSection(
                "This is the **section's title** property",
                "This is the section's text property. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
                "This is the section's activityTitle property",
                "This is the section's activitySubtitle property",
                "This is the section's activityText property.",
                "http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
                "avatar",
                true,
                new List <O365ConnectorCardFact>()
            {
                new O365ConnectorCardFact("This is a fact name", "This is a fact value"),
                new O365ConnectorCardFact("This is a fact name", "This is a fact value"),
                new O365ConnectorCardFact("This is a fact name", "This is a fact value")
            },
                new List <O365ConnectorCardImage>()
            {
                new O365ConnectorCardImage("http://connectorsdemo.azurewebsites.net/images/MicrosoftSurface_024_Cafe_OH-06315_VS_R1c.jpg"),
                new O365ConnectorCardImage("http://connectorsdemo.azurewebsites.net/images/WIN12_Scene_01.jpg"),
                new O365ConnectorCardImage("http://connectorsdemo.azurewebsites.net/images/WIN12_Anthony_02.jpg")
            },
                new List <O365ConnectorCardActionBase>()
            {
                new O365ConnectorCardViewAction(
                    O365ConnectorCardViewAction.Type,
                    "View",
                    null,
                    new List <string>()
                {
                    "http://microsoft.com"
                }),
                new O365ConnectorCardViewAction(
                    O365ConnectorCardViewAction.Type,
                    "View",
                    null,
                    new List <string>()
                {
                    "http://microsoft.com"
                }),
            });

            O365ConnectorCard card = new O365ConnectorCard()
            {
                Summary    = "This is the summary property",
                ThemeColor = "E81123",
                Title      = "This is the card title property",
                Text       = "This is the card's text property. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    actionCard1,
                    actionCard2,
                    actionCard3,
                    new O365ConnectorCardViewAction(
                        O365ConnectorCardViewAction.Type,
                        "View Action",
                        null,
                        new List <string>
                    {
                        "http://microsoft.com"
                    }),
                    new O365ConnectorCardOpenUri(
                        O365ConnectorCardOpenUri.Type,
                        "Open Uri",
                        "open-uri",
                        new List <O365ConnectorCardOpenUriTarget>
                    {
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "default",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "iOS",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "android",
                            Uri = "http://microsoft.com"
                        },
                        new O365ConnectorCardOpenUriTarget
                        {
                            Os  = "windows",
                            Uri = "http://microsoft.com"
                        }
                    })
                }
            };

            this.TestCard(new Attachment
            {
                Content     = card,
                ContentType = O365ConnectorCard.ContentType
            });
        }
Ejemplo n.º 10
0
        public static Attachment GetCardsInformation()
        {
            var section = new O365ConnectorCardSection {
                ActivityTitle = "Track customer belongings",
                Text          = "Using this bot you can<ol><li>Check baggage status</li><li>Track current location</li><li>Re-assign baggage</li><li>Report missing</li></ol> Choose one of the options below to retrieve details"
            };

            var PNRNumberCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Baggage by PNR",
                "PNR",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "pnrNumberInput",
                    true,
                    "Enter PNR number (Ex:DBW6WK, DBW6WF, DBW6RK)",
                    null,
                    false,
                    null)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Show",
                    Constants.PNR,
                    @"{""Value"":""{{pnrNumberInput.value}}""}")
            });
            var TicketNumnerCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Baggage by Ticket#",
                "Ticket Number",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "ticketNumberInput",
                    true,
                    "Enter Ticket number (Ex: DBW612, DBW634, DBW678)",
                    null,
                    false,
                    null)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Show",
                    Constants.TicketNumber,
                    @"{""Value"":""{{ticketNumberInput.value}}""}")
            });
            var NameCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Baggage by Passenger Name",
                "Name",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "NameInput",
                    true,
                    "Enter Passenger Name( Ex: Adele, Alex, Allan)",
                    null,
                    false,
                    null)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Show",
                    Constants.Name,
                    @"{""Value"":""{{NameInput.value}}""}")
            });



            O365ConnectorCard card = new O365ConnectorCard()
            {
                ThemeColor = "#E67A9E",
                Title      = "Passenger Baggage Information",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    PNRNumberCard,
                    TicketNumnerCard,
                    NameCard
                }
            };

            return(card.ToAttachment());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create a sample O365 connector card.
        /// </summary>
        /// <returns>The result card with actions.</returns>
        ///
        public static Attachment CreateSampleO365ConnectorCard(string baseUri)
        {
            string imageUrl = baseUri + "/public/assets/ActionableCardIconImage.png";

            #region Multichoice Card
            var multichoiceCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Multiple Choice",
                "Multiple Choice Card",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "CardsType",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Hero Card", "Hero Card"),
                    new O365ConnectorCardMultichoiceInputChoice("Thumbnail Card", "Thumbnail Card"),
                    new O365ConnectorCardMultichoiceInputChoice("O365 Connector Card", "O365 Connector Card")
                },
                    "expanded",
                    true),
                new O365ConnectorCardMultichoiceInput(
                    O365ConnectorCardMultichoiceInput.Type,
                    "Teams",
                    true,
                    "Pick multiple options",
                    null,
                    new List <O365ConnectorCardMultichoiceInputChoice>
                {
                    new O365ConnectorCardMultichoiceInputChoice("Bot", "Bot"),
                    new O365ConnectorCardMultichoiceInputChoice("Tab", "Tab"),
                    new O365ConnectorCardMultichoiceInputChoice("Connector", "Connector"),
                    new O365ConnectorCardMultichoiceInputChoice("Compose Extension", "Compose Extension")
                },
                    "compact",
                    true)
            },

                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST
                (
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "multichoice",
                    @"{""CardsType"":""{{CardsType.value}}"", ""Teams"":""{{Teams.value}}""}")
            });

            #endregion

            #region Input Card
            var inputCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Text Input",
                "Input Card",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "text-1",
                    false,
                    "multiline, no maxLength",
                    null,
                    true,
                    null)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "inputText",
                    @"{""text1"":""{{text-1.value}}""}")
            });
            #endregion

            #region Date Card
            var dateCard = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Date Input",
                "Date Card",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardDateInput(
                    O365ConnectorCardDateInput.Type,
                    "date-2",
                    false,
                    "date only",
                    null,
                    false)
            },
                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Send",
                    "dateInput",
                    @"{""date1"":""{{date-1.value}}""")
            });
            #endregion

            var section = new O365ConnectorCardSection(
                "",
                "",
                "Actionable Message",
                "",
                "This is an actionable message card. You can add operations within the card.",
                imageUrl,
                true,
                null,
                null);

            O365ConnectorCard card = new O365ConnectorCard()
            {
                Summary    = "O365 card summary",
                ThemeColor = "#E67A9E",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },

                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    multichoiceCard,
                    inputCard,
                    dateCard
                }
            };

            return(card.ToAttachment());
        }
Ejemplo n.º 12
0
        public static O365ConnectorCard GetO365ConnectorCardResult(Product product)
        {
            int balanceItems = product.Quantity - product.Committed;
            var actionId     = Guid.NewGuid().ToString();

            var section = new O365ConnectorCardSection
            {
                ActivityTitle    = $"Item Name: **{product.ProductName}**",
                ActivitySubtitle = $"Item Code: **{product.ItemCode}**",
                ActivityImage    = product.ProductImageUrl,
                Facts            = new List <O365ConnectorCardFact>
                {
                    new O365ConnectorCardFact("Location", product.Location),
                    new O365ConnectorCardFact("Total Inventory", product.Quantity.ToString()),
                    new O365ConnectorCardFact("Quantity committed", product.Committed.ToString()),
                    new O365ConnectorCardFact("Quantity available", balanceItems.ToString()),
                }
            };
            var addInventory = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Add Inventory",
                "Text Input",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "itemCount",
                    true,
                    "Number of items to add",
                    null,
                    false,
                    null)
            },


                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Add Inventory",
                    Constants.newInventoryCount,
                    @"{'newItem':'{{itemCount.value}}', 'ProductId':'" + product.PrdouctId + "'}")
            });

            var blockInventory = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Block Inventory",
                "Text Input1",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "itemCount1",
                    true,
                    "Number of items to blocked",
                    null,
                    false,
                    null)
            },


                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Block Inventory",
                    Constants.BlockInventory,
                    @"{'newItem':'{{itemCount1.value}}', 'ProductId':'" + product.PrdouctId + "'}")
            });
            var retireInventory = new O365ConnectorCardActionCard(
                O365ConnectorCardActionCard.Type,
                "Retire Inventory",
                "Text Input2",
                new List <O365ConnectorCardInputBase>
            {
                new O365ConnectorCardTextInput(
                    O365ConnectorCardTextInput.Type,
                    "itemCount2",
                    true,
                    "Number of items to Retire",
                    null,
                    false,
                    null)
            },


                new List <O365ConnectorCardActionBase>
            {
                new O365ConnectorCardHttpPOST(
                    O365ConnectorCardHttpPOST.Type,
                    "Retire Inventory",
                    Constants.RetireInventory,
                    @"{'newItem':'{{itemCount2.value}}', 'ProductId':'" + product.PrdouctId + "'}")
            });
            O365ConnectorCard card = new O365ConnectorCard()
            {
                Title      = "Product Information",
                ThemeColor = "#E67A9E",
                Sections   = new List <O365ConnectorCardSection> {
                    section
                },
                PotentialAction = new List <O365ConnectorCardActionBase>
                {
                    addInventory,
                    blockInventory,
                    retireInventory,
                    new O365ConnectorCardHttpPOST(O365ConnectorCardHttpPOST.Type, "Request for stock", Constants.RequestNewStock, $"{{'Value':'{product.PrdouctId}'}}"),
                }
            };

            return(card);
        }