Beispiel #1
0
        private void AddBotMsg()
        {
            if ((_stageId == WorkFlowStage.CAR.ItemId &&
                 ((_auditCheck.Settings.IsApplicable.HasValue && _auditCheck.Settings.IsApplicable.Value) ||
                  (_auditCheck.Settings.IsSatisfactory.HasValue && _auditCheck.Settings.IsSatisfactory.Value))) ||
                _stageId == WorkFlowStage.Closed.ItemId || _stageId == WorkFlowStage.CAP.ItemId)
            {
                return;
            }


            if (_stageId > WorkFlowStage.View.ItemId && _stageId < WorkFlowStage.RCA.ItemId)
            {
                var actions = new List <ChatCardAction>
                {
                    new ChatCardAction("Accept")
                };
                var imageCard = new ChatImageCardDataItem(null, "", "", $"Move to next stage({WorkFlowStage.GetItemById(_stageId + 1).FullName})?", actions, null);
                var message   = new ChatCardMessage(imageCard, _author1, DateTime.Now);
                radChat2.AddMessage(message);
            }
            else if (_stageId >= WorkFlowStage.RCA.ItemId && _stageId < WorkFlowStage.Closed.ItemId)
            {
                var actions = new List <ChatCardAction>
                {
                    new ChatCardAction("Accept"),
                    new ChatCardAction("Reject")
                };
                var imageCard = new ChatImageCardDataItem(null, "", "", $"Move to next stage({WorkFlowStage.GetItemById(_stageId + 1).FullName}) press Accept. " +
                                                          $"Move to previous stage({WorkFlowStage.GetItemById(_stageId - 1).FullName}) press Reject. ", actions, null);
                var message = new ChatCardMessage(imageCard, _author1, DateTime.Now);
                radChat2.AddMessage(message);
            }
        }
Beispiel #2
0
            /// <summary>
            /// Add a ChatImageCardElement programmatically
            /// </summary>
            /// <param name="radchat">RadChat Control To Populate</param>
            public void ChatImageCardElement(RadChat radchat)
            {
                Telerik.WinControls.UI.ChatImageCardDataItem imageCard = new ChatImageCardDataItem(Image1.ToImage(), "Benjamin Vilanders", "Senior Architect",
                                                                                                   "As a Senior Architect his experience in the industry allows him to take on increased responsibility. Like other architects, he design buildings " +
                                                                                                   "and makes sure they are structurally sound. Due to his track record of quality performance, Benjamin also serves as a manager, a mentor, an advisor and coordinator.",
                                                                                                   null, null);

                Author          author  = new Author(adminImg2.ToImage(), "Ben");
                ChatCardMessage message = new ChatCardMessage(imageCard, author, DateTime.Now);

                radchat.AddMessage(message);
            }
Beispiel #3
0
        private void RenderCarousel(Activity activity)
        {
            List <ChatImageCardDataItem> cards = new List <ChatImageCardDataItem>();

            foreach (Attachment attachment in activity.Attachments)
            {
                if (attachment.ContentType != "application/vnd.microsoft.card.hero")
                {
                    continue;
                }

                HeroCard heroCard = JsonConvert.DeserializeObject <HeroCard>(attachment.Content.ToString());

                List <ChatCardAction> actions = new List <ChatCardAction>();

                foreach (var action in heroCard.Buttons)
                {
                    ChatCardAction cardAction = new ChatCardAction(action.Title, null, action.Value);
                    actions.Add(cardAction);

                    if (!string.IsNullOrEmpty(action.Image))
                    {
                        this.DownloadImageAsync(cardAction, action.Image);
                    }
                }

                ChatImageCardDataItem card = new ChatImageCardDataItem(null, heroCard.Title, heroCard.Subtitle, heroCard.Text, actions, null);
                cards.Add(card);

                if (heroCard.Images != null && heroCard.Images.Count > 0)
                {
                    this.DownloadImageAsync(card, heroCard.Images[0].Url);
                }
            }

            ChatCarouselMessage message = new ChatCarouselMessage(cards, this.BotAuthor, DateTime.Now);

            this.radChat1.ChatElement.AddMessage(message);
        }
