Exemplo n.º 1
0
 // Currently unused
 private void chooseDoc1_Click(object sender, EventArgs e)
 {
     string client = serverAddress.Text;
     userLabel.Text = "User: "******"From GoogleDoc")
         robot.runFromGoogleSpreadSheet();
     if (role.Text == "From Excel")
         robot.runFromExcel();
 }
Exemplo n.º 2
0
        // button1 is Run Bot
        private void button1_Click(object sender, EventArgs e)
        {
            string client = serverAddress.Text;
            Random rand = new Random();

            switch(botNumber.SelectedIndex)
            {
                case 4:
                    if (shiftAM5.Text == "")
                        shiftAM5.Text = "7:30";
                    if (shiftPM5.Text == "")
                        shiftPM5.Text = "5:30";

                    if (DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftAM5.Text + "AM") ).ToUniversalTime()) >= 0 && DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftPM5.Text + "PM")).ToUniversalTime()) <= 0)
                    {
                        userLabel5.Text = "User: "******"AM");
                        DateTime afternoon = Convert.ToDateTime(shiftPM5.Text + "PM");
                        int hour = 0, minute = 0;
                        if (DateTime.Now.Hour < morning.Hour && DateTime.Now.Minute < morning.Minute)
                        {
                            hour = morning.Hour - DateTime.Now.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        if (DateTime.Now.Hour > afternoon.Hour && DateTime.Now.Minute > afternoon.Minute)
                        {
                            hour = (24 - DateTime.Now.Hour) + morning.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        double time5 = (hour * 3600 * 100) + (minute * 60 * 100);
                        timer5.Interval = time5;
                        time5 = time5 / 1000;
                        string temp5 = time5.ToString("G4");
                        SetText5("Waiting... " + temp5 + " seconds");
                        timer5.Enabled = true;
                    }
                    goto case 3;
                case 3:
                    if (shiftAM4.Text == "")
                        shiftAM4.Text = "7:30";
                    if (shiftPM4.Text == "")
                        shiftPM4.Text = "5:30";

                    if (DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftAM4.Text + "AM")).ToUniversalTime()) >= 0 && DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftPM4.Text + "PM")).ToUniversalTime()) <= 0)
                    {
                        userLabel4.Text = "User: "******"AM");
                        DateTime afternoon = Convert.ToDateTime(shiftPM4.Text + "PM");
                        int hour = 0, minute = 0;
                        if (DateTime.Now.Hour < morning.Hour && DateTime.Now.Minute < morning.Minute)
                        {
                            hour = morning.Hour - DateTime.Now.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        if (DateTime.Now.Hour > afternoon.Hour && DateTime.Now.Minute > afternoon.Minute)
                        {
                            hour = (24 - DateTime.Now.Hour) + morning.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        double time4 = (hour * 3600 * 100) + (minute * 60 * 100);
                        timer4.Interval = time4;
                        time4 = time4 / 1000;
                        string temp4 = time4.ToString("G4");
                        SetText4("Waiting... " + temp4 + " seconds");
                        timer4.Enabled = true;
                    }
                    goto case 2;
                case 2:
                    if (shiftAM3.Text == "")
                        shiftAM3.Text = "7:30";
                    if (shiftPM3.Text == "")
                        shiftPM3.Text = "5:30";

                    if (DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftAM3.Text + "AM")).ToUniversalTime()) >= 0 && DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftPM3.Text + "PM")).ToUniversalTime()) <= 0)
                    {
                        userLabel3.Text = "User: "******"AM");
                        DateTime afternoon = Convert.ToDateTime(shiftPM3.Text + "PM");
                        int hour = 0, minute = 0;
                        if (DateTime.Now.Hour < morning.Hour && DateTime.Now.Minute < morning.Minute)
                        {
                            hour = morning.Hour - DateTime.Now.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        if (DateTime.Now.Hour > afternoon.Hour && DateTime.Now.Minute > afternoon.Minute)
                        {
                            hour = (24 - DateTime.Now.Hour) + morning.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        double time3 = (hour * 3600 * 100) + (minute * 60 * 100);
                        timer3.Interval = time3;
                        time3 = time3 / 1000;
                        string temp3 = time3.ToString("G4");
                        SetText3("Waiting... " + temp3 + " seconds");
                        timer3.Enabled = true;
                    }
                    goto case 1;
                case 1:
                    if (shiftAM2.Text == "")
                        shiftAM2.Text = "7:30";
                    if (shiftPM2.Text == "")
                        shiftPM2.Text = "5:30";

                    if (DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftAM2.Text + "AM")).ToUniversalTime()) >= 0 && DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftPM2.Text + "PM")).ToUniversalTime()) <= 0)
                    {
                        userLabel2.Text = "User: "******"AM");
                        DateTime afternoon = Convert.ToDateTime(shiftPM2.Text + "PM");
                        int hour = 0, minute = 0;
                        if (DateTime.Now.Hour < morning.Hour && DateTime.Now.Minute < morning.Minute)
                        {
                            hour = morning.Hour - DateTime.Now.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        if (DateTime.Now.Hour > afternoon.Hour && DateTime.Now.Minute > afternoon.Minute)
                        {
                            hour = (24 - DateTime.Now.Hour) + morning.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        double time2 = (hour * 3600 * 100) + (minute * 60 * 100);
                        timer2.Interval = time2;
                        time2 = time2 / 1000;
                        string temp2 = time2.ToString("G4");
                        SetText2("Waiting... " + temp2 + " seconds");
                        timer2.Enabled = true;
                    }
                    goto case 0;
                case 0:
                    if (shiftAM.Text == "")
                        shiftAM.Text = "7:30";
                    if (shiftPM.Text == "")
                        shiftPM.Text = "5:30";

                    if (DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftAM.Text + "AM")).ToUniversalTime()) >= 0 && DateTime.Compare(DateTime.Now.ToUniversalTime(), (Convert.ToDateTime(shiftPM.Text + "PM")).ToUniversalTime()) <= 0)
                    {
                        userLabel.Text = "User: "******"AM");
                        DateTime afternoon = Convert.ToDateTime(shiftPM.Text + "PM");
                        int hour = 0, minute = 0;
                        if (DateTime.Now.Hour < morning.Hour && DateTime.Now.Minute < morning.Minute)
                        {
                            hour = morning.Hour - DateTime.Now.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                        }
                        if (DateTime.Now.Hour > afternoon.Hour && DateTime.Now.Minute > afternoon.Minute)
                        {
                            hour = (24 - DateTime.Now.Hour) + morning.Hour;
                            minute = morning.Minute - DateTime.Now.Minute;
                            if (minute < 0)
                            {
                                hour--;
                                minute = minute * -1;
                            }
                        }
                        double time = (hour * 3600 * 100) + (minute * 60 * 100);
                        timer.Interval = time;
                        time = time / 1000;
                        string temp = time.ToString("G4");
                        SetText("Waiting... " + temp + " seconds");
                        timer.Enabled = true;
                    }
                    break;
            }
        }