Пример #1
0
        // Step 2: Display the Add to Project card
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var requestDetails = stepContext.Options is ConsultingRequestDetails
                    ?
                                 stepContext.Options as ConsultingRequestDetails
                    :
                                 new ConsultingRequestDetails();

            // Resolve project if needed
            List <ConsultingProject> result = stepContext.Result as List <ConsultingProject>;

            if (result == null)
            {
                var projectName = stepContext.Result as string;
                result = await ResolveProject(projectName);
            }
            requestDetails.possibleProjects = result;

            // Resolve person
            requestDetails.possiblePersons = await ResolvePerson(requestDetails.personName, stepContext.Context, cancellationToken);

            var projectCard = await AddToProjectCard.GetCardAsync(stepContext.Context, requestDetails);

            var reply = stepContext.Context.Activity.CreateReply();

            reply.Attachments.Add(projectCard.ToAttachment());
            await stepContext.Context.SendActivityAsync(reply).ConfigureAwait(false);

            return(await stepContext.EndDialogAsync(requestDetails, cancellationToken));
        }
        // Called when the task module is fetched for an action
        public async Task <MessagingExtensionActionResponse> HandleMessagingExtensionFetchTaskAsync(ITurnContext turnContext, MessagingExtensionAction query)
        {
            var emptyRequest = new ConsultingRequestDetails();
            ConsultingDataService dataService = new ConsultingDataService();

            emptyRequest.possibleProjects = await dataService.GetProjects("");

            IEnumerable <TeamsChannelAccount> members = await TeamsInfo.GetMembersAsync(turnContext);

            emptyRequest.possiblePersons = members.Select((w) => new Person
            {
                name  = w.Name,
                email = w.Email
            })
                                           .ToList();

            var card = await AddToProjectCard.GetCardAsync(turnContext, emptyRequest);

            var response = new Microsoft.Bot.Schema.Teams.TaskModuleContinueResponse()
            {
                Type  = "continue",
                Value = new TaskModuleTaskInfo()
                {
                    Title = "Select a sample",
                    Card  = card.ToAttachment()
                }
            };

            return(new MessagingExtensionActionResponse
            {
                Task = response
            });
        }
Пример #3
0
        protected override async Task <InvokeResponse> OnTeamsCardActionInvokeAsync(ITurnContext <IInvokeActivity> turnContext, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(turnContext.Activity.Name))
            {
                var val     = turnContext.Activity.Value as JObject;
                var payload = val.ToObject <AddToProjectConfirmationCard.AddToProjectCardActionValue>();
                if (payload.submissionId == AddToProjectCard.SubmissionId)
                {
                    return(await AddToProjectCard.OnSubmit(turnContext, cancellationToken));
                }
            }

            return(await Task.FromResult <InvokeResponse>(null));
        }