示例#1
0
        public MailingDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, IEmailSender emailSender, ISubscriptionManager SubscriptionManager,
                             ThreadedLogger _myLogger,
                             StuddyBotContext db
                             )
            : base(nameof(MailingDialog))
        {
            this._myLogger           = _myLogger;
            DecisionMaker            = decisionMaker;
            EmailSender              = emailSender;
            _db                      = db;
            _dialogInfoStateProperty = dialogInfoStateProperty;
            _subscriptionManager     = SubscriptionManager;

            AddDialog(new TextPrompt(nameof(TextPrompt)));

            AddDialog(new TextPrompt("email", EmailFormValidator));
            AddDialog(new ChoicePrompt("validation", CodeValidator));
            AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new FinishDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                       _myLogger,
                                       db
                                       ));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                CheckForEmailStepAsync,
                AskEmailStepAsync,
                SendDialogStepAsync,
                FinalStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#2
0
        public CoursesDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, IEmailSender emailSender, ISubscriptionManager SubscriptionManager,
                             ThreadedLogger _myLogger,
                             //DialogInfo dialogInfo,
                             //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                             StuddyBotContext db
                             )
            : base(nameof(CoursesDialog))
        {
            this._myLogger = _myLogger;
            DecisionMaker  = decisionMaker;
            //_DialogInfo = dialogInfo;
            //_conversationReferences = conversationReferences;
            _db = db;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            //AddDialog(new ChooseOptionDialog(DecisionMaker, _myLogger, dialogInfo, conversationReferences));
            AddDialog(new FinishDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                       _myLogger,
                                       //dialogInfo,
                                       //conversationReferences,
                                       db
                                       ));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                AskCourseStepAsync,
                SendInfoAboutCourseStepAsync,
                AskForNotifyStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#3
0
        public SubscriptionDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, IEmailSender emailSender, ISubscriptionManager subscriptionManager,
                                  ThreadedLogger _myLogger,
                                  //DialogInfo dialogInfo,
                                  //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                                  StuddyBotContext db
                                  )
            : base(nameof(SubscriptionDialog))
        {
            this._myLogger           = _myLogger;
            DecisionMaker            = decisionMaker;
            _subscriptionManager     = subscriptionManager;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new ChooseOptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, subscriptionManager,
                                             _myLogger,
                                             //dialogInfo,
                                             //conversationReferences,
                                             db
                                             ));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                FirstStepAsync,
                UnsubStepAsync,
                DeleteSubscriptionStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#4
0
        public AddQuestionDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, IEmailSender emailSender,
                                 ThreadedLogger _myLogger,
                                 //DialogInfo dialogInfo,
                                 //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                                 StuddyBotContext db
                                 )
            : base(nameof(AddQuestionDialog))
        {
            this._myLogger = _myLogger;
            DecisionMaker  = decisionMaker;
            //_DialogInfo = dialogInfo;
            //_conversationReferences = conversationReferences;
            _db = db;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            //AddDialog(new FinishDialog(DecisionMaker, _myLogger, dialogInfo, conversationReferences));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                AskForQuestionStepAsync,
                FinalStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
        public NotificationController(IBotFrameworkHttpAdapter adapter,
                                      ICredentialProvider credentials,
                                      //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                                      StuddyBotContext db,
                                      IEmailSender emailSender,
                                      ISubscriptionManager subscriptionManager,
                                      IDecisionMaker decisionMaker)
        {
            _adapter = adapter;
            //_conversationReferences = conversationReferences;
            _appId               = ((SimpleCredentialProvider)credentials).AppId;
            _db                  = db;
            _emailSender         = emailSender;
            _decisionMaker       = decisionMaker;
            _subscriptionManager = subscriptionManager;

            // If the channel is the Emulator, and authentication is not in use,
            // the AppId will be null.  We generate a random AppId for this case only.
            // This is not required for production, since the AppId will have a value.
            if (string.IsNullOrEmpty(_appId))
            {
                _appId = Guid.NewGuid().ToString(); //if no AppId, use a random Guid
            }

            // _appId = "123";
        }
示例#6
0
        public PlannedEventsDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker,
                                   ThreadedLogger _myLogger,
                                   //DialogInfo dialogInfo,
                                   //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                                   StuddyBotContext db
                                   )
            : base(nameof(PlannedEventsDialog))
        {
            this._myLogger = _myLogger;
            DecisionMaker  = decisionMaker;
            //_DialogInfo = dialogInfo;
            //_conversationReferences = conversationReferences;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                AskSelectEventStepAsync,
                FinalStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#7
0
        public LocationDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, ISubscriptionManager SubscriptionManager,
                              ThreadedLogger _myLogger,
                              //DialogInfo dialogInfo,
                              //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                              IEmailSender emailSender,
                              StuddyBotContext db)
            : base(nameof(LocationDialog))//, dialogInfoStateProperty)

        {
            this._myLogger = _myLogger;
            DecisionMaker  = decisionMaker;
            //_DialogInfo = dialogInfo;
            //_conversationReferences = conversationReferences;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new MainMenuDialog(dialogInfoStateProperty, DecisionMaker, SubscriptionManager, _myLogger,
                                         //_DialogInfo,
                                         //_conversationReferences,
                                         db,
                                         emailSender));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                GetCountryStepAsync,
                GetCityStepAsync,
                CallMenuDialogStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#8
