示例#1
0
        // Handle action: User click Start button
        private void tbarStart_Click(object sender, EventArgs e)
        {
            try
            {
                if (listFile.SelectedItem == null)
                {
                    MessageBox.Show("Select 1 file in list box to continue !");
                    return;
                }

                // Get connection option
                int    iCon     = ComFunc.StringToInt32(tbarConnectionTxt.Text);
                int    iLoop    = ComFunc.StringToInt32(tbarLoopTxt.Text);
                string stIPAdd  = objSettingConfig.allItems["SocketIP"];
                int    iPort    = ComFunc.StringToInt32(objSettingConfig.allItems["SocketPort"]);
                string stAES    = objSettingConfig.allItems["SocketAES"];
                string st3DES   = objSettingConfig.allItems["Socket3DES"];
                int    iTimeout = ComFunc.StringToInt32(objSettingConfig.allItems["CONNECTTimeout"]);
                string stUser   = objSettingConfig.allItems["CONNECTUsername"];
                string stPass   = objSettingConfig.allItems["CONNECTPassword"];
                txtStatus.Text = "";
                listStatus.Clear();
                listConnection.Clear();

                // Get scenario step from GUI
                List <string> listScenarioStep = new List <string>();
                for (int i = 0; i < gridFileStep.RowCount; i++)
                {
                    if (gridFileStep.Rows[i].Cells[2].Value != null)
                    {
                        string stStep = gridFileStep.Rows[i].Cells[2].Value.ToString();
                        if (stStep != "")
                        {
                            listScenarioStep.Add(stStep);
                        }
                    }
                }

                // Create connection
                for (int i = 0; i < iCon; i++)
                {
                    // Set parameter for worker thread
                    RunScenarioWorkerThread con = new RunScenarioWorkerThread();
                    con.ThreadID         = i;
                    con.IPAdd            = stIPAdd;
                    con.Port             = iPort;
                    con.Loop             = iLoop;
                    con.EncryptAES       = stAES;
                    con.Encrypt3DES      = st3DES;
                    con.Timeout          = iTimeout;
                    con.objSettingConfig = objSettingConfig;
                    con.listScenario     = listScenarioStep;
                    con.User             = stUser;
                    con.Pass             = stPass;

                    // Add event listener
                    con.EventHappned += OnComNotification;

                    // Add connection to list
                    listConnection.Add(con);

                    // Add list status
                    string status = "";
                    listStatus.Add(status);

                    // Start thread
                    listConnection[i].Run();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error to create connection !\nError =  " + ex.Message);
            }
        }
示例#2
0
        private void tbarTest_Click(object sender, EventArgs e)
        {
            // Get connection option
            int iCon = ComFunc.StringToInt32(tbarConnectionTxt.Text);
            int iLoop = ComFunc.StringToInt32(tbarLoopTxt.Text);
            string stIPAdd = objSettingConfig.allItems["SocketIP"];
            int iPort = ComFunc.StringToInt32(objSettingConfig.allItems["SocketPort"]);
            string stAES = objSettingConfig.allItems["SocketAES"];
            string st3DES = objSettingConfig.allItems["Socket3DES"];
            int iTimeout = ComFunc.StringToInt32(objSettingConfig.allItems["CONNECTTimeout"]);
            string stUser = objSettingConfig.allItems["CONNECTUsername"];
            string stPass = objSettingConfig.allItems["CONNECTPassword"];
            txtStatus.Text = "";
            listStatus.Clear();
            listConnection.Clear();

            // Get scenario step from GUI
            List<string> listScenarioStep = new List<string>();
            for (int i = 0; i < gridFileStep.RowCount; i++)
            {
                if (gridFileStep.Rows[i].Cells[2].Value != null)
                {
                    string stStep = gridFileStep.Rows[i].Cells[2].Value.ToString();
                    if (stStep != "")
                    {
                        listScenarioStep.Add(stStep);
                    }
                }
            }

            // Test to run script
            // Set parameter for worker thread
            RunScenarioWorkerThread con = new RunScenarioWorkerThread();
            con.ThreadID = 0;
            con.IPAdd = stIPAdd;
            con.Port = iPort;
            con.Loop = iLoop;
            con.EncryptAES = stAES;
            con.Encrypt3DES = st3DES;
            con.Timeout = iTimeout;
            con.objSettingConfig = objSettingConfig;
            con.listScenario = listScenarioStep;
            con.User = stUser;
            con.Pass = stPass;

            // Add event listener
            con.EventHappned += OnComNotification;

            // Add connection to list
            listConnection.Add(con);

            // Add list status
            string status = "";
            listStatus.Add(status);

            // Start thread
            listConnection[0].Run();
        }
示例#3
0
        private void tbarTest_Click(object sender, EventArgs e)
        {
            // Get connection option
            int    iCon     = ComFunc.StringToInt32(tbarConnectionTxt.Text);
            int    iLoop    = ComFunc.StringToInt32(tbarLoopTxt.Text);
            string stIPAdd  = objSettingConfig.allItems["SocketIP"];
            int    iPort    = ComFunc.StringToInt32(objSettingConfig.allItems["SocketPort"]);
            string stAES    = objSettingConfig.allItems["SocketAES"];
            string st3DES   = objSettingConfig.allItems["Socket3DES"];
            int    iTimeout = ComFunc.StringToInt32(objSettingConfig.allItems["CONNECTTimeout"]);
            string stUser   = objSettingConfig.allItems["CONNECTUsername"];
            string stPass   = objSettingConfig.allItems["CONNECTPassword"];

            txtStatus.Text = "";
            listStatus.Clear();
            listConnection.Clear();

            // Get scenario step from GUI
            List <string> listScenarioStep = new List <string>();

            for (int i = 0; i < gridFileStep.RowCount; i++)
            {
                if (gridFileStep.Rows[i].Cells[2].Value != null)
                {
                    string stStep = gridFileStep.Rows[i].Cells[2].Value.ToString();
                    if (stStep != "")
                    {
                        listScenarioStep.Add(stStep);
                    }
                }
            }

            // Test to run script
            // Set parameter for worker thread
            RunScenarioWorkerThread con = new RunScenarioWorkerThread();

            con.ThreadID         = 0;
            con.IPAdd            = stIPAdd;
            con.Port             = iPort;
            con.Loop             = iLoop;
            con.EncryptAES       = stAES;
            con.Encrypt3DES      = st3DES;
            con.Timeout          = iTimeout;
            con.objSettingConfig = objSettingConfig;
            con.listScenario     = listScenarioStep;
            con.User             = stUser;
            con.Pass             = stPass;

            // Add event listener
            con.EventHappned += OnComNotification;

            // Add connection to list
            listConnection.Add(con);

            // Add list status
            string status = "";

            listStatus.Add(status);

            // Start thread
            listConnection[0].Run();
        }
示例#4
0
        // Handle action: User click Start button
        private void tbarStart_Click(object sender, EventArgs e)
        {
            try
            {
                if (listFile.SelectedItem == null)
                {
                    MessageBox.Show("Select 1 file in list box to continue !");
                    return;
                }

                // Get connection option
                int iCon = ComFunc.StringToInt32(tbarConnectionTxt.Text);
                int iLoop = ComFunc.StringToInt32(tbarLoopTxt.Text);
                string stIPAdd = objSettingConfig.allItems["SocketIP"];
                int iPort = ComFunc.StringToInt32(objSettingConfig.allItems["SocketPort"]);
                string stAES = objSettingConfig.allItems["SocketAES"];
                string st3DES = objSettingConfig.allItems["Socket3DES"];
                int iTimeout = ComFunc.StringToInt32(objSettingConfig.allItems["CONNECTTimeout"]);
                string stUser = objSettingConfig.allItems["CONNECTUsername"];
                string stPass = objSettingConfig.allItems["CONNECTPassword"];
                txtStatus.Text = "";
                listStatus.Clear();
                listConnection.Clear();

                // Get scenario step from GUI
                List<string> listScenarioStep = new List<string>();
                for (int i=0; i < gridFileStep.RowCount; i++)
                {
                    if (gridFileStep.Rows[i].Cells[2].Value != null)
                    {
                        string stStep = gridFileStep.Rows[i].Cells[2].Value.ToString();
                        if (stStep != "")
                        {
                            listScenarioStep.Add(stStep);
                        }
                    }
                }

                // Create connection
                for (int i=0; i < iCon; i++ )
                {
                    // Set parameter for worker thread
                    RunScenarioWorkerThread con = new RunScenarioWorkerThread();
                    con.ThreadID = i;
                    con.IPAdd = stIPAdd;
                    con.Port = iPort;
                    con.Loop = iLoop;
                    con.EncryptAES = stAES;
                    con.Encrypt3DES = st3DES;
                    con.Timeout = iTimeout;
                    con.objSettingConfig = objSettingConfig;
                    con.listScenario = listScenarioStep;
                    con.User = stUser;
                    con.Pass = stPass;

                    // Add event listener
                    con.EventHappned += OnComNotification;

                    // Add connection to list
                    listConnection.Add(con);

                    // Add list status
                    string status = "";
                    listStatus.Add(status);

                    // Start thread
                    listConnection[i].Run();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error to create connection !\nError =  " + ex.Message);
            }
        }