Beispiel #4
0
            // Chat Cards / Carousel

            public void Add_CarouselMessage(RadChat radchat)
            {
                Telerik.WinControls.UI.ChatImageCardDataItem imageCard = new ChatImageCardDataItem(Image1.ToImage(),
                                                                                                   "Benjamin Vilanders", "Senior Architect",
                                                                                                   "As a Senior Architect his experience in the industry allows him to take on increased responsibility. Like other architects, he design buildings " +
                                                                                                   "and makes sure they are structurally sound. Due to his track record of quality performance, Benjamin also serves as a manager, a mentor, an advisor and coordinator.",
                                                                                                   null, null);

                ChatProductCardDataItem productCard = new ChatProductCardDataItem(Image2.ToImage(),
                                                                                  "Arrive & Drive", "Rating 7/10",
                                                                                  "With our Arrive & Drive Packages, the only thing you will have to think about is driving. We make it simple for you to get more of what you love. We streamline the " +
                                                                                  "entire process and have everything ready for you when you arrive at the track so you can get straight to racing.", "Packages from $340",
                                                                                  null, null);

                ChatWeatherCardDataItem weatherCard = new ChatWeatherCardDataItem("Florence", Image3.ToImage(),
                                                                                  "33°C", "Humidity: 76%", "Dew: 31°C",
                                                                                  "Pressure: 1031 mb", "Wind Speed: 15 km/h NW");

                List <FlightInfo> flights = new List <FlightInfo>();

                flights.Add(new FlightInfo("Los Angelis", "LAX", DateTime.Now.AddDays(7), "New York", "JFK", DateTime.Now.AddDays(7).AddHours(5.5)));
                flights.Add(new FlightInfo("New York", "JFK", DateTime.Now.AddDays(14).AddHours(3), "Los Angelis", "LAX", DateTime.Now.AddDays(14).AddHours(9.1)));
                ChatFlightCardDataItem flightCard = new ChatFlightCardDataItem("Andrew Fuller", flights, Image4.ToImage(), "$341", null);

                List <BaseChatCardDataItem> cards = new List <BaseChatCardDataItem>();

                cards.Add(imageCard);
                cards.Add(productCard);
                cards.Add(weatherCard);
                cards.Add(flightCard);
                Author author = new Author(Image3.ToImage(), "Ben");

                ChatCarouselMessage carouselMessage = new ChatCarouselMessage(cards, author, DateTime.Now);

                radchat.AddMessage(carouselMessage);
            }
