Skip to content

Commit 61cbf1e

Browse files
tduguidtduguid
tduguid
authored and
tduguid
committed
Updated error trapping across all versions
1 parent 94ce8b3 commit 61cbf1e

16 files changed

+168
-81
lines changed

Diff for: CS/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("1.0.0.0")]
37-
[assembly: AssemblyFileVersion("1.0.0.0")]
36+
[assembly: AssemblyVersion("2.0.0.2")]
37+
[assembly: AssemblyFileVersion("2.0.0.2")]
3838

Diff for: CS/Properties/Settings.Designer.cs

+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: CS/Properties/Settings.settings

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<Value Profile="(Default)">Anthony Duguid</Value>
77
</Setting>
88
<Setting Name="App_PathNewIssue" Type="System.String" Scope="User">
9-
<Value Profile="(Default)">https://github.com/Office-projects/Server-Help/issues/new</Value>
9+
<Value Profile="(Default)">https://github.com/Excel-projects/Server-Help/issues/new</Value>
1010
</Setting>
1111
<Setting Name="App_PathReadMe" Type="System.String" Scope="User">
12-
<Value Profile="(Default)">https://github.com/Office-projects/Server-Help/blob/master/README.md</Value>
12+
<Value Profile="(Default)">https://github.com/Excel-projects/Server-Help/blob/master/README.md</Value>
1313
</Setting>
1414
<Setting Name="App_ReleaseDate" Type="System.DateTime" Scope="User">
15-
<Value Profile="(Default)">07/31/2017 12:00:00</Value>
15+
<Value Profile="(Default)">11/02/2018 12:00:00</Value>
1616
</Setting>
1717
<Setting Name="Ping_Results" Type="System.String" Scope="User">
1818
<Value Profile="(Default)">Results</Value>
@@ -44,5 +44,8 @@
4444
<Setting Name="Rdg_SheetName" Type="System.String" Scope="User">
4545
<Value Profile="(Default)">Servers</Value>
4646
</Setting>
47+
<Setting Name="App_PathLocalData" Type="System.String" Scope="User">
48+
<Value Profile="(Default)" />
49+
</Setting>
4750
</Settings>
4851
</SettingsFile>

Diff for: CS/Ribbon.xml

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
33
<ribbon>
4-
<qat>
5-
<sharedControls >
6-
<button idMso ="Copy"/>
7-
</sharedControls>
8-
<documentControls >
9-
<button idMso="Cut"/>
10-
</documentControls>
11-
</qat>
124
<tabs>
135
<tab
146
id="tabServerActions"
@@ -33,7 +25,6 @@
3325
idMso="RemoveDuplicates"
3426
size="large"
3527
/>
36-
3728
</group>
3829
<group
3930
id="grpPing"
@@ -154,15 +145,6 @@
154145
id="grpOptions"
155146
imageMso="PropertySheet"
156147
>
157-
<button
158-
id="btnSettings"
159-
label="Add-In Settings"
160-
onAction="OnAction"
161-
imageMso="PropertySheet"
162-
size="large"
163-
screentip="Setting Form"
164-
supertip="This opens the settings form. The settings are stored as custom properties and can be changed by double-clicking the item or using the update button."
165-
/>
166148
<button
167149
id="btnRefreshServerList"
168150
label="Rebuild Server List"
@@ -191,18 +173,30 @@
191173
label="How To... "
192174
onAction="OnAction"
193175
imageMso="Help"
194-
size="large"
176+
size="normal"
195177
screentip="How To..."
196-
supertip="This opens the read me page from the site with detailed instructions of the Add-In functionality."
178+
supertip="This opens the read me page in GitHub with detailed instructions of the Add-In functionality."
179+
keytip="HLP"
197180
/>
198181
<button
199182
id="btnOpenNewIssue"
200183
label="Report Issue"
201184
onAction="OnAction"
202185
imageMso="MacroSecurity"
203-
size="large"
186+
size="normal"
204187
screentip="Report An Issue"
205-
supertip="This will open a new issue from the site. The user will need to login to raise an issue."
188+
supertip="This will open a new issue page in GitHub. The user will need to login to raise an issue."
189+
keytip="RPT"
190+
/>
191+
<button
192+
id="btnSettings"
193+
label="Settings"
194+
onAction="OnAction"
195+
imageMso="PropertySheet"
196+
size="normal"
197+
screentip="Add-In Settings Form"
198+
supertip="This opens a user form with a list of custom properties stored in the file."
199+
keytip="SET"
206200
/>
207201
</group>
208202
<group

