/// <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");
                }

                ScrumDetails scrumMemberDetails = JsonConvert.DeserializeObject <ScrumDetails>(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);
            }
        }
        /// <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");
                }

                ScrumDetails scrumDetails = JsonConvert.DeserializeObject <ScrumDetails>(JObject.Parse(activity.Value.ToString())["data"].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);
示例#3
0
        /// <summary>
        /// validation card on task module.
        /// </summary>
        /// <param name="scrumDetails">ScrumDetails object.</param>
        /// <returns>return carad.</returns>
        public static Attachment ValidationCard(ScrumDetails 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,
            });
        }
示例#4
0
        /// <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, ScrumDetails 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.Today,
                                    Wrap   = true,
                                    Weight = AdaptiveTextWeight.Lighter,
                                },
                            },
                        },
                    },
                },
            };

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