public NetworkViewForm(string briteFilePath, Type deployType)
        {
            InitializeComponent();

            tb_file_name.Text = briteFilePath;

            m_topo = new NetworkTopology(0, 0);

            m_topo.SetupDrawingControl(draw_panel);

            tb_k.TextChanged += new EventHandler(checkValid);
            tb_n.TextChanged += new EventHandler(checkValid);

            tb_k.KeyPress += new KeyPressEventHandler(checkInputValue);
            tb_n.KeyPress += new KeyPressEventHandler(checkInputValue);

            btn_show.Click += (s, e) =>
            {
                m_topo.ReadBriteFile(tb_file_name.Text);

                int K = int.Parse(tb_k.Text);
                int N = int.Parse(tb_n.Text);

                Deployment deployment = Activator.CreateInstance(deployType, new object[] { 30, 20, 10, K, N }) as Deployment; //new KCutStartWithConsider2KConsiderCoefficient(10, 10, 10, K, N);
                deployment.Deploy(m_topo);

                draw_panel.Invalidate();
            };
        }
Exemple #2
0
        public void DeployTest()
        {
            Info MutantInfo = new Info();

            MutantInfo.URL              = "Test";
            MutantInfo.Username         = "******";
            MutantInfo.Password         = "******";
            MutantInfo.WorkingDirectory = "Test";

            string CurrentDirectory = Directory.GetCurrentDirectory();

            using (StreamWriter file = File.CreateText(CurrentDirectory + @"\.credentials"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, MutantInfo);
            }

            ArtificerFactory artificerFactory = new ArtificerFactory();
            Artificer        selective        = artificerFactory.GetArtificer("Selective");
            TestLevelFactory testFactory      = new TestLevelFactory();
            ITestLevel       none             = testFactory.CreateTestLevel("None");

            Deployment deployment = new Deployment(none, selective);

            try
            {
                deployment.Deploy();
            }
            catch (Exception)
            {
                Console.WriteLine("Expected ex.");
            }
        }