0
        public FinishDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, IEmailSender emailSender, ISubscriptionManager SubscriptionManager,
                            ThreadedLogger _myLogger,
                            //DialogInfo dialogInfo,
                            //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                            StuddyBotContext db
                            )
            : base(nameof(FinishDialog))
        {
            this._myLogger = _myLogger;
            DecisionMaker  = decisionMaker;
            //_DialogInfo = dialogInfo;
            //_conversationReferences = conversationReferences;
            _db = db;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new ChooseOptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                             _myLogger,
                                             //dialogInfo,
                                             //conversationReferences,
                                             db
                                             ));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                DidWeFinishStepAsync,
                LeaveFeedbackStepAsync,
                //testStepAsync,
                FinalStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#9
0
        public HelpDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, ISubscriptionManager SubscriptionManager,
                          ThreadedLogger _myLogger,
                          IEmailSender emailSender,
                          StuddyBotContext db)
            : base(nameof(HelpDialog))//, dialogInfoStateProperty)

        {
            _Logger       = _myLogger;
            DecisionMaker = decisionMaker;

            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new ChooseOptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                             _myLogger, db
                                             ));



            AddDialog(new MainMenuDialog(dialogInfoStateProperty, DecisionMaker, SubscriptionManager, _myLogger,
                                         db,
                                         emailSender));
            AddDialog(new CoursesDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                        _myLogger, db
                                        ));
            AddDialog(new PlannedEventsDialog(dialogInfoStateProperty, DecisionMaker, _myLogger, db
                                              ));
            AddDialog(new QAsDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                    _myLogger, db
                                    ));
            AddDialog(new SubscriptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                             _myLogger, db
                                             ));
            AddDialog(new MailingDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                        _myLogger, db
                                        ));
            AddDialog(new FinishDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                       _myLogger, db
                                       ));



            AddDialog(new TextPrompt(nameof(TextPrompt)));

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                ShowHelpAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#10
0
        public MainMenuDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker,
                              ISubscriptionManager SubscriptionManager,
                              ThreadedLogger _myLogger,
                              //DialogInfo dialogInfo,
                              //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                              StuddyBotContext db,
                              IEmailSender emailSender)
            : base(nameof(MainMenuDialog))
        {
            this._myLogger = _myLogger;
            DecisionMaker  = decisionMaker;

            _dialogInfoStateProperty = dialogInfoStateProperty;


            AddDialog(new CoursesDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                        _myLogger, db
                                        ));
            AddDialog(new ChooseOptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                             _myLogger, db
                                             ));
            AddDialog(new PlannedEventsDialog(dialogInfoStateProperty, DecisionMaker, _myLogger, db
                                              ));
            AddDialog(new QAsDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                    _myLogger, db
                                    ));
            AddDialog(new SubscriptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                             _myLogger, db
                                             ));
            AddDialog(new MailingDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                        _myLogger, db
                                        ));
            AddDialog(new FinishDialog(dialogInfoStateProperty, DecisionMaker, emailSender, SubscriptionManager,
                                       _myLogger, db
                                       ));

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                GetMenuItemsStepAsync,
                StartSelectedDialogStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#11
