示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBoxUserID.Text == "" || textBoxPIN.Text == "")
            {
                MessageBox.Show("You need to enter the UserID and the PIN to make the ninjas' succeed!");
            }
            else
            {
                textTime.Text = "0";
                TextCountNumber.Text = "0";
                userID = textBoxUserID.Text;
                PIN = textBoxPIN.Text;
                textBoxPIN.Text = "******";

                stopwatch = new System.Diagnostics.Stopwatch();
                WeHaveAWinner = false;
                stopwatch.Start();
                timer1.Start();
                RunnerArray = new Runner[numberOfRunners];
                RunnerArray[0] = new Runner(this, 0, UrlOfLogin, userID, PIN);
                RunnerArray[0].Show();
                for (int i = 1; i < numberOfRunners; i++)
                {
                    RunnerArray[i] = new Runner(this, i, UrlOfLogin, userID, PIN);
                    //  RunnerArray[i].Show();
                }
                this.Focus();
            }
        }
示例#2
0
        public void startOverAll()
        {
            for (int t = 0; t < numberOfRunners; t++)
            {
               // if (t != AliveRunnerID)
                RunnerArray[t].Stop();
                RunnerArray[t].Close();
            }
            System.Threading.Thread.Sleep(100);
            RunnerArray = new Runner[numberOfRunners];
            for (int i = 0; i < numberOfRunners; i++)
            {
              //  if (i != AliveRunnerID)
                    RunnerArray[i] = new Runner(this, i, UrlOfLogin, userID, PIN);
            }
            RunnerArray[0].Show();
            totalTryNumber = int.Parse(TextCountNumber.Text);
            WeHaveAWinner = false;
            timer1.Start();
            stopwatch.Start();
            try
            {
                // doing the logging after finishing the real thing for a better life ( without race conditions )
                int GlobalTryCount = 0;
                for (int i = 0; i < numberOfRunners; i++)
                {
                    GlobalTryCount += RunnerArray[i].NumberOFTries;
                }
                TextCountNumber.Text = GlobalTryCount.ToString();
                textTime.Text = stopwatch.Elapsed.ToString();

                //Log keeping
                System.IO.StreamWriter log = new System.IO.StreamWriter("log.txt", true);
                log.Write("------------------------------------------------------\r\n"
                        + "Date: " + System.DateTime.Now.ToString()
                        + "\r\nNumber of tries: " + (GlobalTryCount + totalTryNumber).ToString() + "\r\nTime spend: " + stopwatch.Elapsed.ToString()
                        + "\r\nFake login screen."
                        + "\r\n------------------------------------------------------\r\n\r\n");
                log.Close();
            }
            catch (Exception E)
            {
                System.IO.StreamWriter debug = new System.IO.StreamWriter("debug_document.txt", true);
                debug.Write(E.ToString());
                debug.Close();
            }
        }