First stages of a new logging system being put in place. Updated the group parsing engine for the Projections and Actual Sales tables, and removed the method. Fixed the issue where changes to groups didn't mark the record manipulation form as dirty.

This commit is contained in:
2017-09-18 11:36:23 -05:00
parent ac9f464cf3
commit de1ba4af10
12 changed files with 426 additions and 311 deletions
+32 -17
View File
@@ -6,17 +6,31 @@ namespace AdvertsingProfitControl
{
internal class GlobalClasses
{
public static string LogFilePath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\";
public static string LogFilePath = Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\";
public GlobalClasses()
{
//Check to make sure the directory exists and if it doesn't then create it.
if (Directory.Exists(Logger.LogFolderPath)) return;
try
{
Directory.CreateDirectory(Logger.LogFolderPath);
}
catch (IOException e)
{
MessageBox.Show(e.Message + Environment.NewLine + @"Advertising Profit Control will be forced to exit.", @"Failed to Create Log File Directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// Logs any error related to uncaught thread exceptions.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void LogError(object sender, System.Threading.ThreadExceptionEventArgs e)
{
if (!Directory.Exists(LogFilePath))
{
Directory.CreateDirectory(LogFilePath);
}
using (
var file =
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
new StreamWriter(Logger.LogFolderPath + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
{
file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + Environment.NewLine);
MessageBox.Show(@"An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.",
@@ -25,29 +39,30 @@ namespace AdvertsingProfitControl
}
}
/// <summary>
/// Logs any unhandled exceptions that fires.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void LogError(object sender, UnhandledExceptionEventArgs e)
{
if (!Directory.Exists(LogFilePath))
{
Directory.CreateDirectory(LogFilePath);
}
using (var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
using (var file = new StreamWriter(Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
{
file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject + Environment.NewLine);
MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.",
MessageBox.Show(@"An unknown error has occurred. Advertising Profit Control will be forced to exit.",
@"Fatal Error");
Application.Exit();
}
}
/// <summary>
/// Used to log anything from information for the user to errors that don't cause a total application failure.
/// </summary>
/// <param name="message">The message to log for future use.</param>
public static void WriteToLog(string message)
{
if (!Directory.Exists(LogFilePath))
{
Directory.CreateDirectory(LogFilePath);
}
using (
var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
var file = new StreamWriter(Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
{
file.WriteLine(message);
}