From 1741b0e3e02a95d92531c791b30f671e90e6fe12 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 21 Apr 2010 20:53:31 +0000 Subject: [PATCH] Moved MS Word Terminate code to WordDoc.cs Added a new parameter to SaveWordDoc call --- PROMS/DataLoader/LibDoc.cs | 2 +- PROMS/DataLoader/frmLoader.cs | 24 ++++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/PROMS/DataLoader/LibDoc.cs b/PROMS/DataLoader/LibDoc.cs index ebb42d75..f7bf71dc 100644 --- a/PROMS/DataLoader/LibDoc.cs +++ b/PROMS/DataLoader/LibDoc.cs @@ -71,7 +71,7 @@ namespace DataLoader string title = null; // for docname, remove the '.lib', i.e. substring(0,8) DateTime dts = DateTime.Now; string tmpRtfFileName = GetLibDocData(fi, ci, ref title); - int Docid = SaveWordDoc(tmpRtfFileName, title, null, ci); + int Docid = SaveWordDoc(tmpRtfFileName, title, null, ci, string.Empty); File.Delete(tmpRtfFileName); return Docid; } diff --git a/PROMS/DataLoader/frmLoader.cs b/PROMS/DataLoader/frmLoader.cs index e8996991..997a2e6b 100644 --- a/PROMS/DataLoader/frmLoader.cs +++ b/PROMS/DataLoader/frmLoader.cs @@ -95,6 +95,7 @@ namespace DataLoader while (ex != null) { sb.Append("\r\n" + "".PadRight((++indent)*2,' ') + string.Format("{0} - {1}",ex.GetType().Name,ex.Message)); + sb.Append(ex.StackTrace); ex=ex.InnerException; } MyError = sb.ToString(); @@ -227,13 +228,6 @@ namespace DataLoader ldr.ClearData(); bool suc = ldr.LoadFolders(tbVePromsPath.Text); } - private System.Diagnostics.Process [] WordProcesses - { - get - { - return System.Diagnostics.Process.GetProcessesByName("WINWORD"); - } - } private void btnConvert_Click(object sender, System.EventArgs e) { @@ -245,14 +239,14 @@ namespace DataLoader try { //TextConvert.ResetSpecialCharacters(); - System.Diagnostics.Process[] wordProcesses = WordProcesses; + System.Diagnostics.Process[] wordProcesses = WordDoc.WordProcesses; MyFrmErrors.Clear(); if (wordProcesses.Length > 0) { AddError("{0} copies of MS Word are running", wordProcesses.Length); if (MessageBox.Show("MS Word is Running and must be stopped before proceeding.\n\nStop MS Word?", "MS Word is Running", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - TerminateProcesses(wordProcesses); + WordDoc.TerminateProcesses(wordProcesses); MyFrmErrors.Clear(); } else @@ -314,23 +308,13 @@ namespace DataLoader } catch (Exception ex) { - AddError("===================== Fatal Error ==========================\r\n{0} - {1}", ex.GetType().Name, ex.Message); + AddError(ex,"===================== Fatal Error ==========================\r\n{0} - {1}", ex.GetType().Name, ex.Message); SaveLogFiles(); MessageBox.Show(ex.Message, "Fatal Error During Loading", MessageBoxButtons.OK, MessageBoxIcon.Error); _MyLog.Fatal(ex.Message); } } - private void TerminateProcesses(System.Diagnostics.Process [] wordProcesses) - { - foreach (System.Diagnostics.Process proc in wordProcesses) - { - // TODO: Determine if Word is Visible - // If it is let it run - // otherwise Kill it. - proc.Kill(); - } - } public void UpdateLabels(int incPrc, int incSec, int incStp) { if (incPrc == 0 && incSec == 0 && incStp == 0)//Reset