Esempio n. 1
0
        /// <summary>
        /// Return the appropriate set of card actions based on the state and information in the ticket.
        /// </summary>
        /// <returns>Adaptive card actions.</returns>
        protected virtual List <AdaptiveAction> BuildActions()
        {
            List <AdaptiveAction> actionsList = new List <AdaptiveAction>();

            actionsList.Add(this.CreateChatWithUserAction());

            actionsList.Add(new AdaptiveShowCardAction
            {
                Title = Resource.ChangeStatusButtonText,
                Card  = new AdaptiveCard("1.0")
                {
                    Body = new List <AdaptiveElement>
                    {
                        this.GetAdaptiveChoiceSetInput(),
                    },
                    Actions = new List <AdaptiveAction>
                    {
                        new AdaptiveSubmitAction
                        {
                            Data = new ChangeTicketStatusPayload {
                                TicketId = this.Ticket.TicketId
                            }
                        }
                    },
                }
            });

            if (!string.IsNullOrEmpty(this.Ticket.KnowledgeBaseAnswer))
            {
                actionsList.Add(new AdaptiveShowCardAction
                {
                    Title = Resource.ViewArticleButtonText,
                    Card  = new AdaptiveCard("1.0")
                    {
                        Body = new List <AdaptiveElement>
                        {
                            new AdaptiveTextBlock
                            {
                                Text = CardHelper.TruncateStringIfLonger(this.Ticket.KnowledgeBaseAnswer, CardHelper.KnowledgeBaseAnswerMaxDisplayLength),
                                Wrap = true,
                            }
                        },
                    },
                });
            }

            return(actionsList);
        }
        /// <summary>
        /// Building the fact set to render out the user facing details.
        /// </summary>
        /// <param name="ticket">The current ticket information.</param>
        /// <param name="activityLocalTimestamp">The local timestamp.</param>
        /// <returns>The adaptive facts.</returns>
        private List <AdaptiveFact> BuildFactSet(TicketEntity ticket, DateTimeOffset?activityLocalTimestamp)
        {
            List <AdaptiveFact> factList = new List <AdaptiveFact>();

            //factList.Add(new AdaptiveFact
            //{
            //    Title = Resource.StatusFactTitle,
            //    Value = CardHelper.GetUserTicketDisplayStatus(this.ticket),
            //});

            factList.Add(new AdaptiveFact
            {
                Title = Resource.TitleFact,
                Value = CardHelper.TruncateStringIfLonger(this.ticket.Title, CardHelper.TitleMaxDisplayLength),
            });

            if (!string.IsNullOrEmpty(ticket.Description))
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Resource.DescriptionFact,
                    Value = CardHelper.TruncateStringIfLonger(this.ticket.Description, CardHelper.DescriptionMaxDisplayLength),
                });
            }

            factList.Add(new AdaptiveFact
            {
                Title = Resource.DateCreatedDisplayFactTitle,
                Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateCreated, activityLocalTimestamp),
            });

            if (ticket.Status == (int)TicketState.Closed)
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Resource.ClosedFactTitle,
                    Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateClosed.Value, activityLocalTimestamp),
                });
            }

            return(factList);
        }
        /// <summary>
        /// Return the appropriate fact set based on the state and information in the ticket.
        /// </summary>
        /// <param name="localTimestamp">The current timestamp.</param>
        /// <returns>The fact set showing the necessary details.</returns>
        private List <AdaptiveFact> BuildFactSet(DateTimeOffset?localTimestamp)
        {
            List <AdaptiveFact> factList = new List <AdaptiveFact>();

            if (!string.IsNullOrEmpty(this.Ticket.Description))
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Resource.DescriptionFact,
                    Value = this.Ticket.Description,
                });
            }

            if (!string.IsNullOrEmpty(this.Ticket.UserQuestion))
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Resource.QuestionAskedFactTitle,
                    Value = this.Ticket.UserQuestion
                });
            }

            factList.Add(new AdaptiveFact
            {
                Title = Resource.StatusFactTitle,
                Value = CardHelper.GetTicketDisplayStatusForSme(this.Ticket),
            });

            if (this.Ticket.Status == (int)TicketState.Closed)
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Resource.ClosedFactTitle,
                    Value = CardHelper.GetFormattedDateInUserTimeZone(this.Ticket.DateClosed.Value, localTimestamp),
                });
            }

            return(factList);
        }
