コード例 #1
0
 public void MenuCall(object sender, CQMenuCallEventArgs e)
 {
     e.CQLog.Debug("菜单点击事件", $"点击菜单-{e.Name}");
     IF.InitFiles(e.CQApi.AppDirectory, "Attentions.db", "关注数据库文件", true);
     e.CQLog.Warning("初始化", "关注数据库文件重初始化完成");
 }
コード例 #2
0
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            #region  出CQApi与CQLog供外部调用
            CQ.Api                      = e.CQApi;
            CQ.Log                      = e.CQLog;
            Eas.CQ.Api                  = e.CQApi;
            Eas.CQ.Log                  = e.CQLog;
            Schedule.CQ.Api             = e.CQApi;
            Schedule.CQ.Log             = e.CQLog;
            GithubWatcher.Shared.CQ.Api = e.CQApi;
            GithubWatcher.Shared.CQ.Log = e.CQLog;
            CosOperation.CQ.Api         = e.CQApi;
            CosOperation.CQ.Log         = e.CQLog;
            CourseFunction.CQ.Api       = e.CQApi;
            CourseFunction.CQ.Log       = e.CQLog;
            #endregion

            try
            {
                #region 基础文件初始化
                IF.InitFiles(Environment.CurrentDirectory, "dc.dll", "验证码识别组件");
                IF.InitFiles(Environment.CurrentDirectory, "SQLite.Interop.dll", "SQLite组件");
                IF.InitFiles(e.CQApi.AppDirectory, "jwxt.db", "教务系统数据库文件");
                if (ini.Read(e.CQApi.AppDirectory + @"\配置.ini", "重初始化", "日程", "") == "真")
                {
                    IF.InitFiles(e.CQApi.AppDirectory, "ScheduleDB.db", "日程数据库文件", true);
                    ini.Write(e.CQApi.AppDirectory + @"\配置.ini", "重初始化", "日程", "");
                    e.CQLog.Warning("初始化", "日程数据库文件重初始化完成");
                }
                else
                {
                    IF.InitFiles(e.CQApi.AppDirectory, "ScheduleDB.db", "日程数据库文件");
                }
                IF.InitFiles(e.CQApi.AppDirectory, "GithubWatcher.db", "Git数据库文件");
                IF.InitFiles(e.CQApi.AppDirectory, "Attentions.db", "关注数据库文件");
                IF.InitFiles(e.CQApi.AppDirectory, "FirstWeekDate.ini", "周起始日期文件", true);

                #endregion

                #region 数据库与EF框架初始化
                Eas.InitializeDB.Init();
                Schedule.InitializeDB.Init();
                GithubWatcher.Models.InitializeDB.Init();
                AttentionSpace.InitializeDB.Init();
                #endregion

                #region 启动GithubWatcher Web服务
                var githubWatcherUrl = "http://localhost:44395/";   // run commend: ngrok http -host-header=localhost 44395     120.77.154.219:330
                WebApp.Start <Startup>(url: githubWatcherUrl);

                #endregion

                #region 启动Schedule线程
                Thread GsrTh = new Thread(Schedule.ScheduleThread.GroupScheduleRemind);
                GsrTh.Start();
                Thread PsrTh = new Thread(Schedule.ScheduleThread.PrivateScheduleRemind);
                PsrTh.Start();
                #endregion


                Common.CommandRouter = new CommandRouter.CommandRouter();
                RegisterCommand();

                e.CQLog.InfoSuccess("初始化", "插件初始化成功。");
                Common.IsInitialized = true;
            }
            catch (Exception ex)
            {
                Common.IsInitialized = false;
                e.CQLog.Error("初始化", "插件初始化失败,建议重启再试。错误信息:" + ex.GetType().ToString() + " " + ex.Message + "\n" + ex.StackTrace);
            }
        }