static void Main(string[] args) { InitializeComponent(); Console.WriteLine("欢迎使用中考查分软件。"); Console.WriteLine("本程序自动读取当前目录下的zkcf.xml,请勿不懂就修改。"); Console.WriteLine("本程序分为A——数据下载模块和B——数据整合模块。"); Console.WriteLine(); Console.WriteLine("可用考试类型:"); foreach (KeyValuePair <string, TestInfo> ti in TestPool) { Console.WriteLine("{0}:{1}", ti.Key, ti.Value.Name); } Console.WriteLine("可用学生区域:"); foreach (KeyValuePair <string, StudentInfo> si in StudentPool) { Console.WriteLine("{0}:{1}", si.Key, si.Value.Name); } Console.WriteLine(); Console.Write("您的操作类型为(A/B)"); string type = Console.ReadLine().Trim().ToLower(); if (type == "a") { ParallelPipe.ParallelStart(); } else if (type == "b") { StatisticsPipe.ManageFiles(); } }
static void EnrollGet() { foreach (string var in Directory.GetFiles(Program.CommonFolder + "\\scores", (si.Id / 10000).ToString() + "*", SearchOption.TopDirectoryOnly)) { Scores current = StatisticsPipe.JsonComplete <Scores>(var); ti.Download(long.Parse(current.id), long.Parse(current.zw)); } Console.WriteLine("下载完成,按任意键退出。"); Console.ReadKey(); }
static void ScoresGet() { List <short> stuId = new List <short>(); for (short i = 1; i <= si.IdLength; i++) { stuId.Add(i); } foreach (string var in Directory.GetFiles(Program.CommonFolder + "\\" + test, (si.Id / 10000).ToString() + "*", SearchOption.TopDirectoryOnly)) { Scores current = StatisticsPipe.JsonComplete <Scores>(var); stuId.Remove((short)(long.Parse(current.id) - si.Id)); if (ti.NeedZw) { si.ZwCollection.Remove((short)(long.Parse(current.zw) - si.Zw)); } } Console.Write("输入测试所用线程数:"); byte ThreadNumber = Convert.ToByte(Console.ReadLine()); hThreads = new List <Thread>(ThreadNumber); short Count = (short)(stuId.Count / ThreadNumber); for (int i = 0; i < ThreadNumber; i++) { hThreads.Add(new Thread(new ParameterizedThreadStart(ParallelCalculate))); } Console.WriteLine("退出请关闭窗口!"); for (byte i = 0; i < ThreadNumber; i++) { ThreadData td = new ThreadData(); td.IdRange = stuId.GetRange(i * Count, Count + (i == ThreadNumber ? stuId.Count % ThreadNumber : 0)); td.StudentPool = si; td.TestType = ti; td.ThreadId = i; hThreads[i].Start(td); } while (true) { Console.ReadKey(); } }