Beispiel #1
0
        private void tab1Init()
        {
            BotQQ = CQ.Api.GetLoginQQ();

            bindingSource_StudentDB.DataSource = EasOP.GetAll(Convert.ToString(BotQQ.Id));
            dataGridView_StuList.DataSource    = bindingSource_StudentDB;
            stuDataGridView.DataSource         = bindingSource_StudentDB;

            tb_QQ.Text    = ini.Read(AppDirectory + @"\配置.ini", "主人信息", "QQ", "");
            tb_StuID.Text = ini.Read(AppDirectory + @"\配置.ini", "主人信息", "学号", "");
            if (ini.Read(AppDirectory + @"\配置.ini", "主人信息", "教务系统密码", "") != "")
            {
                tb_jwPw.Text = DESTool.Decrypt(ini.Read(AppDirectory + @"\配置.ini", "主人信息", "教务系统密码", ""), "jw*1");
            }

            if (ini.Read(AppDirectory + @"\配置.ini", "成绩提醒", "启动", "") == "真")
            {
                label_sr1.Text = "本人新出成绩提醒:已开启";
            }
            else
            {
                label_sr1.Text = "本人新出成绩提醒:已关闭";
            }

            tb_ReminderTime.Text = ini.Read(AppDirectory + @"\配置.ini", "成绩提醒", "间隔", "");
        }
        /// <summary>
        /// 更新指定学生的成绩信息 失败将抛出异常
        /// </summary>
        /// <param name="StuQQ">学生QQ</param>
        /// <returns>新成绩列表</returns>
        public static List <Score> UpdateScore(string StuQQ)
        {
            QQ     BotQQ        = CQ.Api.GetLoginQQ();
            string AppDirectory = CQ.Api.AppDirectory;
            string StuID;
            string Pw;

            if (ini.Read(AppDirectory + @"\配置.ini", "主人信息", "QQ", "") == StuQQ)  //是主人
            {
                StuID = ini.Read(AppDirectory + @"\配置.ini", "主人信息", "学号", "");
                Pw    = DESTool.Decrypt(ini.Read(AppDirectory + @"\配置.ini", "主人信息", "教务系统密码", ""), "jw*1");
            }
            else
            {
                StuID = ini.Read(AppDirectory + @"\配置.ini", StuQQ, "学号", "");
                Pw    = DESTool.Decrypt(ini.Read(AppDirectory + @"\配置.ini", StuQQ, "密码", ""), "jw*1");
            }

            if (StuID == "" || Pw == "")
            {
                throw new UpdataErrorException("当前QQ未绑定教务系统账户。");
            }
            EasLogin jwxt = new EasLogin(Convert.ToString(BotQQ.Id), StuQQ, StuID, Pw, 3);

            try
            {
                if (jwxt.TryLogin() == true)
                {
                    EasGetNewScore jwscore = new EasGetNewScore();
                    return(jwscore.GetNewScore(jwxt));
                }
                else
                {
                    return(new List <Score>());   //空列表
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "用户名/密码错误")
                {
                    throw new UpdataErrorException("用户名或密码错误。");
                }
                else if (ex.Message == "验证码错误")
                {
                    throw new UpdataErrorException("验证码错误达到上限,请稍后再试。");
                }
                else
                {
                    CQ.Log.Error("发生错误", "错误信息:" + ex.GetType().ToString() + " " + ex.Message + "\n" + ex.StackTrace);
                    throw new UpdataErrorException("发生未知错误,请联系机器人主人。");
                }
            }
        }
        void IJob.Execute()
        {
            BotQQ = CQ.Api.GetLoginQQ();

            string AppDirectory = CQ.Api.AppDirectory;
            string QQ           = ini.Read(AppDirectory + @"\配置.ini", "主人信息", "QQ", "");
            string StuID        = ini.Read(AppDirectory + @"\配置.ini", "主人信息", "学号", "");
            string Pw           = ini.Read(AppDirectory + @"\配置.ini", "主人信息", "教务系统密码", "");

            if (QQ == "" || StuID == "" || Pw == "")
            {
                CQ.Log.Warning("成绩提醒模块", "本人部分信息为空,提醒任务已停止。");
                JobManager.Stop();
                JobManager.RemoveAllJobs();
            }

            CQ.Log.Debug("成绩提醒模块", "检测运行中……");

            Pw = DESTool.Decrypt(Pw, "jw*1");
            EasLogin jwxt = new EasLogin(Convert.ToString(BotQQ.Id), QQ, StuID, Pw, 3);

            try
            {
                if (jwxt.TryLogin() == true)
                {
                    CQ.Log.Debug("成绩提醒模块", "登录成功");
                    EasGetNewScore jwscore = new EasGetNewScore();
                    var            sList   = jwscore.GetNewScore(jwxt);
                    if (sList.Count != 0)
                    {
                        foreach (var s in sList)
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(QQ), "【新出成绩】\n课程:", s.LessonName, "\n成绩:", s.Mark);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CQ.Log.Warning("成绩提醒模块", "本次检测发生了错误,任务已停止。\n错误信息:" + ex.Message);
                JobManager.Stop();
                JobManager.RemoveAllJobs();
            }
        }
Beispiel #4
0
 public static void FetchConnString()
 {
     ConnectionString = ConfigurationManager.AppSettings["DSN"];
     ConnectionString = DESTool.Decrypt(ConnectionString, ConfigurationManager.AppSettings["cKey"]);
 }