/// <summary> /// Building the fact set to render out the user facing details. /// </summary> /// <returns>The adaptive facts.</returns> private List <AdaptiveFact> BuildFactSet() { List <AdaptiveFact> factList = new List <AdaptiveFact>(); factList.Add(new AdaptiveFact { Title = Strings.StatusFactTitle, Value = CardHelper.GetUserTicketDisplayStatus(this.ticket), }); factList.Add(new AdaptiveFact { Title = Strings.TitleFact, Value = CardHelper.TruncateStringIfLonger(this.ticket.Title, CardHelper.TitleMaxDisplayLength), }); if (!string.IsNullOrEmpty(this.ticket.Description)) { factList.Add(new AdaptiveFact { Title = Strings.DescriptionFact, Value = CardHelper.TruncateStringIfLonger(this.ticket.Description, CardHelper.DescriptionMaxDisplayLength), }); } factList.Add(new AdaptiveFact { Title = Strings.DateCreatedDisplayFactTitle, Value = CardHelper.GetFormattedDateForAdaptiveCard(this.ticket.DateCreated), }); if (this.ticket.Status == (int)TicketState.Closed) { factList.Add(new AdaptiveFact { Title = Strings.ClosedFactTitle, Value = CardHelper.GetFormattedDateForAdaptiveCard(this.ticket.DateClosed.Value), }); } return(factList); }
/// <summary> /// Return the appropriate fact set based on the state and information in the ticket. /// </summary> /// <returns>The fact set showing the necessary details.</returns> private List <AdaptiveFact> BuildFactSet() { List <AdaptiveFact> factList = new List <AdaptiveFact>(); if (!string.IsNullOrEmpty(this.Ticket.Description)) { factList.Add(new AdaptiveFact { Title = Strings.DescriptionFact, Value = this.Ticket.Description, }); } if (!string.IsNullOrEmpty(this.Ticket.UserQuestion)) { factList.Add(new AdaptiveFact { Title = Strings.QuestionAskedFactTitle, Value = this.Ticket.UserQuestion, }); } factList.Add(new AdaptiveFact { Title = Strings.StatusFactTitle, Value = CardHelper.GetTicketDisplayStatusForSme(this.Ticket), }); if (this.Ticket.Status == (int)TicketState.Closed) { factList.Add(new AdaptiveFact { Title = Strings.ClosedFactTitle, Value = CardHelper.GetFormattedDateForAdaptiveCard(this.Ticket.DateClosed.Value), }); } return(factList); }
/// <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) { var textAlignment = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? AdaptiveHorizontalAlignment.Right : AdaptiveHorizontalAlignment.Left; // Constructing adaptive card that is sent to SME team. AdaptiveCard smeFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0)) { Body = new List <AdaptiveElement> { new AdaptiveTextBlock() { Text = Strings.SMEFeedbackHeaderText, Weight = AdaptiveTextWeight.Bolder, Size = AdaptiveTextSize.Medium, HorizontalAlignment = textAlignment, }, new AdaptiveTextBlock() { Text = string.Format(CultureInfo.InvariantCulture, Strings.FeedbackAlertText, userDetails?.Name), Wrap = true, HorizontalAlignment = textAlignment, }, new AdaptiveTextBlock() { Text = Strings.RatingTitle, Weight = AdaptiveTextWeight.Bolder, Wrap = true, HorizontalAlignment = textAlignment, }, new AdaptiveTextBlock() { Text = GetRatingDisplayText(data?.Rating), Spacing = AdaptiveSpacing.None, Wrap = true, HorizontalAlignment = textAlignment, }, }, Actions = new List <AdaptiveAction> { new AdaptiveOpenUrlAction { Title = string.Format(CultureInfo.InvariantCulture, Strings.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 = Strings.DescriptionText, Weight = AdaptiveTextWeight.Bolder, Wrap = true, HorizontalAlignment = textAlignment, }); smeFeedbackCard.Body.Add(new AdaptiveTextBlock() { Text = CardHelper.TruncateStringIfLonger(data.Description, CardHelper.DescriptionMaxDisplayLength), Spacing = AdaptiveSpacing.None, Wrap = true, HorizontalAlignment = textAlignment, }); } // 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 = Strings.QuestionAskedFactTitle, Value = data.UserQuestion, }, }, }); smeFeedbackCard.Actions.AddRange(new List <AdaptiveAction> { new AdaptiveShowCardAction { Title = Strings.ViewArticleButtonText, Card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0)) { Body = new List <AdaptiveElement> { new AdaptiveTextBlock { Text = CardHelper.TruncateStringIfLonger(data.KnowledgeBaseAnswer, CardHelper.KnowledgeBaseAnswerMaxDisplayLength), Wrap = true, HorizontalAlignment = textAlignment, }, }, }, }, }); } return(new Attachment { ContentType = AdaptiveCard.ContentType, Content = smeFeedbackCard, }); }