/// <summary> /// TaskModuleSubmit. /// </summary> /// <param name="turnContext">turnContext.</param> /// <param name="taskModuleRequest">taskmoduleRequest.</param> /// <param name="cancellationToken">cancellationToken.</param> /// <returns>returns task.</returns> protected override async Task <TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken) { try { var activity = (Activity)turnContext.Activity; if (activity.Value == null) { throw new ArgumentException("activity's value should not be null"); } ScrumDetailsEntity scrumDetails = JsonConvert.DeserializeObject <ScrumDetailsEntity>(JObject.Parse(activity.Value.ToString())["data"].ToString()); scrumDetails.Name = turnContext.Activity.From.Name; scrumDetails.UpdateTime = new DateTimeOffset(DateTime.UtcNow); var conversationId = GetConversationId(turnContext); scrumDetails.ThreadConversationId = conversationId; scrumDetails.UniqueRowKey = Guid.NewGuid().ToString(); if (string.IsNullOrEmpty(scrumDetails.Yesterday) || string.IsNullOrEmpty(scrumDetails.Today)) { return(this.GetScrumValidation(scrumDetails, turnContext, cancellationToken)); } string activityId = this.GetActivityIdToMatch(scrumDetails.MembersActivityIdMap, turnContext.Activity.From.Id); // check if member in scrum does not exists if (activityId == null) { await turnContext.SendActivityAsync(string.Format(Resources.NotPartofScrumText, turnContext.Activity.From.Name)); return(default);
/// <summary> /// TaskModuleFetch. /// </summary> /// <param name="turnContext">turnContext.</param> /// <param name="taskModuleRequest">taskmoduleRequest.</param> /// <param name="cancellationToken">cancellationToken.</param> /// <returns>returns task.</returns> protected override async Task <TaskModuleResponse> OnTeamsTaskModuleFetchAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken) { try { var activityFetch = (Activity)turnContext.Activity; if (activityFetch.Value == null) { throw new ArgumentException("activity's value should not be null"); } ScrumDetailsEntity scrumMemberDetails = JsonConvert.DeserializeObject <ScrumDetailsEntity>(JObject.Parse(activityFetch.Value.ToString())["data"].ToString()); string membersId = scrumMemberDetails.MembersActivityIdMap; string activityIdval = this.GetActivityIdToMatch(membersId, turnContext.Activity.From.Id); // A user is added during a running scrum and tries to update his/her details. if (activityIdval == null) { return(new TaskModuleResponse { Task = new TaskModuleContinueResponse { Value = new TaskModuleTaskInfo() { Card = ScrumCards.NoActionScrumCard(), Height = "small", Width = "medium", Title = Resources.NoActiveScrumTitle, }, }, }); } else { return(new TaskModuleResponse { Task = new TaskModuleContinueResponse { Value = new TaskModuleTaskInfo() { Card = ScrumCards.ScrumCard(membersId), Height = "large", Width = "medium", Title = Resources.ScrumTaskModuleTitle, }, }, }); } } catch (Exception ex) { this.telemetryClient.TrackTrace($"Invoke Activity failed: {ex.Message}"); this.telemetryClient.TrackException(ex); return(null); } }
public async Task <bool> SaveOrUpdateScrumUpdatesAsync(ScrumDetailsEntity scrumDetail) { try { scrumDetail.PartitionKey = UpdatesPartitionKey; scrumDetail.RowKey = scrumDetail.UniqueRowKey; var result = await this.StoreOrUpdateScrumEntityAsync(scrumDetail, this.scrumUpdateTable); return(result.HttpStatusCode == (int)HttpStatusCode.NoContent); } catch (Exception ex) { this.telemetryClient.TrackException(ex); this.telemetryClient.TrackTrace($"Exception : {ex.Message}"); return(false); } }
/// <summary> /// validation card on task module. /// </summary> /// <param name="scrumDetails">ScrumDetails object.</param> /// <returns>return carad.</returns> public static Attachment ValidationCard(ScrumDetailsEntity scrumDetails) { string yesterdayValidationText = string.IsNullOrEmpty(scrumDetails.Yesterday) ? Resources.YesterdayValidationText : string.Empty; string todayValidationText = string.IsNullOrEmpty(scrumDetails.Today) ? Resources.TodayValidationText : string.Empty; AdaptiveCard validationCard = new AdaptiveCard("1.0") { Body = new List <AdaptiveElement> { new AdaptiveColumnSet { Columns = new List <AdaptiveColumn> { new AdaptiveColumn { Width = AdaptiveColumnWidth.Auto, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { Size = AdaptiveTextSize.Medium, Wrap = true, Text = Resources.YesterdayText, }, }, }, new AdaptiveColumn { Items = new List <AdaptiveElement> { new AdaptiveTextBlock { Size = AdaptiveTextSize.Medium, Wrap = true, Text = yesterdayValidationText, HorizontalAlignment = AdaptiveHorizontalAlignment.Right, Color = AdaptiveTextColor.Attention, }, }, }, }, }, new AdaptiveTextInput { IsMultiline = true, Style = AdaptiveTextInputStyle.Text, Id = "yesterday", MaxLength = 1000, Value = scrumDetails.Yesterday, }, new AdaptiveColumnSet { Columns = new List <AdaptiveColumn> { new AdaptiveColumn { Width = AdaptiveColumnWidth.Auto, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { Size = AdaptiveTextSize.Medium, Wrap = true, Text = Resources.TodayText, }, }, }, new AdaptiveColumn { Items = new List <AdaptiveElement> { new AdaptiveTextBlock { Size = AdaptiveTextSize.Medium, Wrap = true, Text = todayValidationText, HorizontalAlignment = AdaptiveHorizontalAlignment.Right, Color = AdaptiveTextColor.Attention, }, }, }, }, }, new AdaptiveTextInput { IsMultiline = true, Style = AdaptiveTextInputStyle.Text, Id = "today", MaxLength = 1000, Value = scrumDetails.Today, }, new AdaptiveColumnSet { Columns = new List <AdaptiveColumn> { new AdaptiveColumn { Width = AdaptiveColumnWidth.Auto, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { Size = AdaptiveTextSize.Medium, Wrap = true, Text = Resources.BlockersText, }, }, }, }, }, new AdaptiveTextInput { IsMultiline = true, Style = AdaptiveTextInputStyle.Text, Id = "blockers", MaxLength = 1000, Value = scrumDetails.Blockers, }, }, Actions = new List <AdaptiveAction> { new AdaptiveSubmitAction() { Title = Resources.SubmitTitle, Data = new AdaptiveSubmitActionData { MsTeams = new CardAction { Type = "task/submit", }, MembersActivityIdMap = scrumDetails.MembersActivityIdMap, }, }, }, }; return(new Attachment { ContentType = AdaptiveCard.ContentType, Content = validationCard, }); }
/// <summary> /// Update scrum details to name card. /// </summary> /// <param name="name">name of group member.</param> /// <param name="scrumDetails">scrum details.</param> /// <param name="appBaseUrl">app base url.</param> /// <returns>card.</returns> public static Attachment GetUpdateCard(string name, ScrumDetailsEntity scrumDetails, string appBaseUrl) { Uri blockerImgUrl = new Uri(appBaseUrl + "/content/blocked.png"); string updatedTimeStamp = DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"); AdaptiveColumnSet columnSet = new AdaptiveColumnSet(); var dateTimeinTextFormat = string.Format("{{{{DATE({0}, SHORT)}}}} {{{{TIME({1})}}}}", updatedTimeStamp, updatedTimeStamp); columnSet.Columns.Add( new AdaptiveColumn { Width = AdaptiveColumnWidth.Auto, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { Weight = AdaptiveTextWeight.Bolder, Text = name, Wrap = true, Size = AdaptiveTextSize.Default, }, new AdaptiveTextBlock { Weight = AdaptiveTextWeight.Lighter, Text = string.Format(Resources.UpdateScrumTimeStampText, dateTimeinTextFormat), Wrap = true, IsSubtle = true, }, }, }); if (!string.IsNullOrEmpty(scrumDetails.Blockers)) { AdaptiveColumn column = new AdaptiveColumn(); column.Items.Add(new AdaptiveImage { Style = AdaptiveImageStyle.Default, HorizontalAlignment = AdaptiveHorizontalAlignment.Right, Url = blockerImgUrl, }); columnSet.Columns.Add(column); } AdaptiveCard validationCard = new AdaptiveCard("1.0") { Body = new List <AdaptiveElement> { columnSet, }, Actions = new List <AdaptiveAction> { new AdaptiveShowCardAction() { Title = Resources.ShowScrumDetailsTitle, Card = new AdaptiveCard("1.0") { Body = new List <AdaptiveElement> { new AdaptiveTextBlock { Text = Resources.YesterdayText, Color = AdaptiveTextColor.Dark, Separator = true, IsSubtle = true, Wrap = true, Weight = AdaptiveTextWeight.Bolder, }, new AdaptiveTextBlock { Text = scrumDetails.Yesterday, Wrap = true, Weight = AdaptiveTextWeight.Lighter, }, new AdaptiveTextBlock { Text = Resources.TodayText, Color = AdaptiveTextColor.Dark, Separator = true, IsSubtle = true, Wrap = true, Weight = AdaptiveTextWeight.Bolder, }, new AdaptiveTextBlock { Text = scrumDetails.Today, Wrap = true, Weight = AdaptiveTextWeight.Lighter, }, new AdaptiveTextBlock { Text = Resources.BlockersText, Color = AdaptiveTextColor.Dark, Separator = true, IsSubtle = true, Wrap = true, Weight = AdaptiveTextWeight.Bolder, }, new AdaptiveTextBlock { Text = scrumDetails.Blockers, Wrap = true, Weight = AdaptiveTextWeight.Lighter, }, }, }, }, }, }; return(new Attachment { ContentType = AdaptiveCard.ContentType, Content = validationCard, }); }