From 04d3770f40ff5ff6716d50262ffa6c7feb7920e0 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 6 Aug 2019 19:36:47 +0000 Subject: [PATCH] B2019-106 Added Error Handling to code that opens PDF file --- .../frmPDFStatusForm.cs | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs index 0dc5a6bc..11aa54ad 100644 --- a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs +++ b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs @@ -239,35 +239,43 @@ namespace VEPROMS // - requested by Calvert Cliffs private void OpenPDFandPlacekeeper(string pdffile) { - if ((pdffile ?? "") != "" && !OnlyShowContinuousActionSummary) + try // B2019-106 Error Handling for PDF Open { - System.Diagnostics.Process sdp = System.Diagnostics.Process.Start(pdffile); - sdp.WaitForInputIdle(); + if ((pdffile ?? "") != "" && !OnlyShowContinuousActionSummary) + { + System.Diagnostics.Process sdp = System.Diagnostics.Process.Start(pdffile); + if (sdp != null) + sdp.WaitForInputIdle(); + } + if (OnlyShowContinuousActionSummary) + System.IO.File.Delete(pdffile); // remove the temporary PDF file used to create the Continuous Action Summary + if (MyPromsPrinter.MyPlacekeeper != null) + { + // The PlacekeeperDelay is a switch that can be added to the PROMS.exe shortcut + // ex: VEPROMS.EXE /PlacekeeperDelay=2.5 will delay it 2 1/2 seconds + float delay = Volian.Base.Library.VlnSettings.GetCommandFloat("PlacekeeperDelay", 3.0f); + int mydelay = (int)(1000 * delay); + System.Threading.Thread.Sleep(mydelay); + MyPromsPrinter.MyPlacekeeper.Visible(); + } + // this will display the generated Continuous Action Summary in MS Word (starting a new instance of MS Word outside of PROMS) + if (MyPromsPrinter.MyContActSummary != null) + { + string instructions = "The Continuous Action Summary will be opened in MS Word.\n\nYou can make modifications and copy it into a PROMS Word section."; + MessageBox.Show(instructions, "Continuous Action Summary"); + // The ContActSummaryDelay is a switch that can be added to the PROMS.exe shortcut + // ex: VEPROMS.EXE /ContActSummaryDelay=2.5 will delay it 2 1/2 seconds + float delay = Volian.Base.Library.VlnSettings.GetCommandFloat("ContActSummaryDelay", 1.0f); + int mydelay = (int)(1000 * delay); + System.Threading.Thread.Sleep(mydelay); + MyPromsPrinter.MyContActSummary.Visible(); + } } - if (OnlyShowContinuousActionSummary) - System.IO.File.Delete(pdffile); // remove the temporary PDF file used to create the Continuous Action Summary - if (MyPromsPrinter.MyPlacekeeper != null) + catch (Exception ex) { - // The PlacekeeperDelay is a switch that can be added to the PROMS.exe shortcut - // ex: VEPROMS.EXE /PlacekeeperDelay=2.5 will delay it 2 1/2 seconds - float delay = Volian.Base.Library.VlnSettings.GetCommandFloat("PlacekeeperDelay", 3.0f); - int mydelay =(int) (1000 * delay); - System.Threading.Thread.Sleep(mydelay); - MyPromsPrinter.MyPlacekeeper.Visible(); + string str = string.Format("{0} - {1} - {2}",pdffile,ex.GetType().Name,ex.Message); + MessageBox.Show(str, "Error Opening PDFFile", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } - // this will display the generated Continuous Action Summary in MS Word (starting a new instance of MS Word outside of PROMS) - if (MyPromsPrinter.MyContActSummary != null) - { - string instructions = "The Continuous Action Summary will be opened in MS Word.\n\nYou can make modifications and copy it into a PROMS Word section."; - MessageBox.Show(instructions, "Continuous Action Summary"); - // The ContActSummaryDelay is a switch that can be added to the PROMS.exe shortcut - // ex: VEPROMS.EXE /ContActSummaryDelay=2.5 will delay it 2 1/2 seconds - float delay = Volian.Base.Library.VlnSettings.GetCommandFloat("ContActSummaryDelay", 1.0f); - int mydelay = (int)(1000 * delay); - System.Threading.Thread.Sleep(mydelay); - MyPromsPrinter.MyContActSummary.Visible(); - } - } private void btnOpenFolder_Click(object sender, EventArgs e) {