Ejemplo n.º 1
0
 /// <summary>
 /// Initialize authentication scorable.
 /// </summary>
 /// <param name="botdata">Bot data</param>
 /// <param name="dialogTask">Dialog task</param>
 /// <param name="botToUser">Bot to user</param>
 /// <param name="resourceId">Azure active directory resource identifier.</param>
 public AuthenticationScorable(IBotData botdata, IDialogTask dialogTask, IBotToUser botToUser, AuthenticationOptions authOptions, IAuthProvider authProvider)
 {
     _botData          = botdata;
     _dialogTask       = dialogTask;
     this.authOptions  = authOptions;
     this.authProvider = authProvider;
 }
Ejemplo n.º 2
0
        public NavigationScorable(IDialogStack stack, IDialogTask task)
        {
            SetField.NotNull(out this.stack, nameof(stack), stack);
            SetField.NotNull(out this.task, nameof(task), task);

            this.navigationCommands = new List <string>();

            this.navigationCommands.Add(Resources.Main_Nav_Cmd);

            // Topic 1
            this.navigationCommands.Add(Resources.Topic1_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic1_1_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic1_2_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic1_3_Nav_Cmd);

            // Topic 2
            this.navigationCommands.Add(Resources.Topic2_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic2_1_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic2_2_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic2_3_Nav_Cmd);

            // Topic 3
            this.navigationCommands.Add(Resources.Topic3_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic3_1_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic3_2_Nav_Cmd);
            this.navigationCommands.Add(Resources.Topic3_3_Nav_Cmd);
        }
Ejemplo n.º 3
0
 public ScoringDialogTask(IDialogTask inner, IComparer <Score> comparer, ITraits <Score> traits, params IScorable <Score>[] scorables)
     : base(inner)
 {
     SetField.NotNull(out this.comparer, nameof(comparer), comparer);
     SetField.NotNull(out this.traits, nameof(traits), traits);
     SetField.NotNull(out this.scorables, nameof(scorables), scorables);
 }
Ejemplo n.º 4
0
        public NavigationScorable2(IDialogTask task)
        {
            SetField.NotNull(out this.task, nameof(task), task);

            this.navigationCommands = new List <string>();

            this.navigationCommands.Add(Consts.MainBotKey);
        }
Ejemplo n.º 5
0
 public BotDialogContextArgs(IActivity activity, IDialogTask task, IBotData data, IBotToUser botToUser, ILifetimeScope scope)
 {
     Activity    = activity;
     Task        = task;
     BotData     = data;
     DialogScope = scope;
     BotToUser   = botToUser;
 }
 public LuisScorable(ILuisService luisService, IDialogTask task, ILogger logger, LuisIntentHandlerDialogFactory luisIntentHandlerFactory)
 {
     this.luisService       = luisService;
     this.luisResults       = new Dictionary <string, LuisResult>();
     this.task              = task;
     this.logger            = logger;
     this.luisIntentFactory = luisIntentHandlerFactory;
 }
