public static DateTime WeekdayDate(string weekday)
        {
            int year  = int.Parse(EasOP.GetFirstWeekDate().Split('-')[0]);
            int month = int.Parse(EasOP.GetFirstWeekDate().Split('-')[1]);
            int day   = int.Parse(EasOP.GetFirstWeekDate().Split('-')[2]);

            switch (weekday)
            {
            case "Mon":
                return(new DateTime(year, month, day).AddDays(0));

            case "Tue":
                return(new DateTime(year, month, day).AddDays(1));

            case "Wed":
                return(new DateTime(year, month, day).AddDays(2));

            case "Thu":
                return(new DateTime(year, month, day).AddDays(3));

            case "Fir":
                return(new DateTime(year, month, day).AddDays(4));

            case "Sat":
                return(new DateTime(year, month, day).AddDays(5));

            default:
                return(new DateTime(year, month, day).AddDays(6));
            }
        }
示例#2
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            Student      student    = bindingSource_StudentDB.Current as Student;
            List <Score> temp       = EasOP.GetScores(student.StuID);
            String       CourseName = comboBoxCourseName.SelectedItem.ToString();
            String       Year       = comboBoxYear.SelectedItem.ToString();
            String       Term       = comboBoxTerm.SelectedItem.ToString();
            String       Credit     = comboBoxCreditNum.SelectedItem.ToString();

            if (CourseName != " ")
            {
                Score Course = temp.FirstOrDefault(p => p.LessonName == CourseName);
                bindingSource_StuScore.DataSource = Course;
                bindingSource_StuScore.ResetBindings(false);
                return;
            }

            if (Credit != " ")
            {
                temp = temp.Where(p => p.Credit == Credit).OrderBy(p => p.Year).ThenBy(p => p.Term).ToList();
            }

            if (Year != " ")
            {
                temp = temp.Where(p => p.Year == Year).OrderBy(p => p.Term).ThenBy(p => p.Credit).ToList();
            }

            if (Term != " ")
            {
                temp = temp.Where(p => p.Term == Term).OrderBy(p => p.Year).ThenBy(p => p.Credit).ToList();
            }

            bindingSource_StuScore.DataSource = temp;
            bindingSource_StuScore.ResetBindings(false);
        }
示例#3
0
        public override int HandleImpl()
        {
            try
            {
                Reply("正在尝试更新成绩数据……");
                var    sList = EasOP.UpdateScore(fromQQ);
                string re    = "";
                if (sList.Count != 0)
                {
                    foreach (var s in sList)
                    {
                        re = re + "\n课程:" + s.LessonName + "\n成绩:" + s.Mark + "\n——————————";
                    }
                }
                if (re != "")
                {
                    Reply("更新成功,新出成绩如下:" + re);
                }
                else
                {
                    Reply("更新成功,当前没有新出成绩。");
                }

                return(1);
            }
            catch (UpdataErrorException ex)
            {
                Reply("更新失败 发生错误:\n" + ex.Message);
                return(1);
            }
        }
示例#4
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", "成绩提醒", "间隔", "");
        }
 public override int HandleImpl()
 {
     try
     {
         Reply("正在尝试更新课程数据……");
         EasOP.UpdateCourse(fromQQ);
         Reply("更新成功!");
         return(1);
     }
     catch (UpdataErrorException ex)
     {
         Reply("更新失败 发生错误:\n" + ex.Message);
         return(1);
     }
 }
