Created a new form to allow the user to check the database for internal errors. Needs more testing so this build will have the option not visible. Modified the login form to display database tools.
This commit is contained in:
@@ -137,6 +137,12 @@
|
||||
<Compile Include="FrmChangeShrink.Designer.cs">
|
||||
<DependentUpon>FrmChangeShrink.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FrmIntegrityCheck.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmIntegrityCheck.Designer.cs">
|
||||
<DependentUpon>FrmIntegrityCheck.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FrmLogFileViewer.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -223,6 +229,9 @@
|
||||
<EmbeddedResource Include="FrmChangeShrink.resx">
|
||||
<DependentUpon>FrmChangeShrink.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmIntegrityCheck.resx">
|
||||
<DependentUpon>FrmIntegrityCheck.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmLogFileViewer.resx">
|
||||
<DependentUpon>FrmLogFileViewer.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@@ -317,6 +326,14 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
public partial class FrmIntegrityCheck : Form
|
||||
{
|
||||
//Dictionary<objectId, object>
|
||||
private readonly Dictionary<int, DatabaseTable> _databaseObjectsDictionary = new Dictionary<int, DatabaseTable>();
|
||||
private readonly Dictionary<int, DatabaseTable.RepairLevel> _errorsDictionary = new Dictionary<int, DatabaseTable.RepairLevel>();
|
||||
private readonly List<DatabaseDbCcResult> _databaseDbCcResults = new List<DatabaseDbCcResult>();
|
||||
|
||||
public FrmIntegrityCheck()
|
||||
{
|
||||
InitializeComponent();
|
||||
RunDbCheck();
|
||||
}
|
||||
|
||||
private void RunDbCheck()
|
||||
{
|
||||
var reportsTable = new DataTable();
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(Properties.Settings.Default.ConnectionString))
|
||||
{
|
||||
var query = @"IF NOT OBJECT_ID('tempdb..#CheckDB') IS NULL
|
||||
DROP TABLE #CheckDB;
|
||||
-- Creating temporary table for CheckDB result.
|
||||
CREATE TABLE #CheckDB
|
||||
([Error] int ,[Level] int ,[State] int
|
||||
,[MessageText] varchar(7000)
|
||||
,[RepairLevel] varchar(512)
|
||||
,[Status] int ,[DbId] int ,[DbFragId] bigint
|
||||
,[ObjectID] bigint ,[IndexId] bigint
|
||||
,[PartitionId] bigint ,[AllocUnitId] bigint
|
||||
,[RidDbId] int ,[RidPruId] int ,[File] int
|
||||
,[Page] int ,[Slot] int ,[RefDbID] int
|
||||
,[RefPruId] int ,[RefFile] int ,[RefPage] int
|
||||
,[RefSlot] int ,[Allocation] int);
|
||||
-- Execute CheckDB and insert result to temp table
|
||||
INSERT INTO #CheckDB
|
||||
([Error], [Level], [State], [MessageText], [RepairLevel],
|
||||
[Status], [DbId], [DbFragId], [ObjectID], [IndexId], [PartitionId],
|
||||
[AllocUnitId], [RidDbId], [RidPruId], [File], [Page], [Slot], [RefDbID],
|
||||
[RefPruId], [RefFile], [RefPage], [RefSlot], [Allocation])
|
||||
EXEC ('DBCC CHECKDB(''AdvertisingProfitControl'') WITH TABLERESULTS');
|
||||
-- Show final summary message first with total count of errors
|
||||
-- and warnings. Error number 8989 is for the summary messages,
|
||||
-- the messages that begin with 'CHECKDB'.
|
||||
-- Query the relevant data from the DBCC result set.
|
||||
SELECT OBJ.name AS Name, OBJ.type_desc AS Type,
|
||||
IDX.Name AS PrimaryKey,
|
||||
CDB.RepairLevel, MessageText, CDB.Error, CDB.ObjectID
|
||||
FROM #CheckDB AS CDB
|
||||
LEFT JOIN sys.objects AS OBJ
|
||||
ON CDB.ObjectId = OBJ.object_id
|
||||
|
||||
LEFT JOIN sys.indexes AS IDX
|
||||
ON CDB.ObjectId = IDX.object_id
|
||||
|
||||
AND CDB.IndexID = IDX.index_id
|
||||
|
||||
LEFT JOIN sys.allocation_units AS ALU
|
||||
ON CDB.AllocUnitId = ALU.allocation_unit_id
|
||||
ORDER BY Name;
|
||||
--Post cleanup.
|
||||
DROP TABLE #CheckDB;";
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
connection.Open();
|
||||
reportsTable.Load(command.ExecuteReader());
|
||||
}
|
||||
}
|
||||
/*OBJ.name AS Name, OBJ.type_desc AS Type, IDX.Name AS PrimaryKey,
|
||||
CDB.RepairLevel, MessageText, CDB.Error, CDB.ObjectID */
|
||||
//<object ID, repair level>
|
||||
_errorsDictionary.Clear();
|
||||
foreach (DataRow row in reportsTable.Rows)
|
||||
{
|
||||
var objectId = int.Parse(row[6].ToString());
|
||||
var objectTypeId = int.Parse(row[5].ToString()); //The Error column
|
||||
var repairLevel = row[3].ToString();
|
||||
//Check if the object is a service message.
|
||||
if (objectTypeId == (int) DatabaseObjectType.ServiceBrokerMessage)
|
||||
{
|
||||
//newObject.Type = DatabaseObjectType.ServiceBrokerMessage;
|
||||
//Do nothing, we don't care about service broker messages.
|
||||
}
|
||||
//Or a DBCC summary statement.
|
||||
else if (objectTypeId == (int) DatabaseObjectType.DbCcResult)
|
||||
{
|
||||
var dbCcResult = ParseDbCcResultMessage(row[4].ToString());
|
||||
_databaseDbCcResults.Add(dbCcResult);
|
||||
}
|
||||
//Check to see if the object is a database table
|
||||
else if (objectTypeId == (int) DatabaseObjectType.Table)
|
||||
{
|
||||
var table = ParseDatabaseTableMessage(row[4].ToString());
|
||||
table.Id = objectId;
|
||||
table.Error = objectTypeId;
|
||||
if (_errorsDictionary.ContainsKey(objectId))
|
||||
{
|
||||
table.RecommenedRepairLevel = _errorsDictionary[objectId];
|
||||
//_errorsDictionary.Remove(objectId);
|
||||
}
|
||||
_databaseObjectsDictionary.Add(table.Id, table);
|
||||
}
|
||||
//Check to see if there is a repair level present, this should only occur in error messages
|
||||
//outside of the DBCC summary messages.
|
||||
if (repairLevel != string.Empty)
|
||||
{
|
||||
var recommenedRepairLevel = DatabaseTable.RepairLevel.None;
|
||||
//Use the above ID number to as an index in the dictionary.
|
||||
//repair_allow_data_loss
|
||||
//repair_rebuild
|
||||
if (repairLevel == "repair_allow_data_loss")
|
||||
{
|
||||
recommenedRepairLevel = DatabaseTable.RepairLevel.AllowDataLoss;
|
||||
}
|
||||
else if (repairLevel == "repair_rebuild")
|
||||
{
|
||||
recommenedRepairLevel = DatabaseTable.RepairLevel.Rebuild;
|
||||
}
|
||||
|
||||
if (!_errorsDictionary.ContainsKey(objectId))
|
||||
{
|
||||
_errorsDictionary.Add(objectId, recommenedRepairLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorsDictionary[objectId] = recommenedRepairLevel < _errorsDictionary[objectId]
|
||||
? recommenedRepairLevel
|
||||
: _errorsDictionary[objectId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var table in _databaseObjectsDictionary)
|
||||
{
|
||||
if (table.Value.TypeOfTable == DatabaseTable.TableType.UserTable)
|
||||
{
|
||||
userTablesListBox.Items.Add(table.Value.FullMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
systemTablesListBox.Items.Add(table.Value.FullMessage);
|
||||
}
|
||||
|
||||
if (table.Value.RecommenedRepairLevel != DatabaseTable.RepairLevel.None)
|
||||
{
|
||||
var item = new ListViewItem
|
||||
{
|
||||
Text = $@"{table.Value.Name} has corruption, recommended repair option: {table.Value.RecommenedRepairLevel}."
|
||||
};
|
||||
damagedTablesListView.Items.Add(item);
|
||||
}
|
||||
}
|
||||
//Set the main message for the user.
|
||||
if (damagedTablesListView.Items.Count == 0)
|
||||
{
|
||||
dbCcResultLabel.Text = @"No errors in the database have been detected.";
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCcResultLabel.Text = @"One or more errors have been found, refer to the 'Damaged Tables' section for details.";
|
||||
}
|
||||
}
|
||||
catch (SqlException e)
|
||||
{
|
||||
MessageBox.Show(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//https://gallery.technet.microsoft.com/scriptcenter/59bc1fb6-68de-4624-b338-83dd5461da25
|
||||
private static DatabaseDbCcResult ParseDbCcResultMessage(string message)
|
||||
{
|
||||
//0 1 2 3 4 5 6 7 8 9 10 11
|
||||
//CHECKDB found 0 allocation errors and 0 consistency errors in database 'AdvertisingProfitControl'.
|
||||
//CHECKDB found 0 allocation errors and 3 consistency errors in table 'sys.sysowners'(object ID 27).
|
||||
//NOTE: In the event of errors being found, multiple CHECKDB messages can be found.
|
||||
var connection = new SqlConnection(Properties.Settings.Default.ConnectionString);
|
||||
if (message == string.Empty) return new DatabaseDbCcResult();
|
||||
|
||||
var textArray = message.Split(' ');
|
||||
var allocationErrors = int.Parse(textArray[2]);
|
||||
var consistencyErrors = int.Parse(textArray[6]);
|
||||
var tableName = textArray[11].Replace("'", ""); //Remove all quotes.
|
||||
tableName = tableName.Remove(tableName.Length - 1); //Strip out the period.
|
||||
var objectId = 0;
|
||||
if (tableName != connection.Database)
|
||||
{
|
||||
//This indicates that a specific table has an error in it.
|
||||
ParseTableObjectIdNumber(tableName, out objectId, out tableName);
|
||||
}
|
||||
var dbCc = new DatabaseDbCcResult
|
||||
{
|
||||
AllocationErrorCount = allocationErrors,
|
||||
ConsistencyErrorCount = consistencyErrors,
|
||||
FullMessage = message,
|
||||
AffectedTableId = objectId
|
||||
};
|
||||
return dbCc;
|
||||
}
|
||||
|
||||
private static DatabaseTable ParseDatabaseTableMessage(string message)
|
||||
{
|
||||
//0 1 2 3 4 5 6 7 8 9
|
||||
//There are 1271 rows in 17 pages for object "sys.sysrscols".
|
||||
//There are 425 rows in 6 pages for object "ActualSales".
|
||||
var tempText = message.Split(' ');
|
||||
var tableDetails = new DatabaseTable();
|
||||
var rowCount = int.Parse(tempText[2]);
|
||||
var pageCount = int.Parse(tempText[5]);
|
||||
var tableName = tempText[9].Replace("\"", "");//Remove all quotes.
|
||||
tableName = tableName.Remove(tableName.Length - 1);//Strip out the period.
|
||||
|
||||
tableDetails.TypeOfTable = tableName.StartsWith("sys") ? DatabaseTable.TableType.SystemTable : DatabaseTable.TableType.UserTable;
|
||||
tableDetails.RowCount = rowCount;
|
||||
tableDetails.PageCount = pageCount;
|
||||
tableDetails.FullMessage = message;
|
||||
tableDetails.Name = tableName;
|
||||
|
||||
return tableDetails;
|
||||
}
|
||||
|
||||
private static void ParseTableObjectIdNumber(string text, out int objectId, out string tableName)
|
||||
{
|
||||
//FORMAT IN: sys.sysowners(object ID 27)
|
||||
var tempText = text.Split('('); //tempText[0] = sys.sysowners | tempText[1] = object ID 27)
|
||||
tableName = tempText[0];
|
||||
tempText = tempText[1].Split(' '); //tempText[2] = 27)
|
||||
tempText[0] = tempText[2].Remove(tempText[2].Length - 1); //tempText[0] = 27
|
||||
objectId = int.Parse(tempText[0]);
|
||||
}
|
||||
//Reference for DBCC operations: https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkdb-transact-sql
|
||||
public enum DatabaseObjectType
|
||||
{
|
||||
Table = 2593, //A database table object has this value.
|
||||
DbCcResult = 8989, //This value indicates that DBCHECK has printed a summary statement.
|
||||
ServiceBrokerMessage = 8997, //This value indicated that the message text was made by a service broker.
|
||||
Unkown = 0
|
||||
}
|
||||
//
|
||||
internal class DatabaseTable
|
||||
{
|
||||
public string Name;
|
||||
public int Id;
|
||||
public int Error; //Error seems to indicate the objects category int the database and isn't a unique number.
|
||||
public int RowCount;
|
||||
public int PageCount;
|
||||
public string FullMessage;
|
||||
public TableType TypeOfTable = TableType.Unkown;
|
||||
public RepairLevel RecommenedRepairLevel = RepairLevel.None;
|
||||
|
||||
public enum TableType
|
||||
{
|
||||
UserTable = 0,
|
||||
SystemTable = 1, //Note: Internal_Tables will be counted as system tables.
|
||||
Unkown = 2
|
||||
}
|
||||
|
||||
//Zero is the most sever repair option with possible data loss.
|
||||
public enum RepairLevel
|
||||
{
|
||||
AllowDataLoss = 0,
|
||||
Rebuild = 1,
|
||||
None = 2
|
||||
}
|
||||
}
|
||||
|
||||
internal class DatabaseDbCcResult
|
||||
{
|
||||
private int _allocationErrorsCount;
|
||||
private int _consistencyErrorsCount;
|
||||
public string FullMessage;
|
||||
public int AffectedTableId;
|
||||
|
||||
public int AllocationErrorCount
|
||||
{
|
||||
get { return _allocationErrorsCount; }
|
||||
set
|
||||
{
|
||||
HasErrors = value != 0;
|
||||
_allocationErrorsCount = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int ConsistencyErrorCount
|
||||
{
|
||||
get { return _consistencyErrorsCount; }
|
||||
set
|
||||
{
|
||||
HasErrors = value != 0;
|
||||
_consistencyErrorsCount = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasErrors { get; private set; }
|
||||
}
|
||||
|
||||
private void repairButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//var allowDataLossOnAll = false;
|
||||
foreach (var repairLevel in _errorsDictionary)
|
||||
{
|
||||
var s = _databaseObjectsDictionary[repairLevel.Key];
|
||||
var repairOption = string.Empty;
|
||||
if (s.RecommenedRepairLevel == DatabaseTable.RepairLevel.AllowDataLoss)
|
||||
{
|
||||
repairOption = "repair_allow_data_loss";
|
||||
}
|
||||
else if (s.RecommenedRepairLevel == DatabaseTable.RepairLevel.Rebuild)
|
||||
{
|
||||
repairOption = "repair_rebuild";
|
||||
}
|
||||
var query = $"USE AdvertisingProfitControl\r\nALTER DATABASE AdvertisingProfitControl\r\nSET SINGLE_USER\r\nWITH ROLLBACK IMMEDIATE;\r\ndbcc checktable (\'{s.Name}\', {repairOption})\r\nALTER DATABASE AdvertisingProfitControl\r\nSET MULTI_USER;";
|
||||
using (var connection = new SqlConnection(Properties.Settings.Default.ConnectionString))
|
||||
{
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
connection.Open();
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
-11
@@ -39,12 +39,17 @@
|
||||
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.serverNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.informationLabel = new System.Windows.Forms.Label();
|
||||
this.mainMenu = new System.Windows.Forms.MenuStrip();
|
||||
this.databaseToolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.backupRestoreMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.checkIntegrityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// serverNameLable
|
||||
//
|
||||
this.serverNameLable.AutoSize = true;
|
||||
this.serverNameLable.Location = new System.Drawing.Point(15, 23);
|
||||
this.serverNameLable.Location = new System.Drawing.Point(27, 64);
|
||||
this.serverNameLable.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.serverNameLable.Name = "serverNameLable";
|
||||
this.serverNameLable.Size = new System.Drawing.Size(133, 25);
|
||||
@@ -54,7 +59,7 @@
|
||||
// authenticationTypeLabel
|
||||
//
|
||||
this.authenticationTypeLabel.AutoSize = true;
|
||||
this.authenticationTypeLabel.Location = new System.Drawing.Point(6, 89);
|
||||
this.authenticationTypeLabel.Location = new System.Drawing.Point(18, 130);
|
||||
this.authenticationTypeLabel.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.authenticationTypeLabel.Name = "authenticationTypeLabel";
|
||||
this.authenticationTypeLabel.Size = new System.Drawing.Size(142, 25);
|
||||
@@ -63,7 +68,8 @@
|
||||
//
|
||||
// connectButton
|
||||
//
|
||||
this.connectButton.Location = new System.Drawing.Point(476, 267);
|
||||
this.connectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.connectButton.Location = new System.Drawing.Point(515, 309);
|
||||
this.connectButton.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.connectButton.Name = "connectButton";
|
||||
this.connectButton.Size = new System.Drawing.Size(157, 42);
|
||||
@@ -80,7 +86,7 @@
|
||||
this.authenticationTypeComboBox.Items.AddRange(new object[] {
|
||||
"Windows Authentication",
|
||||
"SQL Server Authentication"});
|
||||
this.authenticationTypeComboBox.Location = new System.Drawing.Point(167, 89);
|
||||
this.authenticationTypeComboBox.Location = new System.Drawing.Point(179, 130);
|
||||
this.authenticationTypeComboBox.MaxDropDownItems = 5;
|
||||
this.authenticationTypeComboBox.Name = "authenticationTypeComboBox";
|
||||
this.authenticationTypeComboBox.Size = new System.Drawing.Size(280, 32);
|
||||
@@ -89,7 +95,7 @@
|
||||
// loginLabel
|
||||
//
|
||||
this.loginLabel.AutoSize = true;
|
||||
this.loginLabel.Location = new System.Drawing.Point(82, 155);
|
||||
this.loginLabel.Location = new System.Drawing.Point(94, 196);
|
||||
this.loginLabel.Name = "loginLabel";
|
||||
this.loginLabel.Size = new System.Drawing.Size(66, 25);
|
||||
this.loginLabel.TabIndex = 6;
|
||||
@@ -98,7 +104,7 @@
|
||||
// passwordLabel
|
||||
//
|
||||
this.passwordLabel.AutoSize = true;
|
||||
this.passwordLabel.Location = new System.Drawing.Point(44, 221);
|
||||
this.passwordLabel.Location = new System.Drawing.Point(56, 262);
|
||||
this.passwordLabel.Name = "passwordLabel";
|
||||
this.passwordLabel.Size = new System.Drawing.Size(104, 25);
|
||||
this.passwordLabel.TabIndex = 7;
|
||||
@@ -107,7 +113,7 @@
|
||||
// loginTextBox
|
||||
//
|
||||
this.loginTextBox.Enabled = false;
|
||||
this.loginTextBox.Location = new System.Drawing.Point(167, 155);
|
||||
this.loginTextBox.Location = new System.Drawing.Point(179, 196);
|
||||
this.loginTextBox.Name = "loginTextBox";
|
||||
this.loginTextBox.Size = new System.Drawing.Size(280, 29);
|
||||
this.loginTextBox.TabIndex = 3;
|
||||
@@ -115,7 +121,7 @@
|
||||
// passwordTextBox
|
||||
//
|
||||
this.passwordTextBox.Enabled = false;
|
||||
this.passwordTextBox.Location = new System.Drawing.Point(167, 218);
|
||||
this.passwordTextBox.Location = new System.Drawing.Point(179, 259);
|
||||
this.passwordTextBox.Name = "passwordTextBox";
|
||||
this.passwordTextBox.PasswordChar = '*';
|
||||
this.passwordTextBox.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
@@ -125,7 +131,7 @@
|
||||
// serverNameComboBox
|
||||
//
|
||||
this.serverNameComboBox.FormattingEnabled = true;
|
||||
this.serverNameComboBox.Location = new System.Drawing.Point(167, 23);
|
||||
this.serverNameComboBox.Location = new System.Drawing.Point(179, 64);
|
||||
this.serverNameComboBox.Name = "serverNameComboBox";
|
||||
this.serverNameComboBox.Size = new System.Drawing.Size(452, 32);
|
||||
this.serverNameComboBox.TabIndex = 1;
|
||||
@@ -133,17 +139,52 @@
|
||||
// informationLabel
|
||||
//
|
||||
this.informationLabel.AutoSize = true;
|
||||
this.informationLabel.Location = new System.Drawing.Point(11, 267);
|
||||
this.informationLabel.Location = new System.Drawing.Point(12, 307);
|
||||
this.informationLabel.Name = "informationLabel";
|
||||
this.informationLabel.Size = new System.Drawing.Size(0, 25);
|
||||
this.informationLabel.TabIndex = 11;
|
||||
//
|
||||
// mainMenu
|
||||
//
|
||||
this.mainMenu.ImageScalingSize = new System.Drawing.Size(28, 28);
|
||||
this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.databaseToolsToolStripMenuItem});
|
||||
this.mainMenu.Location = new System.Drawing.Point(0, 0);
|
||||
this.mainMenu.Name = "mainMenu";
|
||||
this.mainMenu.Size = new System.Drawing.Size(687, 38);
|
||||
this.mainMenu.TabIndex = 12;
|
||||
this.mainMenu.Text = "menuStrip1";
|
||||
//
|
||||
// databaseToolsToolStripMenuItem
|
||||
//
|
||||
this.databaseToolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.backupRestoreMainMenu,
|
||||
this.checkIntegrityToolStripMenuItem});
|
||||
this.databaseToolsToolStripMenuItem.Name = "databaseToolsToolStripMenuItem";
|
||||
this.databaseToolsToolStripMenuItem.Size = new System.Drawing.Size(165, 34);
|
||||
this.databaseToolsToolStripMenuItem.Text = "&Database Tools";
|
||||
//
|
||||
// backupRestoreMainMenu
|
||||
//
|
||||
this.backupRestoreMainMenu.Name = "backupRestoreMainMenu";
|
||||
this.backupRestoreMainMenu.Size = new System.Drawing.Size(287, 34);
|
||||
this.backupRestoreMainMenu.Text = "&Backup and Restore";
|
||||
this.backupRestoreMainMenu.Click += new System.EventHandler(this.backupRestoreToolStripMenuItem_Click);
|
||||
//
|
||||
// checkIntegrityToolStripMenuItem
|
||||
//
|
||||
this.checkIntegrityToolStripMenuItem.Name = "checkIntegrityToolStripMenuItem";
|
||||
this.checkIntegrityToolStripMenuItem.Size = new System.Drawing.Size(287, 34);
|
||||
this.checkIntegrityToolStripMenuItem.Text = "&Check Integrity";
|
||||
this.checkIntegrityToolStripMenuItem.Visible = false;
|
||||
this.checkIntegrityToolStripMenuItem.Click += new System.EventHandler(this.checkIntegrityToolStripMenuItem_Click);
|
||||
//
|
||||
// FrmLoginForm
|
||||
//
|
||||
this.AcceptButton = this.connectButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(648, 324);
|
||||
this.ClientSize = new System.Drawing.Size(687, 366);
|
||||
this.Controls.Add(this.informationLabel);
|
||||
this.Controls.Add(this.serverNameComboBox);
|
||||
this.Controls.Add(this.passwordTextBox);
|
||||
@@ -154,13 +195,17 @@
|
||||
this.Controls.Add(this.connectButton);
|
||||
this.Controls.Add(this.authenticationTypeLabel);
|
||||
this.Controls.Add(this.serverNameLable);
|
||||
this.Controls.Add(this.mainMenu);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.mainMenu;
|
||||
this.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "FrmLoginForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Connect to Database";
|
||||
this.mainMenu.ResumeLayout(false);
|
||||
this.mainMenu.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -177,5 +222,9 @@
|
||||
private System.Windows.Forms.TextBox passwordTextBox;
|
||||
private System.Windows.Forms.ComboBox serverNameComboBox;
|
||||
private System.Windows.Forms.Label informationLabel;
|
||||
private System.Windows.Forms.MenuStrip mainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem databaseToolsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem backupRestoreMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem checkIntegrityToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -89,5 +89,17 @@ namespace AdvertsingProfitControl
|
||||
informationLabel.Text = @"Failed to connect to a database.";
|
||||
}
|
||||
}
|
||||
|
||||
private void backupRestoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new DatabaseRecovery();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void checkIntegrityToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new FrmIntegrityCheck();
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,9 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
@@ -1136,7 +1136,8 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void testToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var t = new FrmIntegrityCheck();
|
||||
t.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
partial class FrmIntegrityCheck
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmIntegrityCheck));
|
||||
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.systemTablesGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.systemTablesListBox = new System.Windows.Forms.ListBox();
|
||||
this.userTablesGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.userTablesListBox = new System.Windows.Forms.ListBox();
|
||||
this.dbCcResultLabel = new System.Windows.Forms.Label();
|
||||
this.databaseCheckResultPanel = new System.Windows.Forms.Panel();
|
||||
this.suggestionLabel = new System.Windows.Forms.Label();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.repairButton = new System.Windows.Forms.Button();
|
||||
this.damagedTablesGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.damagedTablesListView = new System.Windows.Forms.ListView();
|
||||
this.informationLabel = new System.Windows.Forms.Label();
|
||||
this.mainLayoutPanel.SuspendLayout();
|
||||
this.systemTablesGroupBox.SuspendLayout();
|
||||
this.userTablesGroupBox.SuspendLayout();
|
||||
this.databaseCheckResultPanel.SuspendLayout();
|
||||
this.damagedTablesGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// mainLayoutPanel
|
||||
//
|
||||
this.mainLayoutPanel.ColumnCount = 2;
|
||||
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.Controls.Add(this.systemTablesGroupBox, 0, 1);
|
||||
this.mainLayoutPanel.Controls.Add(this.userTablesGroupBox, 0, 2);
|
||||
this.mainLayoutPanel.Controls.Add(this.dbCcResultLabel, 1, 2);
|
||||
this.mainLayoutPanel.Controls.Add(this.databaseCheckResultPanel, 1, 3);
|
||||
this.mainLayoutPanel.Controls.Add(this.damagedTablesGroupBox, 0, 3);
|
||||
this.mainLayoutPanel.Controls.Add(this.informationLabel, 1, 1);
|
||||
this.mainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mainLayoutPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.mainLayoutPanel.Name = "mainLayoutPanel";
|
||||
this.mainLayoutPanel.RowCount = 4;
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.mainLayoutPanel.Size = new System.Drawing.Size(1087, 754);
|
||||
this.mainLayoutPanel.TabIndex = 0;
|
||||
//
|
||||
// systemTablesGroupBox
|
||||
//
|
||||
this.systemTablesGroupBox.Controls.Add(this.systemTablesListBox);
|
||||
this.systemTablesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.systemTablesGroupBox.Location = new System.Drawing.Point(3, 33);
|
||||
this.systemTablesGroupBox.Name = "systemTablesGroupBox";
|
||||
this.systemTablesGroupBox.Size = new System.Drawing.Size(537, 235);
|
||||
this.systemTablesGroupBox.TabIndex = 0;
|
||||
this.systemTablesGroupBox.TabStop = false;
|
||||
this.systemTablesGroupBox.Text = "System Tables";
|
||||
//
|
||||
// systemTablesListBox
|
||||
//
|
||||
this.systemTablesListBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.systemTablesListBox.FormattingEnabled = true;
|
||||
this.systemTablesListBox.ItemHeight = 24;
|
||||
this.systemTablesListBox.Location = new System.Drawing.Point(3, 25);
|
||||
this.systemTablesListBox.Name = "systemTablesListBox";
|
||||
this.systemTablesListBox.Size = new System.Drawing.Size(531, 207);
|
||||
this.systemTablesListBox.TabIndex = 0;
|
||||
//
|
||||
// userTablesGroupBox
|
||||
//
|
||||
this.userTablesGroupBox.Controls.Add(this.userTablesListBox);
|
||||
this.userTablesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.userTablesGroupBox.Location = new System.Drawing.Point(3, 274);
|
||||
this.userTablesGroupBox.Name = "userTablesGroupBox";
|
||||
this.userTablesGroupBox.Size = new System.Drawing.Size(537, 235);
|
||||
this.userTablesGroupBox.TabIndex = 1;
|
||||
this.userTablesGroupBox.TabStop = false;
|
||||
this.userTablesGroupBox.Text = "User Tables";
|
||||
//
|
||||
// userTablesListBox
|
||||
//
|
||||
this.userTablesListBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.userTablesListBox.FormattingEnabled = true;
|
||||
this.userTablesListBox.ItemHeight = 24;
|
||||
this.userTablesListBox.Location = new System.Drawing.Point(3, 25);
|
||||
this.userTablesListBox.Name = "userTablesListBox";
|
||||
this.userTablesListBox.Size = new System.Drawing.Size(531, 207);
|
||||
this.userTablesListBox.TabIndex = 1;
|
||||
//
|
||||
// dbCcResultLabel
|
||||
//
|
||||
this.dbCcResultLabel.AutoSize = true;
|
||||
this.dbCcResultLabel.Location = new System.Drawing.Point(546, 271);
|
||||
this.dbCcResultLabel.Name = "dbCcResultLabel";
|
||||
this.dbCcResultLabel.Size = new System.Drawing.Size(0, 25);
|
||||
this.dbCcResultLabel.TabIndex = 0;
|
||||
//
|
||||
// databaseCheckResultPanel
|
||||
//
|
||||
this.databaseCheckResultPanel.Controls.Add(this.suggestionLabel);
|
||||
this.databaseCheckResultPanel.Controls.Add(this.button2);
|
||||
this.databaseCheckResultPanel.Controls.Add(this.repairButton);
|
||||
this.databaseCheckResultPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.databaseCheckResultPanel.Location = new System.Drawing.Point(546, 515);
|
||||
this.databaseCheckResultPanel.Name = "databaseCheckResultPanel";
|
||||
this.databaseCheckResultPanel.Size = new System.Drawing.Size(538, 236);
|
||||
this.databaseCheckResultPanel.TabIndex = 2;
|
||||
//
|
||||
// suggestionLabel
|
||||
//
|
||||
this.suggestionLabel.AutoSize = true;
|
||||
this.suggestionLabel.Location = new System.Drawing.Point(10, 9);
|
||||
this.suggestionLabel.Name = "suggestionLabel";
|
||||
this.suggestionLabel.Size = new System.Drawing.Size(80, 25);
|
||||
this.suggestionLabel.TabIndex = 3;
|
||||
this.suggestionLabel.Text = "what do";
|
||||
this.suggestionLabel.Visible = false;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.Location = new System.Drawing.Point(352, 175);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(177, 52);
|
||||
this.button2.TabIndex = 2;
|
||||
this.button2.Text = "Verify Integrity";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// repairButton
|
||||
//
|
||||
this.repairButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.repairButton.Location = new System.Drawing.Point(15, 175);
|
||||
this.repairButton.Name = "repairButton";
|
||||
this.repairButton.Size = new System.Drawing.Size(177, 52);
|
||||
this.repairButton.TabIndex = 1;
|
||||
this.repairButton.Text = "Attempt Repairs";
|
||||
this.repairButton.UseVisualStyleBackColor = true;
|
||||
this.repairButton.Click += new System.EventHandler(this.repairButton_Click);
|
||||
//
|
||||
// damagedTablesGroupBox
|
||||
//
|
||||
this.damagedTablesGroupBox.Controls.Add(this.damagedTablesListView);
|
||||
this.damagedTablesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.damagedTablesGroupBox.Location = new System.Drawing.Point(3, 515);
|
||||
this.damagedTablesGroupBox.Name = "damagedTablesGroupBox";
|
||||
this.damagedTablesGroupBox.Size = new System.Drawing.Size(537, 236);
|
||||
this.damagedTablesGroupBox.TabIndex = 3;
|
||||
this.damagedTablesGroupBox.TabStop = false;
|
||||
this.damagedTablesGroupBox.Text = "Damaged Tables";
|
||||
//
|
||||
// damagedTablesListView
|
||||
//
|
||||
this.damagedTablesListView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.damagedTablesListView.Location = new System.Drawing.Point(3, 25);
|
||||
this.damagedTablesListView.Name = "damagedTablesListView";
|
||||
this.damagedTablesListView.Size = new System.Drawing.Size(531, 208);
|
||||
this.damagedTablesListView.TabIndex = 0;
|
||||
this.damagedTablesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.damagedTablesListView.View = System.Windows.Forms.View.List;
|
||||
//
|
||||
// informationLabel
|
||||
//
|
||||
this.informationLabel.AutoSize = true;
|
||||
this.informationLabel.Location = new System.Drawing.Point(546, 30);
|
||||
this.informationLabel.Name = "informationLabel";
|
||||
this.informationLabel.Size = new System.Drawing.Size(464, 125);
|
||||
this.informationLabel.TabIndex = 4;
|
||||
this.informationLabel.Text = resources.GetString("informationLabel.Text");
|
||||
//
|
||||
// FrmIntegrityCheck
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1087, 754);
|
||||
this.Controls.Add(this.mainLayoutPanel);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "FrmIntegrityCheck";
|
||||
this.Text = "Verify Database Integrity";
|
||||
this.mainLayoutPanel.ResumeLayout(false);
|
||||
this.mainLayoutPanel.PerformLayout();
|
||||
this.systemTablesGroupBox.ResumeLayout(false);
|
||||
this.userTablesGroupBox.ResumeLayout(false);
|
||||
this.databaseCheckResultPanel.ResumeLayout(false);
|
||||
this.databaseCheckResultPanel.PerformLayout();
|
||||
this.damagedTablesGroupBox.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel mainLayoutPanel;
|
||||
private System.Windows.Forms.GroupBox systemTablesGroupBox;
|
||||
private System.Windows.Forms.GroupBox userTablesGroupBox;
|
||||
private System.Windows.Forms.ListBox systemTablesListBox;
|
||||
private System.Windows.Forms.ListBox userTablesListBox;
|
||||
private System.Windows.Forms.Panel databaseCheckResultPanel;
|
||||
private System.Windows.Forms.Label dbCcResultLabel;
|
||||
private System.Windows.Forms.GroupBox damagedTablesGroupBox;
|
||||
private System.Windows.Forms.ListView damagedTablesListView;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Button repairButton;
|
||||
private System.Windows.Forms.Label suggestionLabel;
|
||||
private System.Windows.Forms.Label informationLabel;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user