Exemple #3
0
        public HttpResponseMessage Install(string guid)
        {
            if (!SessionManager.SessionExists(guid))
            {
                // Session doesn't exist.
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid session."));
            }

            try
            {
                // Get the users ip address.
                string ipAddress = HttpContext.Current.Request.UserHostAddress;

                // Get the session.
                Session sessionObj = SessionManager.GetSession(guid);

                // Create a deploy operation.
                Deployment deployOperation = new Deployment(sessionObj, ipAddress);

                deployOperation.Deploy();

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                EventLogManager.Log("SESSION_EXCEPTION", EventLogSeverity.Warning, null, ex);

                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
    public void Start(string arguments)
    {
        var isDeployed = string.IsNullOrEmpty(_applicationPath);

        if (!isDeployed)
        {
            var deployment = new Deployment();
            _applicationPath = deployment.Deploy();
        }
        _process = Process.Start(_applicationPath, arguments);
    }
Exemple #5
0
        public override int Run(string[] remainingArguments)
        {
            try
            {
                TestLevelFactory TestLevel = new TestLevelFactory();
                ITestLevel       tests     = TestLevel.CreateTestLevel(TestType);

                ArtificerFactory ArtificerFactory = new ArtificerFactory();
                Artificer        artificer        = ArtificerFactory.GetArtificer(ArtificeType);
                artificer.BaseCommit = BaseCommit;

                Deployment deployment = new Deployment(tests, artificer);

                deployment.Deploy();
            } catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(1);
            }

            return(0);
        }
Exemple #6
0
        public void Deploy(NetworkTopology networkTopology)
        {
            numberOfTTracer = Convert.ToInt32(Math.Round(percentageOfTunnelingTracer * networkTopology.Nodes.Count / 100, 0, MidpointRounding.AwayFromZero));
            numberOfMTracer = Convert.ToInt32(Math.Round(percentageOfMarkingTracer * networkTopology.Nodes.Count / 100, 0, MidpointRounding.AwayFromZero));
            numberOfFTracer = Convert.ToInt32(Math.Round(percentageOfFilteringTracer * networkTopology.Nodes.Count / 100, 0, MidpointRounding.AwayFromZero));

            List <int>        last_deploy_count;
            int               satisfy_count;
            Deployment        try_deploy = null;
            List <Deployment> dList      = new List <Deployment>();

            for (int K = 1; K <= networkTopology.Diameter; K++)
            {
                int N = 0;
                satisfy_count = 0;

                do
                {
                    if (try_deploy != null)
                    {
                        last_deploy_count = new List <int>(try_deploy.DeployNodes);
                    }
                    else
                    {
                        last_deploy_count = new List <int>();
                    }

                    try_deploy = Activator.CreateInstance(m_deploy_type, new object[] { percentageOfTunnelingTracer, percentageOfMarkingTracer, percentageOfFilteringTracer, K, ++N }) as Deployment;
                    try_deploy.Deploy(networkTopology);

                    if (try_deploy.DeployNodes.Count <= numberOfTTracer)
                    {
                        DataUtility.Log(string.Format("K={0},N={1},|D|={2}\n", try_deploy.K, try_deploy.N, try_deploy.DeployNodes.Count));
                        dList.Add(try_deploy);
                    }

                    if (try_deploy.DeployNodes.Except(last_deploy_count).Count() == 0 && last_deploy_count.Except(try_deploy.DeployNodes).Count() == 0)
                    {
                        satisfy_count++;
                    }
                    else
                    {
                        satisfy_count = 0;
                    }
                } while (satisfy_count < 2);
            }

            dList.Sort((x, y) => x.DeployNodes.Count.CompareTo(y.DeployNodes.Count));
            m_deployment = dList.Last();

            int c, e;
            List <NetworkTopology.Node> centerNode = new List <NetworkTopology.Node>();

            foreach (var scope in m_deployment.AllRoundScopeList)
            {
                if (scope.FindCenterNodeID(out c, out e, true))
                {
                    DataUtility.Log(string.Format("center ID: {0}\n", c));
                    centerNode.Add(networkTopology.Nodes.Find(n => n.ID == c));
                }
                else
                {
                    DataUtility.Log(string.Format("center ID: {0}\n", scope.Nodes[0].ID));
                    centerNode.Add(networkTopology.Nodes.Find(n => n.ID == scope.Nodes[0].ID));
                }
            }

            networkTopology.Reset();

            // Clear the deployment method.
            foreach (NetworkTopology.Node node in networkTopology.Nodes)
            {
                node.Tracer = NetworkTopology.TracerType.None;
            }

            centerNode.Sort((x, y) => x.Eccentricity.CompareTo(y.Eccentricity));

            m_deployment.FilteringTracerID = new List <int>();
            m_deployment.MarkingTracerID   = new List <int>();
            m_deployment.TunnelingTracerID = new List <int>();

            for (int i = 0; i < numberOfFTracer; i++)
            {
                NetworkTopology.Node node = centerNode.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                if (node == null)
                {
                    int j = i;
                    do
                    {
                        NetworkTopology t = m_deployment.AllRoundScopeList.Find(s => s.Nodes.Exists(n => n == centerNode[j % centerNode.Count]));
                        node = t.Nodes.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                        j++;
                    } while (node == null);
                }

                node.Tracer = NetworkTopology.TracerType.Filtering;
                m_deployment.FilteringTracerID.Add(node.ID);
            }

            for (int i = 0; i < numberOfMTracer; i++)
            {
                NetworkTopology.Node node = centerNode.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                if (node == null)
                {
                    int j = i;
                    do
                    {
                        NetworkTopology t = m_deployment.AllRoundScopeList.Find(s => s.Nodes.Exists(n => n == centerNode[j % centerNode.Count]));
                        node = t.Nodes.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                        j++;
                    } while (node == null);
                }

                node.Tracer = NetworkTopology.TracerType.Marking;
                m_deployment.MarkingTracerID.Add(node.ID);
            }

            foreach (int id in m_deployment.DeployNodes)
            {
                networkTopology.Nodes.Find(n => n.ID == id).Tracer = NetworkTopology.TracerType.Tunneling;
                m_deployment.TunnelingTracerID.Add(id);
            }

            if (m_deployment.DeployNodes.Count < numberOfTTracer)
            {
                for (int i = 0; i < numberOfTTracer - m_deployment.DeployNodes.Count; i++)
                {
                    NetworkTopology.Node node;
                    int j = i;
                    do
                    {
                        NetworkTopology t = m_deployment.AllRoundScopeList.Find(s => s.Nodes.Exists(n => n == centerNode[j % centerNode.Count]));
                        node = t.Nodes.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                        j++;
                    } while (node == null);
                    node.Tracer = NetworkTopology.TracerType.Tunneling;
                    m_deployment.TunnelingTracerID.Add(node.ID);
                }
            }
        }
Exemple #7
0
        public void Deploy(NetworkTopology networkTopology)
        {
            numberOfTTracer = Convert.ToInt32(Math.Round(percentageOfTunnelingTracer * networkTopology.Nodes.Count / 100, 0, MidpointRounding.AwayFromZero));
            numberOfMTracer = Convert.ToInt32(Math.Round(percentageOfMarkingTracer * networkTopology.Nodes.Count / 100, 0, MidpointRounding.AwayFromZero));
            numberOfFTracer = Convert.ToInt32(Math.Round(percentageOfFilteringTracer * networkTopology.Nodes.Count / 100, 0, MidpointRounding.AwayFromZero));

            List <int>        last_deploy_count;
            int               satisfy_count;
            Deployment        try_deploy = null;
            List <Deployment> dList      = new List <Deployment>();

            for (int K = 1; K <= networkTopology.Diameter; K++)
            {
                int N = 0;
                satisfy_count = 0;

                do
                {
                    if (try_deploy != null)
                    {
                        last_deploy_count = new List <int>(try_deploy.DeployNodes);
                    }
                    else
                    {
                        last_deploy_count = new List <int>();
                    }

                    try_deploy = Activator.CreateInstance(m_deploy_type, new object[] { percentageOfTunnelingTracer, percentageOfMarkingTracer, percentageOfFilteringTracer, K, ++N }) as Deployment;
                    try_deploy.Deploy(networkTopology);

                    if (try_deploy.DeployNodes.Count <= numberOfTTracer + numberOfMTracer + numberOfFTracer)
                    {
                        DataUtility.Log(string.Format("K={0},N={1},|D|={2}\n", try_deploy.K, try_deploy.N, try_deploy.DeployNodes.Count));
                        dList.Add(try_deploy);
                    }

                    if (try_deploy.DeployNodes.Except(last_deploy_count).Count() == 0 && last_deploy_count.Except(try_deploy.DeployNodes).Count() == 0)
                    {
                        satisfy_count++;
                    }
                    else
                    {
                        satisfy_count = 0;
                    }
                } while (satisfy_count < 2);
            }

            dList.Sort((x, y) => x.DeployNodes.Count.CompareTo(y.DeployNodes.Count));
            m_deployment = dList.Last();

            List <NetworkTopology.Node> dNode = new List <NetworkTopology.Node>(networkTopology.Nodes.Where(n => m_deployment.DeployNodes.Contains(n.ID)));

            foreach (NetworkTopology.Node node in networkTopology.Nodes)
            {
                node.Tracer = NetworkTopology.TracerType.None;
            }

            dNode.Sort((x, y) => networkTopology.NodeIDPathDistrib[y.ID].CompareTo(networkTopology.NodeIDPathDistrib[x.ID]));

            m_deployment.FilteringTracerID = new List <int>();
            m_deployment.MarkingTracerID   = new List <int>();
            m_deployment.TunnelingTracerID = new List <int>();

            for (int i = 0; i < numberOfFTracer; i++)
            {
                NetworkTopology.Node node = dNode.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                if (node == null)
                {
                    int j = i;
                    do
                    {
                        NetworkTopology t = m_deployment.AllRoundScopeList.Find(s => s.Nodes.Exists(n => n.Tracer == NetworkTopology.TracerType.None));
                        node = t.Nodes.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                        j++;
                    } while (node == null);
                }

                node.Tracer = NetworkTopology.TracerType.Filtering;
                m_deployment.FilteringTracerID.Add(node.ID);
            }

            for (int i = 0; i < numberOfMTracer; i++)
            {
                NetworkTopology.Node node = dNode.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                if (node == null)
                {
                    int j = i;
                    do
                    {
                        NetworkTopology t = m_deployment.AllRoundScopeList.Find(s => s.Nodes.Exists(n => n.Tracer == NetworkTopology.TracerType.None));
                        node = t.Nodes.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                        j++;
                    } while (node == null);
                }

                node.Tracer = NetworkTopology.TracerType.Marking;
                m_deployment.MarkingTracerID.Add(node.ID);
            }

            for (int i = 0; i < numberOfTTracer; i++)
            {
                NetworkTopology.Node node = dNode.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                if (node == null)
                {
                    int j = i;
                    do
                    {
                        NetworkTopology t = m_deployment.AllRoundScopeList.Find(s => s.Nodes.Exists(n => n.Tracer == NetworkTopology.TracerType.None));
                        node = t.Nodes.Find(n => n.Tracer == NetworkTopology.TracerType.None);
                        j++;
                    } while (node == null);
                }
                node.Tracer = NetworkTopology.TracerType.Tunneling;
                m_deployment.TunnelingTracerID.Add(node.ID);
            }
        }
Exemple #8
0
 public async Task Deploy()
 {
     await Deployment.Deploy(_lastUpdate, Storage.BinariesDirectory);
 }
        private void eventRegist()
        {
            m_simulation_worker.DoWork += (s, e) =>
            {
                Deployment deployment = null;
                Simulator  sim = new Simulator(m_topo, m_now_deployment_method);
                string[]   files = tb_select_file.Text.Split(';');
                int        K, N = 0;

                for (int i = 0; i < files.Length; i++)
                {
                    m_simulation_worker.ReportProgress((int)(((double)(i) / (double)files.Count()) * 100.0),
                                                       new object[] { true, string.Format("Running {0}...", Path.GetFileNameWithoutExtension(files[i])) });

                    if (rdoBtn_specific.Checked)
                    {
                        K = int.Parse(tb_k.Text);
                        N = int.Parse(tb_n.Text);

                        m_simulation_worker.ReportProgress(0,
                                                           new object[] { false, "Preprocessing file...", true, files[i], K, N });

                        m_topo.ReadBriteFile(files[i]);

                        m_simulation_worker.ReportProgress(33,
                                                           new object[] { false, string.Format("Starting Deployment with K: {0}, N: {1}...", K, N), true, files[i], K, N });

                        // Using kcutwithclustering depolyment method.
                        deployment = Activator.CreateInstance(m_deploy_types.Find(t => t.Name == m_now_deployment_method), new object[] { 30, 20, 10, K, N }) as Deployment;// new KCutStartWithConsider2KConsiderWithCoefficient(30, 20, 10, K, N);
                        deployment.Deploy(m_topo);

                        m_simulation_worker.ReportProgress(100,
                                                           new object[] { false, string.Format("Completed for K: {0}, N: {1}.", K, N), true, files[i], K, N });
                    }
                    else
                    {
                        m_simulation_worker.ReportProgress(0,
                                                           new object[] { false, "Preprocessing file...", true, files[i], 0, 0 });

                        m_topo.ReadBriteFile(files[i]);

                        List <int> last_deploy_count;
                        int        satisfy_count;

                        for (K = 2; K <= m_topo.Diameter; K += 2)
                        {
                            N             = 0;
                            satisfy_count = 0;

                            if (m_now_deployment_method == typeof(KCutStartWithSideNodeConsiderCoefficientWithN).Name ||
                                m_now_deployment_method == typeof(KCutStartWithSideNodeConsiderCoefficientWithNRatio).Name ||
                                m_now_deployment_method == typeof(KCutStartWithSideNodeConsiderCoefficientStrictDegreeWithN).Name)
                            {
                                do
                                {
                                    if (N >= 50)
                                    {
                                        break;
                                    }

                                    //if (deployment != null)
                                    //    last_deploy_count = new List<int>(deployment.DeployNodes);
                                    //else
                                    //    last_deploy_count = new List<int>();

                                    using (deployment = Activator.CreateInstance(m_deploy_types.Find(t => t.Name == m_now_deployment_method), new object[] { 30, 20, 10, K, N += 10 }) as Deployment)
                                    {
                                        m_simulation_worker.ReportProgress((int)((double)K / (double)m_topo.Diameter * 100),
                                                                           new object[] { false, string.Format("Starting Deployment with K: {0}, N: {1}...", K, N), true, files[i], K, N });

                                        deployment.Deploy(m_topo);

                                        if (cb_run_sim.Checked && m_sim_run_n_range.Contains(N))
                                        {
                                            sim.Deployment = deployment;
                                            sim.Run();
                                        }

                                        m_simulation_worker.ReportProgress((int)((double)K / (double)m_topo.Diameter * 100),
                                                                           new object[] { false, string.Format("Completed for K: {0}, N: {1}.", K, N), true, files[i], K, N });

                                        //if (deployment.DeployNodes.Except(last_deploy_count).Count() == 0 && last_deploy_count.Except(deployment.DeployNodes).Count() == 0)
                                        //    satisfy_count++;
                                        //else
                                        //    satisfy_count = 0;
                                    }
                                } while (true);//satisfy_count < 2);
                            }
                            else
                            {
                                N = 1;
                                using (deployment = Activator.CreateInstance(m_deploy_types.Find(t => t.Name == m_now_deployment_method), new object[] { 30, 20, 10, K, N }) as Deployment)
                                {
                                    m_simulation_worker.ReportProgress((int)((double)K / (double)m_topo.Diameter * 100),
                                                                       new object[] { false, string.Format("Starting Deployment with K: {0}, N: {1}...", K, N), true, files[i], K, N });

                                    deployment.Deploy(m_topo);

                                    if (cb_run_sim.Checked)
                                    {
                                        sim.Deployment = deployment;
                                        sim.Run();
                                    }

                                    m_simulation_worker.ReportProgress((int)((double)K / (double)m_topo.Diameter * 100),
                                                                       new object[] { false, string.Format("Completed for K: {0}, N: {1}.", K, N), true, files[i], K, N });
                                }
                            }
                        }
                        m_simulation_worker.ReportProgress(100,
                                                           new object[] { false, string.Format("Completed for K: {0}, N: {1}.", K, N), true, files[i], K, N });
                    }

                    m_simulation_worker.ReportProgress((int)(((double)(i + 1) / (double)files.Count()) * 100.0),
                                                       new object[] { true, string.Format("Running {0}...", Path.GetFileNameWithoutExtension(files[i])) });
                }
            };

            m_simulation_worker.ProgressChanged += (s, e) =>
            {
                object[] obj = e.UserState as object[];

                if (obj != null)
                {
                    bool   isMainProgress = (bool)obj[0];
                    string status         = (string)obj[1];

                    if (isMainProgress)
                    {
                        progress_main.Value   = e.ProgressPercentage;
                        lb_main_progress.Text = string.Format("Main Progress: {0}", status);
                    }
                    else
                    {
                        bool isNeedRefreshList = (bool)obj[2];

                        progress_sub.Value   = e.ProgressPercentage;
                        lb_sub_progress.Text = string.Format("Sub Progress: {0}", status);

                        if (isNeedRefreshList)
                        {
                            string fileName = (string)obj[3];
                            int    k        = (int)obj[4];
                            int    n        = (int)obj[5];

                            lv_list.Items[fileName].SubItems[1].Text = k.ToString();
                            lv_list.Items[fileName].SubItems[2].Text = n.ToString();
                            lv_list.Items[fileName].SubItems[3].Text = status;

                            foreach (int index in lv_list.SelectedIndices)
                            {
                                lv_list.Items[index].Selected = false;
                            }

                            lv_list.Items[fileName].Selected = true;
                            lv_list.Items[fileName].Focused  = true;
                            //lv_list.TopItem = lv_list.Items[fileName];
                        }
                    }
                }
            };

            m_simulation_worker.RunWorkerCompleted += (s, e) =>
            {
                btn_run.Enabled       = true;
                groupBox2.Enabled     = true;
                cb_deployment.Enabled = true;

                if (rdoBtn_specific.Checked)
                {
                    tb_k.Enabled = true;
                    tb_n.Enabled = true;
                }

                tb_select_file.Enabled = true;

                lb_main_progress.Text = "Main Progress: Completed.";
                lb_sub_progress.Text  = "Sub Progress: Completed.";
            };

            m_data_worker.DoWork += (s, e) =>
            {
                object[] data = e.Argument as object[];

                if (data != null)
                {
                    bool       isQuery = (bool)data[0];
                    string     sqlCmd;
                    Deployment deployment = Activator.CreateInstance(m_deploy_types.Find(t => t.Name == m_now_deployment_method), new object[] { 30, 20, 10, 1, 1 }) as Deployment;// new Deployment.DeploySQLiteUtility("deploy_simulation");

                    if (isQuery)
                    {
                        sqlCmd = (string)data[1];

                        DataView dv = deployment.sqlite_utility.GetResult(sqlCmd, null);

                        e.Result = new object[] { true, dv };
                    }
                    else
                    {
                        string filePath = (string)data[1];
                        sqlCmd = "SELECT k,n,deploy_type,file_name,node_counts,level,edge_counts,diameter,job_id,deploy_name,node_id FROM (SELECT * FROM NetworkTopology AS N JOIN DeploySimulation AS D on N.n_id=D.n_id JOIN LevelRecord AS L on D.job_id=L.job_id ) AS Data";

                        DataView dv = deployment.sqlite_utility.GetResult(sqlCmd, null);

                        if (dv != null && dv.Count > 0)
                        {
                            DataUtility.ExcelExport(dv.Table, filePath, false);
                            e.Result = data;
                        }
                    }
                }
            };

            m_data_worker.RunWorkerCompleted += (s, e) =>
            {
                object[] data = e.Result as object[];

                if (data != null)
                {
                    bool isQuery = (bool)data[0];

                    if (isQuery)
                    {
                        DataView dv = data[1] as DataView;
                        if (dv != null && dv.Count > 0)
                        {
                            dataGridView1.DataSource = dv;
                        }
                        btn_query.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show(this, string.Format("The file: {0} has been exported.", Path.GetFileName((string)data[1])), "Export Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btn_export.Enabled = true;
                    }
                    Cursor = Cursors.Arrow;
                }
            };

            lv_list.MouseDoubleClick += (s, e) =>
            {
                if (lv_list.SelectedIndices.Count > 0)
                {
                    ListViewItem item = lv_list.Items[lv_list.SelectedIndices[0]];

                    if (item.SubItems[3].Text.Contains("Completed"))
                    {
                        m_now_deployment_method = cb_deployment.SelectedItem.ToString();
                        NetworkViewForm view = new NetworkViewForm(item.Name, m_deploy_types.Find(t => t.Name == m_now_deployment_method));
                        view.Show(this);
                    }
                }
            };

            tb_select_file.Click += (s, e) =>
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Multiselect      = true;
                ofd.InitialDirectory = Environment.CurrentDirectory;
                ofd.Filter           = "Birte File|*.brite";
                ofd.Title            = "Select Brite Files";
                ofd.FileName         = "";

                if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    tb_select_file.Clear();

                    lv_list.BeginUpdate();
                    lv_list.Items.Clear();

                    foreach (string file in ofd.FileNames)
                    {
                        tb_select_file.Text += file + ";";

                        ListViewItem lvi = new ListViewItem(new string[] { Path.GetFileNameWithoutExtension(file), "0", "0", "Queued." });
                        lvi.Name = file;

                        lv_list.Items.Add(lvi);
                    }

                    tb_select_file.Text = tb_select_file.Text.TrimEnd(';');

                    lv_list.EndUpdate();
                }
            };

            btn_run.Click += (s, e) =>
            {
                m_now_deployment_method = cb_deployment.SelectedItem.ToString();
                m_simulation_worker.RunWorkerAsync();
                btn_run.Enabled       = false;
                groupBox2.Enabled     = false;
                cb_deployment.Enabled = false;

                if (rdoBtn_specific.Checked)
                {
                    tb_k.Enabled = false;
                    tb_n.Enabled = false;
                }

                tb_select_file.Enabled = false;
            };

            btn_query.Click += (s, e) =>
            {
                m_now_deployment_method = cb_deployment.SelectedItem.ToString();
                btn_query.Enabled       = false;
                Cursor = Cursors.WaitCursor;
                m_data_worker.RunWorkerAsync(new object[] { true, tb_sql_cmd.Text });
            };

            btn_export.Click += (s, e) =>
            {
                m_now_deployment_method = cb_deployment.SelectedItem.ToString();
                SaveFileDialog sfd = new SaveFileDialog();

                sfd.InitialDirectory = Environment.CurrentDirectory;
                sfd.OverwritePrompt  = true;
                sfd.Title            = "Export to";
                sfd.Filter           = "Excel Files|*.xls";
                sfd.FileName         = "";

                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    btn_export.Enabled = false;
                    Cursor             = Cursors.WaitCursor;
                    m_data_worker.RunWorkerAsync(new object[] { false, sfd.FileName });
                }
            };

            Load += (s, e) =>
            {
                btn_query.PerformClick();
            };

            tb_select_file.TextChanged += new EventHandler(checkValid);
            tb_k.TextChanged           += new EventHandler(checkValid);
            tb_n.TextChanged           += new EventHandler(checkValid);

            tb_k.KeyPress += new KeyPressEventHandler(checkInputValue);
            tb_n.KeyPress += new KeyPressEventHandler(checkInputValue);

            rdoBtn_specific.CheckedChanged += new EventHandler(rdoBtn_CheckedChanged);
            rdoBtn_all.CheckedChanged      += new EventHandler(rdoBtn_CheckedChanged);
        }