示例#6
0
        public bool AddCourseSchedule()  //将课程导入日程
        {
            string        userStuID = EasOP.GetStuID((this.QQ).ToString());
            List <Course> courses   = EasOP.GetCourses(userStuID);

            foreach (Course course in courses)
            {
                List <List <Object> > temp = CourseTime.ParseClassTime(course);
                for (int i = 0; i < temp.Count; i++)
                {
                    DateTime dt = (DateTime)temp[i][0];
                    dt = dt.AddMinutes(-15);
                    string sc       = $"{course.LessonName},{course.Teacher},{course.Time}";
                    int    weekSpan = (int)temp[i][1];
                    if (!AddWeeklySchedule(dt, sc, weekSpan))
                    {
                        return(false);
                    }
                }
                #region 用循环添加日程
                //if (CourseTime.ParseClassTime(course).Count == 1)
                //{
                //  DateTime dt = (DateTime)CourseTime.ParseClassTime(course)[0][0];
                //  string st = "每周课程提醒";
                //  string sc = $"{course.LessonName},{course.Teacher},{course.Time}";
                //  int weekSpan = (int)CourseTime.ParseClassTime(course)[0][1];
                //  if (!AddWeeklySchedule(dt, st, sc, weekSpan))
                //      return false;
                //}
                //else if(CourseTime.ParseClassTime(course).Count == 2)
                //{
                //    DateTime dt = (DateTime)CourseTime.ParseClassTime(course)[0][0];
                //    string st = "每周课程提醒";
                //    string sc = $"{course.LessonName},{course.Teacher},{course.Time}";
                //    int weekSpan = (int)CourseTime.ParseClassTime(course)[0][1];
                //    dt = (DateTime)CourseTime.ParseClassTime(course)[1][0];
                //    weekSpan = (int)CourseTime.ParseClassTime(course)[1][1];
                //    if(!AddWeeklySchedule(dt, st, sc, weekSpan)||!AddWeeklySchedule(dt, st, sc, weekSpan))
                //        return false;
                //}
                #endregion
            }
            return(true);
        }
示例#7
0
 private void buttonSelectCS_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < AllScoredataGridView.Rows.Count - 1; i++)
     {
         if (AllScoredataGridView.CurrentRow != null)
         {
             String Department = EasOP.GetCollege(tb_StuID.Text);
             if (AllScoredataGridView.Rows[i].Cells["Column7"].Value.ToString() == Department
                 &&
                 (AllScoredataGridView.Rows[i].Cells["Column2"].Value.ToString() == "专业选修" ||
                  AllScoredataGridView.Rows[i].Cells["Column2"].Value.ToString() == "专业教育选修"))
             {
                 AllScoredataGridView.Rows[i].Cells[0].Value = "True";
             }
             else
             {
                 AllScoredataGridView.Rows[i].Cells[0].Value = "False";
             }
         }
     }
 }
示例#8
0
        private void tab3Init()
        {
            if (bindingSource_StudentDB.Count != 0)
            {
                Student student = bindingSource_StudentDB.Current as Student;
                bindingSource_StuScore.DataSource = EasOP.GetScores(student.StuID);
                AllScoredataGridView.DataSource   = bindingSource_StuScore;

                //防止列乱序
                AllScoredataGridView.AutoGenerateColumns = false;
                //为DataGridView增加可选框
                DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
                checkBoxColumn.Name = "select";
                //列名
                checkBoxColumn.HeaderText = "选择";
                //第一列插入checkbox
                AllScoredataGridView.Columns.Insert(0, checkBoxColumn);
                AllScoredataGridView.RowHeadersVisible = false;

                AllScoredataGridView.Columns[0].Width = 50;

                //初始化combobox
                List <Score> combo = EasOP.GetScores(student.StuID);
                //提取成绩列表中的唯一值
                List <String> CourseName = combo.Select(x => x.LessonName).Distinct().ToList();
                CourseName.Insert(0, " ");
                List <String> Credit = combo.Select(x => x.Credit).Distinct().ToList();
                Credit.Insert(0, " ");
                List <String> Year = combo.Select(x => x.Year).Distinct().ToList();
                Year.Insert(0, " ");
                List <String> Term = new List <string> {
                    " ", "1", "2"
                };
                comboBoxCourseName.DataSource = CourseName;
                comboBoxCreditNum.DataSource  = Credit;
                comboBoxYear.DataSource       = Year;
                comboBoxTerm.DataSource       = Term;
            }
        }
