Пример #1
0
        protected override async Task <MessagingExtensionActionResponse> OnTeamsMessagingExtensionFetchTaskAsync(ITurnContext <IInvokeActivity> turnContext, MessagingExtensionAction action, CancellationToken cancellationToken)
        {
            string memberName;

            try
            {
                // Check if your app is installed by fetching member information.
                var member = await TeamsInfo.GetMemberAsync(turnContext, turnContext.Activity.From.Id, cancellationToken);

                memberName = member.Name;
            }
            catch (ErrorResponseException ex)
            {
                if (ex.Body.Error.Code == "BotNotInConversationRoster")
                {
                    return(new MessagingExtensionActionResponse
                    {
                        Task = new TaskModuleContinueResponse
                        {
                            Value = new TaskModuleTaskInfo
                            {
                                Card = CardHelper.CreateJustInTimeCard("JITinstallation.json"),
                                Height = 200,
                                Width = 400,
                                Title = "Device Capabilities - App Installation",
                            },
                        },
                    });
                }
                throw;
            }

            if (action.CommandId == Constants.MessageExtensionCommandId)
            {
                var response = new MessagingExtensionActionResponse()
                {
                    Task = new TaskModuleContinueResponse()
                    {
                        Value = new TaskModuleTaskInfo()
                        {
                            Height = 450,
                            Width  = 350,
                            Title  = "Bar Code Scanner",
                            Url    = Constants.BaseUrl + "/Scanner",
                        },
                    },
                };
                return(response);
            }
            return(new MessagingExtensionActionResponse());
        }