From 211e8b086c1967cd30d1dc5dc8bb6fec5a588926 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 6 Feb 2009 15:58:25 +0000 Subject: [PATCH] Added try/catch logic to code that loads formats Add defaults for user configuration data --- PROMS/DataLoader/App.config | 35 ++++++++++++++++++++++++++++++----- PROMS/DataLoader/Formats.cs | 35 +++++++++++++++++++++++++---------- PROMS/DataLoader/frmLoader.cs | 11 +++++------ 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/PROMS/DataLoader/App.config b/PROMS/DataLoader/App.config index db5d0213..3138c1ff 100644 --- a/PROMS/DataLoader/App.config +++ b/PROMS/DataLoader/App.config @@ -2,6 +2,9 @@
+ +
+ @@ -15,7 +18,7 @@ - + @@ -41,7 +44,7 @@ - + @@ -64,8 +67,30 @@ - + + + + + + + + + + + Checked + + + Unchecked + + + Checked + + + + + + diff --git a/PROMS/DataLoader/Formats.cs b/PROMS/DataLoader/Formats.cs index 7b7df56f..20110a70 100644 --- a/PROMS/DataLoader/Formats.cs +++ b/PROMS/DataLoader/Formats.cs @@ -88,20 +88,35 @@ namespace DataLoader foreach (FileInfo fi in fis) { bool issub = (fi.Name.IndexOf("_") > 0) ? true : false; - if (!issub && fi.Name.ToLower()!="baseall.xml") + if (!issub && fi.Name.ToLower() != "baseall.xml") { string fmtname = fi.Name.Substring(0, fi.Name.Length - 7); // remove the all.xml part of the filename. - parent = AddFormatToDB(basefmt, fmtname, issub, DateTime.Now, "Migration"); - - // now see if there are any subformats associated with this, if so - // add them here... - DirectoryInfo sdi = new DirectoryInfo("c:\\development\\fmtall"); - FileInfo[] sfis = di.GetFiles(fmtname+"_*.xml"); - foreach (FileInfo sfi in sfis) + try { - string nm = sfi.Name.Substring(0, sfi.Name.Length-7); - Format subfmt = AddFormatToDB(parent, nm, true, DateTime.Now, "Migration"); + parent = AddFormatToDB(basefmt, fmtname, issub, DateTime.Now, "Migration"); + + // now see if there are any subformats associated with this, if so + // add them here... + DirectoryInfo sdi = new DirectoryInfo("c:\\development\\fmtall"); + FileInfo[] sfis = di.GetFiles(fmtname + "_*.xml"); + foreach (FileInfo sfi in sfis) + { + string nm = sfi.Name.Substring(0, sfi.Name.Length - 7); + Console.WriteLine("Processing {0}", sfi.Name); + try + { + Format subfmt = AddFormatToDB(parent, nm, true, DateTime.Now, "Migration"); + } + catch (Exception ex) + { + Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); + } + } + } + catch (Exception ex) + { + Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); } } } diff --git a/PROMS/DataLoader/frmLoader.cs b/PROMS/DataLoader/frmLoader.cs index 673226f2..821a0ffa 100644 --- a/PROMS/DataLoader/frmLoader.cs +++ b/PROMS/DataLoader/frmLoader.cs @@ -345,15 +345,15 @@ namespace DataLoader private void frmLoader_Load(object sender, EventArgs e) { - if (Properties.Settings.Default["VeSamFilename"] != null) + if (Properties.Settings.Default["VeSamFilename"].ToString() != "") this.tbVesamPath.Text = Properties.Settings.Default.VeSamFilename; - if (Properties.Settings.Default["DbfPathname"] != null) + if (Properties.Settings.Default["DbfPathname"].ToString() != "") this.tbSource.Text = Properties.Settings.Default.DbfPathname; - if (Properties.Settings.Default["LoadWordDoc"] != null) + if (Properties.Settings.Default["LoadWordDoc"].ToString() != "") this.cbSaveDoc.CheckState = Properties.Settings.Default.LoadWordDoc; - if (Properties.Settings.Default["PurgeData"] != null) + if (Properties.Settings.Default["PurgeData"].ToString() != "") this.cbPurgeData.CheckState = Properties.Settings.Default.PurgeData; - if (Properties.Settings.Default["LoadRTFDoc"] != null) + if (Properties.Settings.Default["LoadRTFDoc"].ToString() != "") this.cbSaveRTF.CheckState = Properties.Settings.Default.LoadRTFDoc; if (Properties.Settings.Default["VePromsFilename"] != null) this.tbVePromsPath.Text = Properties.Settings.Default.VePromsFilename; @@ -370,7 +370,6 @@ namespace DataLoader Properties.Settings.Default.VePromsFilename = tbVePromsPath.Text; Properties.Settings.Default.Save(); } - private void btnBrowseVeProms_Click(object sender, EventArgs e) { fbd.SelectedPath = tbVePromsPath.Text;