diff --git a/PROMS/Baseline/Program.cs b/PROMS/Baseline/Program.cs index e245b9d6..9cc8eb91 100644 --- a/PROMS/Baseline/Program.cs +++ b/PROMS/Baseline/Program.cs @@ -16,7 +16,49 @@ namespace Baseline { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmBaseline()); + // B2018-113 Added logic to handle errors generically + if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost")) + { + Application.Run(new frmBaseline()); + } + else + { + Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + Application.Run(new frmBaseline()); + } + } + static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + MessageBox.Show((e.ExceptionObject as Exception).Message,e.ExceptionObject.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + Application.Exit(); + } + + static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) + { + // Roaming folders copied to the server when the user logs off the client computer in a Domain environment. + // Windows uses the Local folder for application data that does not roam with the user. Usually this data is + // either machine specific or too large to roam. The AppData\Local folder in Windows Vista is the same as + // the Documents and Settings\username\Local Settings\Application Data folder in Windows XP. + // Windows uses the Roaming folder for application specific data, such as custom dictionaries, which are + // machine independent and should roam with the user profile. The AppData\Roaming folder in Windows Vista + // is the same as the Documents and Settings\username\Application Data folder in Windows XP. + // SpecialFolder.LocalApplicationData returns \Local & SpecialFolder.ApplicationData returns \Roaming + // for example - the SpecialFolder: + // LocalApplicationData: C:\Users\Kathy.VOLIAN0\AppData\Local + // ApplicationData: C:\Users\Kathy.VOLIAN0\AppData\Roaming + // CommonApplicationData: C:\ProgramData + // MyDocuments: C:\Users\Kathy.VOLIAN0\Documents + + // The error log is created using log4Net. The variables that were tested were: + // - puts in document directory + // - puts in roaming directory + // - Vista - puts in local directory. !Exist for XP + + // Decided to use 'documents directory' for error log file so that it is easily accessible by user: + MessageBox.Show( e.Exception.Message,e.Exception.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + Application.Exit(); } } } diff --git a/PROMS/Baseline/frmBaseline.cs b/PROMS/Baseline/frmBaseline.cs index 3146997c..7c7f89e1 100644 --- a/PROMS/Baseline/frmBaseline.cs +++ b/PROMS/Baseline/frmBaseline.cs @@ -495,7 +495,8 @@ namespace Baseline private string OpenPDF(string line) { int page = int.Parse(line.Substring(0, 6)); - line = line.Substring(8, line.IndexOf(".S") - 8); + // B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file. + line = line.Substring(8, line.IndexOf(".S") - 8).Replace("/", "_").Replace("\\", "_"); FindFile ff = lbDifferent.SelectedItem as FindFile; FileInfo fi1 = new FileInfo(ff.File1); FileInfo fi2 = new FileInfo(ff.File2); @@ -593,7 +594,8 @@ namespace Baseline /// private void OpenOnePDF(Line myLine, int list) { - string proc = myLine.MyProc.Number; + // B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file. + string proc = myLine.MyProc.Number.Replace("/","_").Replace("\\","_"); int pagenum = myLine.MyPage.Number; FindFile ff = lbDifferent.SelectedItem as FindFile; FileInfo fi1 = new FileInfo(ff.File1);