Esempio n. 4
0
        /// <summary>
        /// This method will construct the card for SME team which will have the
        /// feedback details given by the user.
        /// </summary>
        /// <param name="data">user activity payload</param>
        /// <param name="userDetails">User details.</param>
        /// <returns>Sme facing feedback notification card.</returns>
        public static Attachment GetCard(ShareFeedbackCardPayload data, TeamsChannelAccount userDetails)
        {
            // Constructing adaptive card that is sent to SME team.
            AdaptiveCard smeFeedbackCard = new AdaptiveCard("1.0")
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock()
                    {
                        Text   = Resource.SMEFeedbackHeaderText,
                        Weight = AdaptiveTextWeight.Bolder,
                        Size   = AdaptiveTextSize.Medium,
                    },
                    new AdaptiveTextBlock()
                    {
                        Text = string.Format(Resource.FeedbackAlertText, userDetails.Name),
                        Wrap = true,
                    },
                    new AdaptiveTextBlock()
                    {
                        Text   = Resource.RatingTitle,
                        Weight = AdaptiveTextWeight.Bolder,
                        Wrap   = true,
                    },
                    new AdaptiveTextBlock()
                    {
                        Text    = GetRatingDisplayText(data.Rating),
                        Spacing = AdaptiveSpacing.None,
                        Wrap    = true,
                    },
                },
                Actions = new List <AdaptiveAction>
                {
                    new AdaptiveOpenUrlAction
                    {
                        Title     = string.Format(Resource.ChatTextButton, userDetails.GivenName),
                        UrlString = $"https://teams.microsoft.com/l/chat/0/0?users={Uri.EscapeDataString(userDetails.UserPrincipalName)}"
                    }
                }
            };

            // Description fact is available in the card only when user enters description text.
            if (!string.IsNullOrWhiteSpace(data.Description))
            {
                smeFeedbackCard.Body.Add(new AdaptiveTextBlock()
                {
                    Text   = Resource.DescriptionText,
                    Weight = AdaptiveTextWeight.Bolder,
                    Wrap   = true,
                });
                smeFeedbackCard.Body.Add(new AdaptiveTextBlock()
                {
                    Text    = CardHelper.TruncateStringIfLonger(data.Description, CardHelper.DescriptionMaxDisplayLength),
                    Spacing = AdaptiveSpacing.None,
                    Wrap    = true,
                });
            }

            // Question asked fact and view article show card is available when feedback is on QnA Maker response.
            if (!string.IsNullOrWhiteSpace(data.KnowledgeBaseAnswer) && !string.IsNullOrWhiteSpace(data.UserQuestion))
            {
                smeFeedbackCard.Body.Add(new AdaptiveFactSet
                {
                    Facts = new List <AdaptiveFact>
                    {
                        new AdaptiveFact()
                        {
                            Title = Resource.QuestionAskedFactTitle,
                            Value = data.UserQuestion,
                        },
                    }
                });
                smeFeedbackCard.Actions.AddRange(new List <AdaptiveAction>
                {
                    new AdaptiveShowCardAction
                    {
                        Title = Resource.ViewArticleButtonText,
                        Card  = new AdaptiveCard("1.0")
                        {
                            Body = new List <AdaptiveElement>
                            {
                                new AdaptiveTextBlock
                                {
                                    Text = CardHelper.TruncateStringIfLonger(data.KnowledgeBaseAnswer, CardHelper.KnowledgeBaseAnswerMaxDisplayLength),
                                    Wrap = true
                                }
                            }
                        }
                    }
                });
            }

            return(new Attachment
            {
                ContentType = AdaptiveCard.ContentType,
                Content = smeFeedbackCard,
            });
        }