Inheritance: DataContext
Exemplo n.º 1
0
        public override HandleMessageResult HandleMessage(UserActionMessage message)
        {
            if (message.ActionType == UserActionType.Postback &&
                message.Command.CommandName == BotCommandName.StartCommand)
            {
                if (message.Command.MethodName == "StartCommand")
                {
                    var commandName = message.Command.Value.ToEnum <BotCommandName>().Value;
                    this.StartCommand(commandName);
                }
                else if (message.Command.MethodName == "RestartCommand")
                {
                    var dc        = new BotDataContext(this.UserCD);
                    var commandCD = Guid.Parse(message.Command.Value);
                    dc.BotCommand_Restart(commandCD);
                    var r = dc.BotCommand_Get(commandCD);
                    if (r == null)
                    {
                        var cl = new FacebookBotClient();
                        cl.SendMessage(this.RecipientID, this.Text(BotTextKey.ThisCommandMayBeDeleted));
                    }
                    else
                    {
                        var cm = BotCommand.Create(this.RecipientID, this.BotCD, r);
                        cm.ResponseMessage();
                    }
                }

                return(new HandleMessageResult(true));
            }
            return(new HandleMessageResult(false));
        }
Exemplo n.º 2
0
Arquivo: Bot.cs Projeto: pluraldj/Bot
        public Bot()
        {
            BasicConfigurator.Configure();
            log.Info("Starting bot instance...");

            db = new BotDataContext(new SQLiteConnection("DbLinqProvider=Sqlite;Data Source=Bot.db;"));
            userService = new UserService(db);
        }
Exemplo n.º 3
0
        public void ResponseCommandListMessage()
        {
            var dc = new BotDataContext(this.UserCD);

            var l = new List <IButton>();

            {
                var bt = new PostbackButton();
                bt.Title = this.Text(BotTextKey.AddNewSchedule);
                var cm = new PayloadCommand();
                cm.CommandName = BotCommandName.StartCommand;
                cm.MethodName  = "StartCommand";
                cm.Value       = nameof(BotCommandName.ScheduleAdd);
                bt.SetPayload(cm);
                l.Add(bt);
            }
            {
                var bt = new PostbackButton();
                bt.Title = this.Text(BotTextKey.AddNewTask);
                var cm = new PayloadCommand();
                cm.CommandName = BotCommandName.StartCommand;
                cm.MethodName  = "StartCommand";
                cm.Value       = nameof(BotCommandName.TaskAdd);
                bt.SetPayload(cm);
                l.Add(bt);
            }
            {
                var bt = new PostbackButton();
                bt.Title = this.Text(BotTextKey.TaskConfirmation);
                var cm = new PayloadCommand();
                cm.CommandName = BotCommandName.StartCommand;
                cm.MethodName  = "StartCommand";
                cm.Value       = nameof(BotCommandName.TaskComplete);
                bt.SetPayload(cm);
                l.Add(bt);
            }
            foreach (var item in dc.BotCommand_List_Get())
            {
                if (item.CommandName == BotCommandName.StartCommand)
                {
                    continue;
                }
                var cm = BotCommand.Create(this.RecipientID, this.BotCD, item);
                var bt = new PostbackButton();
                bt.Title = cm.GetText();
                bt.SetPayload(BotCommandName.StartCommand, "RestartCommand", item.CommandCD.ToString());
                l.Add(bt);
            }
            this.SendImage(BotActionType.Greeting);
            var cl = new FacebookBotClient();

            foreach (var item in ButtonTemplateMessage.Create(this.RecipientID
                                                              , this.TextManager.Text(BotTextKey.CanIHelpYou), l))
            {
                cl.SendMessage(item);
            }
            dc.BotCommand_Update(_Record);
        }
Exemplo n.º 4
0
        private void StartTaskAddCommand()
        {
            var dc          = new BotDataContext(this.UserCD);
            var data        = new BotCommand_TaskAdd.CommandData();
            var rBotCommand = dc.BotCommand_Add(DatabaseSetting.NewGuid(), this.UserCD, BotCommandName.TaskAdd, null
                                                , DateTimeInfo.GetNow().AddMinutes(BotCommand_TaskAdd.ExpireMinutes), JsonConvert.SerializeObject(data));
            var cm = new BotCommand_TaskAdd(this.RecipientID, this.BotCD, rBotCommand);

            cm.ResponseMessage();
        }
Exemplo n.º 5
0
 public OCUserRepository(BotDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Exemplo n.º 6
0
 public UserService(BotDataContext db)
 {
     this.db = db;
 }
Exemplo n.º 7
0
 public Chanel2ServerRepository(BotDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Exemplo n.º 8
0
        public void DeleteCommandData()
        {
            var dc = new BotDataContext(this.UserCD);

            dc.BotCommand_Delete(_Record.CommandCD);
        }
Exemplo n.º 9
0
        public void UpdateCommandData()
        {
            var dc = new BotDataContext(this.UserCD);

            dc.BotCommand_Update(_Record);
        }