0
        public EmailDialog(IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty, IDecisionMaker decisionMaker, ISubscriptionManager subscriptionManager, IEmailSender emailSender,
                           ThreadedLogger _myLogger,
                           //DialogInfo dialogInfo,
                           //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                           StuddyBotContext db
                           )
            : base(nameof(EmailDialog))
        {
            this._myLogger       = _myLogger;
            DecisionMaker        = decisionMaker;
            _subscriptionManager = subscriptionManager;
            EmailSender          = emailSender;
            //_DialogInfo = dialogInfo;
            _db = db;
            _dialogInfoStateProperty = dialogInfoStateProperty;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new TextPrompt("email", EmailFormValidator));
            AddDialog(new ChoicePrompt("validation", CodeValidator));
            AddDialog(new SubscriptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, subscriptionManager,
                                             _myLogger,
                                             //dialogInfo,
                                             //conversationReferences,
                                             db
                                             ));
            AddDialog(new ChooseOptionDialog(dialogInfoStateProperty, DecisionMaker, emailSender, subscriptionManager,
                                             _myLogger,
                                             //dialogInfo,
                                             //conversationReferences,
                                             db
                                             ));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                FirstStepAsync,
                ChoiceStepAsync,
                PreFinalStepAsync,
                FinalStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#12
0
        /// <summary>
        /// Gets courses in selected city from the json file.
        /// </summary>
        /// <returns></returns>
        public List <Course> GetCourses(string lang)
        {
            var json    = Encoding.Unicode.GetString(Encoding.Unicode.GetBytes(System.IO.File.ReadAllText(_pathSettings.PathCourses)));
            var rss     = JArray.Parse(json);
            var courses = new List <Course>();

            // Taking array of all tokens.
            var tokens = rss.Children();

            // Searching in array token with given topic
            foreach (var item in tokens)
            {
                if (item["lang"].ToObject <string>() == lang)
                {
                    var items = item["courses"];

                    courses = items.ToObject <List <Course> >();
                }
            }

            // ToDo check this !!!!!

            // Insert into db
            studdyBotContext = new StuddyBotContext();
            if (!studdyBotContext.Courses.Any())
            {
                var coursesDB = new List <Course>();
                foreach (var item in tokens)
                {
                    if (item["lang"].ToObject <string>().ToLower() == "en-us")
                    {
                        var items = item["courses"];

                        coursesDB = items.ToObject <List <Course> >();
                    }
                }
                studdyBotContext.PushCoursesToDB(coursesDB);
                studdyBotContext.SaveChanges();
            }

            return(courses);
        }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DecisionMaker"/> class.
        /// </summary>
        public DecisionMaker(IOptions <PathSettings> pathSettings, IOptions <PathSettingsLocal> localPathSettings,
                             StuddyBotContext studdyBotContext)
        {
            this.studdyBotContext = studdyBotContext;
            var lPathSettings   = localPathSettings.Value;
            var tmpPathSettings = pathSettings.Value;
            var props           = tmpPathSettings.GetType().GetProperties();

            if (lPathSettings.IsLocalStart)
            {
                foreach (PropertyInfo prop in props)
                {
                    //var oldPropValue = prop.GetValue(tmpPathSettings) ??null;
                    //if (oldPropValue!=null)
                    //{
                    //var newPropValue = oldPropValue.ToString().Insert(2, lPathSettings.RootForLocalStart);
                    //prop.GetValue(tmpPathSettings).ToString().Insert(2, lPathSettings.RootForLocalStart);
                    prop.SetValue(tmpPathSettings,
                                  prop.GetValue(tmpPathSettings).ToString()
                                  .Insert(2, lPathSettings.RootForLocalStart));
                    //}
                }
            }
            else
            {
                foreach (PropertyInfo prop in props)
                {
                    prop.SetValue(tmpPathSettings,
                                  prop.GetValue(tmpPathSettings).ToString()
                                  .Insert(2, lPathSettings.RootForRemoteStart));
                }
            }
            _pathSettings = tmpPathSettings;
            //_pathSettings = pathSettings.Value;
            DialogsMUI = new Dictionary <string, DialogsMUI>();
            LoadDialogsMUI();
        }
