Skip to content

Commit

Permalink
Resource optimization, remove export functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Syrovatchenko committed Jun 7, 2020
1 parent 387dde7 commit 4401b9d
Show file tree
Hide file tree
Showing 48 changed files with 801 additions and 1,342 deletions.
12 changes: 11 additions & 1 deletion Common/AppInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Reflection;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace SQLIndexManager {

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

private static string ExeName => Process.GetCurrentProcess().ProcessName;
private static string ExePath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

public static string ApplicationName => $"{ExeName}-{Process.GetCurrentProcess().Id}";
public static readonly string LayoutFileName = $"{ExePath}\\{ExeName}.layout";
public static readonly string SettingFileName = $"{ExePath}\\{ExeName}.cfg";
public static readonly string LogFileName = $"{ExePath}\\{ExeName}.log";

}

}
4 changes: 4 additions & 0 deletions Common/GridMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static void GridColumnDisplayText(object sender, CustomColumnDisplayTextE
break;

case "RowsCount":
case "TotalUpdates":
case "TotalScans":
case "TotalSeeks":
case "TotalLookups":
e.DisplayText = $"{e.Value:n0} ";
break;

Expand Down
26 changes: 5 additions & 21 deletions Common/Output.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using DevExpress.XtraBars;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

namespace SQLIndexManager {

Expand All @@ -18,27 +15,21 @@ public class OutputEvent {
public class Output {

private static Output _log;
private readonly List<OutputEvent> _events;
private BarStaticItem _control;
private GridControl _secondaryControl;

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

private Output() {
_events = new List<OutputEvent>();

if (File.Exists(Settings.LogFileName)) {
if (File.Exists(AppInfo.LogFileName)) {
try {
File.Delete(Settings.LogFileName);
File.Delete(AppInfo.LogFileName);
}
catch { }
}
}

public void SetOutputControl(BarStaticItem control, GridControl secondaryControl) {
public void SetOutputControl(BarStaticItem control) {
_control = control;
_secondaryControl = secondaryControl;
_secondaryControl.DataSource = _events;
}

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

_events.Add(ev);

try {
if (_control != null) {
_control.Caption = msg;
}

if (_secondaryControl != null) {
GridView grid = (GridView)_secondaryControl.MainView;
grid.RefreshData();
}

using (StreamWriter sw = File.AppendText(Settings.LogFileName)) {
sw.WriteLine($"[ {now:HH:mm:ss.fff} ] {msg}");
using (StreamWriter sw = File.AppendText(AppInfo.LogFileName)) {
sw.WriteLine($"{now:HH:mm:ss.fff} - {msg}");
if (!string.IsNullOrEmpty(message2))
sw.WriteLine(message2);
}
Expand Down
5 changes: 1 addition & 4 deletions Forms/ErrorBox.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Reflection;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using SQLIndexManager.Properties;
Expand All @@ -14,15 +13,13 @@ public ErrorBox(Exception ex) {
edError.Text =
"Application has encountered an unexpected error" +
$"{Environment.NewLine}Please send error detail to {Resources.GitHubLink}" +
$"{Environment.NewLine}Build: {AssemblyVersion}" +
$"{Environment.NewLine}Build: {AppInfo.Version}" +
$"{Environment.NewLine}OS: {Environment.OSVersion}" +
$"{Environment.NewLine}{Environment.NewLine}{ex.Message}" +
$"{Environment.NewLine}{ex.Source}" +
$"{Environment.NewLine}{ex.StackTrace}";
}

private static string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();

#region Override Methods

protected override bool ProcessDialogKey(Keys keyData) {
Expand Down
660 changes: 195 additions & 465 deletions Forms/MainBox.Designer.cs

Large diffs are not rendered by default.

Loading

0 comments on commit 4401b9d

Please sign in to comment.