Ejemplo n.º 7
0
        public static async Task StartSurvey(ResumptionCookie cookie, CancellationToken token)
        {
            var container = WebApiApplication.FindContainer();

            // the ResumptionCookie has the "key" necessary to resume the conversation
            var message = cookie.GetMessage();

            ConnectorClient client = new ConnectorClient(new Uri(message.ServiceUrl));

            try
            {
                var conversation = await client.Conversations.CreateDirectConversationAsync(message.Recipient, message.From);

                message.Conversation.Id = conversation.Id;
            }
            catch (HttpOperationException ex)
            {
                var reply = message.CreateReply();
                reply.Text = ex.Message;

                await client.Conversations.SendToConversationAsync(reply);

                return;
            }

            // we instantiate our dependencies based on an IMessageActivity implementation
            using (var scope = DialogModule.BeginLifetimeScope(container, message))
            {
                // find the bot data interface and load up the conversation dialog state
                var botData = scope.Resolve <IBotData>();
                await botData.LoadAsync(token);

                // resolve the dialog task
                IDialogTask task = scope.Resolve <IDialogTask>();

                // make a dialog to push on the top of the stack
                var child = scope.Resolve <SurveyDialog>();

                // wrap it with an additional dialog that will restart the wait for
                // messages from the user once the child dialog has finished
                var interruption = child.Void <object, IMessageActivity>();

                try
                {
                    // put the interrupting dialog on the stack
                    task.Call(interruption, null);

                    // start running the interrupting dialog
                    await task.PollAsync(token);
                }
                finally
                {
                    // save out the conversation dialog state
                    await botData.FlushAsync(token);
                }
            }
        }
        public NavigationScorable(IDialogStack stack, IDialogTask task)
        {
            SetField.NotNull(out this.stack, nameof(stack), stack);
            SetField.NotNull(out this.task, nameof(task), task);

            this.navigationCommands = new List <string>();

            this.navigationCommands.Add(Resources.MainBot_Menu);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Load or create the dialog task from the store.
 /// </summary>
 /// <typeparam name="R">The type of the root dialog.</typeparam>
 /// <param name="task">The dialog task.</param>
 /// <param name="MakeRoot">The factory method for the root dialog.</param>
 /// <param name="token">An optional cancellation token.</param>
 /// <returns>A task representing the dialog task load operation.</returns>
 public static async Task LoadAsync <R>(this IDialogTask task, Func <IDialog <R> > MakeRoot, CancellationToken token = default(CancellationToken))
 {
     if (task.Frames.Count == 0)
     {
         var root = MakeRoot();
         var loop = root.Loop();
         task.Call(loop, null);
         await task.PollAsync();
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Helper to quickly go to root dialog and optionally reset the dialog stack.
        /// </summary>
        /// <param name="dialogTask">context/stack</param>
        /// <param name="clearStack">TRUE to clear stack, FALSE to leave it unchanged</param>
        internal async static Task ForwardToRootDialogAsync(IDialogTask dialogTask, bool clearStack)
        {
            if (clearStack)
            {
                dialogTask.Reset();
            }
            var newActivity = Activity.CreateEventActivity();

            newActivity.Value = "INIT_DIALOG";
            await dialogTask.Forward(new RootDialog(), null, newActivity, CancellationToken.None);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Post an item to the dialog task and poll the dialog task for any work to be done.
        /// </summary>
        /// <typeparam name="R">The type of the root dialog.</typeparam>
        /// <typeparam name="T">The type of the item.</typeparam>
        /// <param name="task">The dialog task.</param>
        /// <param name="toBot">The item to be sent to the bot.</param>
        /// <param name="MakeRoot">The factory method for the root dialog.</param>
        /// <param name="token">An optional cancellation token.</param>
        /// <returns>A task representing the post operation.</returns>
        public static async Task PostAsync <T, R>(this IDialogTask task, T toBot, Func <IDialog <R> > MakeRoot, CancellationToken token = default(CancellationToken))
        {
            await LoadAsync(task, MakeRoot, token);

            IPostToBot postToBot = task;

            try
            {
                await postToBot.PostAsync(toBot, token);
            }
            catch
            {
                task.Reset();
                throw;
            }

            task.Save();
        }
Ejemplo n.º 12
0
 public MessageRouterScorable(IDialogTask dialogTask)
 {
     SetField.NotNull(out _dialogTask, nameof(dialogTask), dialogTask);
 }
 public SettingsScorable(IDialogTask task)
 {
Ejemplo n.º 14
0
 public CommonResponseScorable(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 15
0
 // Apparently when this gets constructed, an IDialogTask instance is given to us.
 // I do not understand yet, where this is coming from and what exactly it is...
 public GlobalHandlerDialog(IDialogTask task)
 {
     _task = task;
 }
 public HelpScorable(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 17
0
 public ServerPasswordReset(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 18
0
 public LocalizedDialogTask(IDialogTask inner)
     : base(inner)
 {
 }
 public RestoredFileScorable(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 20
0
 public NotificationsScorable(IDialogTask dialogTask)
 {
     SetField.NotNull(out _dialogTask, nameof(dialogTask), dialogTask);
 }
Ejemplo n.º 21
0
 public ReactiveDialogTask(IDialogTask dialogTask, Func <IDialog <object> > makeRoot)
 {
     SetField.NotNull(out this.dialogTask, nameof(dialogTask), dialogTask);
     SetField.NotNull(out this.makeRoot, nameof(makeRoot), makeRoot);
 }
Ejemplo n.º 22
0
 public StatusScorableDialog(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Interrupt the waiting dialog with a new dialog
        /// </summary>
        /// <typeparam name="T">The type of result expected from the dialog.</typeparam>
        /// <typeparam name="R">The type of the item posted to dialog.</typeparam>
        /// <param name="task">The dialog task.</param>
        /// <param name="dialog">The new interrupting dialog.</param>
        /// <param name="item">The item to forward to the new interrupting dialog.</param>
        /// <param name="token">The cancellation token.</param>
        /// <returns>A task that represents the interruption operation.</returns>
        public static async Task InterruptAsync <T, R>(this IDialogTask task, IDialog <T> dialog, R item, CancellationToken token)
        {
            await task.Forward(dialog.Void <T, R>(), null, item, token);

            await task.PollAsync(token);
        }
Ejemplo n.º 24
0
 public HelpScorable(IDialogTask task, IDialogFactory dialogFactory)
 {
     SetField.NotNull(out this.task, nameof(task), task);
     SetField.NotNull(out this.dialogFactory, nameof(dialogFactory), dialogFactory);
 }
 public VirtualMachineScroable(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 26
0
 public CreateLMSTicketScorable(IDialogTask task)
 {
     SetField.NotNull(out this.task, nameof(task), task);
 }
Ejemplo n.º 27
0
 async Task IScorable <Score> .PostAsync <Item>(IDialogTask task, Item item, object state)
 {
     await this.Scorable.PostAsync(task, item, state);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResetScorable"/> class.
 /// </summary>
 public ResetScorable(IDialogFactory dialogFactory, IDialogStack stack, IBotToUser botToUser, IBotData botData, IDialogTask task)
     : base(Resources.ResetScorable_Match)
 {
     SetField.NotNull(out _task, nameof(task), task);
     SetField.NotNull(out _botData, nameof(botData), botData);
     SetField.NotNull(out _stack, nameof(stack), stack);
     SetField.NotNull(out _dialogFactory, nameof(dialogFactory), dialogFactory);
     SetField.NotNull(out _botToUser, nameof(botToUser), botToUser);
 }
Ejemplo n.º 29
0
 public DebugScorable(IDialogTask task, IMluviiBotDialogFactory dialogFactory)
 {
     SetField.NotNull(out this.task, nameof(task), task);
     SetField.NotNull(out this.dialogFactory, nameof(dialogFactory), dialogFactory);
 }
Ejemplo n.º 30
0
 public CommandScorable(IBotToUser botToUser, IDialogTask task)
 {
     SetField.NotNull(out this.BotToUser, nameof(botToUser), botToUser);
     SetField.NotNull(out this.task, nameof(task), task);
 }