Пример #1
0
        /// <summary>
        /// Loads the selected database.
        /// </summary>
        private void LoadDatabase()
        {
            if (allocationContainer.InvokeRequired)
            {
                Invoke(new LoadDatabaseDelegate(LoadDatabase));
            }
            else
            {
                if (databaseToolStripComboBox.ComboBox.SelectedItem != InternalsViewerConnection.CurrentConnection().CurrentDatabase)
                {
                    databaseToolStripComboBox.ComboBox.SelectedItem = InternalsViewerConnection.CurrentConnection().CurrentDatabase;
                }

                if (InternalsViewerConnection.CurrentConnection().CurrentDatabase != null)
                {
                    allocationContainer.CreateAllocationMaps(InternalsViewerConnection.CurrentConnection().CurrentDatabase.Files);
                }

                CancelWorkerAndWait(allocUnitBackgroundWorker);

                if (mapToolStripButton.Text == AllocationMapText)
                {
                    DisplayAllocationMapLayers();
                }
                else
                {
                    DisplayAllocationUnitLayers();
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Connects the internals viewer singleton
 /// </summary>
 /// <param name="connection">The connection.</param>
 internal static void ConnectInternalsViewer(SqlConnectionInfo connection)
 {
     InternalsViewerConnection.CurrentConnection().SetCurrentServer(connection.ServerName,
                                                                    connection.UseIntegratedSecurity,
                                                                    connection.UserName,
                                                                    connection.Password);
 }
Пример #3
0
        /// <summary>
        /// Requeries buffer pool information.
        /// </summary>
        public void Refresh()
        {
            CleanPages.Clear();
            DirtyPages.Clear();

            if (InternalsViewerConnection.CurrentConnection().CurrentDatabase == null)
            {
                return;
            }

            using (var conn = new SqlConnection(InternalsViewerConnection.CurrentConnection().ConnectionString))
            {
                var cmd = new SqlCommand(Resources.SQL_Buffer_Pool, conn);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("database", InternalsViewerConnection.CurrentConnection().CurrentDatabase.Name);

                conn.Open();

                var reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    if (reader.GetBoolean(2))
                    {
                        DirtyPages.Add(new PageAddress(reader.GetInt32(0), reader.GetInt32(1)));
                    }

                    CleanPages.Add(new PageAddress(reader.GetInt32(0), reader.GetInt32(1)));
                }

                conn.Close();
            }
        }
Пример #4
0
        /// <summary>
        /// Refreshes the databases list
        /// </summary>
        public void RefreshDatabases()
        {
            databaseToolStripComboBox.ComboBox.DataSource = null;

            databaseToolStripComboBox.ComboBox.Items.Clear();

            EnableToolbar(InternalsViewerConnection.CurrentConnection().Databases.Count > 0);

            databaseToolStripComboBox.ComboBox.DataSource    = InternalsViewerConnection.CurrentConnection().Databases;
            databaseToolStripComboBox.ComboBox.DisplayMember = "Name";
            databaseToolStripComboBox.ComboBox.ValueMember   = "DatabaseId";
        }
Пример #5
0
        /// <summary>
        /// Displays the allocation map layers (GAM, SGAM etc.)
        /// </summary>
        private void DisplayAllocationMapLayers()
        {
            allocationContainer.ClearMapLayers();

            if (gamToolStripMenuItem.Checked)
            {
                AddDatabaseAllocation("GAM (Inverted)",
                                      "Unavailable - (Uniform extent/full mixed extent)",
                                      Color.FromArgb(172, 186, 214),
                                      true,
                                      InternalsViewerConnection.CurrentConnection().CurrentDatabase.Gam);
            }

            if (sgamToolStripMenuItem.Checked)
            {
                AddDatabaseAllocation("SGAM",
                                      "Partially Unavailable - (Mixed extent with free pages)",
                                      Color.FromArgb(168, 204, 162),
                                      false,
                                      InternalsViewerConnection.CurrentConnection().CurrentDatabase.SGam);
            }

            if (dcmToolStripMenuItem.Checked)
            {
                AddDatabaseAllocation("DCM",
                                      "Differential Change Map",
                                      Color.FromArgb(120, 150, 150),
                                      false,
                                      InternalsViewerConnection.CurrentConnection().CurrentDatabase.Dcm);
            }

            if (bcmToolStripMenuItem.Checked)
            {
                AddDatabaseAllocation("BCM Allocated",
                                      "Bulk Change Map",
                                      Color.FromArgb(150, 120, 150),
                                      false,
                                      InternalsViewerConnection.CurrentConnection().CurrentDatabase.Bcm);
            }

            ShowExtendedColumns(false);

            NameColumn.HeaderText      = "Layer";
            IndexNameColumn.HeaderText = "Description";

            allocationBindingSource.DataSource = allocationContainer.AllocationLayers;

            keysDataGridView.ClearSelection();

            ShowPfs(false);
        }
        private void AllocationWindow_ViewPage(object sender, Internals.Pages.PageEventArgs e)
        {
            var package = Package as Package;

            var window = package.FindToolWindow(typeof(PageViewerToolWindow), PageViewerCount, true);

            PageViewerCount++;

            if (window?.Frame == null)
            {
                throw new NotSupportedException("Cannot create Internals Viewer");
            }

            var connectionString = InternalsViewerConnection.CurrentConnection().ConnectionString;

            ((PageViewerToolWindow)window).LoadPage(connectionString, e.Address);

            var windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Пример #7
0
        /// <summary>
        /// Show or hide the PFS.
        /// </summary>
        /// <param name="show">if set to <c>true</c> [show].</param>
        private void ShowPfs(bool show)
        {
            if (show)
            {
                allocationContainer.Pfs        = InternalsViewerConnection.CurrentConnection().CurrentDatabase.Pfs;
                allocationContainer.ExtentSize = AllocationMap.Large;
                allocationContainer.Mode       = MapMode.Pfs;
            }
            else
            {
                allocationContainer.Mode       = MapMode.Standard;
                allocationContainer.ExtentSize = AllocationMap.Small;

                if (allocationContainer.AllocationLayers.Count == 0)
                {
                    DisplayAllocationUnitLayers();
                }
            }

            allocationContainer.Refresh();
        }
Пример #8
0
 /// <summary>
 /// Creates a page viewer window with the application level connection string
 /// </summary>
 /// <param name="pageAddress">The page address.</param>
 /// <returns></returns>
 public PageViewerContainer CreatePageViewerWindow(RowIdentifier rowIdentifier)
 {
     return(CreatePageViewerWindow(InternalsViewerConnection.CurrentConnection().ConnectionString, rowIdentifier));
 }
Пример #9
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the DatabaseToolStripComboBox control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void DatabaseToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            InternalsViewerConnection.CurrentConnection().CurrentDatabase = (Database)databaseToolStripComboBox.SelectedItem;

            LoadDatabase();
        }
Пример #10
0
 /// <summary>
 /// Handles the DoWork event of the AllocUnitBackgroundWorker control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param>
 private void AllocUnitBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     e.Result = AllocationUnitsLayer.GenerateLayers(InternalsViewerConnection.CurrentConnection().CurrentDatabase, (BackgroundWorker)sender, true, false);
 }