Exemple #1
0
        public void Setup(string ServerName, bool LoadConfig = false)
        {
            _servername      = ServerName;
            sCalendarCommand = new CalendarCommand(ServerName);
            sBirthdayCommand = new BirthdayCommand(ServerName);
            sBanCommand      = new BanCommand(ServerName);
            sBan             = new Ban(ServerName);

            if (IRCConfig.List[ServerName].ServerId == 1 || LoadConfig)
            {
                _config = new AddonConfig(Name, ".yml");
            }

            _calendar = new Calendar(ServerName);
            _calendar.Start();

            sIrcBase.Networks[ServerName].IrcRegisterHandler("PRIVMSG", HandlePrivmsg);
            InitIrcCommand();
            SchumixBase.DManager.Update("banned", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
            SchumixBase.DManager.Update("birthday", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
            SchumixBase.DManager.Update("calendar", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));

            if (CleanConfig.Database)
            {
                SchumixBase.sCleanManager.CDatabase.CleanTable("banned");
                SchumixBase.sCleanManager.CDatabase.CleanTable("birthday");
                SchumixBase.sCleanManager.CDatabase.CleanTable("calendar");
            }
        }
        public JsonResult ClearMonth([FromBody]  CalendarCommand cmd)
        {
            //TODO this should also filter events by user, or it will be deleting events for all users.
            var smonth = cmd.Month + 1;

            List <Events> monthEvents = ctx.Events.Where(x => x.Start.Month == smonth).ToList();

            ctx.Events.RemoveRange(monthEvents);
            ctx.SaveChanges();

            return(new JsonResult(true));
        }