diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs index 1c6f4f6..d4859ec 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs @@ -349,8 +349,8 @@ private async Task OnAdaptiveCardSubmitInPersonalChatAsync(IMessageActivity mess var userDetails = await this.GetUserDetailsInPersonalChatAsync(turnContext, cancellationToken); newTicket = await this.CreateTicketAsync(message, askAnExpertPayload, userDetails); - smeTeamCard = new SmeTicketCard(newTicket).ToAttachment(message.LocalTimestamp); - userCard = new UserNotificationCard(newTicket).ToAttachment(Resource.NotificationCardContent, message.LocalTimestamp); + smeTeamCard = new SmeTicketCard(newTicket).ToAttachment(); + userCard = new UserNotificationCard(newTicket).ToAttachment(Resource.NotificationCardContent); break; } @@ -464,7 +464,7 @@ private async Task OnAdaptiveCardSubmitInChannelAsync(IMessageActivity message, { Id = ticket.SmeCardActivityId, Conversation = new ConversationAccount { Id = ticket.SmeThreadConversationId }, - Attachments = new List { new SmeTicketCard(ticket).ToAttachment(message.LocalTimestamp) }, + Attachments = new List { new SmeTicketCard(ticket).ToAttachment() }, }; var updateResponse = await turnContext.UpdateActivityAsync(updateCardActivity, cancellationToken); this.telemetryClient.TrackTrace($"Card for ticket {ticket.TicketId} updated to status ({ticket.Status}, {ticket.AssignedToObjectId}), activityId = {updateResponse.Id}"); @@ -477,21 +477,21 @@ private async Task OnAdaptiveCardSubmitInChannelAsync(IMessageActivity message, case ChangeTicketStatusPayload.ReopenAction: smeNotification = string.Format(Resource.SMEOpenedStatus, message.From.Name); - userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ReopenedTicketUserNotification, message.LocalTimestamp)); + userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ReopenedTicketUserNotification)); userNotification.Summary = Resource.ReopenedTicketUserNotification; break; case ChangeTicketStatusPayload.CloseAction: smeNotification = string.Format(Resource.SMEClosedStatus, ticket.LastModifiedByName); - userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ClosedTicketUserNotification, message.LocalTimestamp)); + userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ClosedTicketUserNotification)); userNotification.Summary = Resource.ClosedTicketUserNotification; break; case ChangeTicketStatusPayload.AssignToSelfAction: smeNotification = string.Format(Resource.SMEAssignedStatus, ticket.AssignedToName); - userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.AssignedTicketUserNotification, message.LocalTimestamp)); + userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.AssignedTicketUserNotification)); userNotification.Summary = Resource.AssignedTicketUserNotification; break; } diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/MessagingExtension.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/MessagingExtension.cs index a707aca..bbae2c0 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/MessagingExtension.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/MessagingExtension.cs @@ -191,7 +191,7 @@ public async Task GetSearchResultAsync(string query, s }; var selectedTicketAdaptiveCard = new MessagingExtensionTicketsCard(ticket); - composeExtensionResult.Attachments.Add(selectedTicketAdaptiveCard.ToAttachment(localTimestamp).ToMessagingExtensionAttachment(previewCard.ToAttachment())); + composeExtensionResult.Attachments.Add(selectedTicketAdaptiveCard.ToAttachment().ToMessagingExtensionAttachment(previewCard.ToAttachment())); } return composeExtensionResult; diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/CardHelper.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/CardHelper.cs index 7ecd060..9c85885 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/CardHelper.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/CardHelper.cs @@ -90,11 +90,17 @@ public static string GetTicketDisplayStatusForSme(TicketEntity ticket) /// The date and time to format. /// The sender's local time, as determined by the local timestamp of the activity. /// A datetime string. - public static string GetFormattedDateInUserTimeZone(DateTime dateTime, DateTimeOffset? userLocalTime) + public static string GetFormattedDateInUserTimeZone(DateTime dateTime, DateTimeOffset? userLocalTime = null) { - // Adaptive card on mobile has a bug where it does not support DATE and TIME, so for now we convert the date and time manually - // TODO: Change to use DATE() function - return dateTime.Add(userLocalTime?.Offset ?? TimeSpan.FromMinutes(0)).ToShortDateString(); + if (userLocalTime == null) + { + var timestamp = dateTime.ToString("yyyy-MM-ddTHH:mm:ssZ"); + return "{{DATE(" + timestamp + ", SHORT)}}"; + } + else + { + return dateTime.Add(userLocalTime?.Offset ?? TimeSpan.FromMinutes(0)).ToShortDateString(); + } } } } \ No newline at end of file diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/SmeTicketCard.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/SmeTicketCard.cs index fc7e75e..0979176 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/SmeTicketCard.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/SmeTicketCard.cs @@ -37,9 +37,8 @@ public SmeTicketCard(TicketEntity ticket) /// /// Returns an attachment based on the state and information of the ticket. /// - /// Local timestamp of the user activity. /// Returns the attachment that will be sent in a message. - public Attachment ToAttachment(DateTimeOffset? localTimestamp) + public Attachment ToAttachment() { var card = new AdaptiveCard("1.0") { @@ -59,7 +58,7 @@ public Attachment ToAttachment(DateTimeOffset? localTimestamp) }, new AdaptiveFactSet { - Facts = this.BuildFactSet(localTimestamp), + Facts = this.BuildFactSet(), }, }, Actions = this.BuildActions(), @@ -142,9 +141,8 @@ protected AdaptiveAction CreateChatWithUserAction() /// /// Return the appropriate fact set based on the state and information in the ticket. /// - /// The current timestamp. /// The fact set showing the necessary details. - private List BuildFactSet(DateTimeOffset? localTimestamp) + private List BuildFactSet() { List factList = new List(); @@ -177,7 +175,7 @@ private List BuildFactSet(DateTimeOffset? localTimestamp) factList.Add(new AdaptiveFact { Title = Resource.ClosedFactTitle, - Value = CardHelper.GetFormattedDateInUserTimeZone(this.Ticket.DateClosed.Value, localTimestamp), + Value = CardHelper.GetFormattedDateInUserTimeZone(this.Ticket.DateClosed.Value), }); } diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/UserNotificationCard.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/UserNotificationCard.cs index 170ef8c..535a151 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/UserNotificationCard.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/UserNotificationCard.cs @@ -32,9 +32,8 @@ public UserNotificationCard(TicketEntity ticket) /// Returns a user notification card for the ticket. /// /// The status message to add to the card - /// Local time stamp of user activity. /// An adaptive card as an attachment - public Attachment ToAttachment(string message, DateTimeOffset? activityLocalTimestamp) + public Attachment ToAttachment(string message) { var card = new AdaptiveCard("1.0") { @@ -47,7 +46,7 @@ public Attachment ToAttachment(string message, DateTimeOffset? activityLocalTime }, new AdaptiveFactSet { - Facts = this.BuildFactSet(this.ticket, activityLocalTimestamp) + Facts = this.BuildFactSet(this.ticket) }, }, Actions = this.BuildActions(this.ticket), @@ -94,9 +93,8 @@ private List BuildActions(TicketEntity ticket) /// Building the fact set to render out the user facing details. /// /// The current ticket information. - /// The local timestamp. /// The adaptive facts. - private List BuildFactSet(TicketEntity ticket, DateTimeOffset? activityLocalTimestamp) + private List BuildFactSet(TicketEntity ticket) { List factList = new List(); factList.Add(new AdaptiveFact @@ -123,7 +121,7 @@ private List BuildFactSet(TicketEntity ticket, DateTimeOffset? act factList.Add(new AdaptiveFact { Title = Resource.DateCreatedDisplayFactTitle, - Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateCreated, activityLocalTimestamp), + Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateCreated), }); if (ticket.Status == (int)TicketState.Closed) @@ -131,7 +129,7 @@ private List BuildFactSet(TicketEntity ticket, DateTimeOffset? act factList.Add(new AdaptiveFact { Title = Resource.ClosedFactTitle, - Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateClosed.Value, activityLocalTimestamp), + Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateClosed.Value), }); }