Skip to content

Commit 4401b9d

Browse files
author
Sergey Syrovatchenko
committed
Resource optimization, remove export functionality
1 parent 387dde7 commit 4401b9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+801
-1342
lines changed

Common/AppInfo.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Reflection;
1+
using System.Diagnostics;
2+
using System.IO;
3+
using System.Reflection;
24

35
namespace SQLIndexManager {
46

@@ -9,6 +11,14 @@ public static class AppInfo {
911
public static string Copyright => ((AssemblyCopyrightAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright;
1012
public static string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString();
1113

14+
private static string ExeName => Process.GetCurrentProcess().ProcessName;
15+
private static string ExePath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
16+
17+
public static string ApplicationName => $"{ExeName}-{Process.GetCurrentProcess().Id}";
18+
public static readonly string LayoutFileName = $"{ExePath}\\{ExeName}.layout";
19+
public static readonly string SettingFileName = $"{ExePath}\\{ExeName}.cfg";
20+
public static readonly string LogFileName = $"{ExePath}\\{ExeName}.log";
21+
1222
}
1323

1424
}

Common/GridMethod.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public static void GridColumnDisplayText(object sender, CustomColumnDisplayTextE
5353
break;
5454

5555
case "RowsCount":
56+
case "TotalUpdates":
57+
case "TotalScans":
58+
case "TotalSeeks":
59+
case "TotalLookups":
5660
e.DisplayText = $"{e.Value:n0} ";
5761
break;
5862

Common/Output.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
43
using DevExpress.XtraBars;
5-
using DevExpress.XtraGrid;
6-
using DevExpress.XtraGrid.Views.Grid;
74

85
namespace SQLIndexManager {
96

@@ -18,27 +15,21 @@ public class OutputEvent {
1815
public class Output {
1916

2017
private static Output _log;
21-
private readonly List<OutputEvent> _events;
2218
private BarStaticItem _control;
23-
private GridControl _secondaryControl;
2419

2520
public static Output Current => _log ?? (_log = new Output());
2621

2722
private Output() {
28-
_events = new List<OutputEvent>();
29-
30-
if (File.Exists(Settings.LogFileName)) {
23+
if (File.Exists(AppInfo.LogFileName)) {
3124
try {
32-
File.Delete(Settings.LogFileName);
25+
File.Delete(AppInfo.LogFileName);
3326
}
3427
catch { }
3528
}
3629
}
3730

38-
public void SetOutputControl(BarStaticItem control, GridControl secondaryControl) {
31+
public void SetOutputControl(BarStaticItem control) {
3932
_control = control;
40-
_secondaryControl = secondaryControl;
41-
_secondaryControl.DataSource = _events;
4233
}
4334

4435
public void AddCaption(string message) {
@@ -64,20 +55,13 @@ public void Add(string message, string message2 = null, long? elapsedMillisecond
6455
Duration = duration
6556
};
6657

67-
_events.Add(ev);
68-
6958
try {
7059
if (_control != null) {
7160
_control.Caption = msg;
7261
}
7362

74-
if (_secondaryControl != null) {
75-
GridView grid = (GridView)_secondaryControl.MainView;
76-
grid.RefreshData();
77-
}
78-
79-
using (StreamWriter sw = File.AppendText(Settings.LogFileName)) {
80-
sw.WriteLine($"[ {now:HH:mm:ss.fff} ] {msg}");
63+
using (StreamWriter sw = File.AppendText(AppInfo.LogFileName)) {
64+
sw.WriteLine($"{now:HH:mm:ss.fff} - {msg}");
8165
if (!string.IsNullOrEmpty(message2))
8266
sw.WriteLine(message2);
8367
}

Forms/ErrorBox.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Reflection;
32
using System.Windows.Forms;
43
using DevExpress.XtraEditors;
54
using SQLIndexManager.Properties;
@@ -14,15 +13,13 @@ public ErrorBox(Exception ex) {
1413
edError.Text =
1514
"Application has encountered an unexpected error" +
1615
$"{Environment.NewLine}Please send error detail to {Resources.GitHubLink}" +
17-
$"{Environment.NewLine}Build: {AssemblyVersion}" +
16+
$"{Environment.NewLine}Build: {AppInfo.Version}" +
1817
$"{Environment.NewLine}OS: {Environment.OSVersion}" +
1918
$"{Environment.NewLine}{Environment.NewLine}{ex.Message}" +
2019
$"{Environment.NewLine}{ex.Source}" +
2120
$"{Environment.NewLine}{ex.StackTrace}";
2221
}
2322

24-
private static string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
25-
2623
#region Override Methods
2724

2825
protected override bool ProcessDialogKey(Keys keyData) {

Forms/MainBox.Designer.cs

Lines changed: 195 additions & 465 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)