Beispiel #5
0
        private void RenderAdaptiveCard(Attachment attachment)
        {
            AdaptiveCard adaptiveCard = AdaptiveCard.FromJson(attachment.Content.ToString()).Card;

            if (adaptiveCard.AdditionalProperties["TType"].ToString() == "Flight")
            {
                string   passengerName        = ((AdaptiveTextBlock)adaptiveCard.Body[1]).Text;
                string   outDepartureCity     = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[0].Items[0]).Text;
                string   outDepartureAirport  = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[0].Items[1]).Text;
                DateTime outDepartureDateTime = DateTime.ParseExact(((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[0].Items[2]).Text
                                                                    + " " + ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[0].Items[3]).Text, "d MMM yyyy hh:mm tt", CultureInfo.InvariantCulture);
                string   outArrivalCity     = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[2].Items[0]).Text;
                string   outArrivalAirport  = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[2].Items[1]).Text;
                DateTime outArrivalDateTime = DateTime.ParseExact(((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[2].Items[2]).Text
                                                                  + " " + ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[2].Items[3]).Text, "d MMM yyyy hh:mm tt", CultureInfo.InvariantCulture);
                string   inDepartureCity     = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[0].Items[0]).Text;
                string   inDepartureAirport  = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[0].Items[1]).Text;
                DateTime inDepartureDateTime = DateTime.ParseExact(((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[0].Items[2]).Text
                                                                   + " " + ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[0].Items[3]).Text, "d MMM yyyy hh:mm tt", CultureInfo.InvariantCulture);
                string   inArrivalCity     = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[2].Items[0]).Text;
                string   inArrivalAirport  = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[2].Items[1]).Text;
                DateTime inArrivalDateTime = DateTime.ParseExact(((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[2].Items[2]).Text
                                                                 + " " + ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[2].Items[3]).Text, "d MMM yyyy hh:mm tt", CultureInfo.InvariantCulture);
                string total = ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[5]).Columns[1].Items[0]).Text;

                List <FlightInfo> flights = new List <FlightInfo>()
                {
                    new FlightInfo(outDepartureCity, outDepartureAirport, outDepartureDateTime, outArrivalCity, outArrivalAirport, outArrivalDateTime),
                    new FlightInfo(inDepartureCity, inDepartureAirport, inDepartureDateTime, inArrivalCity, inArrivalAirport, inArrivalDateTime)
                };

                ChatFlightCardDataItem card = new ChatFlightCardDataItem(passengerName, flights, null, total, null);
                this.radChat1.ChatElement.AddMessage(new ChatCardMessage(card, this.BotAuthor, DateTime.Now));

                this.DownloadImageAsync(card, ((AdaptiveImage)((AdaptiveColumnSet)adaptiveCard.Body[3]).Columns[1].Items[0]).Url.ToString());
            }
            else if (adaptiveCard.AdditionalProperties["TType"].ToString() == "Summary")
            {
                string        title = ((AdaptiveTextBlock)adaptiveCard.Body[1]).Text;
                StringBuilder sb    = new StringBuilder();
                sb.AppendLine(((AdaptiveTextBlock)adaptiveCard.Body[2]).Text);
                sb.AppendLine(((AdaptiveTextBlock)adaptiveCard.Body[3]).Text);

                if (adaptiveCard.Body.Count() > 5)
                {
                    sb.AppendLine(((AdaptiveTextBlock)adaptiveCard.Body[4]).Text);
                    sb.AppendLine(((AdaptiveTextBlock)adaptiveCard.Body[5]).Text);
                    sb.AppendLine(((AdaptiveTextBlock)adaptiveCard.Body[6]).Text);
                    sb.AppendLine(((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[7]).Columns[0].Items[0]).Text + ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[7]).Columns[1].Items[0]).Text);
                }
                else
                {
                    sb.AppendLine(((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[0].Items[0]).Text + ((AdaptiveTextBlock)((AdaptiveColumnSet)adaptiveCard.Body[4]).Columns[1].Items[0]).Text);
                }

                ChatImageCardDataItem card = new ChatImageCardDataItem(null, title, null, sb.ToString(), null, null);
                this.radChat1.ChatElement.AddMessage(new ChatCardMessage(card, this.BotAuthor, DateTime.Now));

                this.DownloadImageAsync(card, ((AdaptiveImage)adaptiveCard.Body[0]).Url.ToString());
            }
        }
        public void AddMessageHistory()
        {
            var me = Util.Instance.CurrentUser.Email;

            foreach (var item in AllMessage)
            {
                if (item.ImageMessageDriveID != "")
                {
                    var image        = GoogleDriveFilesRepository.DownloadFile(item.ImageMessageDriveID);
                    var displayImage = ResizeImagePercentage(Image.FromStream(image));
                    if (item.Sender == me)
                    {
                        ChatMediaMessage message = new ChatMediaMessage(displayImage, displayImage.Size, null, authorMe, item.TimeSend);
                        _rcChatlog.AddMessage(message);
                    }
                    else
                    {
                        ChatMediaMessage message = new ChatMediaMessage(displayImage, displayImage.Size, null, authorFriend, item.TimeSend);
                        _rcChatlog.AddMessage(message);
                    }
                }
                else if (item.Message != "")
                {
                    if (item.Sender == me)
                    {
                        ChatTextMessage message = new ChatTextMessage(item.Message, authorMe, item.TimeSend);
                        _rcChatlog.AddMessage(message);
                    }
                    else
                    {
                        ChatTextMessage message = new ChatTextMessage(item.Message, authorFriend, item.TimeSend);
                        _rcChatlog.AddMessage(message);
                    }
                }
                else if (item.Call != null)
                {
                    var tittle = "";
                    if (item.Call.Called)
                    {
                        tittle = "Cuộc gọi";
                    }
                    else
                    {
                        tittle = "Cuộc gọi nhỡ";
                    }
                    List <ChatCardAction> actions = new List <ChatCardAction>();
                    actions.Add(new ChatCardAction("Call"));
                    if (item.Sender == me)
                    {
                        ChatImageCardDataItem card    = new ChatImageCardDataItem(null, tittle, "bạn & " + authorFriend.Name, TimeSpan.FromSeconds(item.Call.Duration).ToString(@"mm\:ss"), actions, item.Receiver);
                        ChatCardMessage       message = new ChatCardMessage(card, authorMe, item.TimeSend);
                        _rcChatlog.AddMessage(message);
                    }
                    else
                    {
                        ChatImageCardDataItem card    = new ChatImageCardDataItem(null, tittle, "bạn & " + authorFriend.Name, TimeSpan.FromSeconds(item.Call.Duration).ToString(@"mm\:ss"), actions, item.Sender);
                        ChatCardMessage       message = new ChatCardMessage(card, authorFriend, item.TimeSend);
                        _rcChatlog.AddMessage(message);
                    }
                }
            }
        }