示例#1
0
        private void button5_Click(object sender, EventArgs e)
        {
            string InputXlPath     = textBox1.Text;
            string OutputXlPath    = textBox2.Text;
            bool   RunAllTestCases = false;

            if (RunAllCases.Checked)
            {
                RunAllTestCases = true;
            }

            if (InputXlPath == "")
            {
                MessageBox.Show("Please provide Input Excel Path");
                return;
            }
            else if (File.Exists(InputXlPath) == false)
            {
                MessageBox.Show("Can not find Input Excel. Please enter a valid Input Excel Path");
                return;
            }

            if (OutputXlPath == "")
            {
                MessageBox.Show("Please provide Output Excel Path");
                return;
            }
            else if (Directory.Exists(OutputXlPath) == false)
            {
                MessageBox.Show("Can not find Output Excel folder. Please enter a valid Output Excel folder");
                return;
            }

            OutputObject outputObject = new OutputObject();

            if (textBox3.Text == "")
            {
                MessageBox.Show("Please provide Output SQL Server Name");
                return;
            }
            outputObject.OutPutServerName = textBox3.Text;
            if (textBox4.Text == "")
            {
                MessageBox.Show("Please provide Output SQL Login");
                return;
            }
            outputObject.OutPutUserName = textBox4.Text;
            if (textBox5.Text == "")
            {
                MessageBox.Show("Please provide Output SQL Password");
                return;
            }
            outputObject.OutPutPass = textBox5.Text;
            if (textBox6.Text == "")
            {
                MessageBox.Show("Please provide Output Database");
                return;
            }
            outputObject.OutPutDataBase = textBox6.Text;

            SqlConnection conn = new SqlConnection();

            try
            {
                conn.ConnectionString = "Server=" + outputObject.OutPutServerName + ";Database=" + outputObject.OutPutDataBase + ";User Id=" + outputObject.OutPutUserName + ";Password="******"Invalid Output SQL Connection. Please check your SQL info. \n Error :" + E.Message);
                return;
            }
            finally
            {
                conn.Close();
            }

            automation = new RMS.NGFMAutomation.LoopEvents.NGFMAutomation(InputXlPath, OutputXlPath, outputObject);
            try
            {
                automation.Run(RunAllTestCases);
            }
            catch (InvalidDataException invalidE)
            {
                MessageBox.Show(invalidE.Message);
                return;
            }
            MessageBox.Show("Automation Run Completed! Please check Output Excel and SQL Database for results.");
            Application.Exit();
        }