diff --git a/PROMS/DataLoader/Procedures.cs b/PROMS/DataLoader/Procedures.cs index 28f0a82c..9b526a8f 100644 --- a/PROMS/DataLoader/Procedures.cs +++ b/PROMS/DataLoader/Procedures.cs @@ -343,7 +343,7 @@ namespace DataLoader { Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"software\dBase\dB2K"); bool retval = key != null; - key.Close(); + if(key != null)key.Close(); return retval; } diff --git a/PROMS/DataLoader/RoFst.cs b/PROMS/DataLoader/RoFst.cs index 5682df15..48b588e9 100644 --- a/PROMS/DataLoader/RoFst.cs +++ b/PROMS/DataLoader/RoFst.cs @@ -37,8 +37,19 @@ namespace DataLoader img_prefix = ele.GetAttribute("Graphics"); } } - if (roDbpath == null || roDbpath == "" || roDbpath.ToLower() == @"..\ro") - roDbpath = fstPath.Substring(0, fstPath.LastIndexOf('\\')) + @"\ro"; + DirectoryInfo di2 = new DirectoryInfo(fstPath); + roDbpath = roDbpath ?? ""; + if (roDbpath == "") + roDbpath = @"..\ro"; + while(roDbpath.StartsWith(@"..\")) + { + di2=di2.Parent; + roDbpath = roDbpath.Substring(3); + } + DirectoryInfo [] dis = di2.GetDirectories(roDbpath); + if (dis.Length > 0) roDbpath = dis[0].FullName; + //if (roDbpath == null || roDbpath == "") + // roDbpath = fstPath.Substring(0, fstPath.LastIndexOf('\\')) + @"\ro"; // first see if this rodb has been migrated (another dataset may have migrated it) rodb = RODb.GetByFolderPath(roDbpath); diff --git a/PROMS/DataLoader/Sections.cs b/PROMS/DataLoader/Sections.cs index 450db6c5..21b53252 100644 --- a/PROMS/DataLoader/Sections.cs +++ b/PROMS/DataLoader/Sections.cs @@ -615,7 +615,7 @@ namespace DataLoader string sQry = string.Format("Step like '[{0}]%' and Sequence='S'", dr["Step"].ToString().Substring(0, 1)); DataView dv = new DataView(dt, sQry, "StepNo", DataViewRowState.CurrentRows); Item FrItem = null; - frmMain.pbStepMaximum = dt.Rows.Count; + frmMain.pbStepMaximum = dt.Rows.Count-frmMain.pbSectMaximum; int type = 6; foreach (DataRowView drv in dv) { diff --git a/PROMS/DataLoader/frmLoader.cs b/PROMS/DataLoader/frmLoader.cs index 4bc7a70c..5fa97d74 100644 --- a/PROMS/DataLoader/frmLoader.cs +++ b/PROMS/DataLoader/frmLoader.cs @@ -73,7 +73,6 @@ namespace DataLoader } } private frmErrors _MyFrmErrors = null; - public frmErrors MyFrmErrors { get @@ -227,8 +226,6 @@ namespace DataLoader tn.Expand(); if (o.GetType() == typeof(DocVersion)) MySettings.ProcedureSetPath = ((DocVersion)o).Title; } - - private void btnLoadTreeDB_Click(object sender, EventArgs e) { // When loading folders, i.e. the tree from dBase (old 16-bit) @@ -247,7 +244,12 @@ namespace DataLoader public DateTime ProcessTime { get { return _ProcessTime; } - set { _ProcessTime = value; } + set + { + _ProcessTime = value; + // Set the Log File Name when the ProcessTime is set + ChangeLogFileName("LogFileAppender", MySettings.DBName + " " + ProcessTime.ToString("yyyyMMdd HHmmss") + " DMErrorLog.txt"); + } } private void btnConvert_Click(object sender, System.EventArgs e) { @@ -563,7 +565,7 @@ namespace DataLoader MySettings.GenMacFolder = Properties.Settings.Default.GenMacFolder; MySettings.LoadApproved = Properties.Settings.Default.LoadApproved; MySettings.Phase4Suffix = Properties.Settings.Default.Phase4; - + MySettings.RedPDFs = (Properties.Settings.Default.RedPDFs == CheckState.Checked); string validity = MySettings.ValidityCheck; if (validity != "") { @@ -618,6 +620,7 @@ namespace DataLoader Properties.Settings.Default.GenMacFolder = MySettings.GenMacFolder; Properties.Settings.Default.LoadApproved = MySettings.LoadApproved; Properties.Settings.Default.Phase4 = MySettings.Phase4Suffix; + Properties.Settings.Default.RedPDFs = MySettings.RedPDFs ? CheckState.Checked : CheckState.Unchecked; Properties.Settings.Default.Save(); } private void frmLoader_Load(object sender, EventArgs e) @@ -747,12 +750,30 @@ namespace DataLoader get { return _ProcessComplete; } set { _ProcessComplete = value; } } + static bool ChangeLogFileName(string AppenderName, string NewFilename) + { + log4net.Repository.ILoggerRepository RootRep; + RootRep = log4net.LogManager.GetRepository(); + foreach (log4net.Appender.IAppender iApp in RootRep.GetAppenders()) + { + if (iApp.Name.CompareTo(AppenderName) == 0 + && iApp is log4net.Appender.FileAppender) + { + log4net.Appender.FileAppender fApp = (log4net.Appender.FileAppender)iApp; + string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + fApp.File = folderPath + @"\VEPROMS\" + NewFilename; + fApp.ActivateOptions(); + return true; // Appender found and name changed to NewFilename + } + } + return false; + } private void completeToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBuilder mb = new MessageBuilder("Performing Complete Process\r\n"); ProcessFailed = false; ProcessComplete = true; ProcessTime = DateTime.Now; + MessageBuilder mb = new MessageBuilder("Performing Complete Process\r\n"); // Phase 1 - Convert dBase to SQL btnConvert_Click(this, new System.EventArgs()); if (ProcessFailed) return; @@ -788,6 +809,8 @@ namespace DataLoader Status = "Backing up Data"; Backup(""); mb.Append("Backup Complete"); + mb.LastTime = ProcessTime; // Reset time to get total time. + mb.Append("Processing Complete"); Status = "Processing Complete"; ProcessComplete = false; //Clipboard.Clear(); @@ -810,11 +833,14 @@ namespace DataLoader btnConvert_Click(this, new System.EventArgs()); if (ProcessFailed) return; MyInfo="Format Load Complete"; + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { Status = "Backing up Format Change Data"; Backup("_" + "FormatChange"); MyInfo="Format Change Backup Complete"; - Status = "Format Change Complete"; - MessageBox.Show("Format Change Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + //Status = "Format Change Complete"; + //MessageBox.Show("Format Change Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void convertDBToolStripMenuItem_Click(object sender, EventArgs e) { @@ -822,20 +848,27 @@ namespace DataLoader btnConvert_Click(this, new System.EventArgs()); if (ProcessFailed) return; MyInfo="dBase Conversion Complete"; + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { Status = "Backing up Phase 1 Data"; Backup("_" + MySettings.Phase1Suffix); MyInfo="Phase 1 Backup Complete"; - Status = "dBase Conversion Complete"; - MessageBox.Show("dBase Conversion Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + //Status = "dBase Conversion Complete"; + //MessageBox.Show("dBase Conversion Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void fixTransitionsToolStripMenuItem_Click(object sender, EventArgs e) { + Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName); ProcessTime = DateTime.Now; btnFixTransitions_Click(this, new System.EventArgs()); MyInfo="Fix Transtions Complete"; + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { Status = "Backing up Phase 2 Data"; Backup("_" + MySettings.Phase2Suffix); MyInfo="Phase 2 Backup Complete"; + } Status = "Fix Transtions Complete"; MessageBox.Show("Fix Transtions Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -844,55 +877,63 @@ namespace DataLoader ProcessTime = DateTime.Now; ConvertToChangeManager(); MyInfo="Conversion to Change Manager Complete"; + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { Status = "Backing up Phase 3 Data"; Backup("_" + MySettings.Phase3Suffix); MyInfo="Phase 3 Backup Complete"; - Status = "Conversion to Change Manager Complete"; - MessageBox.Show("Conversion to Change Manager Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + //Status = "Conversion to Change Manager Complete"; + //MessageBox.Show("Conversion to Change Manager Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void convertToApprovalToolStripMenuItem_Click(object sender, EventArgs e) { ProcessTime = DateTime.Now; ConvertToApproval(); MyInfo="Conversion to Approval Complete"; + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { Status = "Backing up Phase 4 Data"; Backup("_" + MySettings.Phase4Suffix); MyInfo="Phase 4 Backup Complete"; - Status = "Conversion to Approval Complete"; - MessageBox.Show("Conversion to Approval Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + //Status = "Conversion to Approval Complete"; + //MessageBox.Show("Conversion to Approval Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void load16BitApprovalToolStripMenuItem_Click(object sender, EventArgs e) { + Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName); ProcessTime = DateTime.Now; LoadApprovedData(); - Status = "Backing up Data"; - Backup(""); - MyInfo="Backup Complete"; - Status = "Loading 16 Bit Approval Data Complete"; - MessageBox.Show("Loading 16 Bit Approval Data Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - private void LoadApprovedData() - { - Status = "Converting 16-Bit Approved Data"; - Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName); - bool ok = ldr.BuildApprovedRevision(); - Status = "Conversion " + (ok ? "Succeeded" : "Failed"); - if (ok) + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Status = "Backing up Data"; Backup(""); MyInfo="Backup Complete"; - Status = "Processing Complete"; } + Status = "Processing Complete"; + //Status = "Loading 16 Bit Approval Data Complete"; + //MessageBox.Show("Loading 16 Bit Approval Data Complete", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + private void LoadApprovedData() + { + Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName); + Status = "Converting 16-Bit Approved Data"; + Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName); + bool ok = ldr.BuildApprovedRevision(); + Status = "Conversion " + (ok ? "Succeeded" : "Failed"); } private void fixesToolStripMenuItem_Click(object sender, EventArgs e) { FixProceduresAndFunctions(); + if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { Status = "Backing up Data"; Backup("_Fixed"); MyInfo="Backup Complete"; - Status = "Processing Complete"; - MessageBox.Show("Fixed Stored Procedures", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + //Status = "Processing Complete"; + //MessageBox.Show("Fixed Stored Procedures", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void FixProceduresAndFunctions() { @@ -984,13 +1025,16 @@ namespace DataLoader Status = String.Format("Fixing databases complete. {0} Fixed, {1} Failures", good, bad); } } - - } public class MessageBuilder { private StringBuilder _MyStringBulider=new StringBuilder(); - private DateTime _LastTime=DateTime.Now; + private DateTime _LastTime = DateTime.Now; + public DateTime LastTime + { + get { return _LastTime; } + set { _LastTime = value; } + } public MessageBuilder(string heading) { _MyStringBulider.Append(heading);