This commit is contained in:
parent
aeb64e2479
commit
99b6a97fd3
@ -39,33 +39,74 @@ 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":
|
||||
// see if version exists for the input folder, parfld.
|
||||
DocVersion v = GetDocVersionFromName((Folder)parfld, vb.Title);
|
||||
if (v == null)
|
||||
{
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
|
||||
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||
@ -108,9 +149,10 @@ namespace DataLoader
|
||||
}
|
||||
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,7 +194,6 @@ namespace DataLoader
|
||||
{
|
||||
if (vb.Type != "version")
|
||||
{
|
||||
//if(frmMain.MySettings.OnlyThisSet)
|
||||
vb.LoadChildren(vs.GetChildren(vb.ToString()));
|
||||
List<vlnObject> lv = vb.Children;
|
||||
foreach (vlnObject vbc in lv)
|
||||
|
@ -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,14 +176,8 @@ 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);
|
||||
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);
|
||||
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)
|
||||
@ -191,8 +185,17 @@ namespace DataLoader
|
||||
//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))
|
||||
{
|
||||
// if this procedure already exists for this docversion, just use it.
|
||||
if (itm == null && cont == null)
|
||||
{
|
||||
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);
|
||||
|
@ -96,7 +96,8 @@ namespace DataLoader
|
||||
{
|
||||
MyFrmErrors.Add(value, MessageType.Error);
|
||||
_MyLog.ErrorFormat(value);
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount); }
|
||||
tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount);
|
||||
}
|
||||
}
|
||||
public string MyWarning
|
||||
{
|
||||
@ -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();
|
||||
@ -360,7 +368,6 @@ namespace DataLoader
|
||||
_MyLog.Fatal(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void RunScript(string scriptName, string dbName)
|
||||
{
|
||||
Status = String.Format("Running Script '{0}'", scriptName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user