This commit is contained in:
parent
aeb64e2479
commit
99b6a97fd3
@ -39,78 +39,120 @@ namespace DataLoader
|
||||
// Get DataPath
|
||||
string sDP = cfg.ReadString("menu", "DataPath");
|
||||
// Split DataPath into directories
|
||||
|
||||
// Get the current list of folders so that if it already exists, just get the 'Folder', otherwise
|
||||
// make it. It was done this way because there was no way to get the Folder given a name/Title.
|
||||
FolderInfoList fil = FolderInfoList.Get();
|
||||
|
||||
foreach (string s1 in sDP.Split(";".ToCharArray()))
|
||||
{
|
||||
if (s1.Length > 0)
|
||||
{
|
||||
string[] s2 = s1.Split(",".ToCharArray());
|
||||
Folder fld = Folder.MakeFolder(sysFolder, dbConn, s2[1], s2[0], FolderName(s2[0]), null, null, DateTime.Now, "Migration");
|
||||
Folder fld = GetFolderFromName(s2[1], s2[0], fil);
|
||||
if (fld == null)
|
||||
fld = Folder.MakeFolder(sysFolder, dbConn, s2[1], s2[0], FolderName(s2[0]), null, null, DateTime.Now, "Migration");
|
||||
dpf.Add(fld);
|
||||
}
|
||||
}
|
||||
return dpf;
|
||||
}
|
||||
private Folder GetFolderFromName(string name, string title, FolderInfoList fil)
|
||||
{
|
||||
Folder fld = null;
|
||||
foreach (FolderInfo fi in fil)
|
||||
{
|
||||
if (fi.Name.ToUpper() == name.ToUpper() && fi.Title.ToUpper() == title.ToUpper())
|
||||
{
|
||||
fld = Folder.Get(fi.FolderID);
|
||||
return fld;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private string FolderName(string Path)
|
||||
{
|
||||
int ind = Path.LastIndexOf("\\");
|
||||
if (ind == Path.Length-1 || ind < 0) return Path;
|
||||
return Path.Substring(ind + 1);
|
||||
}
|
||||
private DocVersion GetDocVersionFromName(Folder fld, string f)
|
||||
{
|
||||
DocVersion dv = null;
|
||||
DocVersionInfoList dvil = DocVersionInfoList.GetByFolderID(fld.FolderID);
|
||||
foreach (DocVersionInfo dvi in dvil)
|
||||
{
|
||||
if (dvi.Name.ToUpper() == f.ToUpper())
|
||||
{
|
||||
dv = DocVersion.Get(dvi.VersionID);
|
||||
return dv;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private object cslaObject(vlnObject vb, Connection dbConn, Object parfld, TreeNode tn)
|
||||
{
|
||||
switch (vb.Type)
|
||||
{
|
||||
case "plant":
|
||||
case "set":
|
||||
Folder fld = Folder.MakeFolder((Folder)parfld, dbConn, vb.Title, vb.Path, FolderName(vb.Path), null, null, DateTime.Now, "Migration");
|
||||
// if folder exists... get the Folder object, otherwise create it.
|
||||
FolderInfoList fil = FolderInfoList.Get();
|
||||
Folder fld = GetFolderFromName(vb.Title, vb.Path, fil);
|
||||
if (fld==null) fld = Folder.MakeFolder((Folder)parfld, dbConn, vb.Title, vb.Path, FolderName(vb.Path), null, null, DateTime.Now, "Migration");
|
||||
tn.Tag = fld;
|
||||
return (object) fld;
|
||||
case "version":
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
|
||||
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||
//DocVersionConfig fld_cfg = new DocVersionConfig(d == null ? "" : d.InnerXml);
|
||||
FolderConfig fld_cfg = (d==null)?null:new FolderConfig(d.InnerXml);
|
||||
// translate curset.dat into xml & add to d (somehow).
|
||||
string csfile = string.Format("{0}\\curset.dat",vb.Path);
|
||||
string defPlantFmt = null;
|
||||
if (File.Exists(csfile))
|
||||
{
|
||||
CurSet cs = new CurSet(csfile);
|
||||
try
|
||||
{
|
||||
if (fld_cfg == null) fld_cfg = new FolderConfig();
|
||||
fld_cfg = cs.Convert(fld_cfg);
|
||||
defPlantFmt = cs.GetDefFmt();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("error in convert curset.dat, ex = {0}", ex.Message);
|
||||
frmMain.AddError(ex, "error in convert curset.dat");
|
||||
}
|
||||
}
|
||||
// *** RHM 20120613 - Fix
|
||||
// *** This was naming the DocVersion to the folder name
|
||||
//string titlepath = vb.Path + "\\" + "Title";
|
||||
//FileInfo fi = new FileInfo(titlepath);
|
||||
//string thetitle = vb.Title;
|
||||
//if (File.Exists(titlepath))
|
||||
//{
|
||||
// StreamReader myReader = new StreamReader(titlepath);
|
||||
// thetitle = myReader.ReadLine();
|
||||
// myReader.Close();
|
||||
//}
|
||||
Folder tmpfld = (Folder)parfld;
|
||||
FormatInfo format = null;
|
||||
if (defPlantFmt != null && defPlantFmt != "")
|
||||
// see if version exists for the input folder, parfld.
|
||||
DocVersion v = GetDocVersionFromName((Folder)parfld, vb.Title);
|
||||
if (v == null)
|
||||
{
|
||||
format = GetFormat(defPlantFmt);
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
|
||||
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||
//DocVersionConfig fld_cfg = new DocVersionConfig(d == null ? "" : d.InnerXml);
|
||||
FolderConfig fld_cfg = (d == null) ? null : new FolderConfig(d.InnerXml);
|
||||
// translate curset.dat into xml & add to d (somehow).
|
||||
string csfile = string.Format("{0}\\curset.dat", vb.Path);
|
||||
string defPlantFmt = null;
|
||||
if (File.Exists(csfile))
|
||||
{
|
||||
CurSet cs = new CurSet(csfile);
|
||||
try
|
||||
{
|
||||
if (fld_cfg == null) fld_cfg = new FolderConfig();
|
||||
fld_cfg = cs.Convert(fld_cfg);
|
||||
defPlantFmt = cs.GetDefFmt();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("error in convert curset.dat, ex = {0}", ex.Message);
|
||||
frmMain.AddError(ex, "error in convert curset.dat");
|
||||
}
|
||||
}
|
||||
// *** RHM 20120613 - Fix
|
||||
// *** This was naming the DocVersion to the folder name
|
||||
//string titlepath = vb.Path + "\\" + "Title";
|
||||
//FileInfo fi = new FileInfo(titlepath);
|
||||
//string thetitle = vb.Title;
|
||||
//if (File.Exists(titlepath))
|
||||
//{
|
||||
// StreamReader myReader = new StreamReader(titlepath);
|
||||
// thetitle = myReader.ReadLine();
|
||||
// myReader.Close();
|
||||
//}
|
||||
Folder tmpfld = (Folder)parfld;
|
||||
FormatInfo format = null;
|
||||
if (defPlantFmt != null && defPlantFmt != "")
|
||||
{
|
||||
format = GetFormat(defPlantFmt);
|
||||
}
|
||||
else
|
||||
format = FormatInfo.Get(1);
|
||||
|
||||
using (Format fmt = format.Get())
|
||||
v = DocVersion.MakeDocVersion(tmpfld, (int)DocVersionType(vb.Path.ToLower()), vb.Title, vb.Path.ToLower(), null, fmt, fld_cfg == null ? null : fld_cfg.ToString(), DateTime.Now, "Migration");
|
||||
}
|
||||
else
|
||||
format = FormatInfo.Get(1);
|
||||
DocVersion v;
|
||||
using(Format fmt = format.Get())
|
||||
v = DocVersion.MakeDocVersion(tmpfld, (int)DocVersionType(vb.Path.ToLower()), vb.Title, vb.Path.ToLower(), null, fmt, fld_cfg == null ? null : fld_cfg.ToString(), DateTime.Now, "Migration");
|
||||
tn.Tag = v;
|
||||
MigrateDocVersion(v, false);
|
||||
return (object)v;
|
||||
@ -152,18 +194,17 @@ namespace DataLoader
|
||||
{
|
||||
if (vb.Type != "version")
|
||||
{
|
||||
//if(frmMain.MySettings.OnlyThisSet)
|
||||
vb.LoadChildren(vs.GetChildren(vb.ToString()));
|
||||
vb.LoadChildren(vs.GetChildren(vb.ToString()));
|
||||
List<vlnObject> lv = vb.Children;
|
||||
foreach (vlnObject vbc in lv)
|
||||
{
|
||||
if (vbc.Path.ToUpper().StartsWith(OnlyThisFolder) || OnlyThisFolder.StartsWith(vbc.Path.ToUpper()))
|
||||
{
|
||||
TreeNode tnc = tn.Nodes.Add(vbc.Title);
|
||||
object idc = cslaObject(vbc, dbConn, parent, tnc);
|
||||
frmMain.Status = "Loading " + vbc.Title;
|
||||
MigrateChildren(vbc, vs, dbConn, idc, tnc);
|
||||
}
|
||||
if (vbc.Path.ToUpper().StartsWith(OnlyThisFolder) || OnlyThisFolder.StartsWith(vbc.Path.ToUpper()))
|
||||
{
|
||||
TreeNode tnc = tn.Nodes.Add(vbc.Title);
|
||||
object idc = cslaObject(vbc, dbConn, parent, tnc);
|
||||
frmMain.Status = "Loading " + vbc.Title;
|
||||
MigrateChildren(vbc, vs, dbConn, idc, tnc);
|
||||
}
|
||||
}
|
||||
}
|
||||
frmMain.Status = " ";
|
||||
|
@ -106,6 +106,7 @@ namespace DataLoader
|
||||
frmMain.Status = "Load All Formats";
|
||||
//LoadAllFormats();
|
||||
//Format.UpdateFormats(_FmtAllPath, _GenmacAllPath);
|
||||
|
||||
Format.UpdateFormats(frmMain.MySettings.FormatFolder, frmMain.MySettings.GenMacFolder);
|
||||
|
||||
//Format baseFormat = Format.Get(1);
|
||||
@ -139,6 +140,43 @@ namespace DataLoader
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool LoadFoldersIntoExisting(string s)
|
||||
{
|
||||
try
|
||||
{
|
||||
frmMain.Status = "Getting Connection";
|
||||
// get the connection and annotations from the existing database.
|
||||
dbConn = Connection.GetByName("Default");
|
||||
//dbConn = Connection.MakeConnection("Default", "Default", frmMain.MySettings.ConnectionString.Replace("{DBName}",frmMain.MySettings.DBName), 1, null, DateTime.Now, "Migration");
|
||||
|
||||
frmMain.Status = "Getting AnnotationTypes";
|
||||
CommentType = AnnotationType.GetByName("Comment"); // .MakeAnnotationType("Comment", null);
|
||||
MigrationErrorType = AnnotationType.GetByName("Migration Error");
|
||||
VerificationRequiredType = AnnotationType.GetByName("Verification Required");
|
||||
|
||||
List<Folder> lfldr = vlnDataPathFolders(); // get plant level list.
|
||||
|
||||
List<vlnObject> dp2 = new List<vlnObject>();
|
||||
foreach (Folder fldr in lfldr)
|
||||
{
|
||||
TreeNode tn = frmMain.TV.Nodes.Add(fldr.Name);
|
||||
tn.Tag = fldr;
|
||||
vlnObject vb = new vlnObject(null, "datapath", fldr.Name, fldr.Title);
|
||||
dp2.Add(vb);
|
||||
vlnServer vs = new vlnServer();
|
||||
frmMain.Status = "Loading " + fldr.Name;
|
||||
MigrateChildren(vb, vs, dbConn, fldr, tn);
|
||||
tn.Expand();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("Could not load data, error = {0}", ex.Message);
|
||||
//return false;
|
||||
throw new Exception("Error in LoadFolders", ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void ClearData()
|
||||
{
|
||||
Database.PurgeData();
|
||||
|
@ -176,22 +176,25 @@ namespace DataLoader
|
||||
//Console.WriteLine("number {0}", number);
|
||||
//Console.WriteLine("Item Key {0} List {1}", Item.CacheCountPrimaryKey, Item.CacheCountList);
|
||||
//Console.WriteLine("ItemInfo Key {0} List {1}", ItemInfo.CacheCountPrimaryKey, ItemInfo.CacheCountList);
|
||||
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
|
||||
dvi.ResetProcedures(); // need this to clear out Procedures so that they are retrieved (resolves a caching problem)
|
||||
foreach (ItemInfo ii in dvi.Procedures)
|
||||
{
|
||||
if (ii.MyContent.Number == number)
|
||||
{
|
||||
//Console.WriteLine(number);
|
||||
itm = ii.Get();
|
||||
cont = ii.MyContent.Get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!convertProcedures || (docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft && docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.Approved))
|
||||
{
|
||||
cont = Content.New(number, TextConvert.ConvertText(dr["Title"].ToString(), do_cvt), 0, null, ci == null ? null : ci.ToString(), dts, userid);
|
||||
itm = Item.MakeItem(FromItem, cont, dts, userid);
|
||||
}
|
||||
else
|
||||
{
|
||||
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
|
||||
foreach (ItemInfo ii in dvi.Procedures)
|
||||
// if this procedure already exists for this docversion, just use it.
|
||||
if (itm == null && cont == null)
|
||||
{
|
||||
if (ii.MyContent.Number == number)
|
||||
{
|
||||
//Console.WriteLine(number);
|
||||
itm = ii.Get();
|
||||
cont = ii.MyContent.Get();
|
||||
}
|
||||
cont = Content.New(number, TextConvert.ConvertText(dr["Title"].ToString(), do_cvt), 0, null, ci == null ? null : ci.ToString(), dts, userid);
|
||||
itm = Item.MakeItem(FromItem, cont, dts, userid);
|
||||
}
|
||||
}
|
||||
if (convertProcedures /* && number == "001\\u8209?007"/* && number == "0POP05-EO-EC00"*/)
|
||||
@ -359,7 +362,6 @@ namespace DataLoader
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Item MigrateProcedures(OleDbConnection cn, string pth, DocVersion docver, bool convertProcedures, FormatInfo activeFormat)
|
||||
{
|
||||
|
||||
@ -403,6 +405,7 @@ namespace DataLoader
|
||||
}
|
||||
//GC.Collect();
|
||||
}
|
||||
ds.Dispose();
|
||||
da.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -108,6 +108,7 @@ namespace DataLoader
|
||||
MigrateRoFstGraphics(roDbpath, rofstinfo.ROFSTLookup.myHdr.myDbs[i].children, rodb);
|
||||
}
|
||||
}
|
||||
ROImageInfo.FlagImagesZipped();
|
||||
}
|
||||
|
||||
private string NewROName(string roName)
|
||||
@ -180,7 +181,9 @@ namespace DataLoader
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
r.Close();
|
||||
fsIn.Close();
|
||||
roImg = ROImage.MakeROImage(rodb, imgname, ab, null, fi.LastWriteTimeUtc, "Migration");
|
||||
ConfigInfo ci = new ConfigInfo(null);
|
||||
ci.AddItem("Image", "Size", ab.Length.ToString());
|
||||
roImg = ROImage.MakeROImage(rodb, imgname, ROImageInfo.Compress(ab), ci.ToString(), fi.LastWriteTimeUtc, "Migration");
|
||||
}
|
||||
}
|
||||
AddToAvailable(roImg, rodb.RODbID, imgname, fi.LastWriteTimeUtc);
|
||||
|
@ -33,21 +33,21 @@ using System.Data.SqlClient;
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
{
|
||||
#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;
|
||||
#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 FolderTreeNode _topnode;
|
||||
private bool UseVeTree = false;
|
||||
@ -59,15 +59,15 @@ namespace DataLoader
|
||||
public int pbStepMaximum { get { return pbStep.Maximum; } set { pbStep.Maximum = value; } }
|
||||
public int pbStepValue { get { return pbStep.Value; } set { pbStep.Value = value; } }
|
||||
public int pbProcValue { get { return pbProc.Value; } set { pbProc.Value = value; } }
|
||||
public int SkipProcedures
|
||||
{
|
||||
get { return MySettings.Skip; }
|
||||
}
|
||||
public int SkipProcedures
|
||||
{
|
||||
get { return MySettings.Skip; }
|
||||
}
|
||||
public string Status
|
||||
{
|
||||
get { return toolStripStatusLabel1.Text; }
|
||||
set
|
||||
{
|
||||
set
|
||||
{
|
||||
toolStripStatusLabel1.Text = value;
|
||||
Application.DoEvents();
|
||||
}
|
||||
@ -82,66 +82,67 @@ namespace DataLoader
|
||||
_MyFrmErrors = new frmErrors(this);
|
||||
_MyFrmErrors.FormClosing += new FormClosingEventHandler(_MyFrmErrors_FormClosing);
|
||||
}
|
||||
return _MyFrmErrors;
|
||||
return _MyFrmErrors;
|
||||
}
|
||||
}
|
||||
void _MyFrmErrors_FormClosing(object sender, FormClosingEventArgs e)
|
||||
void _MyFrmErrors_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
_MyFrmErrors = null;
|
||||
}
|
||||
public string MyError
|
||||
{
|
||||
get { return tsslError.Text; }
|
||||
set
|
||||
{
|
||||
_MyFrmErrors = null;
|
||||
MyFrmErrors.Add(value, MessageType.Error);
|
||||
_MyLog.ErrorFormat(value);
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount);
|
||||
}
|
||||
public string MyError
|
||||
}
|
||||
public string MyWarning
|
||||
{
|
||||
get { return tsslError.Text; }
|
||||
set
|
||||
{
|
||||
get { return tsslError.Text; }
|
||||
set
|
||||
{
|
||||
MyFrmErrors.Add(value, MessageType.Error);
|
||||
_MyLog.ErrorFormat(value);
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount); }
|
||||
MyFrmErrors.Add(value, MessageType.Warning);
|
||||
_MyLog.WarnFormat(value);
|
||||
//tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount);
|
||||
}
|
||||
public string MyWarning
|
||||
}
|
||||
public string MyInfo
|
||||
{
|
||||
get { return tsslError.Text; }
|
||||
set
|
||||
{
|
||||
get { return tsslError.Text; }
|
||||
set
|
||||
{
|
||||
MyFrmErrors.Add(value, MessageType.Warning);
|
||||
_MyLog.WarnFormat(value);
|
||||
//tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount);
|
||||
}
|
||||
MyFrmErrors.Add(value, MessageType.Information);
|
||||
_MyLog.Info(value);
|
||||
//tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount);
|
||||
}
|
||||
public string MyInfo
|
||||
}
|
||||
public void AddError(string format, params object[] objs)
|
||||
{
|
||||
MyError = string.Format(format, objs);
|
||||
}
|
||||
public void AddWarn(string format, params object[] objs)
|
||||
{
|
||||
MyWarning = string.Format(format, objs);
|
||||
}
|
||||
public void AddInfo(string format, params object[] objs)
|
||||
{
|
||||
MyInfo = string.Format(format, objs);
|
||||
}
|
||||
public void AddError(Exception ex, string format, params object[] objs)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(string.Format(format, objs));
|
||||
int indent = 0;
|
||||
while (ex != null)
|
||||
{
|
||||
get { return tsslError.Text; }
|
||||
set
|
||||
{
|
||||
MyFrmErrors.Add(value, MessageType.Information);
|
||||
_MyLog.Info(value);
|
||||
//tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount);
|
||||
}
|
||||
}
|
||||
public void AddError(string format, params object[] objs)
|
||||
{
|
||||
MyError = string.Format(format, objs);
|
||||
}
|
||||
public void AddWarn(string format, params object[] objs)
|
||||
{
|
||||
MyWarning = string.Format(format, objs);
|
||||
}
|
||||
public void AddInfo(string format, params object[] objs)
|
||||
{
|
||||
MyInfo = string.Format(format, objs);
|
||||
}
|
||||
public void AddError(Exception ex, string format, params object[] objs)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder( string.Format(format, objs));
|
||||
int indent = 0;
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
public frmLoader()
|
||||
{
|
||||
@ -152,74 +153,74 @@ namespace DataLoader
|
||||
}
|
||||
private void btnConvertSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (UseVeTree)
|
||||
{
|
||||
VETreeNode tn = (VETreeNode)tv.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
object o = tn.VEObject;
|
||||
if (o.GetType() != typeof(DocVersionInfo))
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
DocVersion v = ((DocVersionInfo)o).Get();
|
||||
ldr.MigrateDocVersion(v);
|
||||
if (UseVeTree)
|
||||
{
|
||||
VETreeNode tn = (VETreeNode)tv.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
object o = tn.VEObject;
|
||||
if (o.GetType() != typeof(DocVersionInfo))
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
DocVersion v = ((DocVersionInfo)o).Get();
|
||||
ldr.MigrateDocVersion(v);
|
||||
if (v.MyItem != null)
|
||||
{
|
||||
{
|
||||
tn.Checked = true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TreeNode tn = tv.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
object o = tn.Tag;
|
||||
if (o.GetType() != typeof(DocVersion))
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
DocVersion v = (DocVersion)o;
|
||||
ldr.MigrateDocVersion(v);
|
||||
if (v.MyItem != null)
|
||||
{
|
||||
tn.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TreeNode tn = tv.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
object o = tn.Tag;
|
||||
if (o.GetType() != typeof(DocVersion))
|
||||
{
|
||||
MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
|
||||
return;
|
||||
}
|
||||
DocVersion v = (DocVersion)o;
|
||||
ldr.MigrateDocVersion(v);
|
||||
if (v.MyItem != null)
|
||||
{
|
||||
tn.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void tv_BeforeExpand(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
if (UseVeTree)
|
||||
{
|
||||
((VETreeNode)e.Node).LoadChildren();
|
||||
return;
|
||||
}
|
||||
if (UseVeTree)
|
||||
{
|
||||
((VETreeNode)e.Node).LoadChildren();
|
||||
return;
|
||||
}
|
||||
|
||||
TreeNode tn = e.Node;
|
||||
object o = tn.Tag;
|
||||
switch (o.GetType().ToString())
|
||||
{
|
||||
case "Volian.CSLA.Library.FolderInfo":
|
||||
FolderInfo fld = (FolderInfo)o;
|
||||
if (fld.ChildFolderCount>0)
|
||||
TreeNode tn = e.Node;
|
||||
object o = tn.Tag;
|
||||
switch (o.GetType().ToString())
|
||||
{
|
||||
case "Volian.CSLA.Library.FolderInfo":
|
||||
FolderInfo fld = (FolderInfo)o;
|
||||
if (fld.ChildFolderCount > 0)
|
||||
tn.Checked = ldr.LoadChildren(fld, tn); // load docversions.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void tv_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (UseVeTree) return;
|
||||
if (UseVeTree) return;
|
||||
|
||||
TreeNode tn = e.Node;
|
||||
object o = tn.Tag;
|
||||
@ -229,9 +230,9 @@ namespace DataLoader
|
||||
private void btnLoadTreeDB_Click(object sender, EventArgs e)
|
||||
{
|
||||
// When loading folders, i.e. the tree from dBase (old 16-bit)
|
||||
// always clear the data
|
||||
// always clear the data
|
||||
ldr.ClearData();
|
||||
bool suc = ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
bool suc = ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
}
|
||||
private string GetScript(string scriptName)
|
||||
{
|
||||
@ -244,8 +245,8 @@ namespace DataLoader
|
||||
public DateTime ProcessTime
|
||||
{
|
||||
get { return _ProcessTime; }
|
||||
set
|
||||
{
|
||||
set
|
||||
{
|
||||
_ProcessTime = value;
|
||||
// Set the Log File Name when the ProcessTime is set
|
||||
ChangeLogFileName("LogFileAppender", MySettings.DBName + " " + ProcessTime.ToString("yyyyMMdd HHmmss") + " DMErrorLog.txt");
|
||||
@ -269,13 +270,13 @@ namespace DataLoader
|
||||
Loader.OverrideColor = Color.Empty;
|
||||
}
|
||||
//if (!CheckLogPath()) return;
|
||||
//#if (!DEBUG)
|
||||
//#if (!DEBUG)
|
||||
if (!VlnSettings.DebugMode)
|
||||
{
|
||||
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
|
||||
//#endif
|
||||
try
|
||||
{
|
||||
//TextConvert.ResetSpecialCharacters();
|
||||
@ -306,11 +307,12 @@ namespace DataLoader
|
||||
return;
|
||||
}
|
||||
// Create Database
|
||||
RunScript("BuildVEPROMS.Sql", "Master");
|
||||
RunScript("PROMS2010.SQL", MySettings.DBName);
|
||||
|
||||
// if purge data, purge it all & reload folders & security.
|
||||
if (MySettings.PurgeExistingData)
|
||||
{
|
||||
RunScript("BuildVEPROMS.Sql", "Master");
|
||||
RunScript("PROMS2010.SQL", MySettings.DBName);
|
||||
Status = "Purging Data";
|
||||
ldr.ClearData();
|
||||
Status = "Loading Folders";
|
||||
@ -321,6 +323,12 @@ namespace DataLoader
|
||||
success = ldr.LoadSecurity(MySettings.VESamFile, MySettings.VEPromsPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if images have been zipped & if not, zip them:
|
||||
ROImageInfo.ZipImages();
|
||||
success = ldr.LoadFoldersIntoExisting(MySettings.VEPromsPath);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
TimeSpan ts = new TimeSpan();
|
||||
@ -346,7 +354,7 @@ namespace DataLoader
|
||||
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();
|
||||
if(!ProcessComplete) 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();
|
||||
@ -354,27 +362,26 @@ namespace DataLoader
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddError(ex,"===================== 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);
|
||||
}
|
||||
}
|
||||
|
||||
public void RunScript(string scriptName, string dbName)
|
||||
{
|
||||
Status = String.Format("Running Script '{0}'", scriptName);
|
||||
string script = GetScript(scriptName);
|
||||
script=script.Replace("{DBName}", MySettings.DBName);
|
||||
script=script.Replace("{DBPath}", MySettings.DBPath);
|
||||
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.InfoMessage += new SQLScriptRunnerEvent(ssr_InfoMessage);
|
||||
ssr.Run();
|
||||
Status = String.Format("Script '{0}' Complete", scriptName);
|
||||
Status = String.Format("Script '{0}' Complete", scriptName);
|
||||
}
|
||||
private void Backup(string suffix)
|
||||
{
|
||||
SQLScriptRunner ssrbu = new SQLScriptRunner(MySettings.DBName, MySettings.BackupFolder,
|
||||
SQLScriptRunner ssrbu = new SQLScriptRunner(MySettings.DBName, MySettings.BackupFolder,
|
||||
MySettings.ConnectionString.Replace("{DBName}", "Master"), ProcessTime, suffix);
|
||||
ssrbu.InfoMessage += new SQLScriptRunnerEvent(ssr_InfoMessage);
|
||||
ssrbu.Run();
|
||||
@ -430,41 +437,41 @@ namespace DataLoader
|
||||
lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
|
||||
Application.DoEvents();
|
||||
}
|
||||
private void btnLoadTreeCSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
_topnode = FolderTreeNode.BuildTreeList();
|
||||
tv.Nodes.Add(_topnode);
|
||||
tv.Nodes[0].Expand();
|
||||
UseVeTree = false;
|
||||
}
|
||||
private void btnVesam_Click(object sender, EventArgs e)
|
||||
{
|
||||
// if purge data, purge it all & reload folders.
|
||||
if (MySettings.PurgeExistingData)
|
||||
{
|
||||
ldr.ClearData();
|
||||
ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
}
|
||||
bool sec = ldr.LoadSecurity(MySettings.VESamFile, MySettings.VEPromsPath);
|
||||
}
|
||||
private void btnLoadTreeCSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
_topnode = FolderTreeNode.BuildTreeList();
|
||||
tv.Nodes.Add(_topnode);
|
||||
tv.Nodes[0].Expand();
|
||||
UseVeTree = false;
|
||||
}
|
||||
private void btnVesam_Click(object sender, EventArgs e)
|
||||
{
|
||||
// if purge data, purge it all & reload folders.
|
||||
if (MySettings.PurgeExistingData)
|
||||
{
|
||||
ldr.ClearData();
|
||||
ldr.LoadFolders(MySettings.VEPromsPath);
|
||||
}
|
||||
bool sec = ldr.LoadSecurity(MySettings.VESamFile, MySettings.VEPromsPath);
|
||||
}
|
||||
|
||||
private void btnVETree_CSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
tv.Nodes.Add(VETreeNode.GetFolder(1));
|
||||
UseVeTree = true;
|
||||
}
|
||||
private void btnVETree_CSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
tv.Nodes.Add(VETreeNode.GetFolder(1));
|
||||
UseVeTree = true;
|
||||
}
|
||||
|
||||
private void btnGroup_Click(object sender, EventArgs e)
|
||||
{
|
||||
GroupProp f = new GroupProp();
|
||||
f.ShowDialog();
|
||||
}
|
||||
private void btnGroup_Click(object sender, EventArgs e)
|
||||
{
|
||||
GroupProp f = new GroupProp();
|
||||
f.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnCtTok_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmCntTkn frm = new frmCntTkn();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
private void btnCtTok_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmCntTkn frm = new frmCntTkn();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
public void UpdateLabelsSetProc(int prc)
|
||||
{
|
||||
pbProc.Maximum = prc;
|
||||
@ -485,8 +492,8 @@ namespace DataLoader
|
||||
pbProc.Value += incLib;
|
||||
pbSect.Value += incUsages;
|
||||
}
|
||||
lblProc.Text = string.Format("{0}/{1} Lib Docs", pbProc.Value,pbProc.Maximum);
|
||||
lblSection.Text = string.Format("{0}/{1} Usages", pbSect.Value,pbSect.Maximum);
|
||||
lblProc.Text = string.Format("{0}/{1} Lib Docs", pbProc.Value, pbProc.Maximum);
|
||||
lblSection.Text = string.Format("{0}/{1} Usages", pbSect.Value, pbSect.Maximum);
|
||||
lblStep.Text = "";
|
||||
TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ProcessTime.Ticks);
|
||||
lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
|
||||
@ -521,108 +528,108 @@ namespace DataLoader
|
||||
private DataLoaderSettings _MySettings;
|
||||
internal DataLoaderSettings MySettings
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_MySettings==null)
|
||||
_MySettings=new DataLoaderSettings();
|
||||
return _MySettings;
|
||||
get
|
||||
{
|
||||
if (_MySettings == null)
|
||||
_MySettings = new DataLoaderSettings();
|
||||
return _MySettings;
|
||||
}
|
||||
set { _MySettings = value; }
|
||||
}
|
||||
private void LoadSettings()
|
||||
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;
|
||||
MySettings.FormatFolder = Properties.Settings.Default.FormatFolder;
|
||||
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 != "")
|
||||
{
|
||||
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;
|
||||
MySettings.FormatFolder = Properties.Settings.Default.FormatFolder;
|
||||
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 != "")
|
||||
{
|
||||
MessageBox.Show(validity, "Settings Incorrect", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
OpenSettings();
|
||||
}
|
||||
MessageBox.Show(validity, "Settings Incorrect", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
OpenSettings();
|
||||
}
|
||||
private void OpenSettings()
|
||||
}
|
||||
private void OpenSettings()
|
||||
{
|
||||
DataLoaderSettings tmpDLS = (DataLoaderSettings)MySettings.Clone();
|
||||
frmPG myPG = new frmPG("Data Loader Settings", tmpDLS);
|
||||
if (myPG.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
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;
|
||||
}
|
||||
MySettings = tmpDLS;
|
||||
SaveSettings();
|
||||
}
|
||||
private void SaveSettings()
|
||||
string validity = MySettings.ValidityCheck;
|
||||
if (validity != "")
|
||||
{
|
||||
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.FormatFolder = MySettings.FormatFolder;
|
||||
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();
|
||||
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.FormatFolder = MySettings.FormatFolder;
|
||||
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)
|
||||
{
|
||||
LoadSettings();
|
||||
@ -719,13 +726,13 @@ namespace DataLoader
|
||||
string bckupFileName = MySettings.BackupFileName;
|
||||
if (!bckupFileName.EndsWith(".bak")) bckupFileName += ".bak";
|
||||
string backupPath = MySettings.LogFilePath + @"\" + bckupFileName + "'\"";
|
||||
string bckupcmd = string.Format("sqlcmd -E -S.\\sqlexpress -Q \"backup database [{0}] to disk = '{1}",MySettings.DBName,backupPath);
|
||||
string rstorecmd = string.Format("sqlcmd -E -S.\\sqlexpress -Q \"restore database [{0}] from disk = '{1}",MySettings.DBName,backupPath);
|
||||
StreamWriter fsbackup = new StreamWriter(MySettings.LogFilePath + @"\Backup" + bckupFileName.Substring(0,bckupFileName.Length-4) + ".bat");
|
||||
string bckupcmd = string.Format("sqlcmd -E -S.\\sqlexpress -Q \"backup database [{0}] to disk = '{1}", MySettings.DBName, backupPath);
|
||||
string rstorecmd = string.Format("sqlcmd -E -S.\\sqlexpress -Q \"restore database [{0}] from disk = '{1}", MySettings.DBName, backupPath);
|
||||
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(MySettings.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();
|
||||
@ -793,7 +800,7 @@ namespace DataLoader
|
||||
Status = "Backing up Phase 3 Data";
|
||||
Backup("_" + MySettings.Phase3Suffix);
|
||||
mb.Append("Phase 3 Backup Complete");
|
||||
//Phase 4 - Convert to Approval Version
|
||||
//Phase 4 - Convert to Approval Version
|
||||
ConvertToApproval();
|
||||
FixProceduresAndFunctions();
|
||||
mb.Append("Conversion to Approval Complete");
|
||||
@ -832,12 +839,12 @@ namespace DataLoader
|
||||
FormatsOnly = true;
|
||||
btnConvert_Click(this, new System.EventArgs());
|
||||
if (ProcessFailed) return;
|
||||
MyInfo="Format Load Complete";
|
||||
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 = "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);
|
||||
@ -847,12 +854,12 @@ namespace DataLoader
|
||||
ProcessTime = DateTime.Now;
|
||||
btnConvert_Click(this, new System.EventArgs());
|
||||
if (ProcessFailed) return;
|
||||
MyInfo="dBase Conversion Complete";
|
||||
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 = "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);
|
||||
@ -862,12 +869,12 @@ namespace DataLoader
|
||||
Database.VEPROMS_Connection = MySettings.ConnectionString.Replace("{DBName}", MySettings.DBName);
|
||||
ProcessTime = DateTime.Now;
|
||||
btnFixTransitions_Click(this, new System.EventArgs());
|
||||
MyInfo="Fix Transtions Complete";
|
||||
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 = "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);
|
||||
@ -876,12 +883,12 @@ namespace DataLoader
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
ConvertToChangeManager();
|
||||
MyInfo="Conversion to Change Manager Complete";
|
||||
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 = "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);
|
||||
@ -890,12 +897,12 @@ namespace DataLoader
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
ConvertToApproval();
|
||||
MyInfo="Conversion to Approval Complete";
|
||||
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 = "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);
|
||||
@ -909,7 +916,7 @@ namespace DataLoader
|
||||
{
|
||||
Status = "Backing up Data";
|
||||
Backup("");
|
||||
MyInfo="Backup Complete";
|
||||
MyInfo = "Backup Complete";
|
||||
}
|
||||
Status = "Processing Complete";
|
||||
//Status = "Loading 16 Bit Approval Data Complete";
|
||||
@ -928,9 +935,9 @@ namespace DataLoader
|
||||
FixProceduresAndFunctions();
|
||||
if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
Status = "Backing up Data";
|
||||
Backup("_Fixed");
|
||||
MyInfo="Backup Complete";
|
||||
Status = "Backing up Data";
|
||||
Backup("_Fixed");
|
||||
MyInfo = "Backup Complete";
|
||||
}
|
||||
//Status = "Processing Complete";
|
||||
//MessageBox.Show("Fixed Stored Procedures", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
@ -975,7 +982,7 @@ namespace DataLoader
|
||||
{
|
||||
btnConvertSelected_Click(this, new EventArgs());
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private void approvalDatabasesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -1021,14 +1028,14 @@ namespace DataLoader
|
||||
bad++;
|
||||
}
|
||||
}
|
||||
AddInfo("\r\nFixing databases complete. {0} Fixed, {1} Failures",good,bad);
|
||||
AddInfo("\r\nFixing databases complete. {0} Fixed, {1} Failures", good, bad);
|
||||
Status = String.Format("Fixing databases complete. {0} Fixed, {1} Failures", good, bad);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class MessageBuilder
|
||||
{
|
||||
private StringBuilder _MyStringBulider=new StringBuilder();
|
||||
private StringBuilder _MyStringBulider = new StringBuilder();
|
||||
private DateTime _LastTime = DateTime.Now;
|
||||
public DateTime LastTime
|
||||
{
|
||||
@ -1039,9 +1046,9 @@ namespace DataLoader
|
||||
{
|
||||
_MyStringBulider.Append(heading);
|
||||
}
|
||||
public void Append(string format, params object [] args)
|
||||
public void Append(string format, params object[] args)
|
||||
{
|
||||
string msg = string.Format(format,args);
|
||||
string msg = 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user