Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            LogHelper.StartService();

            var     s  = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "config.json"));
            JObject jo = (JObject)JsonConvert.DeserializeObject(s);

            ip   = jo["LOGIN_IP"].ToString();
            port = jo["LOGIN_PORT"].ToString();
            preclass_server_url = jo["PRECLASS_SERVER_URL"].ToString();
            timeTableId         = jo["TIME_TABLE_ID"].ToString();
            courseId            = jo["COURSE_ID"].ToString();
            resourceId          = jo["RESOURCE_ID"].ToString();
            pwd             = TokenHelper.Md5(jo["PASSWORD"].ToString());
            studentFileName = Path.Combine(Environment.CurrentDirectory, jo["STUDENT_FILE_NAME"].ToString());
            var studentAccountList = StudentHelper.GetStudentList(studentFileName);

            // 读取答案列表
            answserList = AnswerHelper.GetAnswerList(Path.Combine(Environment.CurrentDirectory, "answers"));

            for (var i = 0; i < studentAccountList.Count; i++)
            {
                try
                {
                    Task.Run(() => Work(studentAccountList[i]));
                    //Work(studentAccountList[i]);
                    break;
                }
                catch (Exception ex)
                {
                    LogHelper.Trace(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Work(string studentName)
        {
            // get access token
            var accessToken = TokenHelper.GetToken(ip, port, studentName, pwd);
            var answer      = AnswerHelper.RandomOneOfAnswer(answserList); // ONE OF ANSWER LIST

            // 回答问题
            AnswerQuestionStudent(studentName, answer, accessToken);
        }