Ejemplo n.º 1
0
        private void ScanDatabases(object sender, DoWorkEventArgs e)
        {
            using (SqlConnection connection = Connection.Create(Settings.ActiveHost)) {
                try {
                    connection.Open();

                    try { _disks = QueryEngine.GetDiskInfo(connection); }
                    catch (Exception ex) { Utils.ShowErrorFrom(ex, "Refresh disk info failed"); }

                    try { _databases = QueryEngine.GetDatabases(connection); }
                    catch (Exception ex) { Utils.ShowErrorFrom(ex, "Refresh databases failed"); }

                    if (_databases.Count > 0 && !Settings.ServerInfo.IsAzure)
                    {
                        try { QueryEngine.RefreshDatabaseSize(connection, _databases); }
                        catch (Exception ex) { Utils.ShowErrorFrom(ex, "Refresh database sizes failed"); }
                    }
                }
                catch (Exception ex) {
                    Utils.ShowErrorFrom(ex, "Refresh failed");
                }
                finally {
                    connection.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void RefreshDatabases()
        {
            grid.DataSource = null;
            Stopwatch ts = Stopwatch.StartNew();

            using (SqlConnection connection = Connection.Create(Settings.ActiveHost)) {
                try {
                    connection.Open();

                    grid.DataSource = QueryEngine.GetDatabases(connection);

                    Output.Current.Add("Refresh databases", null, ts.ElapsedMilliseconds);

                    foreach (string db in Settings.ActiveHost.Databases)
                    {
                        int index = view.LocateByValue(colDatabase.FieldName, db);
                        view.SelectRow(index);
                    }
                }
                catch (Exception ex) {
                    Output.Current.Add("Refresh databases failed", ex.Message, ts.ElapsedMilliseconds);
                    XtraMessageBox.Show(ex.Message.Replace(". ", "." + Environment.NewLine), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally {
                    connection.Close();
                }
            }
        }
Ejemplo n.º 3
0
        private void RefreshDatabases()
        {
            Stopwatch ts = Stopwatch.StartNew();

            Output.Current.Add("Refresh databases");

            grid.DataSource   = null;
            buttonOK.Enabled  = false;
            TotalSize.Visible = DataSize.Visible = LogSize.Visible = DataFreeSize.Visible = LogFreeSize.Visible = !Settings.ServerInfo.IsAzure;

            using (SqlConnection connection = Connection.Create(Settings.ActiveHost)) {
                try {
                    connection.Open();

                    if (!Settings.ServerInfo.IsAzure && Settings.ServerInfo.IsSysAdmin)
                    {
                        Output.Current.Add("Get disk info");
                        try {
                            List <DiskInfo> di = QueryEngine.GetDiskInfo(connection);
                            if (di.Count > 0)
                            {
                                Text = $"{Resources.DatabaseBoxTitle}      {string.Join("  |  ", di.Select(_ => _.ToString()))}";
                            }
                        }
                        catch (Exception ex) {
                            Output.Current.Add("Refresh disk info failed", ex.Message);
                        }
                    }

                    List <Database> dbs = QueryEngine.GetDatabases(connection);
                    var             max = dbs.Max(_ => _.TotalSize);
                    foreach (var rule in view.FormatRules)
                    {
                        ((FormatConditionRuleDataBar)rule.Rule).Maximum = max;
                    }

                    grid.DataSource = dbs;

                    foreach (string db in Settings.ActiveHost.Databases)
                    {
                        int index = view.LocateByValue(DatabaseName.FieldName, db);
                        view.SelectRow(index);
                    }

                    Output.Current.Add($"Found {dbs.Count} databases", null, ts.ElapsedMilliseconds);
                }
                catch (Exception ex) {
                    Output.Current.Add("Refresh databases failed", ex.Message, ts.ElapsedMilliseconds);
                    XtraMessageBox.Show(ex.Message.Replace(". ", "." + Environment.NewLine), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally {
                    connection.Close();
                }
            }
        }
Ejemplo n.º 4
0
        private void ScanDatabases(object sender, DoWorkEventArgs e)
        {
            using (SqlConnection connection = Connection.Create(Settings.ActiveHost)) {
                try {
                    connection.Open();

                    _disks     = QueryEngine.GetDiskInfo(connection);
                    _databases = QueryEngine.GetDatabases(connection);
                }
                catch (Exception ex) {
                    Output.Current.Add("Refresh failed", ex.Message);
                    XtraMessageBox.Show(ex.Message.Replace(". ", "." + Environment.NewLine), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally {
                    connection.Close();
                }
            }
        }
Ejemplo n.º 5
0
        private void RefreshDatabases(bool scanUsedSpace)
        {
            grid.DataSource  = null;
            buttonOK.Enabled = false;

            colDataSize.Visible = colLogSize.Visible = !Settings.ServerInfo.IsAzure &&
                                                       Settings.ServerInfo.IsSysAdmin;

            colDataFreeSize.Visible = colLogFreeSize.Visible = scanUsedSpace &&
                                                               !Settings.ServerInfo.IsAzure &&
                                                               Settings.ServerInfo.IsSysAdmin;

            Stopwatch ts = Stopwatch.StartNew();

            using (SqlConnection connection = Connection.Create(Settings.ActiveHost)) {
                try {
                    connection.Open();

                    List <Database> dbs = QueryEngine.GetDatabases(connection, scanUsedSpace);
                    var             max = dbs.Max(_ => Math.Max(_.DataSize, _.LogSize));
                    foreach (var rule in view.FormatRules)
                    {
                        ((FormatConditionRuleDataBar)rule.Rule).Maximum = max;
                    }

                    grid.DataSource = dbs;
                    Output.Current.Add($"Refresh {dbs.Count} databases", null, ts.ElapsedMilliseconds);

                    foreach (string db in Settings.ActiveHost.Databases)
                    {
                        int index = view.LocateByValue(colDatabase.FieldName, db);
                        view.SelectRow(index);
                    }
                }
                catch (Exception ex) {
                    Output.Current.Add("Refresh databases failed", ex.Message, ts.ElapsedMilliseconds);
                    XtraMessageBox.Show(ex.Message.Replace(". ", "." + Environment.NewLine), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally {
                    connection.Close();
                }
            }
        }