Diff for: CS/Scripts/ErrorHandler.cs

+71-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using System;
2+
using System.Linq;
3+
using System.Text;
4+
using System.Collections.Generic;
25
using System.Windows.Forms;
36
using System.Runtime.InteropServices;
47
using Excel = Microsoft.Office.Interop.Excel;
@@ -26,8 +29,8 @@ public static void SetLogPath()
2629
{
2730
XmlConfigurator.Configure();
2831
log4net.Repository.Hierarchy.Hierarchy h = (log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository();
29-
//string logFileName = System.IO.Path.Combine(Properties.Settings.Default.App_PathLocalData, AssemblyInfo.Product + ".log");
30-
string logFileName = @"C:\Temp\ServerActions.log";
32+
string logFileName = System.IO.Path.Combine(Properties.Settings.Default.App_PathLocalData, AssemblyInfo.Product + ".log");
33+
3134
foreach (var a in h.Root.Appenders)
3235
{
3336
if (a is log4net.Appender.FileAppender)
@@ -49,10 +52,20 @@ public static void CreateLogRecord()
4952
{
5053
try
5154
{
52-
System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1);
53-
System.Reflection.MethodBase caller = sf.GetMethod();
54-
string currentProcedure = (caller.Name).Trim();
55-
log.Info("[PROCEDURE]=|" + currentProcedure + "|[USER NAME]=|" + Environment.UserName + "|[MACHINE NAME]=|" + Environment.MachineName);
55+
// gather context
56+
var sf = new System.Diagnostics.StackFrame(1);
57+
var caller = sf.GetMethod();
58+
var currentProcedure = caller.Name.Trim();
59+
60+
// handle log record
61+
var logMessage = string.Concat(new Dictionary<string, string>
62+
{
63+
["PROCEDURE"] = currentProcedure,
64+
["USER NAME"] = Environment.UserName,
65+
["MACHINE NAME"] = Environment.MachineName
66+
}.Select(x => $"[{x.Key}]=|{x.Value}|"));
67+
log.Info(logMessage);
68+
5669
}
5770
catch (Exception ex)
5871
{
@@ -74,19 +87,35 @@ public static void CreateLogRecord()
7487
/// <remarks></remarks>
7588
public static void DisplayMessage(Exception ex, Boolean isSilent = false)
7689
{
77-
System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1);
78-
System.Reflection.MethodBase caller = sf.GetMethod();
79-
string currentProcedure = (caller.Name).Trim();
80-
string currentFileName = AssemblyInfo.GetCurrentFileName();
81-
string errorMessageDescription = ex.ToString();
82-
errorMessageDescription = System.Text.RegularExpressions.Regex.Replace(errorMessageDescription, @"\r\n+", " "); //the carriage returns were messing up my log file
83-
string msg = "Contact your system administrator. A record has been created in the log file." + Environment.NewLine;
84-
msg += "Procedure: " + currentProcedure + Environment.NewLine;
85-
msg += "Description: " + ex.ToString() + Environment.NewLine;
86-
log.Error("[PROCEDURE]=|" + currentProcedure + "|[USER NAME]=|" + Environment.UserName + "|[MACHINE NAME]=|" + Environment.MachineName + "|[FILE NAME]=|" + currentFileName + "|[DESCRIPTION]=|" + errorMessageDescription);
90+
// gather context
91+
var sf = new System.Diagnostics.StackFrame(1);
92+
var caller = sf.GetMethod();
93+
var errorDescription = ex.ToString().Replace("\r\n", " "); // the carriage returns were messing up my log file
94+
var currentProcedure = caller.Name.Trim();
95+
var currentFileName = AssemblyInfo.GetCurrentFileName();
96+
97+
// handle log record
98+
var logMessage = string.Concat(new Dictionary<string, string>
99+
{
100+
["PROCEDURE"] = currentProcedure,
101+
["USER NAME"] = Environment.UserName,
102+
["MACHINE NAME"] = Environment.MachineName,
103+
["FILE NAME"] = currentFileName,
104+
["DESCRIPTION"] = errorDescription,
105+
}.Select(x => $"[{x.Key}]=|{x.Value}|"));
106+
log.Error(logMessage);
107+
108+
// format message
109+
var userMessage = new StringBuilder()
110+
.AppendLine("Contact your system administrator. A record has been created in the log file.")
111+
.AppendLine("Procedure: " + currentProcedure)
112+
.AppendLine("Description: " + errorDescription)
113+
.ToString();
114+
115+
// handle message
87116
if (isSilent == false)
88117
{
89-
MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
118+
MessageBox.Show(userMessage, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
90119
}
91120
}
92121

@@ -314,5 +343,30 @@ public static bool IsDate(object expression)
314343
return false;
315344
}
316345

346+
/// <summary>
347+
/// Check if the object is a time
348+
/// </summary>
349+
/// <param name="expression">Represents the cell value </param>
350+
/// <returns>A method that returns true or false if there is a valid time </returns>
351+
/// <remarks></remarks>
352+
public static bool IsTime(object expression)
353+
{
354+
try
355+
{
356+
string timeValue = Convert.ToString(expression);
357+
//timeValue = String.Format("{0:" + Properties.Settings.Default.Table_ColumnFormatTime + "}", expression);
358+
//timeValue = timeValue.ToString(Properties.Settings.Default.Table_ColumnFormatTime, System.Globalization.CultureInfo.InvariantCulture);
359+
//timeValue = timeValue.ToString(Properties.Settings.Default.Table_ColumnFormatTime);
360+
//string timeValue = expression.ToString().Format(Properties.Settings.Default.Table_ColumnFormatTime);
361+
TimeSpan time1;
362+
//return TimeSpan.TryParse((string)expression, out time1);
363+
return TimeSpan.TryParse(timeValue, out time1);
364+
}
365+
catch (Exception)
366+
{
367+
return false;
368+
}
369+
}
370+
317371
}
318372
}

Diff for: CS/ServerHelp.csproj

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
<IsWebBootstrapper>True</IsWebBootstrapper>
3333
<BootstrapperEnabled>true</BootstrapperEnabled>
3434
<PublishUrl>publish\</PublishUrl>
35-
<InstallUrl>https://github.com/Office-projects/Server-Help/master/CS/publish/</InstallUrl>
35+
<InstallUrl>https://github.com/Excel-projects/Server-Help/master/CS/publish/</InstallUrl>
3636
<TargetCulture>en</TargetCulture>
37-
<ApplicationVersion>2.0.0.0</ApplicationVersion>
37+
<ApplicationVersion>2.0.0.2</ApplicationVersion>
3838
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
3939
<UpdateEnabled>true</UpdateEnabled>
4040
<UpdateInterval>0</UpdateInterval>
@@ -198,7 +198,9 @@
198198
<DependentUpon>Settings.cs</DependentUpon>
199199
</EmbeddedResource>
200200
<None Include="AnthonyDuguid.pfx" />
201-
<None Include="app.config" />
201+
<None Include="app.config">
202+
<SubType>Designer</SubType>
203+
</None>
202204
<None Include="packages.config" />
203205
<None Include="Properties\Settings.settings">
204206
<Generator>SettingsSingleFileGenerator</Generator>

Diff for: CS/app.config

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
<userSettings>
1212
<ServerActions.Properties.Settings>
1313
<setting name="App_PathNewIssue" serializeAs="String">
14-
<value>https://github.com/Office-projects/Server-Help/issues/new</value>
14+
<value>https://github.com/Excel-projects/Server-Help/issues/new</value>
1515
</setting>
1616
<setting name="App_PathReadMe" serializeAs="String">
17-
<value>https://github.com/Office-projects/Server-Help/blob/master/README.md</value>
17+
<value>https://github.com/Excel-projects/Server-Help/blob/master/README.md</value>
1818
</setting>
1919
<setting name="App_ReleaseDate" serializeAs="String">
20-
<value>07/31/2017 12:00:00</value>
20+
<value>11/02/2018 12:00:00</value>
2121
</setting>
2222
<setting name="Ping_Results" serializeAs="String">
2323
<value>Results</value>
@@ -49,6 +49,9 @@
4949
<setting name="Rdg_SheetName" serializeAs="String">
5050
<value>Servers</value>
5151
</setting>
52+
<setting name="App_PathLocalData" serializeAs="String">
53+
<value />
54+
</setting>
5255
</ServerActions.Properties.Settings>
5356
</userSettings>
5457
<applicationSettings>

Diff for: VB/My Project/AssemblyInfo.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Imports System.Security
3535
' by using the '*' as shown below:
3636
' <Assembly: AssemblyVersion("1.0.*")>
3737

38-
<Assembly: AssemblyVersion("2.0.0.0")>
39-
<Assembly: AssemblyFileVersion("2.0.0.0")>
38+
<Assembly: AssemblyVersion("2.0.0.2")>
39+
<Assembly: AssemblyFileVersion("2.0.0.2")>
4040

4141
Friend Module DesignTimeConstants
4242
Public Const RibbonTypeSerializer As String = "Microsoft.VisualStudio.Tools.Office.Ribbon.Serialization.RibbonTypeCodeDomSerializer, Microsoft.VisualStudio.Tools.Office.Designer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

Diff for: VB/My Project/Settings.Designer.vb

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: VB/My Project/Settings.settings

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Value Profile="(Default)">Anthony Duguid</Value>
77
</Setting>
88
<Setting Name="App_PathReadMe" Type="System.String" Scope="User">
9-
<Value Profile="(Default)">https://github.com/Office-projects/Server-Help/blob/master/README.md</Value>
9+
<Value Profile="(Default)">https://github.com/Excel-projects/Server-Help/blob/master/README.md</Value>
1010
</Setting>
1111
<Setting Name="Ping_ServerName" Type="System.String" Scope="User">
1212
<Value Profile="(Default)">dNSHostname</Value>
@@ -24,10 +24,10 @@
2424
<Value Profile="(Default)">C:\Temp\Test.rdg</Value>
2525
</Setting>
2626
<Setting Name="App_PathNewIssue" Type="System.String" Scope="User">
27-
<Value Profile="(Default)">https://github.com/Office-projects/Server-Help/issues/new</Value>
27+
<Value Profile="(Default)">https://github.com/Excel-projects/Server-Help/issues/new</Value>
2828
</Setting>
2929
<Setting Name="App_ReleaseDate" Type="System.DateTime" Scope="User">
30-
<Value Profile="(Default)">07/31/2017 12:00:00</Value>
30+
<Value Profile="(Default)">11/02/2018 12:00:00</Value>
3131
</Setting>
3232
<Setting Name="Rdg_Comment" Type="System.String" Scope="User">
3333
<Value Profile="(Default)">OperatingSystem</Value>

Diff for: VB/Ribbon.xml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
idMso="RemoveDuplicates"
2626
size="large"
2727
/>
28-
2928
</group>
3029
<group
3130
id="grpPing"

0 commit comments

Comments
 (0)