This commit is contained in:
2010-03-31 16:48:15 +00:00
parent 8d946d1f26
commit bf33f71a1a
4 changed files with 326 additions and 82 deletions

View File

@@ -134,7 +134,12 @@ namespace DataLoader
//tbSource.Text = @"G:\PromsDat\VEHP1B\SAMGS.PRC";// South Texas STPNOC
break;
default:
throw new Exception("Not configured for " + SystemInformation.ComputerName);
#if (!DEBUG)
tbSource.Text = "";
break;
#else
throw new Exception("Not configured for " + SystemInformation.ComputerName);
#endif
}
}
private void btnConvertSelected_Click(object sender, EventArgs e)
@@ -232,6 +237,11 @@ namespace DataLoader
private void btnConvert_Click(object sender, System.EventArgs e)
{
if (!CheckLogPath()) return;
#if (!DEBUG)
DialogResult dlgrst = MessageBox.Show("The VE-PROMS data currently in SQL Server (Express) will be deleted.\r\n\nProceed with Data Conversion?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dlgrst == DialogResult.No) return;
#endif
try
{
//TextConvert.ResetSpecialCharacters();
@@ -270,26 +280,34 @@ namespace DataLoader
}
if (success)
{
bool allSets = !_DeveloperMode || !cbxOnlyThisSet.Checked;
TimeSpan ts = new TimeSpan();
DocVersionInfoList vl = DocVersionInfoList.Get();
DocVersion v = null;
MyError = "Computer Name: " + SystemInformation.ComputerName.ToUpper();
foreach (DocVersionInfo vi in vl)
{
//if (vi.Title.ToUpper() == tbSource.Text.ToUpper()) // is this the procedure set we want to convert?
//{
//if (!_DeveloperMode || (cbxOnlyThisSet.Checked && vi.Title.ToUpper() == tbSource.Text.ToUpper())) // is this the procedure set we want to convert?
if (allSets || (cbxOnlyThisSet.Checked && vi.Title.ToUpper() == tbSource.Text.ToUpper())) // is this the procedure set we want to convert?
{
v = DocVersion.Get(vi.VersionID);
Status = "Load " + v.Title + " - " + v.Name;
lblCurSetFolder.Text = v.Title;
lblCurSetFolder.Visible = true;
lblProcessing.Visible = true;
MyError = "Data Set: " + v.Title;
ts += ldr.MigrateDocVersion(v, true);
//}
}
//v = DocVersion.Get(vi.VersionID);
//bool convertProcedures = (vi.Title.ToUpper() == tbSource.Text.ToUpper());
//Item itm = ldr.MigrateDocVersion(v, convertProcedures);
}
MessageBox.Show(string.Format("Conversion completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds, ts.TotalSeconds));
string ConversionTime = string.Format("Conversion completion time: {0:D2}:{1:D2}:{2:D2}.{3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
MyError = ConversionTime;
SaveLogFiles();
MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", ConversionTime, ts.TotalSeconds));
//MessageBox.Show(string.Format("Conversion completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds, ts.TotalSeconds));
//MessageBox.Show(string.Format("{0} seconds", ts.TotalSeconds));
//TextConvert.ListSpecialCharacters();
}
@@ -297,6 +315,7 @@ namespace DataLoader
catch (Exception ex)
{
AddError("===================== 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);
}
@@ -401,11 +420,6 @@ namespace DataLoader
f.ShowDialog();
}
private void tbSource_TextChanged(object sender, EventArgs e)
{
}
private void btnCtTok_Click(object sender, EventArgs e)
{
frmCntTkn frm = new frmCntTkn();
@@ -454,18 +468,23 @@ namespace DataLoader
this.cbSaveRTF.CheckState = Properties.Settings.Default.LoadRTFDoc;
if (Properties.Settings.Default["VePromsFilename"] != null)
this.tbVePromsPath.Text = Properties.Settings.Default.VePromsFilename;
if (Properties.Settings.Default["LogFileLoc"].ToString() != "")
this.txbLogFileLoc.Text = Properties.Settings.Default.LogFileLoc;
if (Properties.Settings.Default["BackupFileName"].ToString() != "")
this.tbxBackupFileName.Text = Properties.Settings.Default.BackupFileName;
_Loading = false;
}
private void frmLoader_FormClosing(object sender, FormClosingEventArgs e)
{
TextConvert.MyGlitches.Save(@"C:\Temp\ConversionGlitches.xml");
Properties.Settings.Default.VeSamFilename = tbVesamPath.Text;
Properties.Settings.Default.DbfPathname = tbSource.Text;
Properties.Settings.Default.LoadWordDoc = cbSaveDoc.CheckState;
Properties.Settings.Default.LoadRTFDoc = cbSaveRTF.CheckState;
Properties.Settings.Default.PurgeData = cbPurgeData.CheckState;
Properties.Settings.Default.VePromsFilename = tbVePromsPath.Text;
Properties.Settings.Default.LogFileLoc = txbLogFileLoc.Text;
Properties.Settings.Default.BackupFileName = tbxBackupFileName.Text;
Properties.Settings.Default.Save();
}
private void btnBrowseVeProms_Click(object sender, EventArgs e)
@@ -482,16 +501,118 @@ namespace DataLoader
private void btnFixTransitions_Click(object sender, EventArgs e)
{
if (!CheckLogPath()) return;
StepRTB rtb = new StepRTB();
TransitionFixer myFixer = new TransitionFixer(rtb);
TransitionFixer myFixer = new TransitionFixer(rtb,_LogFilePath);
myFixer.StatusChanged += new TransitionFixerEvent(myFixer_StatusChanged);
TimeSpan howlong = myFixer.Process();
MessageBox.Show(string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds, howlong.TotalSeconds));
string TransFixTime = string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds);
MyError = TransFixTime;
MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", TransFixTime, howlong.TotalSeconds));
//MessageBox.Show(string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds, howlong.TotalSeconds));
CreateBackupRestoreBatchFiles();
}
void myFixer_StatusChanged(object sender, TransitionFixerEventArgs args)
{
Status = args.MyStatus;
}
private bool _DeveloperMode = false;
private void ToggleDeveloperMode()
{
DialogResult dr = MessageBox.Show((_DeveloperMode)?"Make the User Interface Less Confusing?":"Make the User Interface More Confusing?", "DataLoader UI", MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
_DeveloperMode = !_DeveloperMode;
btnLoadTreeDB.Visible = _DeveloperMode;
btnLoadTreeCSLA.Visible = _DeveloperMode;
btnVETree_CSLA.Visible = _DeveloperMode;
btnGroup.Visible = _DeveloperMode;
btnCtTok.Visible = _DeveloperMode;
btnVesam.Visible = _DeveloperMode;
tbVesamPath.Visible = _DeveloperMode;
btnBrowseVesam.Visible = _DeveloperMode;
tbSource.Visible = _DeveloperMode;
btnBrowse.Visible = _DeveloperMode;
cbSaveDoc.Visible = _DeveloperMode;
cbSaveRTF.Visible = _DeveloperMode;
cbPurgeData.Visible = _DeveloperMode;
cbLazy.Visible = _DeveloperMode;
cbFormatsOnly.Visible = _DeveloperMode;
btnConvertSelected.Visible = _DeveloperMode;
cbxOnlyThisSet.Visible = _DeveloperMode;
}
}
private void sc_Panel1_DoubleClick(object sender, EventArgs e)
{
ToggleDeveloperMode();
}
private void LogLoc_Click(object sender, EventArgs e)
{
fbd.SelectedPath = txbLogFileLoc.Text;
if (fbd.ShowDialog() == DialogResult.OK)
txbLogFileLoc.Text = fbd.SelectedPath;
}
private bool _DidLogPathCheck = false;
private string _LogFilePath = "";
private bool CheckLogPath()
{
bool rtn = false;
if (_DidLogPathCheck) return true;
try
{
_LogFilePath = txbLogFileLoc.Text;
if (!Directory.Exists(_LogFilePath))
Directory.CreateDirectory(_LogFilePath);
if (_LogFilePath.EndsWith(@"\")) _LogFilePath = _LogFilePath.Substring(0, _LogFilePath.Length - 1);
rtn = true;
_DidLogPathCheck = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Invalid Path for Log Files", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return rtn;
}
private void SaveLogFiles()
{
if (_LogFilePath == "") return;
// Save the Glitches log
if (TextConvert.MyGlitches.Glitches.Count > 0)
TextConvert.MyGlitches.Save(_LogFilePath + @"\ConversionGlitches.xml");
// Save the Error Log
if (_MyFrmErrors.ItemCount() > 0)
_MyFrmErrors.Save(_LogFilePath + @"\ConversionErrors.txt");
}
private bool _EnteredFileLoc = false;
private void txbLogFileLoc_TextChanged(object sender, EventArgs e)
{
_DidLogPathCheck = false;
}
private void CreateBackupRestoreBatchFiles()
{
string pause = "pause";
string bckupFileName = tbxBackupFileName.Text;
if (!bckupFileName.EndsWith(".bck")) bckupFileName += ".bck";
string backupPath = _LogFilePath + @"\" + bckupFileName;
string bckupcmd = "sqlcmd -E -S.\\sqlexpress -Q \"backup database [VEPROMS] to disk = '" + backupPath + "'\"";
string rstorecmd = "sqlcmd -E -S.\\sqlexpress -Q \"restore database [VEPROMS] from disk = '" + backupPath + "'\"";
StreamWriter fsbackup = new StreamWriter(_LogFilePath + @"\BackupVEPROMS.bat");
fsbackup.WriteLine(bckupcmd);
fsbackup.WriteLine(pause);
fsbackup.Close();
StreamWriter fsrestore = new StreamWriter(_LogFilePath + @"\RestoreVEPROMS.bat");
fsrestore.WriteLine(rstorecmd);
fsrestore.WriteLine(pause);
fsrestore.Close();
}
}
}