DataLoader changes during development
This commit is contained in:
@@ -19,7 +19,7 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using vlnObjectLibrary;
|
||||
using vlnServerLibrary;
|
||||
using Org.Mentalis.Files;
|
||||
@@ -28,7 +28,7 @@ using Utils;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private List<Folder> vlnDataPathFolders() // was vlnDataPath
|
||||
{
|
||||
@@ -44,34 +44,44 @@ namespace DataLoader
|
||||
if (s1.Length > 0)
|
||||
{
|
||||
string[] s2 = s1.Split(",".ToCharArray());
|
||||
Folder fld = Folder.MakeFolder(sysFolder.FolderID, dbConn.DBID, s2[1], s2[0], null);
|
||||
Folder fld = Folder.MakeFolder(sysFolder, dbConn, s2[1], s2[0], FolderName(s2[0]), null, null, DateTime.Now, "Migration");
|
||||
dpf.Add(fld);
|
||||
}
|
||||
}
|
||||
return dpf;
|
||||
}
|
||||
private int cslaObject(vlnObject vb, int dbid, int parentid, TreeNode tn)
|
||||
private string FolderName(string Path)
|
||||
{
|
||||
int ind = Path.LastIndexOf("\\");
|
||||
if (ind == Path.Length-1 || ind < 0) return Path;
|
||||
return Path.Substring(ind + 1);
|
||||
}
|
||||
private object cslaObject(vlnObject vb, Connection dbConn, Object parfld, TreeNode tn)
|
||||
{
|
||||
switch (vb.Type)
|
||||
{
|
||||
case "plant":
|
||||
case "set":
|
||||
Folder fld = Folder.MakeFolder(parentid, dbid, vb.Title, vb.Path, string.Empty);
|
||||
Folder fld = Folder.MakeFolder((Folder)parfld, dbConn, vb.Title, vb.Path, FolderName(vb.Path), null, null, DateTime.Now, "Migration");
|
||||
tn.Tag = fld;
|
||||
return fld.FolderID;
|
||||
return (object) fld;
|
||||
case "version":
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
|
||||
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||
FolderConfig fld_cfg = new FolderConfig(d==null?"":d.InnerXml);
|
||||
//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)
|
||||
{
|
||||
@@ -87,13 +97,21 @@ namespace DataLoader
|
||||
thetitle = myReader.ReadLine();
|
||||
myReader.Close();
|
||||
}
|
||||
DocVersion v = DocVersion.MakeDocVersion(parentid, (int)DocVersionType(vb.Path.ToLower()), thetitle, vb.Path, 0, fld_cfg == null ? null : fld_cfg.ToString());
|
||||
Folder tmpfld = (Folder)parfld;
|
||||
Format format = null;
|
||||
if (defPlantFmt != null && defPlantFmt != "")
|
||||
{
|
||||
format = GetFormat(defPlantFmt);
|
||||
}
|
||||
else
|
||||
format = Format.Get(1);
|
||||
DocVersion v = DocVersion.MakeDocVersion(tmpfld, (int)DocVersionType(vb.Path.ToLower()), thetitle, vb.Path.ToLower(), null, format, fld_cfg == null ? null : fld_cfg.ToString(), DateTime.Now, "Migration");
|
||||
tn.Tag = v;
|
||||
return v.VersionID;
|
||||
return (object) v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private void MigrateChildren(vlnObject vb, vlnServer vs, int dbid, int parentid, TreeNode tn)
|
||||
private void MigrateChildren(vlnObject vb, vlnServer vs, Connection dbConn, Object parent, TreeNode tn)
|
||||
{
|
||||
if (vb.Type != "version")
|
||||
{
|
||||
@@ -102,10 +120,12 @@ namespace DataLoader
|
||||
foreach (vlnObject vbc in lv)
|
||||
{
|
||||
TreeNode tnc = tn.Nodes.Add(vbc.Title);
|
||||
int idc = cslaObject(vbc, dbid, parentid, tnc);
|
||||
MigrateChildren(vbc, vs, dbid, idc, tnc);
|
||||
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