Beispiel #1
0
        /*
         * Prepara los Objectos que seran cargado en forma de Row en el Data grid view
         * */
        private void LoadedDataGridView(List <string> selectListServices, int index)
        {
            indexServicesProgressBar = selectListServices.Count;
            foreach (String sl in selectListServices)
            {
                string server = query.CsvServer.Rows[index]["ServerName"].ToString();

                ServiceController sc = query.GetServiceQuery(sl, server);
                try
                {
                    string     estado = query.StartModeService(server, sl);
                    ServerInfo Info   = new ServerInfo
                    {
                        Select      = query.Estado,
                        Place       = query.CsvServer.Rows[index]["PlaceName"].ToString(),
                        ServerName  = query.CsvServer.Rows[index]["ServerName"].ToString(),
                        ServiceName = Convert.ToString(sc.ServiceName),
                        StartType   = estado,
                        State       = Convert.ToString(sc.Status)
                    };

                    SetDataSource(Info);
                    CellColorDataGridView();
                }
                catch (ThreadAbortException ex)
                {
                    if (MessageBox.Show("Die Abfrage der Diente wurde abgebrochen", "Services Control", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        indexServicesProgressBar = 0;
                        break;
                    }
                    else
                    {
                        Environment.Exit(0);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    if (MessageBox.Show(ex.Message + " . Continue?", "Services Control", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        indexServicesProgressBar -= 1;
                        continue;
                    }
                    else
                    {
                        Environment.Exit(0);
                        break;
                    }
                }
            }
        }
        /*
         * Prepara los Objectos que seran cargado en forma de Row en el Data grid view
         * */
        private void LoadedDataGridView(List <string> selectListServices, int index)
        {
            indexServicesProgressBar = selectListServices.Count;
            foreach (String sl in selectListServices)
            {
                string server = query.CsvServer.Rows[index]["ServerName"].ToString();

                ServiceController sc = query.GetServiceQuery(sl, server);
                try
                {
                    string     estado = query.StartModeService(server, sl);
                    ServerInfo Info   = new ServerInfo
                    {
                        Select      = query.Estado,
                        Place       = query.CsvServer.Rows[index]["PlaceName"].ToString(),
                        ServerName  = query.CsvServer.Rows[index]["ServerName"].ToString(),
                        ServiceName = Convert.ToString(sc.ServiceName),
                        StartType   = estado,
                        State       = Convert.ToString(sc.Status)
                    };

                    SetDataSource(Info);
                    CellColorDataGridView();
                }
                catch (ThreadAbortException ex)
                {
                    if (MetroMessageBox.Show(this, "The query has been canceled", "", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        indexServicesProgressBar = 0;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    if (MetroMessageBox.Show(this, ex.Message + " . Continue?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        indexServicesProgressBar -= 1;
                        continue;
                    }
                    else
                    {
                        //This will switch to main thread and Call method CancelCurrentQuery
                        Invoke(new Action(() => { CancelCurrentQuery(); }));
                        break;
                    }
                }
            }
        }