/// <summary> /// Store current values in DatabaseInfo history table. /// </summary> /// <param name="instance"></param> /// <param name="database"></param> private void TakeSnapShot(string instanceName, SQLInformation.Data.ApplicationDataSet.DatabasesRow databaseRow) { //SMO.Server server = SMOH.SMOD.GetServer(instanceName); SMO.Server server = SQLInformation.SMO.Helper.GetServer(instanceName); SQLInformation.Data.ApplicationDataSetTableAdapters.DatabaseInfoTableAdapter tableAdapter = new SQLInformation.Data.ApplicationDataSetTableAdapters.DatabaseInfoTableAdapter(); tableAdapter.Connection.ConnectionString = SQLInformation.Data.Config.SQLMonitorDBConnection; int dbID = databaseRow.ID_DB; SMO.Database db = server.Databases.ItemById(dbID); SQLInformation.Data.ApplicationDataSet.DatabaseInfoRow newSnapShot = Common.ApplicationDataSet.DatabaseInfo.NewDatabaseInfoRow(); newSnapShot.SnapShotDate = DateTime.Now; newSnapShot.Database_ID = databaseRow.ID; newSnapShot.Instance_ID = databaseRow.Instance_ID; newSnapShot.IndexSpaceUsage = db.IndexSpaceUsage; newSnapShot.DataSpaceUsage = db.DataSpaceUsage; newSnapShot.Size = db.Size; newSnapShot.SpaceAvailable = db.SpaceAvailable; Common.ApplicationDataSet.DatabaseInfo.AddDatabaseInfoRow(newSnapShot); tableAdapter.Update(Common.ApplicationDataSet.DatabaseInfo); }
private void OnLoaded(object sender, RoutedEventArgs e) { SQLInformation.Data.ApplicationDataSet applicationDataSet = ((SQLInformation.Data.ApplicationDataSet)(this.FindResource("applicationDataSet"))); // Load data into the table Servers. You can modify this code as needed. SQLInformation.Data.ApplicationDataSetTableAdapters.ServersTableAdapter applicationDataSetServersTableAdapter = new SQLInformation.Data.ApplicationDataSetTableAdapters.ServersTableAdapter(); applicationDataSetServersTableAdapter.Fill(applicationDataSet.Servers); System.Windows.Data.CollectionViewSource serversViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("serversViewSource"))); serversViewSource.View.MoveCurrentToFirst(); // Load data into the table Databases. You can modify this code as needed. SQLInformation.Data.ApplicationDataSetTableAdapters.DatabasesTableAdapter applicationDataSetDatabasesTableAdapter = new SQLInformation.Data.ApplicationDataSetTableAdapters.DatabasesTableAdapter(); applicationDataSetDatabasesTableAdapter.Fill(applicationDataSet.Databases); System.Windows.Data.CollectionViewSource databasesViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("databasesViewSource"))); databasesViewSource.View.MoveCurrentToFirst(); // Load data into the table DatabaseInfo. You can modify this code as needed. SQLInformation.Data.ApplicationDataSetTableAdapters.DatabaseInfoTableAdapter applicationDataSetDatabaseInfoTableAdapter = new SQLInformation.Data.ApplicationDataSetTableAdapters.DatabaseInfoTableAdapter(); applicationDataSetDatabaseInfoTableAdapter.Fill(applicationDataSet.DatabaseInfo); System.Windows.Data.CollectionViewSource databasesDatabaseInfoViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("databasesDatabaseInfoViewSource"))); databasesDatabaseInfoViewSource.View.MoveCurrentToFirst(); }