//This will interrupt the conversation and send the user to SurveyDialog, then wait until that's done
        public static async Task Resume()
        {
            var message = JsonConvert.DeserializeObject <ConversationReference>(conversationReference).GetPostToBotMessage();
            var client  = new ConnectorClient(new Uri(message.ServiceUrl));

            using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
            {
                var botData = scope.Resolve <IBotData>();
                await botData.LoadAsync(CancellationToken.None);

                //This is our dialog stack
                var task = scope.Resolve <IDialogTask>();

                //Do we have a root dialog yet?
                if (task.Frames.Count == 0)
                {
                    var root = Chain.Loop(new RootDialog());
                    task.Call(root, null);

                    await task.PollAsync(CancellationToken.None);
                }

                //interrupt the stack. This means that we're stopping whatever conversation that is currently happening with the user
                //Then adding this stack to run and once it's finished, we will be back to the original conversation
                var dialog = new SurveyDialog();
                task.Call(dialog.Void <object, IMessageActivity>(), null);

                await task.PollAsync(CancellationToken.None);

                //flush dialog stack
                await botData.FlushAsync(CancellationToken.None);
            }
        }
Ejemplo n.º 2
0
        //This will interrupt the conversation and send the user to SurveyDialog, then wait until that's done
        public static async Task Resume()
        {
            var asReference = JsonConvert.DeserializeObject <ConversationReference>(conversationReference);
            var message     = asReference.GetPostToBotMessage();
            var client      = new ConnectorClient(new Uri(message.ServiceUrl));

            // Create a scope that can be used to work with state from bot framework.
            using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
            {
                var botData = scope.Resolve <IBotData>();
                await botData.LoadAsync(CancellationToken.None);

                //This is our dialog stack
                var stack = scope.Resolve <IDialogStack>();

                //interrupt the stack. This means that we're stopping whatever conversation that is currently happening with the user
                //Then adding this stack to run and once it's finished, we will be back to the original conversation
                var dialog = new SurveyDialog();
                stack.Call(dialog.Void <object, IMessageActivity>(), null);

                await scope.Resolve <IDialogTask>().PollAsync(CancellationToken.None);

                // Flush the dialog stack back to its state store.
                await botData.FlushAsync(CancellationToken.None);
            }
        }
        //This will interrupt the conversation and send the user to SurveyDialog, then wait until that's done
        public static async Task Resume()
        {
            var message = ResumptionCookie.GZipDeserialize(resumptionCookie).GetMessage();
            var client  = new ConnectorClient(new Uri(message.ServiceUrl));

            using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
            {
                var botData = scope.Resolve <IBotData>();
                await botData.LoadAsync(CancellationToken.None);

                //This is our dialog stack
                var stack = scope.Resolve <IDialogStack>();

                //interrupt the stack. This means that we're stopping whatever conversation that is currently happening with the user
                //Then adding this stack to run and once it's finished, we will be back to the original conversation
                var dialog = new SurveyDialog();
                stack.Call(dialog.Void <object, IMessageActivity>(), null);
                await stack.PollAsync(CancellationToken.None);

                //flush dialog stack
                await botData.FlushAsync(CancellationToken.None);
            }
        }