Sql Script to Build Empty VE-PROMS Database
Use new settings (ConvertTo and ExecutableMode) New Settings Use new setting (PDF Folder) Use and Control new settings
This commit is contained in:
@@ -33,23 +33,24 @@ using Volian.Base.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class frmLoader : Form
|
||||
{
|
||||
#region Log4Net
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#region Log4Net
|
||||
public static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region settings
|
||||
private bool _FormatsOnly = false;
|
||||
public bool FormatsOnly
|
||||
{
|
||||
get { return _FormatsOnly; }
|
||||
set { _FormatsOnly = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
private bool _Loading = true;
|
||||
private bool _Loading = true;
|
||||
|
||||
private FolderTreeNode _topnode;
|
||||
private bool UseVeTree = false;
|
||||
#region Log4Net
|
||||
public static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
private Loader ldr;
|
||||
public bool cbSaveDocChecked { get { return cbSaveDoc.Checked; } }
|
||||
public bool cbSaveRTFChecked { get { return cbSaveRTF.Checked; } }
|
||||
public TreeView TV { get { return tv; } }
|
||||
public int pbProcMaximum { get { return pbProc.Maximum; } set { pbProc.Maximum = value; } }
|
||||
public int pbSectMaximum { get { return pbSect.Maximum; } set { pbSect.Maximum = value; } }
|
||||
@@ -59,17 +60,7 @@ namespace DataLoader
|
||||
public int pbProcValue { get { return pbProc.Value; } set { pbProc.Value = value; } }
|
||||
public int SkipProcedures
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return int.Parse(tbSkip.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
get { return MySettings.Skip; }
|
||||
}
|
||||
public string Status
|
||||
{
|
||||
@@ -104,7 +95,7 @@ namespace DataLoader
|
||||
set
|
||||
{
|
||||
MyFrmErrors.Add(value);
|
||||
log.ErrorFormat(value);
|
||||
_MyLog.ErrorFormat(value);
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.MyErrors.Count); }
|
||||
}
|
||||
public string MyWarning
|
||||
@@ -113,7 +104,7 @@ namespace DataLoader
|
||||
set
|
||||
{
|
||||
MyFrmErrors.Add(value);
|
||||
log.WarnFormat(value);
|
||||
_MyLog.WarnFormat(value);
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.MyErrors.Count);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +114,7 @@ namespace DataLoader
|
||||
set
|
||||
{
|
||||
MyFrmErrors.Add(value);
|
||||
log.InfoFormat(value);
|
||||
_MyLog.InfoFormat(value);
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.MyErrors.Count);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +142,6 @@ namespace DataLoader
|
||||
}
|
||||
MyError = sb.ToString();
|
||||
}
|
||||
public string tbSourceText { get { return tbSource.Text; } set { tbSource.Text = value; } }
|
||||
|
||||
public frmLoader()
|
||||
{
|
||||
@@ -159,50 +149,6 @@ namespace DataLoader
|
||||
InitializeComponent();
|
||||
MSWordToPDF.FormForPlotGraphics = this;
|
||||
lblTime.Tag = DateTime.Now;
|
||||
switch (SystemInformation.ComputerName.ToUpper())
|
||||
{
|
||||
case "KATHYXP":
|
||||
//tbSource.Text = "G:\\VEIP2\\PROCS"; // basic data
|
||||
//tbSource.Text = "G:\\VEFNP\\AOP1.PRC"; // test subsections, checkoffs, comments & continuous action flag
|
||||
//tbSource.Text = "G:\\vecal\\eops.bck"; // test link seq STP_LNK_SEQ
|
||||
tbSource.Text = "G:\\vehlp\\procs";// G:\\vewcnckl\\ckl.prc - multiple change ids.
|
||||
break;
|
||||
case "KATHY-VISTA":
|
||||
tbSource.Text = @"c:\16bit\debug\vehlp\procs";// G:\\vewcnckl\\ckl.prc - multiple change ids.
|
||||
break;
|
||||
case "RHMDESKTOP":
|
||||
//tbSource.Text = @"I:\UNZIPPED ACTIVE BASELINE DATA\vehlp\Procs"; // Sub-sections
|
||||
tbSource.Text = @"I:\veDATA\vehlp\Procs"; // Sub-sections
|
||||
break;
|
||||
case "RMARK-PC":
|
||||
//tbSource.Text = @"I:\UNZIPPED ACTIVE BASELINE DATA\vehlp\Procs"; // Sub-sections
|
||||
tbSource.Text = @"C:\VE_PROMS Data\Plant\HLP\vehlp\Procs"; // Sub-sections
|
||||
break;
|
||||
case "JOHN":
|
||||
tbSource.Text = @"G:\PROMSDAT\vehlp\procs";// South Texas EOPS
|
||||
//tbSource.Text = @"G:\PromsDat\VEHP1B\SAMGS.PRC";// South Texas STPNOC
|
||||
break;
|
||||
case "JOHN-VISTA":
|
||||
tbSource.Text = @"C:\16bit\PROMSDAT\vehlp\procs";// South Texas EOPS
|
||||
//tbSource.Text = @"G:\PromsDat\VEHP1B\SAMGS.PRC";// South Texas STPNOC
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!VlnSettings.DebugMode)
|
||||
tbSource.Text = "";
|
||||
// if in debug mode, pdf output is red (checkbox1 is what controls this).
|
||||
checkBox1.Checked = VlnSettings.DebugMode;
|
||||
if (checkBox1.Checked)
|
||||
{
|
||||
MSWordToPDF.DebugStatus = 1;
|
||||
Loader.OverrideColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSWordToPDF.DebugStatus = 0;
|
||||
Loader.OverrideColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
private void btnConvertSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -278,7 +224,7 @@ namespace DataLoader
|
||||
TreeNode tn = e.Node;
|
||||
object o = tn.Tag;
|
||||
tn.Expand();
|
||||
if (o.GetType() == typeof(DocVersion)) tbSource.Text = ((DocVersion)o).Title;
|
||||
if (o.GetType() == typeof(DocVersion)) MySettings.ProcedureSetPath = ((DocVersion)o).Title;
|
||||
}
|
||||
|
||||
|
||||
@@ -287,12 +233,39 @@ namespace DataLoader
|
||||
// When loading folders, i.e. the tree from dBase (old 16-bit)
|
||||
// always clear the data
|
||||
ldr.ClearData();
|
||||
bool suc = ldr.LoadFolders(tbVePromsPath.Text);
|
||||
bool suc = ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
}
|
||||
private string GetScript(string scriptName)
|
||||
{
|
||||
StreamReader sr = File.OpenText(Application.StartupPath + "\\" + scriptName);
|
||||
string myScript = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
return myScript;
|
||||
}
|
||||
private DateTime _ProcessTime;
|
||||
public DateTime ProcessTime
|
||||
{
|
||||
get { return _ProcessTime; }
|
||||
set { _ProcessTime = value; }
|
||||
}
|
||||
|
||||
private void btnConvert_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (!CheckLogPath()) return;
|
||||
// Set Connection String
|
||||
Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName);
|
||||
// Setup based upon RedPDF Setting
|
||||
// if in debug mode, pdf output is red
|
||||
VlnSettings.DebugMode = (MySettings.ExecutionMode == ExecutionMode.Debug) && MySettings.RedPDFs;
|
||||
if (VlnSettings.DebugMode) // Debug Mode
|
||||
{
|
||||
MSWordToPDF.DebugStatus = 1;
|
||||
Loader.OverrideColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSWordToPDF.DebugStatus = 0;
|
||||
Loader.OverrideColor = Color.Empty;
|
||||
}
|
||||
//if (!CheckLogPath()) return;
|
||||
//#if (!DEBUG)
|
||||
if (!VlnSettings.DebugMode)
|
||||
{
|
||||
@@ -304,8 +277,8 @@ namespace DataLoader
|
||||
{
|
||||
//TextConvert.ResetSpecialCharacters();
|
||||
System.Diagnostics.Process[] wordProcesses = WordDoc.WordProcesses;
|
||||
MyFrmErrors.Clear();
|
||||
if (cbFormatsOnly.Checked == false && wordProcesses.Length > 0)
|
||||
//MyFrmErrors.Clear();
|
||||
if (!FormatsOnly && 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)
|
||||
@@ -318,7 +291,7 @@ namespace DataLoader
|
||||
}
|
||||
Database.LoggingInfo = false;
|
||||
bool success = true;
|
||||
if (cbFormatsOnly.Checked)
|
||||
if (FormatsOnly)
|
||||
{
|
||||
// ASSUMES No Formats/genmacs exist in database.
|
||||
MessageBox.Show(@"Format files are taken from c:\development\fmtall");
|
||||
@@ -328,30 +301,32 @@ namespace DataLoader
|
||||
MessageBox.Show("Formats Loaded");
|
||||
return;
|
||||
}
|
||||
// Create Database
|
||||
RunScript("BuildVEPROMS.Sql", "Master");
|
||||
RunScript("PROMS2010.SQL", MySettings.DBName);
|
||||
// if purge data, purge it all & reload folders & security.
|
||||
if (cbPurgeData.Checked)
|
||||
if (MySettings.PurgeExistingData)
|
||||
{
|
||||
Status = "Purging Data";
|
||||
ldr.ClearData();
|
||||
Status = "Loading Folders";
|
||||
success = ldr.LoadFolders(tbVePromsPath.Text);
|
||||
success = ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
if (success)
|
||||
{
|
||||
Status = "Loading Security";
|
||||
success = ldr.LoadSecurity(tbVesamPath.Text, tbVePromsPath.Text);
|
||||
success = ldr.LoadSecurity(MySettings.VESamFile, MySettings.VEPromsPath);
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
bool allSets = !_DeveloperMode || !cbxOnlyThisSet.Checked;
|
||||
bool allSets = !_DeveloperMode || !MySettings.OnlyThisSet;
|
||||
TimeSpan ts = new TimeSpan();
|
||||
DocVersionInfoList vl = DocVersionInfoList.Get();
|
||||
DocVersion v = null;
|
||||
MyInfo = "Computer Name: " + SystemInformation.ComputerName.ToUpper();
|
||||
foreach (DocVersionInfo vi in vl)
|
||||
{
|
||||
//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?
|
||||
if (allSets || (MySettings.OnlyThisSet && vi.Title.ToUpper() == MySettings.ProcedureSetPath.ToUpper())) // is this the procedure set we want to convert?
|
||||
{
|
||||
v = DocVersion.Get(vi.VersionID);
|
||||
Status = "Load " + v.Title + " - " + v.Name;
|
||||
@@ -361,15 +336,11 @@ namespace DataLoader
|
||||
MyInfo = "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);
|
||||
|
||||
}
|
||||
string ConversionTime = string.Format("Conversion completion time: {0:D2}:{1:D2}:{2:D2}.{3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
|
||||
MyInfo = ConversionTime;
|
||||
SaveLogFiles();
|
||||
MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", ConversionTime, ts.TotalSeconds));
|
||||
if(!ProcessComplete) 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();
|
||||
@@ -384,6 +355,26 @@ namespace DataLoader
|
||||
}
|
||||
}
|
||||
|
||||
private void RunScript(string scriptName, string dbName)
|
||||
{
|
||||
string script = GetScript(scriptName);
|
||||
script=script.Replace("{DBName}", MySettings.DBName);
|
||||
script=script.Replace("{DBPath}", MySettings.DBPath);
|
||||
SQLScriptRunner ssr = new SQLScriptRunner(script, MySettings.ConnectionString.Replace("{DBName}", dbName));
|
||||
ssr.InfoMessage += new SQLScriptRunnerEvent(ssr_InfoMessage);
|
||||
ssr.Run();
|
||||
}
|
||||
private void Backup(string suffix)
|
||||
{
|
||||
SQLScriptRunner ssrbu = new SQLScriptRunner(MySettings.DBName, MySettings.BackupFolder,
|
||||
MySettings.ConnectionString.Replace("{DBName}", "Master"), ProcessTime, suffix);
|
||||
ssrbu.InfoMessage += new SQLScriptRunnerEvent(ssr_InfoMessage);
|
||||
ssrbu.Run();
|
||||
}
|
||||
void ssr_InfoMessage(object sender, System.Data.SqlClient.SqlInfoMessageEventArgs args)
|
||||
{
|
||||
MyInfo = args.Message;
|
||||
}
|
||||
public void UpdateLabels(int incPrc, int incSec, int incStp)
|
||||
{
|
||||
if (incPrc == 0 && incSec == 0 && incStp == 0)//Reset
|
||||
@@ -418,22 +409,6 @@ namespace DataLoader
|
||||
lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
|
||||
Application.DoEvents();
|
||||
}
|
||||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
fbd.SelectedPath = tbSource.Text;
|
||||
if (fbd.ShowDialog() == DialogResult.OK)
|
||||
tbSource.Text = fbd.SelectedPath;
|
||||
}
|
||||
private void cbSaveRTF_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (cbSaveRTF.Checked) cbSaveDoc.Checked = false;
|
||||
}
|
||||
private void cbSaveDoc_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (cbSaveDoc.Checked) cbSaveRTF.Checked = false;
|
||||
}
|
||||
|
||||
|
||||
private void btnLoadTreeCSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
_topnode = FolderTreeNode.BuildTreeList();
|
||||
@@ -441,24 +416,15 @@ namespace DataLoader
|
||||
tv.Nodes[0].Expand();
|
||||
UseVeTree = false;
|
||||
}
|
||||
|
||||
private void btnBrowseVesam_Click(object sender, EventArgs e)
|
||||
{
|
||||
fbd.SelectedPath = tbVesamPath.Text;
|
||||
if (fbd.ShowDialog() == DialogResult.OK)
|
||||
tbVesamPath.Text = fbd.SelectedPath;
|
||||
}
|
||||
|
||||
|
||||
private void btnVesam_Click(object sender, EventArgs e)
|
||||
{
|
||||
// if purge data, purge it all & reload folders.
|
||||
if (cbPurgeData.Checked)
|
||||
if (MySettings.PurgeExistingData)
|
||||
{
|
||||
ldr.ClearData();
|
||||
ldr.LoadFolders(tbVePromsPath.Text);
|
||||
ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
}
|
||||
bool sec = ldr.LoadSecurity(tbVesamPath.Text, tbVePromsPath.Text);
|
||||
bool sec = ldr.LoadSecurity(MySettings.VESamFile, MySettings.VEPromsPath);
|
||||
}
|
||||
|
||||
private void btnVETree_CSLA_Click(object sender, EventArgs e)
|
||||
@@ -506,63 +472,117 @@ namespace DataLoader
|
||||
lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
private DataLoaderSettings _MySettings;
|
||||
internal DataLoaderSettings MySettings
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_MySettings==null)
|
||||
_MySettings=new DataLoaderSettings();
|
||||
return _MySettings;
|
||||
}
|
||||
set { _MySettings = value; }
|
||||
}
|
||||
private void LoadSettings()
|
||||
{
|
||||
Console.WriteLine("Start");
|
||||
if (Properties.Settings.Default["VePromsFilename"].ToString() != "")
|
||||
MySettings.VEPromsPath = Properties.Settings.Default.VePromsFilename;
|
||||
if (Properties.Settings.Default["VeSamFilename"].ToString() != "")
|
||||
MySettings.VESamFile = Properties.Settings.Default.VeSamFilename;
|
||||
if (Properties.Settings.Default["DbfPathname"].ToString() != "")
|
||||
MySettings.ProcedureSetPath = Properties.Settings.Default.DbfPathname;
|
||||
if (Properties.Settings.Default["BackupFileName"].ToString() != "")
|
||||
MySettings.BackupFileName = Properties.Settings.Default.BackupFileName;
|
||||
if (Properties.Settings.Default["BackupFolder"].ToString() != "")
|
||||
MySettings.BackupFolder = Properties.Settings.Default.BackupFolder;
|
||||
if (Properties.Settings.Default["LogFileLoc"].ToString() != "")
|
||||
MySettings.LogFilePath = Properties.Settings.Default.LogFileLoc;
|
||||
if (Properties.Settings.Default["ConnectionString"].ToString() != "")
|
||||
MySettings.ConnectionString = Properties.Settings.Default.ConnectionString;
|
||||
if (Properties.Settings.Default["DBName"].ToString() != "")
|
||||
MySettings.DBName = Properties.Settings.Default.DBName;
|
||||
if (Properties.Settings.Default["DBPath"].ToString() != "")
|
||||
MySettings.DBPath = Properties.Settings.Default.DBPath;
|
||||
MySettings.PurgeExistingData = (Properties.Settings.Default.PurgeData == CheckState.Checked);
|
||||
if (Properties.Settings.Default["PDFFolder"].ToString() != "")
|
||||
MySettings.PDFFolder = Properties.Settings.Default.PDFFolder;
|
||||
MySettings.OnlyThisSet = (Properties.Settings.Default.OnlyThisSet == CheckState.Checked);
|
||||
MySettings.CheckRTF = (Properties.Settings.Default.CheckRTF == CheckState.Checked);
|
||||
MySettings.Skip = Properties.Settings.Default.Skip;
|
||||
MySettings.ConvertTo = (AccPageConversion) Properties.Settings.Default.ConvertTo;
|
||||
MySettings.ExecutionMode = (ExecutionMode)Properties.Settings.Default.ExecutionMode;
|
||||
MySettings.Phase1Suffix = Properties.Settings.Default.Phase1;
|
||||
MySettings.Phase2Suffix = Properties.Settings.Default.Phase2;
|
||||
MySettings.Phase3Suffix = Properties.Settings.Default.Phase3;
|
||||
string validity = MySettings.ValidityCheck;
|
||||
if (validity != "")
|
||||
{
|
||||
MessageBox.Show(validity, "Settings Incorrect", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
OpenSettings();
|
||||
}
|
||||
}
|
||||
private void OpenSettings()
|
||||
{
|
||||
DataLoaderSettings tmpDLS = (DataLoaderSettings) MySettings.Clone();
|
||||
frmPG myPG = new frmPG("Data Loader Settings", tmpDLS);
|
||||
if (myPG.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
MySettings = tmpDLS;
|
||||
SaveSettings();
|
||||
}
|
||||
string validity = MySettings.ValidityCheck;
|
||||
if (validity != "")
|
||||
{
|
||||
processToolStripMenuItem.Enabled = false;
|
||||
oldToolStripMenuItem.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
processToolStripMenuItem.Enabled = true;
|
||||
oldToolStripMenuItem.Enabled = true;
|
||||
}
|
||||
}
|
||||
private void SaveSettings()
|
||||
{
|
||||
Properties.Settings.Default.DbfPathname = MySettings.ProcedureSetPath;
|
||||
Properties.Settings.Default.VePromsFilename = MySettings.VEPromsPath;
|
||||
Properties.Settings.Default.VeSamFilename = MySettings.VESamFile;
|
||||
Properties.Settings.Default.DbfPathname = MySettings.ProcedureSetPath;
|
||||
Properties.Settings.Default.BackupFileName = MySettings.BackupFileName;
|
||||
Properties.Settings.Default.BackupFolder = MySettings.BackupFolder;
|
||||
Properties.Settings.Default.LogFileLoc = MySettings.LogFilePath;
|
||||
Properties.Settings.Default.ConnectionString = MySettings.ConnectionString;
|
||||
Properties.Settings.Default.DBName = MySettings.DBName;
|
||||
Properties.Settings.Default.DBPath = MySettings.DBPath;
|
||||
Properties.Settings.Default.PurgeData = MySettings.PurgeExistingData ? CheckState.Checked : CheckState.Unchecked;
|
||||
Properties.Settings.Default.PDFFolder = MySettings.PDFFolder;
|
||||
Properties.Settings.Default.OnlyThisSet = MySettings.OnlyThisSet ? CheckState.Checked : CheckState.Unchecked;
|
||||
Properties.Settings.Default.CheckRTF = MySettings.CheckRTF ? CheckState.Checked : CheckState.Unchecked;
|
||||
Properties.Settings.Default.Skip = MySettings.Skip;
|
||||
Properties.Settings.Default.ConvertTo = (int)MySettings.ConvertTo;
|
||||
Properties.Settings.Default.ExecutionMode = (int)MySettings.ExecutionMode;
|
||||
Properties.Settings.Default.Phase1 = MySettings.Phase1Suffix;
|
||||
Properties.Settings.Default.Phase2 = MySettings.Phase2Suffix;
|
||||
Properties.Settings.Default.Phase3 = MySettings.Phase3Suffix;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
private void frmLoader_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Properties.Settings.Default["VeSamFilename"].ToString() != "")
|
||||
this.tbVesamPath.Text = Properties.Settings.Default.VeSamFilename;
|
||||
if (Properties.Settings.Default["DbfPathname"].ToString() != "")
|
||||
this.tbSource.Text = Properties.Settings.Default.DbfPathname;
|
||||
if (Properties.Settings.Default["LoadWordDoc"].ToString() != "")
|
||||
this.cbSaveDoc.CheckState = Properties.Settings.Default.LoadWordDoc;
|
||||
if (Properties.Settings.Default["PurgeData"].ToString() != "")
|
||||
this.cbPurgeData.CheckState = Properties.Settings.Default.PurgeData;
|
||||
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;
|
||||
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;
|
||||
LoadSettings();
|
||||
_Loading = false;
|
||||
MSWordToPDF.CloseWordWhenDone = false;
|
||||
}
|
||||
|
||||
private void frmLoader_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
fbd.SelectedPath = tbVePromsPath.Text;
|
||||
if (fbd.ShowDialog() == DialogResult.OK)
|
||||
tbVePromsPath.Text = fbd.SelectedPath;
|
||||
}
|
||||
|
||||
private void tbVePromsPath_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
tbVesamPath.Text = tbVePromsPath.Text + @"\vesam.opt";
|
||||
}
|
||||
|
||||
private void btnFixTransitions_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLogPath()) return;
|
||||
//if (!CheckLogPath()) return;
|
||||
StepRTB rtb = new StepRTB();
|
||||
TransitionFixer myFixer = new TransitionFixer(rtb,_LogFilePath);
|
||||
TransitionFixer myFixer = new TransitionFixer(rtb,MySettings.LogFilePath);
|
||||
myFixer.StatusChanged += new TransitionFixerEvent(myFixer_StatusChanged);
|
||||
TimeSpan howlong = myFixer.Process(cbCheckRTF.Checked);
|
||||
TimeSpan howlong = myFixer.Process(MySettings.CheckRTF);
|
||||
string TransFixTime = string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds);
|
||||
MyInfo = TransFixTime;
|
||||
MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", TransFixTime, howlong.TotalSeconds));
|
||||
if(!ProcessComplete) 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();
|
||||
}
|
||||
@@ -578,26 +598,6 @@ namespace DataLoader
|
||||
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;
|
||||
cbCheckRTF.Visible = _DeveloperMode;
|
||||
tbSkip.Visible = _DeveloperMode;
|
||||
lblSkip.Visible = _DeveloperMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,47 +605,38 @@ namespace DataLoader
|
||||
{
|
||||
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 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 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;
|
||||
//if (_LogFilePath == "") return;
|
||||
// Save the Glitches log
|
||||
if (TextConvert.MyGlitches.Glitches.Count > 0)
|
||||
TextConvert.MyGlitches.Save(_LogFilePath + @"\ConversionGlitches.xml");
|
||||
TextConvert.MyGlitches.Save(MySettings.LogFilePath + @"\ConversionGlitches.xml");
|
||||
// Save the Error Log
|
||||
if (_MyFrmErrors.ItemCount() > 0)
|
||||
_MyFrmErrors.Save(_LogFilePath + @"\ConversionErrors.txt");
|
||||
_MyFrmErrors.Save(MySettings.LogFilePath + @"\ConversionErrors.txt");
|
||||
}
|
||||
|
||||
private bool _EnteredFileLoc = false;
|
||||
@@ -657,36 +648,171 @@ namespace DataLoader
|
||||
private void CreateBackupRestoreBatchFiles()
|
||||
{
|
||||
string pause = "pause";
|
||||
string bckupFileName = tbxBackupFileName.Text;
|
||||
string bckupFileName = MySettings.BackupFileName;
|
||||
if (!bckupFileName.EndsWith(".bak")) bckupFileName += ".bak";
|
||||
string backupPath = _LogFilePath + @"\" + bckupFileName;
|
||||
string backupPath = MySettings.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");
|
||||
StreamWriter fsbackup = new StreamWriter(_LogFilePath + @"\Backup" + bckupFileName.Substring(0,bckupFileName.Length-4) + ".bat");
|
||||
StreamWriter fsbackup = new StreamWriter(MySettings.LogFilePath + @"\Backup" + bckupFileName.Substring(0,bckupFileName.Length-4) + ".bat");
|
||||
fsbackup.WriteLine(bckupcmd);
|
||||
fsbackup.WriteLine(pause);
|
||||
fsbackup.Close();
|
||||
//StreamWriter fsrestore = new StreamWriter(_LogFilePath + @"\RestoreVEPROMS.bat");
|
||||
StreamWriter fsrestore = new StreamWriter(_LogFilePath + @"\Restore" + bckupFileName.Substring(0,bckupFileName.Length-4) + ".bat");
|
||||
StreamWriter fsrestore = new StreamWriter(MySettings.LogFilePath + @"\Restore" + bckupFileName.Substring(0,bckupFileName.Length-4) + ".bat");
|
||||
fsrestore.WriteLine(rstorecmd);
|
||||
fsrestore.WriteLine(pause);
|
||||
fsrestore.Close();
|
||||
}
|
||||
|
||||
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
||||
// Menu Items
|
||||
#region File Menu Items
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
VlnSettings.DebugMode = checkBox1.Checked;
|
||||
if (checkBox1.Checked)
|
||||
{
|
||||
MSWordToPDF.DebugStatus = 1;
|
||||
Loader.OverrideColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSWordToPDF.DebugStatus = 0;
|
||||
Loader.OverrideColor = Color.Empty;
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
#endregion
|
||||
#region Process Menu Items
|
||||
private bool _ProcessFailed = false;
|
||||
public bool ProcessFailed
|
||||
{
|
||||
get { return _ProcessFailed; }
|
||||
set { _ProcessFailed = value; }
|
||||
}
|
||||
private bool _ProcessComplete = false;
|
||||
public bool ProcessComplete
|
||||
{
|
||||
get { return _ProcessComplete; }
|
||||
set { _ProcessComplete = value; }
|
||||
}
|
||||
private void completeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBuilder mb = new MessageBuilder("Performing Complete Process\r\n");
|
||||
ProcessFailed = false;
|
||||
ProcessComplete = true;
|
||||
ProcessTime = DateTime.Now;
|
||||
// Phase 1 - Convert dBase to SQL
|
||||
btnConvert_Click(this, new System.EventArgs());
|
||||
if (ProcessFailed) return;
|
||||
mb.Append("dBase Conversion Complete");
|
||||
Status = "Backing up Phase 1 Data";
|
||||
Backup("_" + MySettings.Phase1Suffix);
|
||||
mb.Append("Phase 1 Backup Complete");
|
||||
// Phase 2 - Fix Transitions
|
||||
btnFixTransitions_Click(this, new System.EventArgs());
|
||||
mb.Append("Fix Transtions Complete");
|
||||
Status = "Backing up Phase 2 Data";
|
||||
mb.Append("dBase Conversion Complete");
|
||||
Backup("_" + MySettings.Phase2Suffix);
|
||||
mb.Append("Phase 2 Backup Complete");
|
||||
// Phase 3 - Convert to Change Manager Version
|
||||
ConvertToChangeManager();
|
||||
mb.Append("Conversion to Change Manager Complete");
|
||||
Status = "Backing up Phase 3 Data";
|
||||
//Backup("_" + MySettings.Phase3Suffix);
|
||||
//mb.Append("Phase 3 Backup Complete");
|
||||
// Phase 4 - Convert to Approval Version
|
||||
//ConvertToApproval();
|
||||
//mb.Append("Conversion to Approval Complete");
|
||||
//Status = "Backing up Phase 4 Data";
|
||||
Backup("");
|
||||
mb.Append("Backup Complete");
|
||||
Status = "Processing Complete";
|
||||
ProcessComplete = false;
|
||||
MessageBox.Show(mb.ToString(), "Processing Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void ConvertToChangeManager()
|
||||
{
|
||||
RunScript("PROMStoCM.sql", MySettings.DBName);
|
||||
}
|
||||
private void ConvertToApproval()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
RunScript("PROMStoApproval.sql", MySettings.DBName);
|
||||
}
|
||||
private void formatOnlyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
FormatsOnly = true;
|
||||
btnConvert_Click(this, new System.EventArgs());
|
||||
}
|
||||
private void convertDBToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
btnConvert_Click(this, new System.EventArgs());
|
||||
}
|
||||
private void fixTransitionsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
btnFixTransitions_Click(this, new System.EventArgs());
|
||||
}
|
||||
private void convertToChangeManagerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
ConvertToChangeManager();
|
||||
}
|
||||
private void convertToApprovalToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
ConvertToApproval();
|
||||
}
|
||||
#endregion
|
||||
#region Settings Menu Items
|
||||
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenSettings();
|
||||
}
|
||||
#endregion
|
||||
#region Old Menu Items
|
||||
private void convertSecurityToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnVesam_Click(this, new EventArgs());
|
||||
}
|
||||
private void convertTopFoldersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnLoadTreeDB_Click(this, new EventArgs());
|
||||
}
|
||||
private void loadTreeFromCSLAToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnLoadTreeCSLA_Click(this, new EventArgs());
|
||||
}
|
||||
private void loadVETreeFromCSLAToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnVETree_CSLA_Click(this, new EventArgs());
|
||||
}
|
||||
private void groupSecurityToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnGroup_Click(this, new EventArgs());
|
||||
}
|
||||
private void countTokensToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnCtTok_Click(this, new EventArgs());
|
||||
}
|
||||
private void convertDbfSelectedInTreeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnConvertSelected_Click(this, new EventArgs());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class MessageBuilder
|
||||
{
|
||||
private StringBuilder _MyStringBulider=new StringBuilder();
|
||||
private DateTime _LastTime=DateTime.Now;
|
||||
public MessageBuilder(string heading)
|
||||
{
|
||||
_MyStringBulider.Append(heading);
|
||||
}
|
||||
public void Append(string format, params object [] args)
|
||||
{
|
||||
string msg = "\r\n" + string.Format(format,args);
|
||||
DateTime now = DateTime.Now;
|
||||
TimeSpan ts = TimeSpan.FromTicks(now.Ticks - _LastTime.Ticks);
|
||||
string timestamp = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
|
||||
_LastTime = now;
|
||||
_MyStringBulider.Append("\r\n" + timestamp + " " + msg);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return _MyStringBulider.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user