示例#9
0
        private void btn_jwlogin_Click(object sender, EventArgs e)
        {
            EasLogin jwxt = new EasLogin(Convert.ToString(BotQQ.Id), tb_QQ.Text, tb_StuID.Text, tb_jwPw.Text, 3);

            try
            {
                if (jwxt.TryLogin() == true)
                {
                    EasGetScore jwscore = new EasGetScore();
                    jwscore.GetScore(jwxt);
                    EasGetCourse jwcourse = new EasGetCourse();
                    jwcourse.GetCourse(jwxt);
                    MessageBox.Show(jwxt.StuName + " " + jwxt.College, "登录成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    bindingSource_StudentDB.DataSource = EasOP.GetAll(Convert.ToString(BotQQ.Id));
                    dataGridView_StuList.DataSource    = bindingSource_StudentDB;

                    //课程表 数据绑定
                    stuDataGridView.DataSource = bindingSource_StudentDB;

                    tab2Init();
                    tab3Init();
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "密码错误")
                {
                    MessageBox.Show("用户名或密码错误。", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (ex.Message == "验证码错误")
                {
                    MessageBox.Show("验证码错误次数达到上限,可稍后尝试重新登录再试。", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    throw ex;
                }
            }
        }
示例#10
0
        public override int HandleImpl()
        {
            string StuID     = EasOP.GetStuID(fromQQ);
            Regex  regex     = new Regex(@"[0-9]{4}");
            Regex  regexTerm = new Regex(@"第?[123一二三]?学期?");            //可以匹配1,2,3,一,二,三,第x学期
            Regex  regexAny  = new Regex(@"[A-Za-z0-9\u4e00-\u9fa5]+"); //匹配课程名

            if (StuID != "")
            {
                List <Score> Slist     = EasOP.GetScores(StuID);
                List <Score> SlistTemp = EasOP.GetScores(StuID);//用于查询单科使用
                GPAInfo      StuGPA;
                int          isIlegal = 0;
                bool         flag     = false;
                string       msg      = message.Replace(" ", ""); //去除空格
                //无额外操作,直接返回总成绩
                if (msg == "计算成绩")
                {
                    StuGPA = ScoreService.AllCredit(Slist);
                    CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【GPA信息】\nGPA:{StuGPA.GPA}\n平均分:{StuGPA.AverageScore}\n所选学分:{StuGPA.CreditSum}");
                }
                //存在操作
                else
                {
                    try
                    {
                        string       msg1         = msg.Substring(4);
                        string[]     msgprocess   = msg1.Split('|');
                        bool         isCourseFlag = false;
                        int          isCourse     = 0;
                        List <Score> SlistCourse  = new List <Score>();
                        for (int i = 0; i < msgprocess.Length; i++)
                        {
                            isIlegal = 0;
                            string msgtemp = msgprocess[i];
                            if (regexAny.IsMatch(msgtemp) && (isCourse == 0 || isCourseFlag))//处理操作中有课程名,若为课程名,则其他去除公选的操作不考虑
                            {
                                List <Score> temp = ScoreService.onlyThisCourse(SlistTemp, msgtemp);
                                if (temp.Count != 0)
                                {
                                    SlistCourse.AddRange(temp);
                                    isCourseFlag = true;
                                    isCourse++;
                                    continue;
                                }
                            }
                            if (msgtemp == "去除公选")
                            {
                                Slist = ScoreService.noGongXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除公必")
                            {
                                Slist = ScoreService.noGongBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专选")
                            {
                                Slist = ScoreService.noZhuanXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专必")
                            {
                                Slist = ScoreService.noZhuanBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除非本院")
                            {
                                Slist = ScoreService.onlyDepartment(Slist, EasOP.GetCollege(StuID));
                                isIlegal++;
                            }
                            if (regex.IsMatch(msgtemp))
                            {
                                Slist = ScoreService.onlyThisYear(Slist, msgtemp);
                                isIlegal++;
                            }
                            if (regexTerm.IsMatch(msgtemp))
                            {
                                msgtemp = msgtemp.Replace("一", "1");
                                msgtemp = msgtemp.Replace("二", "2");
                                msgtemp = msgtemp.Replace("三", "3");
                                Slist   = ScoreService.onlyThisTerm(Slist, msgtemp[1].ToString());
                                isIlegal++;
                            }
                            if (isIlegal == 0)
                            {
                                flag = true;
                            }
                            if (i == msgprocess.Length - 1 && flag == true)
                            {
                                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【存在非法指令】\n非法指令已被跳过,请检查后重新输入。");
                            }
                        }
                        if (isCourseFlag)
                        {
                            Slist = SlistCourse;
                        }
                        StuGPA = ScoreService.Compute(Slist);
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【GPA信息】\nGPA:{StuGPA.GPA}\n平均分:{StuGPA.AverageScore}\n所选学分:{StuGPA.CreditSum}");
                    }
                    catch (Exception e)
                    {
                        if (e.Message == "学年不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学年不存在】\n请输入正确的学年进行查询");
                        }
                        if (e.Message == "学期不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学期不存在】\n请输入正确的学年及学期进行查询");
                        }
                    }
                }
            }
            else
            {
                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【未绑定教务系统】\n请先绑定教务系统,格式:绑定教务系统 学号|密码");
            }

            return(0);
        }
示例#11
0
        private void buttonRestore_Click(object sender, EventArgs e)
        {
            Student student = bindingSource_StudentDB.Current as Student;

            bindingSource_StuScore.DataSource = EasOP.GetScores(student.StuID);
        }
示例#12
0
 private void btn_refreshMainList_Click(object sender, EventArgs e)
 {
     bindingSource_StudentDB.DataSource = EasOP.GetAll(Convert.ToString(BotQQ.Id));
     dataGridView_StuList.DataSource    = bindingSource_StudentDB;
 }
示例#13
0
 private void button1_Click(object sender, EventArgs e)
 {
     EasOP.DeleteStu(CurrentStuID_jw);
     bindingSource_StudentDB.DataSource = EasOP.GetAll(Convert.ToString(BotQQ.Id));
     dataGridView_StuList.DataSource    = bindingSource_StudentDB;
 }
示例#14
0
        public override int HandleImpl()
        {
            string msg      = message.Replace(" ", ""); //去除空格
            var    StuID    = textOp.GetMiddleText(msg, "绑定教务系统", "|");
            var    Password = textOp.GetRightText(msg, "|");

            if (StuID == "" || Password == "")
            {
                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "命令格式错误,请检查输入信息。\n命令格式:绑定教务系统 学号|密码");
                return(1);
            }
            EasLogin jwxt         = new EasLogin(botQQ, fromQQ, StuID, Password, 3);
            string   AppDirectory = CQ.Api.AppDirectory;

            for (int i = 0; i <= jwxt.TryNum; i++)
            {
                try
                {
                    if (EasOP.StuExist(StuID) == false)
                    {
                        jwxt.LoginSys();
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【登录成功】\n", jwxt.College, " ", jwxt.StuName);
                        ini.Write(AppDirectory + @"\配置.ini", fromQQ, "学号", StuID);
                        ini.Write(AppDirectory + @"\配置.ini", fromQQ, "密码", DESTool.Encrypt(Password, "jw*1"));

                        EasGetCourse jwcourse = new EasGetCourse();
                        jwcourse.GetCourse(jwxt);
                        EasGetScore jwScore = new EasGetScore();
                        jwScore.GetScore(jwxt);

                        break;
                    }
                    else
                    {
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【绑定失败】\n当前学号已被QQ:", EasOP.GetStuQQ(StuID), "绑定,不能再次绑定。");
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message == "密码错误")
                    {
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【用户名或密码错误】\n请确认无误后重新发送命令再试。");
                    }
                    else if (ex.Message == "验证码错误")
                    {
                        if (i == jwxt.TryNum)
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "验证码错误已达最大尝试上限,如需继续登录可重新发送命令再试。");
                        }
                        else
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【验证码错误】\n正在重试。");
                            System.Threading.Thread.Sleep(1000);    //休眠1s后重试请求
                            continue;
                        }
                    }
                    else
                    {
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "发生未知错误,请联系机器人主人。");
                        CQ.Log.Error("发生未知错误", ex.ToString());
                        break;
                    }
                }
            }

            return(0);
        }
        public override int HandleImpl()
        {
            string StuID     = EasOP.GetStuID(fromQQ);
            Regex  regex     = new Regex(@"[0-9]{4}");
            Regex  regexTerm = new Regex(@"第+[123一二三]+学+期+");           //可以匹配1,2,3,一,二,三,第x学期
            Regex  regexAny  = new Regex(@"[A-Za-z0-9\u4e00-\u9fa5]+"); //匹配课程名

            if (StuID != "")
            {
                List <Score> Slist     = EasOP.GetScores(StuID);
                List <Score> SlistTemp = EasOP.GetScores(StuID);//用于查询单科使用
                GPAInfo      StuGPA;
                int          isIlegal = 0;
                bool         flag     = false;
                string       msg      = message.Replace(" ", ""); //去除空格
                string       str;
                str = padRightEx("课程名", 8) + padRightEx("学分", 6) + padRightEx("成绩", 6) + "\n";
                //str = string.Format("{0,30}", "课程名") + string.Format("{0,6}", "学分") + string.Format("{0,6}", "成绩") + "\n";
                //无额外操作,直接返回总成绩
                if (msg == "查询成绩")
                {
                    foreach (Score temp in Slist)
                    {
                        //str += string.Format("{0,30}", temp.LessonName) + string.Format("{0,6}", temp.Credit) + string.Format("{0,6}", temp.Mark) + "\n";
                        str += padRightEx(temp.LessonName, 36) + "\n" + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6) + "\n";

                        /* str.Append(padRightEx(temp.LessonName, 30) + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6));
                         * str.Append(Environment.NewLine);*/
                    }
                    CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【成绩信息】\n" + str);
                }
                //存在操作
                else
                {
                    try
                    {
                        string       msg1         = msg.Substring(4);
                        string[]     msgprocess   = msg1.Split('|');
                        bool         isCourseFlag = false;
                        int          isCourse     = 0;
                        List <Score> SlistCourse  = new List <Score>();
                        for (int i = 0; i < msgprocess.Length; i++)
                        {
                            isIlegal = 0;
                            string msgtemp = msgprocess[i];
                            if (regexAny.IsMatch(msgtemp) && (isCourse == 0 || isCourseFlag))//处理操作中有课程名,若为课程名,则其他去除公选的操作不考虑
                            {
                                List <Score> temp = ScoreService.onlyThisCourse(SlistTemp, msgtemp);
                                if (temp.Count != 0)
                                {
                                    SlistCourse.AddRange(temp);
                                    isCourseFlag = true;
                                    isCourse++;
                                    continue;
                                }
                            }
                            if (msgtemp == "去除公选")
                            {
                                Slist = ScoreService.noGongXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除公必")
                            {
                                Slist = ScoreService.noGongBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专选")
                            {
                                Slist = ScoreService.noZhuanXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专必")
                            {
                                Slist = ScoreService.noZhuanBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除非本院")
                            {
                                Slist = ScoreService.onlyDepartment(Slist, EasOP.GetCollege(StuID));
                                isIlegal++;
                            }
                            if (regex.IsMatch(msgtemp))
                            {
                                Slist = ScoreService.onlyThisYear(Slist, msgtemp);
                                isIlegal++;
                            }
                            if (regexTerm.IsMatch(msgtemp))
                            {
                                msgtemp = msgtemp.Replace("一", "1");
                                msgtemp = msgtemp.Replace("二", "2");
                                msgtemp = msgtemp.Replace("三", "3");
                                Slist   = ScoreService.onlyThisTerm(Slist, msgtemp[1].ToString());
                                isIlegal++;
                            }
                            if (isIlegal == 0)
                            {
                                flag = true;
                            }
                            if (i == msgprocess.Length - 1 && flag == true)
                            {
                                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【存在非法指令】\n非法指令已被跳过,请检查后重新输入。");
                            }
                        }
                        if (isCourseFlag)
                        {
                            Slist = SlistCourse;
                        }
                        foreach (Score temp in Slist)
                        {
                            //str += string.Format("{0,30}", temp.LessonName) + string.Format("{0,6}", temp.Credit) + string.Format("{0,6}", temp.Mark) + "\n";
                            str += padRightEx(temp.LessonName, 36) + "\n" + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6) + "\n";

                            /*str.Append(padRightEx(temp.LessonName, 30) + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6));
                             * str.Append(Environment.NewLine);*/
                        }
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【成绩信息】\n" + str);
                    }
                    catch (Exception e)
                    {
                        if (e.Message == "学年不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学年不存在】\n请输入正确的学年进行查询");
                        }
                        if (e.Message == "学期不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学期不存在】\n请输入正确的学年及学期进行查询");
                        }
                    }
                }
            }
            else
            {
                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【未绑定教务系统】\n请先绑定教务系统,格式:绑定教务系统 学号|密码");
            }

            return(0);
        }