示例#14
0
 public QuestionsController(StuddyBotContext context)
 {
     _context = context;
 }
示例#15
0
 public GetCoursesHelper(StuddyBotContext dbContext)
 {
     _db = dbContext;
 }
示例#16
0
 public UnitOfWork(StuddyBotContext studdyBotContext)
 {
     db = studdyBotContext;
 }
示例#17
0
 public DialogRepository(StuddyBotContext context)
 {
     db = context;
 }
示例#18
0
 public SubscriptionManager(StuddyBotContext db)
 {
     _db = db;
 }
示例#19
0
 public FeedbacksController(StuddyBotContext context)
 {
     _context = context;
 }
示例#20
0
 public CoursesController(StuddyBotContext db, IPathSettings ps)
 {
     _db          = db;
     _pathCourses = ps.PathCourses;
 }
示例#21
0
        /// <summary>
        /// conversations with users which subscribed to notifications
        /// TODO: possible renaming needed
        /// </summary>
        //private readonly ConcurrentDictionary<string, ConversationReference> _conversationReferences;


        public MainDialog(UserState state, IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty,
                          IConfiguration configuration, IDecisionMaker decisionMaker,
                          ISubscriptionManager subscriptionManager, IEmailSender emailSender,
                          ThreadedLogger Logger,
                            //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                          StuddyBotContext db
                          ) // DialogInfo dialogInfo, StuddyBotContext db
            : base(nameof(MainDialog), dialogInfoStateProperty, Logger)
        {
            Configuration = configuration;
            this._Logger  = Logger;
            DecisionMaker = decisionMaker;
            EmailSender   = emailSender;
            //_conversationReferences = conversationReferences;

            _QuestionAndAnswerModel = new QuestionAndAnswerModel();
            _QuestionAndAnswerModel.QuestionModel           = new QuestionModel();
            _QuestionAndAnswerModel.QuestionModel.Questions = new List <Question>();
            _QuestionAndAnswerModel.QuestionModel.Decisions = new List <DecisionModel>();
            _QuestionAndAnswerModel.Answers = new List <string>();
            _DecisionModel = new DecisionModel();
            //_DialogInfo = new DialogInfo(); //dialogInfo;
            _dialogInfoStateProperty = dialogInfoStateProperty; //state.CreateProperty<DialogInfo>(nameof(DialogInfo));
            //_DialogInfo = _dialogInfoState.GetAsync();

            _db = db;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));

            AddDialog(new LanguageDialog(_dialogInfoStateProperty, DecisionMaker, subscriptionManager, _Logger,
                                         EmailSender, db, Configuration));
            AddDialog(new LocationDialog(_dialogInfoStateProperty, DecisionMaker, subscriptionManager, _Logger,

                                         EmailSender, db));

            AddDialog(new MailingDialog(_dialogInfoStateProperty, DecisionMaker, emailSender, subscriptionManager,
                                        _Logger, db));


            AddDialog(new EmailDialog(_dialogInfoStateProperty, decisionMaker, subscriptionManager, emailSender,
                                      Logger,
                                      //_DialogInfo,
                                      //conversationReferences,
                                      db
                                      ));
            AddDialog(new HelpDialog(_dialogInfoStateProperty, DecisionMaker, subscriptionManager, _Logger,

                                     EmailSender, db));

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                StartLanguageDialogAsync
            }));


            StartServices();

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
示例#22
0
 public UserRepository(StuddyBotContext context)
 {
     db = context;
 }