This commit is contained in:
@@ -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 = " ";
|
||||
|
Reference in New Issue
Block a user