private void comboBox4_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox4.SelectedIndex != 0 && comboBox4.SelectedIndex != 1 && comboBox4.SelectedIndex != 2) { ArrayList seats = new ArrayList(); if (comboBox4.SelectedValue.GetType() == typeof(string)) { if (int.Parse(comboBox4.SelectedValue.ToString()) > 1) { RushSeat.GetSeats(comboBox4.SelectedValue.ToString(), seats); } } seats.Insert(0, new DictionaryEntry("0", "(从0开始顺序检索)")); comboBox5.DataSource = seats; comboBox5.DisplayMember = "Value"; comboBox5.ValueMember = "Key"; } else { comboBox5.DataSource = null; comboBox5.Items.Clear(); comboBox5.Items.Add("特殊模式下该项不可用"); comboBox5.SelectedIndex = 0; } }
private void button2_Click(object sender, EventArgs e) { if (button2.Text == "取消预约") { if (RushSeat.CancelReservation(RushSeat.resID)) { button2.Enabled = false; } } if (button2.Text == "结束使用") { if (RushSeat.StopUsing()) { button2.Enabled = false; } } if (button2.Text != "取消预约" && button2.Text != "结束使用") { config.textBox1.AppendText("程序出现逻辑BUG,请联系开发者"); } }
public static void run() { Config.config.button2.Enabled = false; int count = 0; int wrong_count = 0; success = false; while (true) { bool get_list = false; //逻辑BUG 每次循环应重置 if (RushSeat.stop_rush == true) { Config.config.textBox1.AppendText("用户取消抢座\r\n"); Config.config.textBox1.AppendText("-------------------------------------------\r\n"); Config.config.button1.Text = "开始抢座"; RushSeat.stop_rush = false; return; } Config.config.textBox1.AppendText("即将开始第 " + (++count).ToString() + " 次检索...\r\n"); //移除之前的空座列表 RushSeat.freeSeats.Clear(); lastFreeSeatCount = RushSeat.freeSeats.Count; //单个房间检索 if (Config.config.comboBox4.SelectedIndex != 0 && Config.config.comboBox4.SelectedIndex != 1 && Config.config.comboBox4.SelectedIndex != 2) { //获取房间空座列表 string stat = ""; stat = RushSeat.SearchFreeSeat(buildingID, roomID, date, startTime, endTime); //成功检索到空座以及没有符合条件座位但是勾选了改抢附近座位 if (stat == "Success" || (stat == "NoMatchSeat" && Config.config.checkBox5.Checked == true)) { Config.config.textBox1.AppendText("单一房间模式下检索到符合条件空座列表,开始尝试预约...\r\n"); get_list = true; } //如果没有勾选可以改抢附近座位并且是指定座位情况下,直接跳出该循环 if (stat == "NoMatchSeat" && Config.config.checkBox5.Checked != true) { Config.config.textBox1.AppendText("没有勾选改抢附近座位选项,进行下一轮抢座...\r\n"); } } else //特殊模式,例如全馆检索 { switch (Config.config.comboBox4.SelectedIndex) { case 0: { foreach (string mroomID in RushSeat.roomList_b1) { if (RushSeat.SearchFreeSeatMulti(buildingID, mroomID, date, startTime, endTime) == "Success") { get_list = true; break; } Thread.Sleep(repeatSearchInterval); if (RushSeat.stop_rush == true) { Config.config.textBox1.AppendText("用户取消抢座\r\n"); Config.config.textBox1.AppendText("-------------------------------------------\r\n"); Config.config.button1.Text = "开始抢座"; RushSeat.stop_rush = false; return; } } break; } case 1: { foreach (string mroomID in RushSeat.roomList_f1) { if (RushSeat.SearchFreeSeatMulti(buildingID, mroomID, date, startTime, endTime) == "Success") { get_list = true; break; } Thread.Sleep(repeatSearchInterval); if (RushSeat.stop_rush == true) { Config.config.textBox1.AppendText("用户取消抢座\r\n"); Config.config.textBox1.AppendText("-------------------------------------------\r\n"); Config.config.button1.Text = "开始抢座"; RushSeat.stop_rush = false; return; } } break; } case 2: { foreach (string mroomID in RushSeat.roomList_f2t4) { if (RushSeat.SearchFreeSeatMulti(buildingID, mroomID, date, startTime, endTime) == "Success") { get_list = true; break; } Thread.Sleep(repeatSearchInterval); if (RushSeat.stop_rush == true) { Config.config.textBox1.AppendText("用户取消抢座\r\n"); Config.config.textBox1.AppendText("-------------------------------------------\r\n"); Config.config.button1.Text = "开始抢座"; RushSeat.stop_rush = false; return; } } break; } } } //如果检索到空座 if (get_list == true) { //阶级等待 if (Config.rank != 'A') { Thread.Sleep(rankSuccessGetFreeSeat); } //先释放当前座位 string resInfo = RushSeat.CheckHistoryInf(false); if (resInfo == "RESERVE") { if (RushSeat.CancelReservation(RushSeat.resID) != true) { Config.config.textBox1.AppendText("释放座位失败,请手动重试..."); Config.config.comboBox1.Enabled = true; Config.config.comboBox2.Enabled = true; Config.config.comboBox3.Enabled = true; Config.config.comboBox4.Enabled = true; Config.config.comboBox5.Enabled = true; return; } } if (resInfo == "CHECK_IN" || resInfo == "AWAY") { if (RushSeat.StopUsing() != true) { Config.config.textBox1.AppendText("释放座位失败,请手动重试..."); Config.config.comboBox1.Enabled = true; Config.config.comboBox2.Enabled = true; Config.config.comboBox3.Enabled = true; Config.config.comboBox4.Enabled = true; Config.config.comboBox5.Enabled = true; return; } } foreach (string seatID in RushSeat.freeSeats) { string status_1 = RushSeat.BookSeat(seatID, date, startTime, endTime); //bool outloop = false; int count_1 = 0; if (status_1 == "Success") { success = true; break; } //间隔 Thread.Sleep(500); //如果在系统开放的前后3s内没抢到座位,即使座位还在,也会自动改签 //所以说要注意系统的时间 while (status_1 == "NotAtTime" && count_1 < 10) { count_1 = count_1 + 1; //真的服了 status_1 = RushSeat.BookSeat(seatID, date, startTime, endTime); if (status_1 == "Success") { success = true; break; } else if (status_1 == "NotAtTime") { Config.config.textBox1.AppendText("系统尚未开放...\r\n"); Thread.Sleep(500); } //status_1 = RushSeat.BookSeat(seatID, date, startTime, endTime); //放在这里就GG了 } //如果成功抢座就跳出foreach循环,如果是抢座失败就根据情况进行下一步操作 if (success == true) { break; } else //这种情况是没抢过别人,但是这个循环被多重抢座、指定抢座共同使用,不能再根据是否勾选改签来改选,只能先将就一下,指定座位模式下自动改签 { Thread.Sleep(500); Config.config.textBox1.AppendText("座位ID " + seatID.ToString() + " 预约失败,尝试预约下一个座位\r\n"); } } //成功抢座后自动关机 if (success == true) { //静默检查预约信息,激活释放按钮 RushSeat.CheckHistoryInf(false); //窗口弹出 if (Config.config.Visible != true) { Config.config.Visible = true; } Config.config.WindowState = FormWindowState.Normal; //发短信 if (Config.config.checkBox4.Checked) { Config.config.textBox1.AppendText("短信已发送,返回值:\r\n" + RushSeat.SendMessage() + "\r\n"); Config.config.textBox1.AppendText("若返回值小于0为发送失败,请联系开发者\r\n"); Config.config.textBox1.AppendText("------------------------------------------\r\n"); } if (Config.config.checkBox3.Checked) { Config.config.textBox1.AppendText("2min后自动关机\r\n"); Config.config.textBox1.AppendText("如果想取消自动关机请在桌面用快捷键win + R启动控制台, 在控制台自行输入 shutdown -a\r\n"); Config.config.textBox1.AppendText("-----------------------------------------------------\r\n"); Process.Start("shutdown.exe", "-s -t " + "120"); } else { //Config.config.textBox1.AppendText("订座成功"); } Config.config.button1.Text = "开始抢座"; Config.config.comboBox1.Enabled = true; Config.config.comboBox2.Enabled = true; Config.config.comboBox3.Enabled = true; Config.config.comboBox4.Enabled = true; Config.config.comboBox5.Enabled = true; break; } else { //有空座但是抢座失败(别人手快或者碰到更高级的了) wrong_count++; Config.config.textBox1.AppendText("*****预约失败," + (((double)repeatSearchInterval) / 1000).ToString() + "s后重新开始检索...*****\r\n"); get_list = false; if (wrong_count == 5) { Config.config.textBox1.AppendText("多次抢座失败,为防止封号中止抢座\r\n"); Config.config.textBox1.AppendText("这种情况不常见,请保存工作记录并联系开发者\r\n"); Config.config.comboBox1.Enabled = true; Config.config.comboBox2.Enabled = true; Config.config.comboBox3.Enabled = true; Config.config.comboBox4.Enabled = true; Config.config.comboBox5.Enabled = true; return; } } } Thread.Sleep(repeatSearchInterval); preventCount++; //if (preventCount == 30) //{ // Config.config.textBox1.AppendText("防止被封,睡眠10s..........\r\n"); // Thread.Sleep(10000); // preventCount = 0; //} } }
private void button1_Click(object sender, EventArgs e) { if (checkBox4.Checked) { string[] strs = { textBox3.Text.ToString() }; File.WriteAllLines(@"telnumber.txt", strs); } if (config.checkBox1.Checked) { Run.only_window = true; } else { Run.only_window = false; } if (config.checkBox2.Checked) { Run.only_computer = true; } else { Run.only_computer = false; } if (button1.Text == "开始抢座") { comboBox1.Enabled = false; comboBox2.Enabled = false; comboBox3.Enabled = false; comboBox4.Enabled = false; comboBox5.Enabled = false; button1.Enabled = false; //保存配置信息 string[] strsC = { config.comboBox4.SelectedIndex.ToString(), config.comboBox5.SelectedIndex.ToString(), config.comboBox1.SelectedIndex.ToString(), config.comboBox2.SelectedIndex.ToString(), config.comboBox3.SelectedIndex.ToString() }; File.WriteAllLines(@"configuration.txt", strsC); backgroundWorker2.RunWorkerAsync(); RushSeat.stop_waiting = false; Run.roomID = comboBox4.SelectedValue.ToString(); Run.startTime = comboBox2.SelectedValue.ToString(); Run.endTime = comboBox3.SelectedValue.ToString(); //在22:45之前预约明天的 if (Config.config.comboBox1.SelectedIndex == 1 && DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 22:44:50")) < 0) { button1.Text = "结束等待"; Run.date = comboBox1.SelectedValue.ToString(); //防止系统拥堵,不同等级加入不同延迟 Random rd = new Random(); /****这里保留了对D级用户的尊重****/ //if (rank == 'C') // Run.waitsecond = rd.Next(7, 10); // //else if (rank == 'A') // Run.waitsecond = 0; //else if (rank == 'B') // Run.waitsecond = rd.Next(3, 5); // //else //{ // Run.waitsecond = 3600; //} //RushSeat.Wait("22", "45", Run.waitsecond.ToString()); textBox1.AppendText("将于22:44:50重新获取登录令牌\r\n"); RushSeat.Wait("22", "44", "50"); Thread.Sleep(1000); //如果是用户停止等待 if (RushSeat.stop_waiting) { //RushSeat.stop_waiting = false; return; } //正常等待结束,重新登录 string response = RushSeat.GetToken(true); if (response == "Success") { textBox1.AppendText("重新获取登录令牌成功!\r\n"); if (rank == 'A') { RushSeat.WaitNew("22", "44", "59"); } else { //18-12-24 现在所有用户处于同一起跑线上 RushSeat.WaitNew("22", "44", "59"); } //极速模式,此模式下不作任何其它判断,直接抢想要的座位 if (comboBox4.SelectedIndex != 0 && comboBox4.SelectedIndex != 1 && comboBox4.SelectedIndex != 2 && comboBox5.SelectedIndex != 0 && checkBox6.Checked == true) { for (int i = 0; i < 20; i++) { if (RushSeat.BookSeat(comboBox5.SelectedValue.ToString(), Run.date, Run.startTime, Run.endTime) == "Success") { //textBox1.AppendText("急速模式下抢座成功!\r\n"); //静默检查预约信息,激活释放按钮 RushSeat.CheckHistoryInf(false); //窗口弹出 if (Config.config.Visible != true) { Config.config.Visible = true; } Config.config.WindowState = FormWindowState.Normal; //发短信 if (Config.config.checkBox4.Checked) { Config.config.textBox1.AppendText("短信已发送,返回值:\r\n" + RushSeat.SendMessage() + "\r\n"); Config.config.textBox1.AppendText("若返回值小于0为发送失败,请联系开发者\r\n"); Config.config.textBox1.AppendText("------------------------------------------\r\n"); } if (Config.config.checkBox3.Checked) { Config.config.textBox1.AppendText("2min后自动关机\r\n"); Config.config.textBox1.AppendText("如果想取消自动关机请在桌面用快捷键win + R启动控制台, 在控制台自行输入 shutdown -a\r\n"); Config.config.textBox1.AppendText("-----------------------------------------------------\r\n"); Process.Start("shutdown.exe", "-s -t " + "120"); } else { //Config.config.textBox1.AppendText("订座成功"); } Config.config.button1.Text = "开始抢座"; Config.config.comboBox1.Enabled = true; Config.config.comboBox2.Enabled = true; Config.config.comboBox3.Enabled = true; Config.config.comboBox4.Enabled = true; Config.config.comboBox5.Enabled = true; return; } //0.5s后再次尝试抢倾向座位 textBox1.AppendText("急速抢座失败,0.5s后再次尝试..."); Thread.Sleep(500); } textBox1.AppendText("急速抢座失败,转入普通模式"); } //如果是用户停止等待 if (RushSeat.stop_waiting) { //RushSeat.stop_waiting = false; return; } //启动抢座进程 Run.Start(); } else { textBox1.AppendText("重新获取登录令牌失败,相应信息如下:\r\n"); textBox1.AppendText(response); } } //在1点之前预约今天的 else if (DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 01:00:00")) < 0 && Config.config.comboBox1.SelectedIndex == 0) { button1.Text = "结束等待"; Run.date = comboBox1.SelectedValue.ToString(); Random rd = new Random(); if (rank == 'C') { Run.waitsecond = rd.Next(7, 10); } else if (rank == 'A') { Run.waitsecond = rd.Next(0, 2); } else if (rank == 'B') { Run.waitsecond = rd.Next(3, 5); } else { Run.waitsecond = 3600; } RushSeat.Wait("01", "00", Run.waitsecond.ToString()); //如果是用户停止等待 if (RushSeat.stop_waiting) { //RushSeat.stop_waiting = false; return; } //正常等待结束,重新登录 string response = RushSeat.GetToken(true); if (response == "Success") { textBox1.AppendText("再次登录成功!\r\n"); Run.Start(); } else { textBox1.AppendText(response); } } //在1:00 之后 22:00之前预约今天的 else if (DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 01:00:00")) > 0 && DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 22:00:00")) < 0 && Config.config.comboBox1.SelectedIndex == 0) { button1.Text = "结束抢座"; Run.date = comboBox1.SelectedValue.ToString(); Run.Start(); } //在22:45之后 23:50之前预约明天的 else if (DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 22:45:00")) > 0 && Config.config.comboBox1.SelectedIndex == 1 && DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 23:50:00")) < 0) { button1.Text = "结束抢座"; Run.date = comboBox1.SelectedValue.ToString(); Run.Start(); } //在23:50后预约明天的 else if (DateTime.Compare(DateTime.Now, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 23:50:00")) > 0) { textBox1.AppendText("预约时间已过"); } return; } if (button1.Text == "结束等待") { comboBox1.Enabled = true; comboBox2.Enabled = true; comboBox3.Enabled = true; comboBox4.Enabled = true; comboBox5.Enabled = true; button1.Enabled = false; backgroundWorker2.RunWorkerAsync(); RushSeat.CheckHistoryInf(false); RushSeat.stop_waiting = true; button1.Text = "开始抢座"; return; } if (button1.Text == "结束抢座") { comboBox1.Enabled = true; comboBox2.Enabled = true; comboBox3.Enabled = true; comboBox4.Enabled = true; comboBox5.Enabled = true; button1.Enabled = false; backgroundWorker2.RunWorkerAsync(); RushSeat.CheckHistoryInf(false); RushSeat.stop_rush = true; button1.Text = "开始抢座"; return; } }
private void button1_Click(object sender, EventArgs e) { RushSeat.studentID = textBox1.Text.ToString(); RushSeat.password = textBox2.Text.ToString(); if (checkBox1.Checked) { string[] strs = { DES.EncryptDES(textBox1.Text.ToString(), "shAurora"), DES.EncryptDES(textBox2.Text.ToString(), "shAurora") }; File.WriteAllLines(@"userInfo.txt", strs); } Hide(); Config config = new Config(); config.Show(); string response = "empty"; int tryNum = 1, col = 0; while (response != "Success" && tryNum != 5) { response = RushSeat.GetToken(true); if (response == "Success") { //Hide(); //Config config = new Config(); //config.Show(); col = 1; config.textBox1.AppendText("登录成功!\n"); Config.config.textBox1.AppendText("---------------------------------------\n"); //获取各个房间的座位列表 config.comboBox4.SelectedIndex = 0; config.comboBox2.SelectedIndex = 4; //默认10点开始 config.comboBox1.SelectedIndex = 1; //加载 if (File.Exists(@"configuration.txt")) { Config.strC = File.ReadAllLines(@"configuration.txt"); config.comboBox4.SelectedIndex = Convert.ToInt32(Config.strC[0]); config.comboBox5.SelectedIndex = Convert.ToInt32(Config.strC[1]); config.comboBox1.SelectedIndex = Convert.ToInt32(Config.strC[2]); config.comboBox2.SelectedIndex = Convert.ToInt32(Config.strC[3]); config.comboBox3.SelectedIndex = Convert.ToInt32(Config.strC[4]); } RushSeat.GetUserInfo(); if (RushSeat.CheckHistoryInf(true) == "NO") { config.textBox1.AppendText("当前无有效预约\n"); } else //已经有有效预约 { } Config.config.textBox1.AppendText("剩余可发送短信数目:" + RushSeat.GetSMSNum() + "\n"); Config.config.textBox1.AppendText("---------------------\n"); } else { config.textBox1.AppendText("第" + tryNum + "次登录失败,3s后重试\n"); config.textBox1.AppendText("[info]" + response + "\n"); for (int i = 0; i < 10; i++) { Application.DoEvents(); //防止控件假死 Thread.Sleep(300); } tryNum++; } } if (col == 0) { config.textBox1.AppendText("尝试登录失败次数过多,请检查网络连接或服务器状态"); } }