DataLoader changes during development
This commit is contained in:
parent
da9b899424
commit
ef81207dbe
@ -21,7 +21,7 @@ namespace DataLoader
|
||||
{
|
||||
xmldoc = new XmlDocument();
|
||||
if (xml == null)
|
||||
xmldoc.LoadXml("<config/>");
|
||||
xmldoc.LoadXml("<Config/>");
|
||||
else
|
||||
xmldoc.LoadXml(xml);
|
||||
}
|
||||
@ -30,7 +30,7 @@ namespace DataLoader
|
||||
{
|
||||
xmldoc = new XmlDocument();
|
||||
if (xml == null)
|
||||
xmldoc.LoadXml("<config/>");
|
||||
xmldoc.LoadXml("<Config/>");
|
||||
else
|
||||
xmldoc.LoadXml(xml);
|
||||
AddItem(ename, aname.Replace(' ','_'), avalue);
|
||||
|
@ -15,7 +15,7 @@ using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
@ -26,10 +26,12 @@ namespace Utils
|
||||
{
|
||||
private int NUMCBTEXTYPE = 5; // number of changebar text types.
|
||||
public string PathName;
|
||||
private string DefaultPlantFmt;
|
||||
|
||||
public CurSet(string pname)
|
||||
{
|
||||
PathName = pname;
|
||||
DefaultPlantFmt = null;
|
||||
}
|
||||
|
||||
private string ReadTheString(BinaryReader bw, int maxlen)
|
||||
@ -62,7 +64,7 @@ namespace Utils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DataLoader.frmLoader.log.ErrorFormat("Error migrating Curset.dat, error = {0}", e.Message);
|
||||
DataLoader.frmLoader.log.ErrorFormat("Error migrating {0} Curset.dat, error = {1}", PathName, e.Message);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@ -83,6 +85,7 @@ namespace Utils
|
||||
cfg.Print_Pagination=(FolderConfig.PrintPagination) br.ReadSByte();
|
||||
tmpstring = ReadTheString(br,4); // DefaultPrinter not used
|
||||
cfg.Format_Plant = ReadTheString(br,10);
|
||||
DefaultPlantFmt = cfg.Format_Plant;
|
||||
tmpstring = ReadTheString(br, 128); // DefaultDestFName not used
|
||||
tmpsbyte = br.ReadSByte(); // DefaultPlotterType not used
|
||||
tmpsbyte = br.ReadSByte(); // DefaultPlotterPort not used
|
||||
@ -95,16 +98,20 @@ namespace Utils
|
||||
tmpsbyte = br.ReadSByte(); // DontPrintStatusTree not used
|
||||
cfg.Print_UserFormat = ReadTheString(br, 10);
|
||||
tmpsbyte = br.ReadSByte();
|
||||
cfg.Print_DisableDuplex = tmpsbyte == 0 ? false : true;
|
||||
//cfg.Print_Duplex = tmpsbyte == 0 ? true : false;
|
||||
br.Close();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
if(br!=null) br.Close();
|
||||
DataLoader.frmLoader.log.ErrorFormat("Error migrating Curset.dat, error = {0}", e.Message);
|
||||
DataLoader.frmLoader.log.ErrorFormat("Error migrating {0} Curset.dat, error = {1}", PathName, e.Message);
|
||||
}
|
||||
fs.Close();
|
||||
return cfg;
|
||||
}
|
||||
public string GetDefFmt()
|
||||
{
|
||||
return DefaultPlantFmt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,43 +19,57 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private Int32 MigrateDocVersion(string pth)
|
||||
public Item MigrateDocVersion(DocVersion docver)
|
||||
{
|
||||
|
||||
Int32 iStructureID = 0;
|
||||
string pth = docver.Title;
|
||||
// Open connection
|
||||
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pth + ";Extended Properties=dBase III;Persist Security Info=False");
|
||||
// load rofst (use it later)....
|
||||
Database.LogInfoFormat("Before ROFST");
|
||||
rofst = new ROFST(pth + "\\ro.fst");
|
||||
// Migrate library documents
|
||||
Database.LogInfoFormat("Before MigrateLibDocs");
|
||||
MigrateLibDocs(cn, pth);
|
||||
// Initialize Dictionaries
|
||||
dicTrans_StrDone = new Dictionary<string, int>();
|
||||
dicTrans_StrIds = new Dictionary<string, int>();
|
||||
dicTrans_ItemDone = new Dictionary<string, Item>();
|
||||
dicTrans_ItemIds = new Dictionary<string, Item>();
|
||||
|
||||
// Create a 'dummy' content record. This will be used for any transitions 'to'
|
||||
// that don't exist when dbf is processed. At end, use this to see if there
|
||||
// are missing transitions.
|
||||
TransDummyCont = Content.MakeContent(null, "DUMMY CONTENT FOR TRANSITION MIGRATION", null, null, null);
|
||||
|
||||
// Process Procedures
|
||||
iStructureID = MigrateProcedures(cn,pth);
|
||||
Item itm = MigrateProcedures(cn,pth,docver);
|
||||
// Show any Missing Transtitons (i.e. Transitions which have not been processed)
|
||||
ShowMissingTransitions();
|
||||
log.InfoFormat("Completed Migration of {0}", pth);
|
||||
MessageBox.Show("Completed Migration of " + pth);
|
||||
rofst.Close();
|
||||
cn.Close();
|
||||
dicTrans_StrDone.Clear();
|
||||
dicTrans_StrDone = null;
|
||||
return iStructureID;
|
||||
}
|
||||
private Volian.CSLA.Library.VersionTypeEnum DocVersionType(string s)
|
||||
dicTrans_ItemDone.Clear();
|
||||
dicTrans_ItemDone = null;
|
||||
if (itm != null)
|
||||
{
|
||||
if (s.EndsWith("approved")) return Volian.CSLA.Library.VersionTypeEnum.Approved;
|
||||
if (s.EndsWith("chgsht")) return Volian.CSLA.Library.VersionTypeEnum.Revision;
|
||||
if (s.EndsWith("tmpchg")) return Volian.CSLA.Library.VersionTypeEnum.Temporary;
|
||||
return Volian.CSLA.Library.VersionTypeEnum.WorkingDraft;
|
||||
docver.MyItem = itm;
|
||||
docver.Title = "";
|
||||
if (!docver.IsSavable) ErrorRpt.ErrorReport(docver);
|
||||
docver.Save();
|
||||
}
|
||||
return itm;
|
||||
}
|
||||
private VEPROMS.CSLA.Library.VersionTypeEnum DocVersionType(string s)
|
||||
{
|
||||
if (s.EndsWith("approved")) return VEPROMS.CSLA.Library.VersionTypeEnum.Approved;
|
||||
if (s.EndsWith("chgsht")) return VEPROMS.CSLA.Library.VersionTypeEnum.Revision;
|
||||
if (s.EndsWith("tmpchg")) return VEPROMS.CSLA.Library.VersionTypeEnum.Temporary;
|
||||
return VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,13 +20,13 @@ using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.MSWord;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private void SaveSectionDocument(string fname, string stpseq, ref byte ctype, ref int cid)
|
||||
private void SaveSectionDocument(string fname, string stpseq, ref int cid)
|
||||
{
|
||||
int docid = SaveWordDoc(fname);
|
||||
switch (docid)
|
||||
@ -40,7 +40,6 @@ namespace DataLoader
|
||||
log.ErrorFormat("Could not complete save of word document, oldstepsequence = {0}", stpseq);
|
||||
break;
|
||||
default:
|
||||
ctype = 2;
|
||||
cid = docid;
|
||||
break;
|
||||
}
|
||||
@ -50,7 +49,7 @@ namespace DataLoader
|
||||
int docid = 0;
|
||||
if (System.IO.File.Exists(fname))
|
||||
{
|
||||
if (cbSaveDoc.Checked)
|
||||
if (frmMain.cbSaveDocChecked)
|
||||
{
|
||||
WordDoc d = new WordDoc(fname);
|
||||
string temppath = Path.GetTempFileName();
|
||||
@ -62,10 +61,12 @@ namespace DataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cbSaveRTF.Checked)
|
||||
if (frmMain.cbSaveRTFChecked)
|
||||
docid = SaveDoc(fname, title, ci);
|
||||
}
|
||||
}
|
||||
else
|
||||
log.ErrorFormat("Missing rtf file: {0}", fname);
|
||||
return docid;
|
||||
}
|
||||
private int SaveWordDoc(string temppath)
|
||||
@ -81,8 +82,8 @@ namespace DataLoader
|
||||
byte[] ByteArray = new byte[len];
|
||||
int nBytesRead = fs.Read(ByteArray, 0, (int)len);
|
||||
fs.Close();
|
||||
string t1 = (title == null || title == "") ? "notitle" : title;
|
||||
Document doc = Document.MakeDocument(t1, ByteArray, null, ci == null ? null : ci.ToString());
|
||||
string t1 = (title == null || title == "") ? null : title;
|
||||
Document doc = Document.MakeDocument(t1, ByteArray, null, ci == null ? null : ci.ToString(), DateTime.Now, "Migration");
|
||||
return doc.DocID;
|
||||
}
|
||||
// for an io exception, keep trying
|
||||
|
28
PROMS/DataLoader/ErrorReport.cs
Normal file
28
PROMS/DataLoader/ErrorReport.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Csla.Validation;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public static class ErrorRpt
|
||||
{
|
||||
public static void ErrorReport(IVEHasBrokenRules mybr)
|
||||
{
|
||||
string smess = mybr.GetType().Name;
|
||||
IVEHasBrokenRules hbr = mybr.HasBrokenRules;
|
||||
if (hbr == null) smess += "\n Unknown Error";
|
||||
else
|
||||
{
|
||||
smess += "\n In object" + hbr.GetType().Name;
|
||||
foreach (BrokenRule br in hbr.BrokenRules)
|
||||
{
|
||||
smess += "\n" + br.Property + " - " + br.Description;
|
||||
}
|
||||
}
|
||||
MessageBox.Show(smess);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Csla;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@ -69,7 +69,7 @@ namespace DataLoader
|
||||
ftp = new FolderTreeNode(fi.ParentID.ToString());
|
||||
dicMissing.Add(fi.ParentID, ftp);
|
||||
dicExists.Add(fi.ParentID, ftp);
|
||||
if (fi.DocVersionCount > 0)
|
||||
if (fi.FolderDocVersionCount > 0)
|
||||
{
|
||||
TreeNode tn = new TreeNode("dummy");
|
||||
tn.Tag = "dummy";
|
||||
@ -87,7 +87,7 @@ namespace DataLoader
|
||||
else
|
||||
{
|
||||
ft = new FolderTreeNode(fi);
|
||||
if (fi.DocVersionCount > 0)
|
||||
if (fi.FolderDocVersionCount > 0)
|
||||
{
|
||||
TreeNode tn = new TreeNode("dummy");
|
||||
tn.Tag = "dummy";
|
||||
|
145
PROMS/DataLoader/Formats.cs
Normal file
145
PROMS/DataLoader/Formats.cs
Normal file
@ -0,0 +1,145 @@
|
||||
// ========================================================================
|
||||
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
|
||||
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
// ------------------------------------------------------------------------
|
||||
// $Workfile: $ $Revision: $
|
||||
// $Author: $ $Date: $
|
||||
//
|
||||
// $History: $
|
||||
// ========================================================================
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class Loader
|
||||
{
|
||||
|
||||
private Format AddFormatToDB(Format parent, string format, bool issub, DateTime Dts, string Userid)
|
||||
{
|
||||
string fmtdata = null;
|
||||
string genmacdata = null;
|
||||
XmlDocument xd = null;
|
||||
|
||||
string path = "e:\\fmtall\\" + format + "all.xml";
|
||||
if (File.Exists(path))
|
||||
{
|
||||
xd = new XmlDocument();
|
||||
xd.Load(path);
|
||||
fmtdata = xd.OuterXml;
|
||||
}
|
||||
|
||||
// Do we need genmac - only if non-subformat
|
||||
if (!issub)
|
||||
{
|
||||
path = "e:\\genmacall\\" + format + ".svg";
|
||||
if (File.Exists(path))
|
||||
{
|
||||
XmlDocument xdg = new XmlDocument();
|
||||
xdg.Load(path);
|
||||
genmacdata = xdg.OuterXml;
|
||||
}
|
||||
}
|
||||
// Get the name & then create the record.
|
||||
if (Userid == null || Userid == "") Userid = "Migration";
|
||||
|
||||
string nmattr = "Default";
|
||||
|
||||
// use xpath to get name.
|
||||
if (parent != null)
|
||||
{
|
||||
XmlNode nmnode = xd.SelectSingleNode("//FormatData");
|
||||
if (nmnode is XmlElement)
|
||||
{
|
||||
XmlElement xm = (XmlElement)nmnode;
|
||||
nmattr = xm.GetAttribute("Name");
|
||||
}
|
||||
}
|
||||
// use the format name if base or non sub. If it's a sub, remove the "_".
|
||||
string fname = issub ? format.Replace("_", "") : format;
|
||||
Format rec = Format.MakeFormat(parent, fname, nmattr, fmtdata, genmacdata, Dts, Userid);
|
||||
return rec;
|
||||
}
|
||||
public void LoadAllFormats()
|
||||
{
|
||||
Format basefmt = null;
|
||||
Format parent = null;
|
||||
|
||||
// Load base format.
|
||||
basefmt = AddFormatToDB(null, "base", false, DateTime.Now, "Migration");
|
||||
|
||||
// now loop through all files... If there is an _ in the name, it's a subformat
|
||||
// (for example, AEP_00.xml) skip it in main loop, it's handled for each format.
|
||||
DirectoryInfo di = new DirectoryInfo("e:\\fmtall");
|
||||
FileInfo[] fis = di.GetFiles("*.xml");
|
||||
|
||||
foreach (FileInfo fi in fis)
|
||||
{
|
||||
bool issub = (fi.Name.IndexOf("_") > 0) ? true : false;
|
||||
if (!issub && fi.Name.ToLower()!="baseall.xml")
|
||||
{
|
||||
string fmtname = fi.Name.Substring(0, fi.Name.Length - 7);
|
||||
// remove the all.xml part of the filename.
|
||||
parent = AddFormatToDB(basefmt, fmtname, issub, DateTime.Now, "Migration");
|
||||
|
||||
// now see if there are any subformats associated with this, if so
|
||||
// add them here...
|
||||
DirectoryInfo sdi = new DirectoryInfo("e:\\fmtall");
|
||||
FileInfo[] sfis = di.GetFiles(fmtname+"_*.xml");
|
||||
foreach (FileInfo sfi in sfis)
|
||||
{
|
||||
string nm = sfi.Name.Substring(0, sfi.Name.Length-7);
|
||||
Format subfmt = AddFormatToDB(parent, nm, true, DateTime.Now, "Migration");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public Format GetFormat(string format)
|
||||
{
|
||||
Format parent = null;
|
||||
Format rec = null;
|
||||
|
||||
// get base
|
||||
Format baseparent = Format.Get(1);
|
||||
|
||||
// if there is no format - what should be done? maybe nothing.
|
||||
if (format == null || format == "") return null;
|
||||
|
||||
try
|
||||
{
|
||||
if (format.IndexOf(' ') > -1) // will have spaces if it's a user format
|
||||
{
|
||||
string part1 = format.Substring(0, format.IndexOf(' '));
|
||||
string part2 = format.Substring(format.LastIndexOf(' ') + 1, 2);
|
||||
format = part1 + part2;
|
||||
|
||||
// get the parent format's id (for example, AEP for AEP00).
|
||||
parent = Format.GetExistingByParentID_Name(baseparent.FormatID, part1);
|
||||
}
|
||||
else
|
||||
parent = baseparent;
|
||||
|
||||
// see if the format has been added, if not go get it.
|
||||
rec = Format.GetExistingByParentID_Name(parent.FormatID, format);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("Error getting xml version of format {0}", ex.Message);
|
||||
}
|
||||
return rec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Csla;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
@ -39,6 +39,7 @@ namespace DataLoader
|
||||
}
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!grp.IsSavable) ErrorRpt.ErrorReport(grp);
|
||||
grp.Save();
|
||||
}
|
||||
}
|
||||
|
@ -26,28 +26,9 @@ using Org.Mentalis.Files;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private void UpdateLabelsLibDocs(int incLib, int incUsages)
|
||||
{
|
||||
if (incLib == 0 && incUsages == 0)//Reset
|
||||
{
|
||||
lblTime.Tag = DateTime.Now;
|
||||
pbProc.Value = 0;
|
||||
pbSect.Value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pbProc.Value += incLib;
|
||||
pbSect.Value += incUsages;
|
||||
}
|
||||
lblProc.Text = string.Format("{0} Lib Docs", pbProc.Value);
|
||||
lblSection.Text = string.Format("{0} Usages", pbSect.Value);
|
||||
lblStep.Text = "";
|
||||
TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ((DateTime)lblTime.Tag).Ticks);
|
||||
lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
private void MigrateLibDocs(OleDbConnection cn, string pth)
|
||||
{
|
||||
// Get all of the library documents - the first list has the entire list of files
|
||||
@ -56,15 +37,15 @@ namespace DataLoader
|
||||
// will be migrated. After that, any remaining library documents will be added to
|
||||
// the section table without a reference from the structuretbl.
|
||||
Dictionary<string, int> dicLibDocSect = new Dictionary<string, int>();
|
||||
UpdateLabelsLibDocs(0, 0);
|
||||
frmMain.UpdateLabelsLibDocs(0, 0);
|
||||
if (Directory.Exists(pth + "\\rtffiles"))
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(pth + "\\RTFFILES");
|
||||
FileInfo[] fis = di.GetFiles("DOC_*.LIB");
|
||||
pbProc.Maximum = fis.Length;
|
||||
frmMain.UpdateLabelsSetProc(fis.Length);
|
||||
foreach (FileInfo fi in fis)
|
||||
{
|
||||
UpdateLabelsLibDocs(1, 0);
|
||||
frmMain.UpdateLabelsLibDocs(1, 0);
|
||||
dicLibDocSect[fi.Name.Substring(0, 8).ToUpper()] = MigrateLibDoc(fi);
|
||||
}
|
||||
}
|
||||
@ -72,10 +53,10 @@ namespace DataLoader
|
||||
OleDbDataAdapter da_doc = new OleDbDataAdapter("select [FROMNUMBER], [FROMSEQUEN], [TONUMBER] from [tran] where [TONUMBER] LIKE 'doc_%' or [TONUMBER] like 'DOC_%'", cn);
|
||||
DataSet ds_doc = new DataSet();
|
||||
da_doc.Fill(ds_doc);
|
||||
pbSect.Maximum = ds_doc.Tables[0].Rows.Count;
|
||||
frmMain.UpdateLabelsSetSect(ds_doc.Tables[0].Rows.Count);
|
||||
foreach (DataRow dr_doc in ds_doc.Tables[0].Rows)
|
||||
{
|
||||
UpdateLabelsLibDocs(0, 1);
|
||||
frmMain.UpdateLabelsLibDocs(0, 1);
|
||||
string key = dr_doc["FROMNUMBER"].ToString().PadRight(20) + dr_doc["FROMSEQUEN"].ToString().PadRight(10);
|
||||
if (!dicLibDocSect.ContainsKey(dr_doc["TONUMBER"].ToString().ToUpper()))
|
||||
log.ErrorFormat("Error setting library document references: {0}", dr_doc["TONUMBER"].ToString().ToUpper());
|
||||
@ -150,4 +131,5 @@ namespace DataLoader
|
||||
return tmpRtfFileName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
@ -177,6 +177,22 @@ namespace Config
|
||||
return null;
|
||||
}
|
||||
XmlDocument d = IniToXml(inipath);
|
||||
// see if default image file extension was set, if not make it TIF
|
||||
XmlNode gr = d.SelectSingleNode("//Graphics");
|
||||
XmlNode ext = null;
|
||||
if (gr != null) ext = gr.SelectSingleNode("@defaultext");
|
||||
if (ext == null)
|
||||
{
|
||||
// if the graphics node doesn't exist, make it.
|
||||
if (gr == null)
|
||||
{
|
||||
gr = d.CreateElement("Graphics");
|
||||
d.DocumentElement.AppendChild(gr);
|
||||
}
|
||||
XmlAttribute xa = d.CreateAttribute("defaultext");
|
||||
xa.Value = "TIF";
|
||||
gr.Attributes.Append(xa);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -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 = " ";
|
||||
}
|
||||
}
|
||||
}
|
@ -20,21 +20,21 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private bool LoadChildren(FolderInfo fld, TreeNode tn)
|
||||
public bool LoadChildren(FolderInfo fld, TreeNode tn)
|
||||
{
|
||||
tn.Nodes.Clear();
|
||||
bool bLoaded = true;
|
||||
foreach (DocVersionInfo fdv in fld.DocVersions)
|
||||
foreach (DocVersionInfo fdv in fld.FolderDocVersions)
|
||||
{
|
||||
TreeNode tnc = tn.Nodes.Add(fdv.Title);
|
||||
tnc.Tag = fdv;
|
||||
tnc.Checked = fdv.StructureID != 0;
|
||||
tnc.Checked = fdv.ItemID != 0;
|
||||
bLoaded &= tnc.Checked;
|
||||
}
|
||||
return bLoaded;
|
||||
|
212
PROMS/DataLoader/Loader.cs
Normal file
212
PROMS/DataLoader/Loader.cs
Normal file
@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.MSWord;
|
||||
using vlnObjectLibrary;
|
||||
using vlnServerLibrary;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Config;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class Loader
|
||||
{
|
||||
#region ClassProperties
|
||||
private int wms = 500;
|
||||
private static int EDDATA = 0x01;
|
||||
private static int PH = 0x02;
|
||||
private static int TOC = 0x04;
|
||||
private static int AUTOIND = 0x08;
|
||||
private static int AUTOGEN = 0x40;
|
||||
|
||||
private static int STP_MULT_CHGID = 1;
|
||||
private static int STP_LNK_SEQ = 2;
|
||||
private static int STP_OVR_TAB = 3;
|
||||
|
||||
private string ProcFileName;
|
||||
private string ProcNumber;
|
||||
private ROFST rofst;
|
||||
private int EditSectId;
|
||||
private Dictionary<string, int> dicLibDocRef;
|
||||
|
||||
// have a few variables for storing the database id record & the system record.
|
||||
public Connection dbConn;
|
||||
public Folder sysFolder;
|
||||
public AnnotationType CommentType; // this holds the annotationtype of comment for future use
|
||||
public Document MissingDocument=null; // make a document if there is a missing rtf file
|
||||
// any missing will use this.
|
||||
private Content TransDummyCont;
|
||||
// the following two dictionaries are used to handle migration of the
|
||||
// transitions... dicTrans_ItemDone gets an entry for procnumber, sequence
|
||||
// number and the new item id as a step or section is created (transitions
|
||||
// can go to steps or sections). When a transition is encountered, check this
|
||||
// dictionary to see if the step or section was migrated & use the item
|
||||
// for the step or section if it was migrated. When a transition is migrated where
|
||||
// the 'to' has not been migrated yet, check if an entry exists in dicTrans_ItemIds,
|
||||
// if so, use the item listed here. If no entry exists in dicTrans_ItemIds, create
|
||||
// an item table record and use the id as part of the 'to', and add an entry to
|
||||
// dicTrans_ItemIds to flag that the record was already created. As migrating sections
|
||||
// and steps, check this dicTrans_ItemIds to see if the item record has already
|
||||
// been create, if so use it and remove it from the dicTrans_ItemIds dictionary,
|
||||
// otherwise, create a new item record.
|
||||
private Dictionary<string, Item> dicTrans_ItemDone;
|
||||
private Dictionary<string, Item> dicTrans_ItemIds;
|
||||
private Dictionary<object, string> dicOldStepSequence;
|
||||
private Dictionary<TreeNode, TreeNode> dicNeedToLoad;
|
||||
private log4net.ILog log;
|
||||
#endregion
|
||||
private frmLoader frmMain;
|
||||
public Loader(log4net.ILog lg, frmLoader fm)
|
||||
{
|
||||
dicNeedToLoad = new Dictionary<TreeNode, TreeNode>();
|
||||
log = lg;
|
||||
frmMain = fm;
|
||||
}
|
||||
public bool LoadFolders()
|
||||
{
|
||||
try
|
||||
{
|
||||
frmMain.Status = "Make Connection";
|
||||
// make the initial database connection record, annotation types & top
|
||||
// system folder.
|
||||
dbConn = Connection.MakeConnection("Default", "Default", "Data Source=.\\SQLEXPRESS;Initial Catalog=VEPROMS;Integrated Security=True", 1, null, DateTime.Now, "Migration");
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
|
||||
frmMain.Status = "Add AnnotationTypes";
|
||||
CommentType = AnnotationType.MakeAnnotationType("Comment", null);
|
||||
|
||||
AnnotationType at = AnnotationType.MakeAnnotationType("Reference", null);
|
||||
at = AnnotationType.MakeAnnotationType("Action Items", null);
|
||||
|
||||
frmMain.Status = "Load veproms.ini";
|
||||
XmlDocument d = cfg.LoadSystemIni();
|
||||
|
||||
frmMain.Status = "Load All Formats";
|
||||
LoadAllFormats();
|
||||
|
||||
Format baseFormat = Format.Get(1);
|
||||
sysFolder = Folder.MakeFolder(null, dbConn, "VEPROMS", "VEPROMS", "VEPROMS", baseFormat, d.InnerXml, DateTime.Now, "Migration");
|
||||
|
||||
// This is to test the vln Libraries
|
||||
List<Folder> lfldr = vlnDataPathFolders();
|
||||
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void ClearData()
|
||||
{
|
||||
Database.PurgeData();
|
||||
}
|
||||
public static string MakeDate(string src)
|
||||
{
|
||||
if (src.Trim() == "") return null;
|
||||
int[] DateOffset ={ 4, 5, 47, 6, 7, 47, 0, 1, 2, 3 }; // 47 = '/'
|
||||
StringBuilder datebuff = new StringBuilder(10);
|
||||
for (int i = 0; i < DateOffset.Length; i++)
|
||||
{
|
||||
if (DateOffset[i] < 9)
|
||||
datebuff.Append(src[DateOffset[i]]);
|
||||
else
|
||||
datebuff.Append(System.Convert.ToChar(DateOffset[i]));
|
||||
}
|
||||
return datebuff.ToString();
|
||||
}
|
||||
public DateTime GetDTS(string date, string time)
|
||||
{
|
||||
// Set the date/time stamp. If there is no 'date', set the date
|
||||
// to 1/1/2000 (this can be changed!). If there is not 'time',
|
||||
// set the time to 0:0:0 (midnight).
|
||||
|
||||
DateTime dts = DateTime.Now;
|
||||
string month = "01";
|
||||
string day = "01";
|
||||
string year = "2000";
|
||||
string hour = "";
|
||||
string minute = "";
|
||||
try
|
||||
{
|
||||
if (date != null && date != "")
|
||||
{
|
||||
int indx1 = date.IndexOf("/");
|
||||
month = date.Substring(0, indx1);
|
||||
int indx2 = date.IndexOf("/", indx1 + 1);
|
||||
day = date.Substring(indx1 + 1, indx2 - indx1 - 1);
|
||||
year = date.Substring(indx2 + 1, 4);
|
||||
}
|
||||
if (time == null || time == "")
|
||||
{
|
||||
hour = "0";
|
||||
minute = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
hour = time.Substring(0, 2);
|
||||
int indxc = time.IndexOfAny(":A-".ToCharArray());
|
||||
if (indxc == time.Length - 1)
|
||||
minute = time.Substring(2, 2);
|
||||
else
|
||||
minute = time.Substring(indxc + 1, time.Length - indxc - 1);
|
||||
}
|
||||
dts = new DateTime(System.Convert.ToInt32(year), System.Convert.ToInt32(month), System.Convert.ToInt32(day),
|
||||
System.Convert.ToInt32(hour), System.Convert.ToInt32(minute), 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("Bad Date/Time {0} {1}. Set to NOW.", date, time);
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
//log.ErrorFormat(ex.StackTrace);
|
||||
return dts;
|
||||
}
|
||||
return dts;
|
||||
}
|
||||
|
||||
public bool LoadSecurity(string VeSamPath)
|
||||
{
|
||||
Security sec = new Security(VeSamPath);
|
||||
return sec.Migrate();
|
||||
}
|
||||
private void WaitMS(int n)
|
||||
{
|
||||
DateTime dtw = DateTime.Now.AddMilliseconds(n);
|
||||
while (DateTime.Now < dtw)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
private void Wait(int n)
|
||||
{
|
||||
DateTime dtw = DateTime.Now.AddSeconds(n);
|
||||
while (DateTime.Now < dtw)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -55,6 +55,7 @@ namespace Config
|
||||
// We now strip spaces before and after any Attribute that is written.
|
||||
sValue = sValue.Trim(' ');
|
||||
sName = sName.Replace(' ', '_');
|
||||
sName = sName.Replace("\\", "_slash_");
|
||||
|
||||
// Add an attribute
|
||||
if(sValue=="")
|
||||
@ -82,6 +83,7 @@ namespace Config
|
||||
string elename = sSection.Substring(1, sSection.IndexOf("]") - 1);
|
||||
while(elename.IndexOf(' ')>-1) elename = elename.Remove(elename.IndexOf(' '),1);
|
||||
if (!ele.Contains(elename.ToLower())) elename = 'z' + elename;
|
||||
elename = elename.Replace("\\", "_slash_");
|
||||
// Add a section [name]
|
||||
XmlNode nd = AddNode(xParent, elename);
|
||||
//AddAttribute(nd,"name",sSection.Substring(1,sSection.IndexOf("]")-1));
|
||||
@ -145,7 +147,7 @@ namespace Config
|
||||
private void LoadXML()
|
||||
{
|
||||
string sLine;
|
||||
ppXml.LoadXml("<ConfigInfo/>");// initialize ppXml
|
||||
ppXml.LoadXml("<Config/>");// initialize ppXml
|
||||
XmlNode xmlTop=ppXml.DocumentElement;
|
||||
XmlNode xmlNd=ppXml.DocumentElement;
|
||||
//XmlNode xmlNd_UC=ppXml.DocumentElement;
|
||||
|
@ -19,13 +19,13 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private Int32 MigrateProcedure(OleDbConnection cn, DataRow dr, Byte FromType, Int32 FromID, string pth)
|
||||
private Item MigrateProcedure(OleDbConnection cn, DataRow dr, Item FromItem, string pth, DocVersion docver)
|
||||
{
|
||||
dicOldStepSequence = new Dictionary<object, string>();
|
||||
Stack<int> SubSectLevels = new Stack<int>(); // levels of subsections
|
||||
@ -33,6 +33,7 @@ namespace DataLoader
|
||||
ProcNumber = dr["Number"].ToString();
|
||||
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
|
||||
string userid = dr["initials"].ToString().Trim();
|
||||
if (userid == null || userid == "") userid = "Migration";
|
||||
|
||||
ConfigInfo ci = null;
|
||||
string tstr = dr["Proccode"].ToString();
|
||||
@ -41,19 +42,40 @@ namespace DataLoader
|
||||
ci = new ConfigInfo(null);
|
||||
ci.AddItem("Procedure", "ProcCode", tstr);
|
||||
}
|
||||
|
||||
// check that there is a "Series" column, i.e. the 10th column, some datasets
|
||||
// may not have it, for example vetuec\master.sl1
|
||||
if (dr.ItemArray.Length > 10)
|
||||
{
|
||||
tstr = dr["Series"].ToString();
|
||||
if (tstr != null && tstr != "")
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Procedure", "Series", tstr);
|
||||
}
|
||||
}
|
||||
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = null;
|
||||
|
||||
// check that file exists, i.e. if proc file doesn't exist but has entry in set
|
||||
// file, flag error, but continue.
|
||||
string fname = frmMain.tbSourceText +"\\"+ dr["entry"] + ".dbf";
|
||||
if (File.Exists(fname))
|
||||
{
|
||||
// if the dbt is bad, fix it.
|
||||
DbtOk(dr["entry"].ToString());
|
||||
// See if there is PSI and if so, add it to the xml.
|
||||
OleDbDataAdapter dapsi = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where [STEP] is null", cn);
|
||||
try
|
||||
{
|
||||
dapsi.Fill(ds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Application.Exit();
|
||||
}
|
||||
dt = ds.Tables[0];
|
||||
|
||||
if (dt.Rows.Count > 0)
|
||||
@ -83,21 +105,29 @@ namespace DataLoader
|
||||
}
|
||||
}
|
||||
dapsi.Dispose();
|
||||
}
|
||||
else // log an error
|
||||
{
|
||||
log.ErrorFormat("Missing DBF: {0}", fname);
|
||||
}
|
||||
|
||||
// Note, for now the data from the format field will be saved. Later, xpath, ??
|
||||
EditSectId = 0;
|
||||
|
||||
Byte FrType = 2;
|
||||
Int32 FrID = 0;// str.Structureid;
|
||||
Procedure prc = Procedure.MakeProcedure(TextConvert.ConvertText(dr["Number"].ToString()), TextConvert.ConvertText(dr["Title"].ToString()), ci==null?null:ci.ToString(), null, 0, 0, dts, userid);
|
||||
Structure str = Structure.MakeStructure(FromType, FromID, 1, prc.ProcID, dts, userid);
|
||||
UpdateLabels(1, 0, 0);
|
||||
//OleDbDataAdapter da = new OleDbDataAdapter("select * from (select asc(mid(sequence,2,1)) as locb,* from [" + dr["entry"] + "] where sequence like ' %') order by locb asc", cn);
|
||||
// See if no caret convert...
|
||||
Format docverFormat = docver.ActiveFormat;
|
||||
bool do_cvt = !(docverFormat.PlantFormat.FormatData.XtraOptions("DontConvertCarrotToDelta"));
|
||||
// pass in a 0 on MakeContent for type of procedure, i.e. procedure = 0 (on type field)
|
||||
Content cont = Content.New(TextConvert.ConvertText(dr["Number"].ToString()), TextConvert.ConvertText(dr["Title"].ToString(),do_cvt), 0, null, ci == null ? null : ci.ToString(), dts, userid);
|
||||
Item itm = Item.MakeItem(FromItem, cont, dts, userid);
|
||||
frmMain.UpdateLabels(1, 0, 0);
|
||||
Database.LogInfoFormat("Processing Procedure [{0}] - [{1}] - {2} - {3}", frmMain.pbProcValue, dr["entry"], cont.Number, cont.Text);
|
||||
|
||||
OleDbDataAdapter da = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where sequence like ' %'", cn);
|
||||
try
|
||||
{
|
||||
LoadSection(ds, da, dr["entry"].ToString());
|
||||
da.SelectCommand.CommandText = "select * from [" + dr["entry"] + "] where step not like ' '";
|
||||
da.SelectCommand.CommandText = "select * from [" + dr["entry"] + "] where step not like ' ' and step not like '%~'";
|
||||
da.Fill(ds, "Steps");
|
||||
dt = ds.Tables["Steps"];
|
||||
dt.CaseSensitive = true;
|
||||
@ -120,70 +150,107 @@ namespace DataLoader
|
||||
log.Error(ex.StackTrace);
|
||||
}
|
||||
|
||||
// dicSecCount is dictionary to track number of subsections for the parent at a level
|
||||
// dicSecID is the parent at that level
|
||||
Dictionary<int, int> dicSecCount = new Dictionary<int, int>();
|
||||
Dictionary<int, int> dicSecID = new Dictionary<int, int>();
|
||||
pbSect.Maximum = ds.Tables["Sections"].Rows.Count;
|
||||
pbSect.Value = 0;
|
||||
Dictionary<int, Item> dicSecParentItem = new Dictionary<int, Item>();
|
||||
frmMain.pbSectMaximum = ds.Tables["Sections"].Rows.Count;
|
||||
frmMain.pbSectValue = 0;
|
||||
|
||||
DataTable dtsect = ds.Tables["Sections"];
|
||||
dtsect.CaseSensitive = true;
|
||||
DataView dv = new DataView(dtsect, "", "locb", DataViewRowState.CurrentRows);
|
||||
Item SectItm = null;
|
||||
int level = 0;
|
||||
bool addpart = true;
|
||||
Item parentitem = itm;
|
||||
foreach (DataRowView drw in dv)
|
||||
{
|
||||
FrID = MigrateSection(prc, cn, drw, ds.Tables["Steps"], FrType, FrID, dicSecCount.Count > 0 ? true : false, pth);
|
||||
if (prc.StructureID == 0)
|
||||
SectItm = MigrateSection(parentitem, cont.Number, cn, drw, ds.Tables["Steps"], SectItm, dicSecCount.Count > 0 ? true : false, pth, docver);
|
||||
|
||||
// if no children, add first child (cont)
|
||||
if (addpart)
|
||||
{
|
||||
prc.StructureID = FrID;
|
||||
prc.Save(true); //force update
|
||||
// ContentsParts.Add can use 'fromtype', item - fromtype here = 2, section
|
||||
cont.ContentParts.Add(2,SectItm);
|
||||
if (cont.MyZContent.OldStepSequence == null || cont.MyZContent.OldStepSequence == "") cont.MyZContent.OldStepSequence = ProcNumber;
|
||||
if (!cont.IsSavable) ErrorRpt.ErrorReport(cont);
|
||||
cont.Save();
|
||||
addpart = false;
|
||||
}
|
||||
FrType = 0;
|
||||
dicSecID[dicSecCount.Count] = FrID;
|
||||
if (dicSecCount.Count > 0)
|
||||
//FrType = 0;
|
||||
dicSecParentItem[level] = SectItm;
|
||||
if (level > 0)
|
||||
{
|
||||
if ((dicSecCount[dicSecCount.Count]) == 1)
|
||||
{
|
||||
dicSecCount.Remove(dicSecCount.Count);
|
||||
FrID = dicSecID[dicSecCount.Count];
|
||||
}
|
||||
if ((dicSecCount[level]) == 1)
|
||||
// shift up a level, i.e. give me the parent for the previous level
|
||||
SectItm = dicSecParentItem[--level];
|
||||
else
|
||||
{
|
||||
dicSecCount[dicSecCount.Count] = dicSecCount[dicSecCount.Count] - 1;
|
||||
}
|
||||
dicSecCount[level]--; // decrements number of sections to process
|
||||
}
|
||||
// get number of subsections for this section
|
||||
int subSecs = drw["Sequence"].ToString().PadRight(12, ' ')[5] - 48;
|
||||
if (subSecs > 0)
|
||||
{
|
||||
dicSecCount[dicSecCount.Count + 1] = subSecs;
|
||||
FrType = 2;
|
||||
dicSecCount[++level] = subSecs;
|
||||
cont = SectItm.MyContent;
|
||||
parentitem = SectItm;
|
||||
addpart = true;
|
||||
SectItm = null; // no previous sibling for the first child node.
|
||||
}
|
||||
}
|
||||
// need section start
|
||||
if (EditSectId != 0)
|
||||
{
|
||||
prc.StructureStart = EditSectId;
|
||||
EditSectId = 0;
|
||||
prc.Save(true); // force update
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Procedure", "SectionStart", string.Format("{0}", EditSectId));
|
||||
itm.MyContent.Config = (ci == null) ? null : ci.ToString();
|
||||
if (!itm.IsSavable) ErrorRpt.ErrorReport(itm);
|
||||
itm.Save();
|
||||
}
|
||||
return str.StructureID;
|
||||
return itm;
|
||||
}
|
||||
private Int32 MigrateProcedures(OleDbConnection cn, string pth)
|
||||
private Item MigrateProcedures(OleDbConnection cn, string pth, DocVersion docver)
|
||||
{
|
||||
// Loop through Set File for each Procedure
|
||||
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [set] where entry is not null", cn);
|
||||
DataSet ds = new DataSet();
|
||||
da.Fill(ds);
|
||||
Byte FrType = 1;
|
||||
Int32 FrID = 0;
|
||||
Int32 FirstID = 0;
|
||||
pbProc.Maximum = ds.Tables[0].Rows.Count;
|
||||
UpdateLabels(0, 0, 0);
|
||||
Item FrItm = null;
|
||||
Item FirstItm = null;
|
||||
frmMain.pbProcMaximum = ds.Tables[0].Rows.Count;
|
||||
frmMain.UpdateLabels(0, 0, 0);
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
FrID = MigrateProcedure(cn, dr, FrType, FrID, pth);
|
||||
if (FirstID == 0) FirstID = FrID;
|
||||
FrType = 0;
|
||||
FrItm = MigrateProcedure(cn, dr, FrItm, pth, docver);
|
||||
if (FirstItm == null) FirstItm = FrItm;
|
||||
}
|
||||
da.Dispose();
|
||||
return FirstID;
|
||||
return FirstItm;
|
||||
}
|
||||
private void DbtOk(string fname)
|
||||
{
|
||||
string dbtname = frmMain.tbSourceText + "\\" + fname + ".dbt";
|
||||
if (File.Exists(dbtname))
|
||||
{
|
||||
// check if dbt is at least 512, if not append 508 bytes. This is to fix
|
||||
// a problem where dbts were created with only 4 bytes in the 16-bit code.
|
||||
// if only 4 bytes, ado.net gives an "External table not in expected format"
|
||||
// error
|
||||
FileInfo fi = new FileInfo(dbtname);
|
||||
if (fi.Length < 512)
|
||||
{
|
||||
FileStream fs = new FileStream(dbtname, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
|
||||
BinaryWriter bw = new BinaryWriter(fs);
|
||||
bw.Seek(0, SeekOrigin.End);
|
||||
byte[] wrBytes = new byte[512 - fi.Length];
|
||||
for (int i = 0; i < 512 - fi.Length; i++) wrBytes[i] = 0;
|
||||
wrBytes[4] = 0x02;
|
||||
bw.Write(wrBytes);
|
||||
bw.Close();
|
||||
}
|
||||
fi = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -139,7 +139,8 @@ namespace DataLoader
|
||||
tmp.children = tmpg.children;
|
||||
tmp.value = tmpg.value;
|
||||
tmp.appid = tmpg.appid;
|
||||
tmp.roid = TableID.ToString("X4") + tmp.ID.ToString("X8");
|
||||
string tmpstr = TableID.ToString("X4") + tmp.ID.ToString("X8");
|
||||
tmp.roid = tmpstr.ToUpper();
|
||||
dicRos.Add(tmp.roid, tmp);
|
||||
int j;
|
||||
for (j = i - 1; j >= 0 && tmp.ID < myGrp.children[j].ID; j--)
|
||||
|
@ -19,19 +19,13 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private void AddRoUsage(int structId, string ROID)
|
||||
{
|
||||
RoUsage ro = RoUsage.MakeRoUsage(structId, ROID);
|
||||
ro.StructureID = structId;
|
||||
ro.ROID = ROID;
|
||||
}
|
||||
private string MigrateRos(OleDbConnection cn, string textm, string seqcvt, int structId)
|
||||
private string MigrateRos(OleDbConnection cn, string textm, string seqcvt, Content content)
|
||||
{
|
||||
StringBuilder rotxt = new StringBuilder();
|
||||
int instance = 0;
|
||||
@ -39,7 +33,7 @@ namespace DataLoader
|
||||
DataTable dt = null;
|
||||
DataSet ds = null;
|
||||
OleDbDataAdapter da = null;
|
||||
//TODO: ZSteps
|
||||
|
||||
string cmd = "SELECT * FROM USAGERO WHERE [NUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [SEQUENCE] ='" + seqcvt + "' ORDER BY [INSTANCE]";
|
||||
da = new OleDbDataAdapter(cmd, cn);
|
||||
// get usage records for the ROID.
|
||||
@ -63,17 +57,26 @@ namespace DataLoader
|
||||
// found a token, add the roid & value into the string and
|
||||
// add an ro usage for it.
|
||||
rotxt.Append(textm.Substring(beg, tok - beg));
|
||||
if (instance < dt.Rows.Count)
|
||||
{
|
||||
DataRow dr = dt.Rows[instance];
|
||||
string ROID = dr["ROID"].ToString();
|
||||
AddRoUsage(structId, ROID);
|
||||
rotxt.Append("\x15{{");
|
||||
rotxt.Append(ROID);
|
||||
rotxt.Append("}{");
|
||||
|
||||
string val = rofst.GetRoValue(ROID.Substring(0, 12));
|
||||
RoUsage ro = RoUsage.MakeRoUsage(content, ROID, null, DateTime.Now, "Migration");
|
||||
rotxt.Append("\x15\\v RO\\v0 ");
|
||||
string val = rofst.GetRoValue(ROID.Substring(0, 12).ToUpper());
|
||||
rotxt.Append(val);
|
||||
rotxt.Append("}}");
|
||||
rotxt.Append("\\v #");
|
||||
rotxt.Append(ro.ROUsageID.ToString());
|
||||
rotxt.Append(" ");
|
||||
rotxt.Append(ROID);
|
||||
rotxt.Append("\\v0 ");
|
||||
instance++;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Error("Error setting RO data in text field");
|
||||
log.ErrorFormat("proc number = {0}, oldstepsequence = {1}, instance = {2}", ProcNumber, seqcvt, instance);
|
||||
}
|
||||
beg = tok + 1;
|
||||
if (beg > textm.Length)
|
||||
{
|
||||
@ -89,4 +92,5 @@ namespace DataLoader
|
||||
return rotxt.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Config;
|
||||
|
||||
namespace DataLoader
|
||||
@ -584,12 +584,14 @@ namespace DataLoader
|
||||
Role role = Role.New();
|
||||
role.Name = defaultRole[i];
|
||||
role.Title = defaultRoleTitle[i];
|
||||
if (!role.IsSavable) ErrorRpt.ErrorReport(role);
|
||||
role.Save();
|
||||
Permission perm = Permission.New();
|
||||
perm.RID = role.RID;
|
||||
perm.MyRole = role;
|
||||
perm.PermLevel = defaultPermData[i, 0];
|
||||
perm.VersionType = defaultPermData[i, 1];
|
||||
perm.PermValue = defaultPermData[i, 2];
|
||||
if (!perm.IsSavable) ErrorRpt.ErrorReport(perm);
|
||||
perm.Save();
|
||||
rdic.Add(role.RID, role);
|
||||
for (int j = 1; j < accessLevelSetup.Length; j++)
|
||||
@ -755,7 +757,7 @@ namespace DataLoader
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("here");
|
||||
MessageBox.Show("here: " + ex.Message);
|
||||
}
|
||||
if (!dicOldFolders.ContainsKey(pl.Path.ToUpper()+"\\"+ps.Path.ToUpper()))dicOldFolders.Add(pl.Path.ToUpper()+"\\"+ps.Path.ToUpper(), oldFolderCount++);
|
||||
string sName = FixName(ps.Name);
|
||||
@ -880,12 +882,17 @@ namespace DataLoader
|
||||
}
|
||||
if (pathInData>0)
|
||||
{
|
||||
if (!grp.IsSavable) ErrorRpt.ErrorReport(grp);
|
||||
grp.Save();
|
||||
Folder tmpfld = Folder.Get(pathInData);
|
||||
foreach (int roleId in accessRights[folderId])
|
||||
{
|
||||
grp.GroupAssignments.Add(roleId, pathInData);
|
||||
Role tmprole = Role.Get(roleId);
|
||||
grp.GroupAssignments.Add(tmprole, tmpfld);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!grp.IsSavable) ErrorRpt.ErrorReport(grp);
|
||||
grp.Save();
|
||||
dicGroupIds[s] = grp.GID;
|
||||
}
|
||||
@ -901,7 +908,9 @@ namespace DataLoader
|
||||
newusr.UserID = sUser;
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
cfg.LoadUsrCfg(newusr);
|
||||
newusr.UserMemberships.Add(dicGroupIds[s]);
|
||||
Group tmpgrp = Group.Get(dicGroupIds[s]);
|
||||
newusr.UserMemberships.Add(tmpgrp);
|
||||
if (!newusr.IsSavable) ErrorRpt.ErrorReport(newusr);
|
||||
newusr.Save();
|
||||
}
|
||||
|
||||
|
@ -17,55 +17,52 @@ using System.Data.OleDb;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private Section AddSection(string Number, string Title, DateTime Dts, string Userid, ConfigInfo ci, string stpseq, string fmt, int libdocid, string pth)
|
||||
private Dictionary<string, int> dicOldToNew;
|
||||
private Item AddSection(Item procitem, string Number, string Title, string SecType, DateTime Dts, string Userid, ConfigInfo ci, string stpseq, string fmt, int libdocid, string pth, Item FromItem, DocVersion docver)
|
||||
{
|
||||
UpdateLabels(0, 1, 0);
|
||||
frmMain.UpdateLabels(0, 1, 0);
|
||||
try
|
||||
{
|
||||
string Format = null;
|
||||
Format format = null;
|
||||
|
||||
// do the format field, an xpath for the format & last part is column
|
||||
// mode if a step section.
|
||||
try
|
||||
// Tie the section to format used, this will add the format xml if it doesn't exist in
|
||||
// the database yet. Note that if there is no format at this level then none should
|
||||
// be set so that the inheritance works correctly.
|
||||
if (fmt != null && fmt != "") format = GetFormat(fmt);
|
||||
|
||||
// Find the docstyle based on the section type (step[1]) & the 'type' from the dbf
|
||||
// record sectype[0])
|
||||
string dstyleindx = ((stpseq == null || stpseq == "") ? " " : stpseq.Substring(1, 1)) + ((SecType==null||SecType == "") ? " " : SecType.Substring(0, 1));
|
||||
int docstyleindx = GetDocStyleIndx(dstyleindx, format, procitem, docver);
|
||||
|
||||
// tack on the column mode - add to config xml for node.
|
||||
if (stpseq != null && stpseq.Substring(1, 1) == "0" && stpseq.Substring(5, 1) != " ")
|
||||
{
|
||||
if (fmt != null && fmt != "")
|
||||
{
|
||||
if (fmt.IndexOf(' ') > -1) // will have spaces if it's a user format
|
||||
{
|
||||
string part1 = "/" + fmt.Substring(0, fmt.IndexOf(' ')) + "/";
|
||||
string part2 = "USER=" + fmt.Substring(fmt.LastIndexOf(' ') + 1, 2);
|
||||
Format = part1 + part2;
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Section", "ColumnMode", stpseq.Substring(5, 1));
|
||||
}
|
||||
else
|
||||
Format = "/" + fmt;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("Error getting format {0}", ex.Message);
|
||||
}
|
||||
// tack on the column mode:
|
||||
if (stpseq != null && stpseq.Substring(1, 1) == "0" && stpseq.Substring(5, 1) != " ") Format = Format + "/COL=" + stpseq.Substring(5, 1);
|
||||
|
||||
// find rtf file (or use the library document temp file) & read it into the field
|
||||
// acccontent
|
||||
int Contentid=0;
|
||||
byte ContentType=0;
|
||||
int Documentid=0;
|
||||
bool needEntry = false;
|
||||
if (libdocid != 0 || stpseq.Substring(1, 1) != "0")
|
||||
{
|
||||
needEntry = true;
|
||||
string fname = null;
|
||||
if (libdocid != 0)
|
||||
{
|
||||
Contentid = libdocid;
|
||||
ContentType = 2;
|
||||
Documentid = libdocid;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -73,13 +70,53 @@ namespace DataLoader
|
||||
string thenum = num.ToString("d2");
|
||||
fname = string.Format("{0}\\rtffiles\\{1}.A{2}", pth, ProcFileName, thenum);
|
||||
Application.DoEvents();
|
||||
SaveSectionDocument(fname, stpseq, ref ContentType, ref Contentid);
|
||||
SaveSectionDocument(fname, stpseq, ref Documentid);
|
||||
if (Documentid == 0)
|
||||
{
|
||||
if (MissingDocument==null) MissingDocument = Document.MakeDocument("MISSING FILE IN CONVERSION", null, null, null);
|
||||
Documentid = MissingDocument.DocID;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Userid == null || Userid == "") Userid = "Migration";
|
||||
|
||||
Section sec = Section.MakeSection(Number, Title,ContentType, Contentid, Format, ci.ToString(), Dts, Userid);
|
||||
dicOldStepSequence[sec] = stpseq;
|
||||
return sec;
|
||||
// test for performance
|
||||
Content cont = Content.New(Number, Title, 10000+docstyleindx, format, ci==null?null:ci.ToString(), Dts, Userid);
|
||||
Entry entry = cont.MyEntry;
|
||||
if (needEntry)
|
||||
{
|
||||
entry.MyDocument = Document.Get(Documentid);
|
||||
entry.DTS = Dts;
|
||||
entry.UserID = Userid;
|
||||
//entry = Entry.MakeEntry(cont.ContentID, Document.Get(Documentid), Dts, Userid);
|
||||
}
|
||||
cont.MyZContent.OldStepSequence = ProcNumber + "|" + stpseq;
|
||||
Item itm = null;
|
||||
// the stpseq for section records may include a space & some other data. This
|
||||
// was not part of what is stored in the transition records, so just look at
|
||||
// the sequence before the space for section records. Then use the first character
|
||||
// with a '0'. This is what's stored in the transition record, for example, if the
|
||||
// section was BI, the transition record would have B0 (the reasoning is that
|
||||
// for steps, this is what could be stored if there were enough steps.
|
||||
int trindxsp = stpseq.IndexOf(' ');
|
||||
string trstpseq = trindxsp < 0 ? stpseq : stpseq.Substring(0, 1)+ "0";
|
||||
if (dicTrans_ItemIds.ContainsKey(ProcNumber + "|" + trstpseq))
|
||||
{
|
||||
itm = dicTrans_ItemIds[ProcNumber + "|" + trstpseq];
|
||||
itm.MyContent = cont;
|
||||
itm.MyPrevious = FromItem;
|
||||
itm.DTS = Dts;
|
||||
itm.UserID = Userid;
|
||||
if (!itm.IsSavable) ErrorRpt.ErrorReport(itm);
|
||||
itm.Save();
|
||||
dicTrans_ItemIds.Remove(ProcNumber + "|" + trstpseq);
|
||||
}
|
||||
else
|
||||
itm = Item.MakeItem(FromItem, cont, Dts, Userid);
|
||||
|
||||
dicTrans_ItemDone[ProcNumber+"|"+trstpseq] = itm;
|
||||
dicOldStepSequence[itm] = stpseq;
|
||||
return itm;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -90,11 +127,106 @@ namespace DataLoader
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private string SectTitle(OleDbConnection cn, DataRowView dr)
|
||||
|
||||
private int LookupOldToNew(string lkup)
|
||||
{
|
||||
if (dicOldToNew == null)
|
||||
{
|
||||
dicOldToNew = new Dictionary<string, int>();
|
||||
//dicOldToNew.Add("", 1);
|
||||
dicOldToNew.Add("0", 1);
|
||||
dicOldToNew.Add("0 ", 1);
|
||||
dicOldToNew.Add("00", 1);
|
||||
dicOldToNew.Add("01", 2);
|
||||
dicOldToNew.Add("02", 4);
|
||||
dicOldToNew.Add("03", 8);
|
||||
dicOldToNew.Add("04", 16);
|
||||
dicOldToNew.Add("I", 32);
|
||||
dicOldToNew.Add("I ", 32);
|
||||
dicOldToNew.Add("I0", 32);
|
||||
dicOldToNew.Add("I1", 64);
|
||||
dicOldToNew.Add("I2", 128);
|
||||
dicOldToNew.Add("I3", 256);
|
||||
dicOldToNew.Add("I4", 512);
|
||||
dicOldToNew.Add("A", 1024);
|
||||
dicOldToNew.Add("A ", 1024);
|
||||
dicOldToNew.Add("A0", 1024);
|
||||
dicOldToNew.Add("A1", 2048);
|
||||
dicOldToNew.Add("A2", 4096);
|
||||
dicOldToNew.Add("A3", 8192);
|
||||
dicOldToNew.Add("A4", 16384);
|
||||
dicOldToNew.Add("F", 32768);
|
||||
dicOldToNew.Add("F ", 32768);
|
||||
dicOldToNew.Add("F0", 32768);
|
||||
dicOldToNew.Add("F1", 65536);
|
||||
dicOldToNew.Add("F2", 131072);
|
||||
dicOldToNew.Add("F3", 262144);
|
||||
dicOldToNew.Add("F4", 524288);
|
||||
dicOldToNew.Add("05", 1048576);
|
||||
dicOldToNew.Add("06", 2097152);
|
||||
dicOldToNew.Add("07", 4194304);
|
||||
dicOldToNew.Add("08", 8388608);
|
||||
dicOldToNew.Add("09", 16777216);
|
||||
dicOldToNew.Add("0:", 33554432);
|
||||
dicOldToNew.Add("0;", 67108864);
|
||||
dicOldToNew.Add("0<", 134217728);
|
||||
dicOldToNew.Add("0=", 268435456);
|
||||
dicOldToNew.Add("0>", 536870912);
|
||||
}
|
||||
int retval = -1;
|
||||
try
|
||||
{
|
||||
retval = dicOldToNew[lkup];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(string.Format("Error in oldtonew {0}", lkup));
|
||||
Console.WriteLine(string.Format("Error = {0}", ex.Message));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
private int GetDocStyleIndx(string dstyleindx, Format format, Item procitem, DocVersion docver)
|
||||
{
|
||||
// get the format, if format is set, use it, otherwise walk
|
||||
if (format == null)
|
||||
{
|
||||
format = GetFormat(procitem, docver);
|
||||
}
|
||||
int docstyle = LookupOldToNew(dstyleindx);
|
||||
foreach (DocStyle ds in format.PlantFormat.DocStyles.DocStyleList)
|
||||
{
|
||||
if ((ds.OldToNew & docstyle)>0) return (int)ds.Index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private Format GetFormat(Item procitem, DocVersion docver)
|
||||
{
|
||||
while (procitem.MyContent.MyFormat == null)
|
||||
{
|
||||
// find the first sibling
|
||||
while (procitem.PreviousID != null)
|
||||
procitem = procitem.MyPrevious;
|
||||
if (procitem.ItemPartCount == 0) return GetFormat(docver);
|
||||
// find the parent node
|
||||
procitem = procitem.ItemParts[0].MyContent.ContentItems[0].MyItem;
|
||||
}
|
||||
return procitem.MyContent.MyFormat;
|
||||
}
|
||||
private Format GetFormat(DocVersion docver)
|
||||
{
|
||||
if (docver.MyFormat != null) return docver.MyFormat;
|
||||
return GetFormat(docver.MyFolder);
|
||||
}
|
||||
private Format GetFormat(Folder folder)
|
||||
{
|
||||
if (folder.MyFormat != null) return folder.MyFormat;
|
||||
return GetFormat(folder.MyParent);
|
||||
}
|
||||
private string SectTitle(OleDbConnection cn, DataRowView dr, bool UseMultiLineSectionTitle, bool ConvertCaret)
|
||||
{
|
||||
string tbuff = null;
|
||||
string menustr = null;
|
||||
bool UseMultiLineSectionTitle = false; // TODO KBR: format flag
|
||||
|
||||
if (UseMultiLineSectionTitle)
|
||||
{
|
||||
bool titleInMemo = false;
|
||||
@ -112,11 +244,11 @@ namespace DataLoader
|
||||
if (ds.Tables[0].Rows.Count == 1)
|
||||
{
|
||||
DataRow row = ds.Tables[0].Rows[0];
|
||||
tbuff = TextConvert.ConvertText(row["Textm"].ToString());
|
||||
if (tbuff != null || tbuff[0] != '\0') titleInMemo = true;
|
||||
tbuff = TextConvert.ConvertText(row["Textm"].ToString(),ConvertCaret);
|
||||
if (tbuff != null && tbuff != "") titleInMemo = true;
|
||||
}
|
||||
else // no long section title existed for this accessory page
|
||||
tbuff = TextConvert.ConvertText(dr["Text"].ToString().PadRight(130, ' ').Substring(0, 75).TrimEnd());
|
||||
tbuff = TextConvert.ConvertText(dr["Text"].ToString().PadRight(130, ' ').Substring(0, 75).TrimEnd(), ConvertCaret);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -127,45 +259,69 @@ namespace DataLoader
|
||||
// (see above comment for accessory pages to see the difference)
|
||||
else
|
||||
{
|
||||
tbuff = TextConvert.ConvertText(dr["TextM"].ToString().Trim());
|
||||
tbuff = TextConvert.ConvertText(dr["TextM"].ToString().Trim(), ConvertCaret);
|
||||
}
|
||||
|
||||
//// TESTS were run & it looked like that whitespace was removed before saving,
|
||||
//// so, put up a message box if find out otherwise....
|
||||
int nl = tbuff.IndexOf("\n");
|
||||
if (nl > -1)
|
||||
MessageBox.Show("multiline text for section title, fix this!!");
|
||||
//int nl = tbuff.IndexOf("\n");
|
||||
//if (nl > -1)
|
||||
// MessageBox.Show("multiline text for section title, fix this!!");
|
||||
|
||||
//// remove newlines & any other escape/whitespace chars.
|
||||
//int nl = tbuff.IndexOf("\n");
|
||||
//if (nl > -1 || titleInMemo)
|
||||
//{
|
||||
int nl = tbuff.IndexOf("\n");
|
||||
if (nl > -1 || titleInMemo)
|
||||
{
|
||||
|
||||
// string tmpstr = tbuff.Replace("\r", "");
|
||||
// tmpstr = tmpstr.Replace("\t", "");
|
||||
// tmpstr = tmpstr.Replace("\n", " ");
|
||||
// // get rid of multiple spaces
|
||||
// while (tmpstr.IndexOf(" ") > -1) tmpstr = tmpstr.Replace(" ", " ");
|
||||
// tbuff = tmpstr;
|
||||
// if (tbuff.Substring(tbuff.Length-1, 1) == " ") tbuff = tbuff.Substring(0, tbuff.Length - 1);
|
||||
//}
|
||||
//menustr = tbuff;
|
||||
string tmpstr = tbuff.Replace("\r", "");
|
||||
tmpstr = tmpstr.Replace("\t", "");
|
||||
tmpstr = tmpstr.Replace("\n", " ");
|
||||
// get rid of multiple spaces
|
||||
while (tmpstr.IndexOf(" ") > -1) tmpstr = tmpstr.Replace(" ", " ");
|
||||
tbuff = tmpstr;
|
||||
if (tbuff.Substring(tbuff.Length - 1, 1) == " ") tbuff = tbuff.Substring(0, tbuff.Length - 1);
|
||||
menustr = tbuff;
|
||||
}
|
||||
else
|
||||
{
|
||||
menustr = TextConvert.ConvertText(dr["Text"].ToString().PadRight(80, ' ').Substring(0, 75).TrimEnd(), ConvertCaret);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // format does not include long section title
|
||||
menustr = TextConvert.ConvertText(dr["Text"].ToString().PadRight(80, ' ').Substring(0, 75).TrimEnd());
|
||||
menustr = TextConvert.ConvertText(dr["Text"].ToString().PadRight(80, ' ').Substring(0, 75).TrimEnd(), ConvertCaret);
|
||||
}
|
||||
return menustr;
|
||||
}
|
||||
private Int32 MigrateSection(Procedure prc, OleDbConnection cn, DataRowView dr, DataTable dt, Byte FromType, Int32 FromID, bool isSubSection, string pth)
|
||||
private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool isSubSection, string pth, DocVersion docver)
|
||||
{
|
||||
Int32 thesectid = 0;
|
||||
bool islibdoc = false;
|
||||
//bool hasxml = false;
|
||||
bool isautogen = false;
|
||||
string stype = dr["type"].ToString();
|
||||
string s = dr["text"].ToString().PadRight(130, ' ');
|
||||
string num = s.Substring(85, 20).TrimEnd();
|
||||
string fmt = s.Substring(75, 10).TrimEnd();
|
||||
string title = SectTitle(cn, dr);
|
||||
if (fmt == "") fmt = null;
|
||||
bool ismulti = false;
|
||||
bool conv_caret = true;
|
||||
|
||||
// sectFormat is a local that represents the format to be used by this section.
|
||||
// Note that if the format is set for this section, check it against what the inherited
|
||||
// value would be (for example, what the format is for the set), if they are the same
|
||||
// clear the format at the section level.
|
||||
Format sectFormat = null;
|
||||
Format docverFormat = docver.ActiveFormat;
|
||||
if (fmt != null&& fmt !="") // Is there a long section title (from format flag)
|
||||
sectFormat = GetFormat(fmt);
|
||||
else // either from this format, or the plant.
|
||||
sectFormat = docverFormat;
|
||||
if (sectFormat != null)
|
||||
{
|
||||
ismulti = sectFormat.PlantFormat.FormatData.XtraOptions("UseMultiLineSectionTitle");
|
||||
conv_caret = !(sectFormat.PlantFormat.FormatData.XtraOptions("DontConvertCarrotToDelta"));
|
||||
}
|
||||
if (fmt != null && fmt != "") if (fmt == docverFormat.Name) fmt = null;
|
||||
string title = SectTitle(cn, dr, ismulti, conv_caret);
|
||||
string init = dr["initials"].ToString().Trim();
|
||||
string sequence = dr["CSequence"].ToString().PadRight(10);
|
||||
string step = dr["CStep"].ToString();
|
||||
@ -173,7 +329,8 @@ namespace DataLoader
|
||||
|
||||
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
|
||||
|
||||
ConfigInfo ci = new ConfigInfo(null);
|
||||
ConfigInfo ci = null;
|
||||
|
||||
// for steps sections...
|
||||
// Step Section Header Format:
|
||||
// A0 1X2S51 &Y
|
||||
@ -199,37 +356,40 @@ namespace DataLoader
|
||||
// set pagination, continuous, separate. If blank, don't create attribute - uses format default.
|
||||
if (sequence.Substring(4, 1) == "T")
|
||||
{
|
||||
if(ci==null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Section", "Pagination", "C");
|
||||
//hasxml = SetXml(xmldoc, topElement, "Section", "Pagination", "C");
|
||||
}
|
||||
else if (sequence.Substring(4, 1) == "S")
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Section", "Pagination", "S");
|
||||
//hasxml = SetXml(xmldoc, topElement, "Section", "Pagination", "S");
|
||||
}
|
||||
|
||||
// Step: linked to enhanced (!exist = N)
|
||||
if (sequence.Substring(7, 1) == "1")
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Step", "LnkEnh", "Y");
|
||||
//hasxml = SetXml(xmldoc, topElement, "Step", "LnkEnh", "Y");
|
||||
}
|
||||
char cbittst = sequence.PadRight(10)[8];
|
||||
if (cbittst == ' ') cbittst = '\0';
|
||||
|
||||
if (cbittst == ' ')
|
||||
cbittst = '\0';
|
||||
else
|
||||
{
|
||||
// determine if TOC element (!exist = N)
|
||||
if ((cbittst & TOC) > 1)
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Section", "TOC", "Y");
|
||||
//hasxml = SetXml(xmldoc, topElement, "Section", "TOC", "Y");
|
||||
}
|
||||
// determine if autogenerated section (!exist = N)
|
||||
if ((cbittst & AUTOGEN) > 1)
|
||||
{
|
||||
isautogen = true;
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Section", "AutoGen", "Y");
|
||||
//hasxml = SetXml(xmldoc, topElement, "Section", "AutoGen", "Y");
|
||||
}
|
||||
|
||||
}
|
||||
// Here are subsection flags, i.e. the following are only set if this
|
||||
// is a subsection.
|
||||
bool didsub = false;
|
||||
@ -238,29 +398,29 @@ namespace DataLoader
|
||||
// Subsection: editable (!exist = Y)
|
||||
if ((cbittst & EDDATA) > 0)
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("SubSection", "Edit", "N");
|
||||
//SetXml(xmldoc, topElement, "SubSection", "Edit", "N");
|
||||
}
|
||||
|
||||
// Subsection: print section headers (!exist = Y)
|
||||
if ((cbittst & PH) > 0)
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
didsub = true;
|
||||
ci.AddItem("SubSection", "PH", "N");
|
||||
//SetXml(xmldoc, topElement, "SubSection", "PH", "N");
|
||||
}
|
||||
|
||||
// Subsection: autoindent (!exist = Y)
|
||||
if ((cbittst & AUTOIND) > 0)
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("SubSection", "AutoIndent", "N");
|
||||
//SetXml(xmldoc, topElement, "SubSection", "AutoIndent", "N");
|
||||
}
|
||||
}
|
||||
if (!didsub && sequence.Substring(4, 1) == "N")
|
||||
{
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("SubSection", "PH", "N");
|
||||
//SetXml(xmldoc, topElement, "SubSection", "PH", "N");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -273,26 +433,29 @@ namespace DataLoader
|
||||
// || `--- Position within the procedure
|
||||
// |`----- Acc. page type (A,I, or F)
|
||||
// `------ Internal section number (starts at A)
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Section", "NumPages", sequence.Substring(3, 1));
|
||||
//hasxml = SetXml(xmldoc, topElement, "Section", "NumPages", sequence.Substring(3, 1));
|
||||
|
||||
// see if it's a libdoc too.0
|
||||
string thekey = prc.Number.PadRight(20) + step.Substring(0, 1).PadRight(10);
|
||||
// see if it's a libdoc too
|
||||
string thekey = procnum.PadRight(20) + step.Substring(0, 1).PadRight(10);
|
||||
if (dicLibDocRef.ContainsKey(thekey))
|
||||
{
|
||||
// if it is a library document, see if the section record has already been
|
||||
// saved. If it has, just use this section id, otherwise, create the
|
||||
// section record with info from the library document file.
|
||||
libDocid = dicLibDocRef[thekey];
|
||||
islibdoc = true;
|
||||
}
|
||||
}
|
||||
|
||||
Section sec = AddSection(num, title, dts, init, ci, step + sequence, fmt, libDocid, pth);
|
||||
thesectid = sec.SectID;
|
||||
Item secitem = AddSection(procitem, num, title, stype, dts, init, ci, step + sequence, fmt, libDocid, pth, FromItem, docver);
|
||||
thesectid = secitem.ItemID;
|
||||
|
||||
// if this section has the original edit section flag (sequence[2]) save the id.
|
||||
if (!islibdoc && step[1] == '0' && (sequence[2] == 'x' || sequence[2] == 'X'))
|
||||
// if the editsectid hasn't been set yet, set it to this section id, i.e. the first
|
||||
// one processed. Then if this section has the original edit section flag (sequence[2])
|
||||
// save the id. The first step is necessary in case there is no original edit section
|
||||
// flag set, so that the first section is the default one to get opened in edit.
|
||||
if (EditSectId==0)EditSectId = thesectid;
|
||||
if (libDocid<1 && step[1] == '0' && (sequence[2] == 'x' || sequence[2] == 'X'))
|
||||
EditSectId = thesectid;
|
||||
// ContentType (2 in the following call) are:
|
||||
// 0 = structure,
|
||||
@ -302,35 +465,35 @@ namespace DataLoader
|
||||
// 4 = branch
|
||||
|
||||
// fromtype values are (see steps.cs too)
|
||||
// 0 = next of same type
|
||||
// 1 = procedure,
|
||||
// 2 = section,
|
||||
// 3 = caution
|
||||
// 4 = note
|
||||
// 5 = RNO
|
||||
// 6 = substep
|
||||
// 6 = step
|
||||
// 7 = table
|
||||
|
||||
Structure str = AddStructure(FromType, FromID, 2, thesectid, step + sequence, dts, init);
|
||||
if (!isautogen)
|
||||
{
|
||||
// Process the Data Table - First look for High Level Steps
|
||||
string sQry = string.Format("Step like '[{0}]%' and Sequence='S'", dr["Step"].ToString().Substring(0, 1));
|
||||
DataView dv = new DataView(dt, sQry, "StepNo", DataViewRowState.CurrentRows);
|
||||
Byte FrType = 6;
|
||||
Int32 FrID = 0;
|
||||
pbStep.Maximum = dt.Rows.Count;
|
||||
pbStep.Value = 0;
|
||||
Item FrItem = null;
|
||||
frmMain.pbStepMaximum = dt.Rows.Count;
|
||||
frmMain.pbStepValue = 0;
|
||||
foreach (DataRowView drv in dv)
|
||||
{
|
||||
FrID = MigrateStep(cn, dt, drv, FrType, FrID);
|
||||
if (sec.ContentID == 0)
|
||||
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret);
|
||||
if (secitem.MyContent.ContentParts.Count == 0)
|
||||
{
|
||||
sec.ContentID = FrID;
|
||||
sec.ContentType = 1;
|
||||
sec.Save(true);
|
||||
// type 6 is step
|
||||
secitem.MyContent.ContentParts.Add(6, FrItem);
|
||||
if (!secitem.MyContent.IsSavable) ErrorRpt.ErrorReport(secitem.MyContent);
|
||||
secitem.MyContent.Save();
|
||||
}
|
||||
FrType = 0;
|
||||
}
|
||||
return str.StructureID;
|
||||
}
|
||||
return secitem;
|
||||
}
|
||||
private void LoadSection(DataSet ds, OleDbDataAdapter da, string FileName)
|
||||
{
|
||||
@ -359,12 +522,12 @@ namespace DataLoader
|
||||
switch (ex.Message)
|
||||
{
|
||||
case "Index file not found.":// then delete inf file
|
||||
fi = new FileInfo(tbSource.Text + "\\" + FileName + ".inf");
|
||||
fi = new FileInfo(frmMain.tbSourceText + "\\" + FileName + ".inf");
|
||||
fi.Delete();
|
||||
LoadSection(ds, da, FileName);// Try Again
|
||||
break;
|
||||
case "External table is not in the expected format.": // then pad dbt file with 128 zeros.
|
||||
fi = new FileInfo(tbSource.Text + "\\" + FileName + ".dbt");
|
||||
fi = new FileInfo(frmMain.tbSourceText + "\\" + FileName + ".dbt");
|
||||
FileStream fs = fi.OpenWrite();
|
||||
fs.Position = fs.Length;
|
||||
byte[] buf = new byte[128];
|
||||
|
@ -10,19 +10,21 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private Step AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, int structid, DateTime dts, string userid)
|
||||
private Item AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, Item FromItem, DateTime dts, string userid, bool conv_caret)
|
||||
{
|
||||
Step stp = null;
|
||||
UpdateLabels(0, 0, 1);
|
||||
bool hasxml = false;
|
||||
ConfigInfo ci = new ConfigInfo(null);
|
||||
Content content = null;
|
||||
Item item = null;
|
||||
|
||||
frmMain.UpdateLabels(0, 0, 1);
|
||||
ConfigInfo ci = null;
|
||||
string stptext = null;
|
||||
if (userid == null || userid == "") userid = "Migration";
|
||||
int tok = -1;
|
||||
char[] chrarr = { '\x1', '\x2', '\x3', '\x5' };
|
||||
try
|
||||
@ -31,9 +33,9 @@ namespace DataLoader
|
||||
// with it with a 'token' as a separator (see below).
|
||||
tok = Textm.IndexOfAny(chrarr);
|
||||
if (tok < 0)
|
||||
stptext = TextConvert.ConvertText(Textm);
|
||||
stptext = TextConvert.ConvertText(Textm, conv_caret);
|
||||
else
|
||||
stptext = TextConvert.ConvertText(Textm.Substring(0, tok));
|
||||
stptext = TextConvert.ConvertText(Textm.Substring(0, tok), conv_caret);
|
||||
|
||||
string seqcvt = TextConvert.ConvertSeq(stpseq);
|
||||
|
||||
@ -44,9 +46,30 @@ namespace DataLoader
|
||||
log.Error("Found a old style figure!");
|
||||
log.ErrorFormat("oldstepsequence = {0}", stpseq);
|
||||
}
|
||||
string newstptyp = null;
|
||||
bool ManualPagebreak = false;
|
||||
char cbittst = StepType.PadRight(2)[0];
|
||||
if (cbittst != ' ' && (cbittst & 0x80) > 1)
|
||||
{
|
||||
ManualPagebreak = true;
|
||||
if (ci==null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Step", "ManualPagebreak", "True");
|
||||
newstptyp = StepType.Substring(1, 1);
|
||||
}
|
||||
|
||||
// Need the content record for the RO & transitions.
|
||||
//content = Content.MakeContent(null, stptext, 20000 + int.Parse(newstptyp!=null?newstptyp:StepType),null, ManualPagebreak?ci.ToString():null, dts, userid);
|
||||
content = Content.New(null, stptext, 20000 + int.Parse(newstptyp != null ? newstptyp : StepType), null, ManualPagebreak ? ci.ToString() : null, dts, userid);
|
||||
content.MyZContent.OldStepSequence = ProcNumber + "|" + stpseq;
|
||||
|
||||
// Before we save it, handle RO & Transitions tokens.
|
||||
int tokrt = Textm.IndexOf('\x15');
|
||||
if (tokrt > -1) stptext = MigrateRos(cn, stptext, seqcvt, structid);
|
||||
bool txtdirty = false;
|
||||
if (tokrt > -1)
|
||||
{
|
||||
txtdirty = true;
|
||||
stptext = MigrateRos(cn, stptext, seqcvt, content);
|
||||
}
|
||||
|
||||
// 16-bit code has the following two defines.
|
||||
// #define TransitionMarker 0xC2
|
||||
@ -55,10 +78,34 @@ namespace DataLoader
|
||||
// use the unicode chars.
|
||||
char[] chrrotrn = { '\x252C', '\x2566' };
|
||||
tokrt = Textm.IndexOfAny(chrrotrn);
|
||||
if (tokrt > -1) stptext = MigrateTrans(cn, stptext, seqcvt, structid);
|
||||
TextM tm = TextM.MakeTextM(stptext);
|
||||
stp = Step.MakeStep(StepType, tm.TextMID, null, dts, userid);
|
||||
dicOldStepSequence[stp] = seqcvt;
|
||||
if (tokrt > -1)
|
||||
{
|
||||
txtdirty = true;
|
||||
stptext = MigrateTrans(cn, stptext, seqcvt, content);
|
||||
}
|
||||
if (txtdirty)
|
||||
{
|
||||
content.Text = stptext;
|
||||
//content.Save();
|
||||
}
|
||||
if (!content.IsSavable) ErrorRpt.ErrorReport(content);
|
||||
content.Save();
|
||||
// check if already created thru new during transition migration...
|
||||
if (dicTrans_ItemIds.ContainsKey(ProcNumber + "|" + seqcvt))
|
||||
{
|
||||
item = dicTrans_ItemIds[ProcNumber + "|" + seqcvt];
|
||||
item.MyPrevious = FromItem;
|
||||
item.MyContent = content;
|
||||
item.DTS = dts;
|
||||
item.UserID = userid;
|
||||
if (!item.IsSavable) ErrorRpt.ErrorReport(item);
|
||||
item.Save();
|
||||
dicTrans_ItemIds.Remove(ProcNumber + "|" + seqcvt);
|
||||
}
|
||||
else
|
||||
item = Item.MakeItem(FromItem, content, content.DTS, content.UserID);
|
||||
dicTrans_ItemDone[ProcNumber + "|" + seqcvt] = item;
|
||||
dicOldStepSequence[content] = seqcvt;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -66,7 +113,7 @@ namespace DataLoader
|
||||
log.ErrorFormat("oldstepsequence = {0}", stpseq);
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
log.ErrorFormat(ex.StackTrace);
|
||||
stp = null;
|
||||
item = null;
|
||||
}
|
||||
|
||||
// now add on any support pieces of text associated with the step.
|
||||
@ -77,15 +124,21 @@ namespace DataLoader
|
||||
// '\3\3'override tab
|
||||
// '\5' continuous action summary flag
|
||||
|
||||
bool recdirty = false;
|
||||
try
|
||||
{
|
||||
while (tok >= 0 && tok != Textm.Length)
|
||||
{
|
||||
int nxttok = Textm.IndexOfAny(chrarr, tok + 1);
|
||||
|
||||
char chr = Textm[tok];
|
||||
int typ = 0;
|
||||
if (chr == '\x1')
|
||||
typ = STP_COMMENT;
|
||||
{
|
||||
// add the comment to annotation table. Set type to comment.
|
||||
if (nxttok < 0) nxttok = Textm.Length;
|
||||
Annotation annot = Annotation.MakeAnnotation(item, CommentType, null, Textm.Substring(tok + 1, nxttok - tok - 1), null, dts, userid);
|
||||
}
|
||||
else if (chr == '\x2')
|
||||
typ = STP_MULT_CHGID;
|
||||
else if (chr == '\x3')
|
||||
@ -105,25 +158,27 @@ namespace DataLoader
|
||||
}
|
||||
else if (chr == '\x5')
|
||||
{
|
||||
recdirty = true;
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Step", "ContActSum", "True");
|
||||
//hasxml = SetXml(xmldoc, topElement, "Step", "ContActSum", "True");
|
||||
if (nxttok < 0) nxttok = Textm.Length;
|
||||
}
|
||||
|
||||
// if not xml, i.e. chr=='\x5', make a textm element
|
||||
if (chr != '\x5')
|
||||
// if not comment or ContActSum (xml) make a steptext element
|
||||
if (typ == STP_MULT_CHGID || typ == STP_LNK_SEQ || typ == STP_OVR_TAB)
|
||||
{
|
||||
if (nxttok < 0) nxttok = Textm.Length;
|
||||
// if this is a sequence number - may need to convert hi-end chars
|
||||
string str = null;
|
||||
string strn = null;
|
||||
if (typ == STP_LNK_SEQ)
|
||||
str = TextConvert.ConvertSeq(Textm.Substring(tok + 1, nxttok - tok - 1));
|
||||
strn = TextConvert.ConvertSeq(Textm.Substring(tok + 1, nxttok - tok - 1));
|
||||
else
|
||||
str = Textm.Substring(tok + 1, nxttok - tok - 1);
|
||||
//StepText stptxt = StepText.MakeStepText(typ, str, true);
|
||||
//stptxt.ItemType = typ;
|
||||
//stptxt.Textm = str;
|
||||
//stp.StepStepTexts.Add(
|
||||
strn = Textm.Substring(tok + 1, nxttok - tok - 1);
|
||||
if (strn != null && strn != "")
|
||||
{
|
||||
recdirty = true;
|
||||
content.ContentDetails.Add(typ, strn);
|
||||
}
|
||||
}
|
||||
tok = nxttok;
|
||||
}
|
||||
@ -131,9 +186,10 @@ namespace DataLoader
|
||||
// also see if a check-off needs added.
|
||||
if (Recid[0] != '0')
|
||||
{
|
||||
recdirty = true;
|
||||
string chkindx = Recid[0].ToString();
|
||||
if (ci == null) ci = new ConfigInfo(null);
|
||||
ci.AddItem("Step", "CheckOffIndex", chkindx);
|
||||
//hasxml = SetXml(xmldoc, topElement, "Step", "CheckOffIndex", chkindx);
|
||||
}
|
||||
|
||||
// here's where it knows if it's a linked step (or in processstep)
|
||||
@ -143,15 +199,12 @@ namespace DataLoader
|
||||
}
|
||||
|
||||
// if checkoffs or the continuous action summary flag, save the xml.
|
||||
if (hasxml)
|
||||
if (recdirty)
|
||||
{
|
||||
stp.Config = ci.ToString();
|
||||
stp.Save(true);
|
||||
if (ci != null) content.Config = ci.ToString();
|
||||
if (!content.IsSavable) ErrorRpt.ErrorReport(content);
|
||||
content.Save();
|
||||
}
|
||||
// if this has associated steptext, such as tab override or comment,
|
||||
// save it.
|
||||
//else if (stp.StepStepTexts.Count > 0)
|
||||
// stp.Save(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -160,29 +213,8 @@ namespace DataLoader
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
log.ErrorFormat(ex.StackTrace);
|
||||
}
|
||||
return stp;
|
||||
return item;
|
||||
}
|
||||
|
||||
// private void ProcessSubStep(DataTable dt,DataRowView drv,StepTbl stpP)
|
||||
// {
|
||||
// // TODO: Need logic for TextM Support
|
||||
// StepTbl stp = AddStep(stpP,drv["Type"].ToString(),drv["Text"].ToString(),drv["Step"].ToString()+drv["sequence"].ToString());
|
||||
// // TODO: Logic to add Sub-steps
|
||||
// string sPre = drv["Sequence"].ToString();
|
||||
// ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"[*!]?",stp);// Cautions and Notes
|
||||
// ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"$",stp);// RNOs
|
||||
// ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"?",stp);// Substeps
|
||||
// //ProcessSubSteps(dt,drv["Step"],"S_",stp);// Tables
|
||||
// }
|
||||
// private void ProcessSubSteps(DataTable dt,string step,string lookfor,StepTbl stp)
|
||||
// {
|
||||
// DataView dv = new DataView(dt,"Step='" + step + "' and Sequence like'" + lookfor + "'",
|
||||
// "sequence",DataViewRowState.OriginalRows);
|
||||
// foreach(DataRowView drv in dv)
|
||||
// {
|
||||
// ProcessSubStep(dt,drv,stp);
|
||||
// }
|
||||
// }
|
||||
private string GetParent(string s)
|
||||
{
|
||||
string retval = "S";
|
||||
@ -219,30 +251,30 @@ namespace DataLoader
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
private Int32 MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Byte FromType, Int32 FromID)
|
||||
private Item MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Item FromItem, bool conv_caret)
|
||||
{
|
||||
try
|
||||
{
|
||||
int tmpid = 1;
|
||||
|
||||
// Do the structure record first because usages from the step require a structure
|
||||
// id.
|
||||
string sType = GetStructType(drv["CSequence"].ToString());
|
||||
// Structures str = AddStructure(FromType, FromID, (byte)(3 + ("CNRST".IndexOf(sType))), tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(),
|
||||
Structure str = AddStructure(FromType, FromID, 3, tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(),
|
||||
GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||
Step stp = AddStep(cn, drv["Type"].ToString()
|
||||
Item item = AddStep(cn, drv["Type"].ToString()
|
||||
, (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString())
|
||||
, drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", str.StructureID
|
||||
, GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||
str.ContentID = stp.StepID;
|
||||
str.Save(true);
|
||||
Dictionary<string, Step> dicStep = new Dictionary<string, Step>();
|
||||
dicStep[drv["CSequence"].ToString()] = stp;
|
||||
Dictionary<string, Dictionary<string, int>> dicStruct = new Dictionary<string, Dictionary<string, int>>();
|
||||
Dictionary<string, int> dicBase = new Dictionary<string, int>();
|
||||
, drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", FromItem // was str
|
||||
, GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString(), conv_caret);
|
||||
//Content cont = Content.MakeContent(null,(drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString()),drv["Type"]+20000,null,null,
|
||||
// GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||
//Item item = Item.MakeItem(FromItem, cont, cont.DTS, cont.UserID);
|
||||
//Structure str = AddStructure(FromType, FromID, 3, tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(),
|
||||
// GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||
//Step stp = AddStep(cn, drv["Type"].ToString()
|
||||
// , (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString())
|
||||
// , drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", str
|
||||
// , GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||
Dictionary<string, Item> dicStep = new Dictionary<string, Item>();
|
||||
dicStep[drv["CSequence"].ToString()] = item;
|
||||
Dictionary<string, Dictionary<string, Item>> dicStruct = new Dictionary<string, Dictionary<string, Item>>();
|
||||
Dictionary<string, Item> dicBase = new Dictionary<string, Item>();
|
||||
dicStruct[drv["CSequence"].ToString()] = dicBase;
|
||||
dicBase[""] = str.StructureID;
|
||||
dicBase[""] = item;
|
||||
// Logic to add Sub-steps
|
||||
string sQry = "CStep = '" + drv["CStep"].ToString() + "' and CSequence <> 'S'";
|
||||
// sort order - for sections use currentrows.
|
||||
@ -250,8 +282,8 @@ namespace DataLoader
|
||||
//dataGrid1.DataSource=dv;
|
||||
//Loop through DataView and add Steps one at a time
|
||||
//Console.WriteLine("={0}",drv["Step"]);
|
||||
Byte FrType = 0;
|
||||
Int32 FrID = str.StructureID;
|
||||
int FrType = 0; // type of relationship (not type of step)
|
||||
Item FrItem = item;
|
||||
foreach (DataRowView drvs in dv)
|
||||
{
|
||||
//Console.WriteLine(">{0}",drvs["CStep"]);
|
||||
@ -259,49 +291,53 @@ namespace DataLoader
|
||||
string sParent = GetParent(drvs["CSequence"].ToString());
|
||||
if (dicStep.ContainsKey(sParent))
|
||||
{
|
||||
Step stpp = dicStep[sParent];
|
||||
Item itemp = dicStep[sParent];
|
||||
sType = GetStructType(drvs["CSequence"].ToString());
|
||||
Dictionary<string,int> dicStr = dicStruct[sParent];
|
||||
if (dicStr.ContainsKey(sType))
|
||||
Dictionary<string,Item> dicStr = dicStruct[sParent];
|
||||
// check if a step type of 'sType' exists to see if child/sibling
|
||||
//Content contc = Content.MakeContent(null,(drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString()),drvs["Type"]+20000,null,null,
|
||||
// GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString()));
|
||||
Item itemc = null;
|
||||
if (dicStr.ContainsKey(sType)) // next sibling
|
||||
{
|
||||
FrID = (Int32)dicStr[sType];
|
||||
FrItem = dicStr[sType];
|
||||
FrType = 0;
|
||||
}
|
||||
else
|
||||
else // child of a node
|
||||
{
|
||||
FrID = (Int32)dicStr[""];
|
||||
FrType = (byte)(3 + ("CNRST".IndexOf(sType)));
|
||||
FrItem = null;
|
||||
FrType = (3 + ("CNRST".IndexOf(sType)));
|
||||
}
|
||||
Structure str1 = AddStructure(FrType, FrID, 3, tmpid++, drvs["CStep"].ToString() + drvs["CSequence"].ToString(),
|
||||
GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString());
|
||||
Step stpc = AddStep(cn, drvs["Type"].ToString()
|
||||
itemc = AddStep(cn, drvs["Type"].ToString()
|
||||
, (drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString())
|
||||
, drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString(), GetStructType(drvs["sequence"].ToString()), str1.StructureID
|
||||
, GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString());
|
||||
str1.ContentID = stpc.StepID;
|
||||
str1.Save(true);
|
||||
dicStep[drvs["CSequence"].ToString()] = stpc;
|
||||
, drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString()
|
||||
, GetStructType(drvs["sequence"].ToString()), FrItem
|
||||
, GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString(), conv_caret);
|
||||
|
||||
dicBase = new Dictionary<string, int>();
|
||||
dicStruct[drvs["CSequence"].ToString()] = dicBase;
|
||||
dicBase[""] = str1.StructureID;
|
||||
dicStr[sType] = str1.StructureID;
|
||||
if (FrType > 0 )
|
||||
{
|
||||
itemp.MyContent.ContentParts.Add(FrType, itemc);
|
||||
if (!itemp.MyContent.IsSavable) ErrorRpt.ErrorReport(itemp.MyContent);
|
||||
itemp.MyContent.Save();
|
||||
}
|
||||
dicStr[sType] = itemc;
|
||||
dicStruct[drvs["CSequence"].ToString()] = new Dictionary<string, Item>();
|
||||
dicStep[drvs["CSequence"].ToString()] = itemc;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.ErrorFormat("Parent {0} Could not be found for {1}", sParent, drvs["sequence"].ToString());
|
||||
}
|
||||
}
|
||||
return str.StructureID;
|
||||
return item;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("PROCESS STEP");
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
log.ErrorFormat(ex.StackTrace);
|
||||
return 0;
|
||||
}
|
||||
//return 0;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -88,6 +88,8 @@ namespace DataLoader
|
||||
dicChar[8734] = 8857;
|
||||
dicChar[7] = 9679;
|
||||
dicChar[8976] = 9830;
|
||||
dicChar[9632] = 9604;
|
||||
//dicChar[236] = 38914;
|
||||
char[] creg = new char[dicChar.Count];
|
||||
int i = 0;
|
||||
foreach (int ic in dicChar.Keys)
|
||||
@ -111,9 +113,86 @@ namespace DataLoader
|
||||
}
|
||||
return new string(cs);
|
||||
}
|
||||
public static string ConvertText(string s1, bool DoCaret)
|
||||
{
|
||||
string s2 = s1;
|
||||
if (DoCaret) s2 = s2.Replace("^", @"\u916");
|
||||
return ConvertText(s2);
|
||||
}
|
||||
public static string ReplaceUnicode(string s2)
|
||||
{
|
||||
char[] tmp;
|
||||
tmp = s2.ToCharArray();
|
||||
s2 = s2.Replace("`", "\'b0"); // convert backquote to degree - left over from DOS days.
|
||||
s2 = s2.Replace("\'a0",@"\'a0"); // hardspace
|
||||
s2 = s2.Replace("\xb0", @"\'b0"); // degree
|
||||
s2 = s2.Replace("\x7f", @"\u916?"); // delta
|
||||
s2 = s2.Replace("\x2265",@"\u8805?"); // greater than or equal
|
||||
s2 = s2.Replace("\x2264",@"\u8804?"); // less than or equal
|
||||
s2 = s2.Replace("\xB1",@"\'b1"); // plus minus
|
||||
s2 = s2.Replace("\x3A3",@"\u931?"); // sigma
|
||||
s2 = s2.Replace("\x3C4",@"\u947?"); // gamma
|
||||
s2 = s2.Replace("\xBD",@"\'bd"); // half
|
||||
s2 = s2.Replace("\x25A0",@"\u9604?"); // accum 2584
|
||||
s2 = s2.Replace("\x7",@"\u9679?"); // bullet 25CF
|
||||
s2 = s2.Replace("\x2248",@"\u8776?"); // approx eq
|
||||
s2 = s2.Replace("\x2261",@"\u8773?"); // similar eq 2245
|
||||
s2 = s2.Replace("\xF7",@"\'f7"); // division
|
||||
s2 = s2.Replace("\x221A",@"\u8730?"); // square root
|
||||
s2 = s2.Replace("\x393",@"\u961?"); // rho 3C1
|
||||
s2 = s2.Replace("\x3C0",@"\u960?"); // pi
|
||||
s2 = s2.Replace("\xb5", @"\u956?"); // micro 3BC (try e6, if not work try 109)
|
||||
s2 = s2.Replace("\x3B4", @"\u948?"); // lower case delta
|
||||
s2 = s2.Replace("\x3C3", @"\u963?"); // lower case sigma
|
||||
s2 = s2.Replace("\xBC", @"\'bc"); // quarter
|
||||
s2 = s2.Replace("\x3C6", @"\'d8"); // dist zero, D8
|
||||
s2 = s2.Replace("\xC9", @"\u274?"); // energy, 112
|
||||
s2 = s2.Replace("\xEC", @"\'ec"); // grave
|
||||
s2 = s2.Replace("\x2502", @"\u9474?"); // bar
|
||||
s2 = s2.Replace("\x3B5", @"\u949?"); // epsilon
|
||||
s2 = s2.Replace("\x398", @"\u952?"); // theta, 3B8
|
||||
s2 = s2.Replace("\x221E", @"\u8857?"); // dot in oval, 2299
|
||||
s2 = s2.Replace("\xBF", @"\u964?"); // tau, 3C4
|
||||
s2 = s2.Replace("\x2310", @"\u9830?"); // diamond, 2666
|
||||
s2 = s2.Replace("\x2192", @"\u8594?");
|
||||
s2 = s2.Replace("\x2190", @"\u8592?");
|
||||
s2 = s2.Replace("\x2191", @"\u8593?");
|
||||
s2 = s2.Replace("\x2193", @"\u8595?");
|
||||
s2 = s2.Replace("\x2207", @"\u8711?");
|
||||
|
||||
return s2;
|
||||
}
|
||||
public static string ConvertText(string s1)
|
||||
{
|
||||
string s2 = Reg2.Replace(s1, new MatchEvaluator(ReplaceChars));
|
||||
string s2 = s1;
|
||||
|
||||
s2 = ReplaceUnicode(s2);
|
||||
// now replace underline on/off (AE,AF), super on/off (C6,C7)
|
||||
// bold on/off (D5, D6), subscript on/off (D1 A6), and
|
||||
// italics on/off (B2, DD)
|
||||
s2 = s2.Replace("\xAB", "\\ul ");
|
||||
s2 = s2.Replace("\xBB", "\\ul0 ");
|
||||
s2 = s2.Replace("\x255E", "\\super ");
|
||||
s2 = s2.Replace("\x255F", "\\nosupersub ");
|
||||
s2 = s2.Replace("\x2552", "\\b ");
|
||||
s2 = s2.Replace("\x2553", "\\b0 ");
|
||||
s2 = s2.Replace("\x2564", "\\sub ");
|
||||
s2 = s2.Replace("\xAA", "\\nosupersub ");
|
||||
s2 = s2.Replace("\x2593", "\\i ");
|
||||
s2 = s2.Replace("\x258C", "\\i0 ");
|
||||
s2 = s2.Replace("\x2559", "\\ul\\b ");
|
||||
s2 = s2.Replace("\x2558", "\\b0\\ul0 ");
|
||||
|
||||
// underline next word is 0x17
|
||||
// superscript next is 0x18
|
||||
// subscript next is 0x19
|
||||
// bold next is 0x13
|
||||
s2 = Regex.Replace(s2, @"\x17([^\x17 ]*?)(?:[\x17]|(?= )|\Z)(.*?)", @"\ul $1\ul0 $2");
|
||||
s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\super $1\nosupersub $2");
|
||||
s2 = Regex.Replace(s2, @"\x19([^\x19 ]*?)(?:[\x19]|(?= )|\Z)(.*?)", @"\sub $1\nosupersub $2");
|
||||
s2 = Regex.Replace(s2, @"\x13([^\x13 ]*?)(?:[\x13]|(?= )|\Z)(.*?)", @"\b $1\b0 $2");
|
||||
|
||||
s2 = Reg2.Replace(s2, new MatchEvaluator(ReplaceChars));
|
||||
return s2;
|
||||
}
|
||||
}
|
||||
|
@ -20,43 +20,147 @@ using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
public partial class Loader
|
||||
{
|
||||
private int AddTrans(int fromId, DataRow dr)
|
||||
private string AddTrans(Content fromCon, DataRow dr, DataRow dr2)
|
||||
{
|
||||
//TODO: ZTransitions tr.Oldto = dr["OLDTO"].ToString();
|
||||
string thekey = dr["TONUMBER"].ToString() + "|" + dr["TOSEQUENCE"].ToString();
|
||||
string dti = dr["DTI"].ToString().PadRight(18, ' ');
|
||||
string userid = dti.Substring(13, 5).Trim();
|
||||
int itype = 0;
|
||||
ConfigInfo ci = null;
|
||||
// The transition type was stored as a character & also, when read in thru
|
||||
// ado.net may have been converted into unicode. So in order to get the
|
||||
// correct type, first, use the TextConvert to eliminate the conversion done
|
||||
// by ado.net. Then convert to a number. The 'anding of 0x80' flags that it
|
||||
// is a formatted transition (i.e. this was done for byron/braidwood to
|
||||
// show the transition with a page number or not). The 'anding of 0x7f' gets
|
||||
// the actual number when subtracted from 0x30 (the value of the 0 character).
|
||||
try
|
||||
{
|
||||
char typech = TextConvert.ConvertSeq(dr["TYPE"].ToString())[0];
|
||||
int tmpitype = Convert.ToInt32(typech);
|
||||
if ((tmpitype & 0x80) > 0)
|
||||
{
|
||||
ci = new ConfigInfo(null);
|
||||
ci.AddItem("Transition", "Formatted", "True");
|
||||
}
|
||||
itype = (tmpitype&0x7F) - 0x30;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("Error converting transition type");
|
||||
log.ErrorFormat("type from database = {0}", dr["TYPE"].ToString());
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
itype = -1;
|
||||
}
|
||||
DateTime dts = GetDTS(MakeDate(dti.Substring(0, 8).Trim()), dti.Substring(8, 5).Trim());
|
||||
// if it's in the dictionary of structure elements already migrated, just use this
|
||||
// structure id, or if it's in the dictionary of structure elements that have
|
||||
// not been migrated but a record was created from this code, use it. Otherwise
|
||||
// create a new structure record and use its id, its data will be updated later.
|
||||
// a structure record.
|
||||
int toid;
|
||||
if (dicTrans_StrDone.ContainsKey(thekey))
|
||||
toid = dicTrans_StrDone[thekey];
|
||||
Item toItem = null;
|
||||
Item toItem2 = null;
|
||||
if (dicTrans_ItemDone.ContainsKey(thekey))
|
||||
{
|
||||
toItem = dicTrans_ItemDone[thekey];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dicTrans_StrIds.ContainsKey(thekey))
|
||||
toid = dicTrans_StrIds[thekey];
|
||||
if (dicTrans_ItemIds.ContainsKey(thekey))
|
||||
{
|
||||
toItem = dicTrans_ItemIds[thekey];
|
||||
}
|
||||
else
|
||||
{
|
||||
Structure str = Structure.MakeStructure(0, 0, 0, 0);
|
||||
toid = str.StructureID;
|
||||
dicTrans_StrIds.Add(thekey, toid);
|
||||
// note that parent is null right now - it will be filled in later.
|
||||
//toItem = Item.MakeItem(null, fromCon, DateTime.Now, "Migration");
|
||||
toItem = Item.New(null, TransDummyCont, DateTime.Now, "Migration");
|
||||
dicTrans_ItemIds.Add(thekey, toItem);
|
||||
}
|
||||
}
|
||||
Transition tr = Transition.MakeTransition(fromId, toid, System.Convert.ToInt32(dr["TYPE"].ToString()),0,0,0,0,dts,userid);
|
||||
return tr.TransitionId;
|
||||
}
|
||||
|
||||
private string MigrateTrans(OleDbConnection cn, string textm, string seqcvt, int structId)
|
||||
// if there is data in dr2, it means that it is a range transition. Get its item
|
||||
// data too.
|
||||
toItem2 = toItem;
|
||||
if (dr2 != null)
|
||||
{
|
||||
string thekey2 = dr2["TONUMBER"].ToString() + "|" + dr2["TOSEQUENCE"].ToString();
|
||||
if (dicTrans_ItemDone.ContainsKey(thekey2))
|
||||
{
|
||||
toItem2 = dicTrans_ItemDone[thekey2];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dicTrans_ItemIds.ContainsKey(thekey2))
|
||||
{
|
||||
toItem2 = dicTrans_ItemIds[thekey2];
|
||||
}
|
||||
else
|
||||
{
|
||||
toItem2 = Item.MakeItem(null, TransDummyCont, DateTime.Now, "Migration");
|
||||
dicTrans_ItemIds.Add(thekey2, toItem2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userid == null || userid == "") userid = "Migration";
|
||||
Transition tr = null;
|
||||
try
|
||||
{
|
||||
tr = Transition.New(fromCon, toItem, toItem2, itype, ci!=null?ci.ToString():null, dts, userid);
|
||||
tr.MyZTransition.Oldto = dr["OLDTO"].ToString();
|
||||
if (!tr.IsSavable) ErrorRpt.ErrorReport(tr);
|
||||
tr.Save();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("Error addition transition record");
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
}
|
||||
StringBuilder trtxt = new StringBuilder();
|
||||
|
||||
// the following is pre RTB link code, i.e. <token>{tranid {type toid (rangeid}}
|
||||
trtxt.Append("\\v TRAN\\v0 (Resolved Transition Text)\\v ");
|
||||
|
||||
trtxt.Append(tr.TranType.ToString());
|
||||
trtxt.Append(" ");
|
||||
trtxt.Append(tr.TransitionID.ToString());
|
||||
trtxt.Append(" ");
|
||||
trtxt.Append(tr.ToID.ToString());
|
||||
if (toItem.ItemID == toItem2.ItemID)
|
||||
trtxt.Append("\\v0 ");
|
||||
else
|
||||
{
|
||||
trtxt.Append(" ");
|
||||
trtxt.Append(tr.RangeID.ToString());
|
||||
trtxt.Append("\\v0 ");
|
||||
}
|
||||
//trtxt.Append("{");
|
||||
//trtxt.Append(tr.TransitionID.ToString());
|
||||
//trtxt.Append("{");
|
||||
//trtxt.Append(tr.TranType.ToString());
|
||||
//trtxt.Append(" ");
|
||||
//trtxt.Append(tr.ToID.ToString());
|
||||
//if (toItem.ItemID == toItem2.ItemID)
|
||||
// trtxt.Append("}}");
|
||||
//else
|
||||
//{
|
||||
// trtxt.Append(" ");
|
||||
// trtxt.Append(tr.RangeID.ToString());
|
||||
// trtxt.Append("}}");
|
||||
//}
|
||||
|
||||
return trtxt.ToString();
|
||||
}
|
||||
|
||||
private string MigrateTrans(OleDbConnection cn, string textm, string seqcvt, Content content)
|
||||
{
|
||||
StringBuilder trtxt = new StringBuilder();
|
||||
int instance = 0;
|
||||
@ -95,17 +199,30 @@ namespace DataLoader
|
||||
// we have too many tokens and not enough usage records - report an error...
|
||||
if (instance >= dt.Rows.Count)
|
||||
{
|
||||
log.ErrorFormat("Error - ran out of usage records for step, check data ");
|
||||
log.ErrorFormat("Error - ran out of transition records for step, check data ");
|
||||
log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt);
|
||||
}
|
||||
else
|
||||
{
|
||||
DataRow dr = dt.Rows[instance];
|
||||
int trid = AddTrans(structId, dr);
|
||||
|
||||
// if type is 2 or 3, this is a range transition, need to get the next
|
||||
// record too
|
||||
bool trange = false;
|
||||
if (dr["Type"].ToString() == "2" || dr["Type"].ToString() == "3")
|
||||
trange = true;
|
||||
|
||||
string rectxt = null;
|
||||
if (trange)
|
||||
{
|
||||
instance++;
|
||||
DataRow dr2 = dt.Rows[instance];
|
||||
rectxt = AddTrans(content, dr, dr2);
|
||||
}
|
||||
else
|
||||
rectxt = AddTrans(content, dr, null);
|
||||
trtxt.Append(textm[tok]);
|
||||
trtxt.Append("{{");
|
||||
trtxt.Append(trid.ToString());
|
||||
trtxt.Append("}}");
|
||||
trtxt.Append(rectxt);
|
||||
}
|
||||
instance++;
|
||||
beg = tok + 1;
|
||||
@ -121,18 +238,25 @@ namespace DataLoader
|
||||
trtxt.Append(textm.Substring(beg, textm.Length - beg));
|
||||
if (dt.Rows.Count > instance + 1)
|
||||
{
|
||||
log.ErrorFormat("Error - extra usage records for step, check data ");
|
||||
log.ErrorFormat("Error - extra transition records for step, check data ");
|
||||
log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt);
|
||||
}
|
||||
return trtxt.ToString();
|
||||
}
|
||||
private void ShowMissingTransitions()
|
||||
{
|
||||
log.Info("Missing Transitions");
|
||||
foreach (string s in dicTrans_StrIds.Keys)
|
||||
log.Info("Missing Transitions from Dictionary");
|
||||
foreach (string s in dicTrans_ItemIds.Keys)
|
||||
{
|
||||
log.InfoFormat("{0} - {1}", s, dicTrans_StrIds[s]);
|
||||
log.InfoFormat("{0} - {1}", s, dicTrans_ItemIds[s]);
|
||||
}
|
||||
|
||||
log.Info("Bad transitions to 'dummy' content");
|
||||
foreach (ContentItem itm in TransDummyCont.ContentItems)
|
||||
{
|
||||
log.InfoFormat("ItemID = {0}", itm.ItemID);
|
||||
}
|
||||
|
||||
log.Info("End of Missing Transitions");
|
||||
}
|
||||
}
|
||||
|
74
PROMS/DataLoader/frmCntTkn.Designer.cs
generated
Normal file
74
PROMS/DataLoader/frmCntTkn.Designer.cs
generated
Normal file
@ -0,0 +1,74 @@
|
||||
namespace DataLoader
|
||||
{
|
||||
partial class frmCntTkn
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.button1.Location = new System.Drawing.Point(12, 8);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(132, 22);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Count Chars/Tokens";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
this.listBox1.Font = new System.Drawing.Font("Arial Unicode MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listBox1.FormattingEnabled = true;
|
||||
this.listBox1.ItemHeight = 15;
|
||||
this.listBox1.Location = new System.Drawing.Point(12, 36);
|
||||
this.listBox1.Name = "listBox1";
|
||||
this.listBox1.Size = new System.Drawing.Size(225, 409);
|
||||
this.listBox1.TabIndex = 55;
|
||||
//
|
||||
// frmCntTkn
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(331, 486);
|
||||
this.Controls.Add(this.listBox1);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Name = "frmCntTkn";
|
||||
this.Text = "frmCntTkn";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.ListBox listBox1;
|
||||
}
|
||||
}
|
71
PROMS/DataLoader/frmCntTkn.cs
Normal file
71
PROMS/DataLoader/frmCntTkn.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmCntTkn : Form
|
||||
{
|
||||
private Dictionary<char, int> dicCharCount;
|
||||
|
||||
public frmCntTkn()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CountChars(string txt)
|
||||
{
|
||||
foreach (char ch in txt)
|
||||
{
|
||||
//'A' is a newline
|
||||
int ich = Convert.ToInt32(ch);
|
||||
if (ich == 0xD) Console.WriteLine("D is {0}", txt);
|
||||
if (ich == 0x17) Console.WriteLine("17 is {0}", txt);
|
||||
if (!dicCharCount.ContainsKey(ch))
|
||||
dicCharCount[ch] = 1;
|
||||
else
|
||||
dicCharCount[ch] = dicCharCount[ch] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//private void ProcessText()
|
||||
//{
|
||||
// TextMInfoList txtMList = TextMInfoList.Get();
|
||||
// foreach (TextMInfo txtM in txtMList)
|
||||
// {
|
||||
// string thetext = txtM.TextMValue;
|
||||
// CountChars(thetext);
|
||||
// }
|
||||
//}
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Create a dictionary that stores characters
|
||||
// read in data from dbf
|
||||
// list chars
|
||||
dicCharCount = new Dictionary<char, int>();
|
||||
//ProcessText();
|
||||
|
||||
// now display dictionary results..
|
||||
Console.WriteLine("Char\t\tHex\t\tDec\t\tCount");
|
||||
foreach (char ch in dicCharCount.Keys)
|
||||
{
|
||||
// if character is a 'token' and not a hardspace (A0), linefeed (A), RO token (15)
|
||||
// Transition tokens (0x252c & -x2566) then show it.
|
||||
if ((ch < 0x20 || ch > 0x7E) && ch!= 0xA0 && ch != 0xA && ch != 0x15 && ch != 0x252C && ch != 0x2566)
|
||||
{
|
||||
int ich = Convert.ToInt32(ch);
|
||||
string cntstr = String.Format("{0}\t\t{1}\t\t{2}\t\t{3}", ch, ich.ToString("X4"), ich.ToString(), dicCharCount[ch]);
|
||||
listBox1.Items.Add(cntstr);
|
||||
Console.WriteLine(cntstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
PROMS/DataLoader/frmCntTkn.resx
Normal file
120
PROMS/DataLoader/frmCntTkn.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
123
PROMS/DataLoader/frmLoader.Designer.cs
generated
123
PROMS/DataLoader/frmLoader.Designer.cs
generated
@ -29,6 +29,8 @@ namespace DataLoader
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.sc = new System.Windows.Forms.SplitContainer();
|
||||
this.btnCtTok = new System.Windows.Forms.Button();
|
||||
this.btnGroup = new System.Windows.Forms.Button();
|
||||
this.btnVETree_CSLA = new System.Windows.Forms.Button();
|
||||
this.btnBrowseVesam = new System.Windows.Forms.Button();
|
||||
this.tbVesamPath = new System.Windows.Forms.TextBox();
|
||||
@ -52,10 +54,12 @@ namespace DataLoader
|
||||
this.btnConvert = new System.Windows.Forms.Button();
|
||||
this.tv = new System.Windows.Forms.TreeView();
|
||||
this.fbd = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.btnGroup = new System.Windows.Forms.Button();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.sc.Panel1.SuspendLayout();
|
||||
this.sc.Panel2.SuspendLayout();
|
||||
this.sc.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// sc
|
||||
@ -68,6 +72,7 @@ namespace DataLoader
|
||||
//
|
||||
// sc.Panel1
|
||||
//
|
||||
this.sc.Panel1.Controls.Add(this.btnCtTok);
|
||||
this.sc.Panel1.Controls.Add(this.btnGroup);
|
||||
this.sc.Panel1.Controls.Add(this.btnVETree_CSLA);
|
||||
this.sc.Panel1.Controls.Add(this.btnBrowseVesam);
|
||||
@ -95,15 +100,35 @@ namespace DataLoader
|
||||
//
|
||||
this.sc.Panel2.Controls.Add(this.tv);
|
||||
this.sc.Size = new System.Drawing.Size(623, 413);
|
||||
this.sc.SplitterDistance = 172;
|
||||
this.sc.SplitterDistance = 190;
|
||||
this.sc.SplitterWidth = 3;
|
||||
this.sc.TabIndex = 46;
|
||||
//
|
||||
// btnCtTok
|
||||
//
|
||||
this.btnCtTok.Location = new System.Drawing.Point(482, 0);
|
||||
this.btnCtTok.Name = "btnCtTok";
|
||||
this.btnCtTok.Size = new System.Drawing.Size(96, 20);
|
||||
this.btnCtTok.TabIndex = 70;
|
||||
this.btnCtTok.Text = "Count Tokens";
|
||||
this.btnCtTok.UseVisualStyleBackColor = true;
|
||||
this.btnCtTok.Click += new System.EventHandler(this.btnCtTok_Click);
|
||||
//
|
||||
// btnGroup
|
||||
//
|
||||
this.btnGroup.Location = new System.Drawing.Point(387, -3);
|
||||
this.btnGroup.Name = "btnGroup";
|
||||
this.btnGroup.Size = new System.Drawing.Size(89, 23);
|
||||
this.btnGroup.TabIndex = 69;
|
||||
this.btnGroup.Text = "Group/Security";
|
||||
this.btnGroup.UseVisualStyleBackColor = true;
|
||||
this.btnGroup.Click += new System.EventHandler(this.btnGroup_Click);
|
||||
//
|
||||
// btnVETree_CSLA
|
||||
//
|
||||
this.btnVETree_CSLA.Location = new System.Drawing.Point(293, 121);
|
||||
this.btnVETree_CSLA.Location = new System.Drawing.Point(248, -1);
|
||||
this.btnVETree_CSLA.Name = "btnVETree_CSLA";
|
||||
this.btnVETree_CSLA.Size = new System.Drawing.Size(145, 21);
|
||||
this.btnVETree_CSLA.Size = new System.Drawing.Size(133, 21);
|
||||
this.btnVETree_CSLA.TabIndex = 68;
|
||||
this.btnVETree_CSLA.Text = "Load VETree from CSLA";
|
||||
this.btnVETree_CSLA.UseVisualStyleBackColor = true;
|
||||
@ -111,7 +136,7 @@ namespace DataLoader
|
||||
//
|
||||
// btnBrowseVesam
|
||||
//
|
||||
this.btnBrowseVesam.Location = new System.Drawing.Point(479, 150);
|
||||
this.btnBrowseVesam.Location = new System.Drawing.Point(479, 26);
|
||||
this.btnBrowseVesam.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnBrowseVesam.Name = "btnBrowseVesam";
|
||||
this.btnBrowseVesam.Size = new System.Drawing.Size(119, 19);
|
||||
@ -122,7 +147,7 @@ namespace DataLoader
|
||||
//
|
||||
// tbVesamPath
|
||||
//
|
||||
this.tbVesamPath.Location = new System.Drawing.Point(114, 150);
|
||||
this.tbVesamPath.Location = new System.Drawing.Point(114, 26);
|
||||
this.tbVesamPath.Name = "tbVesamPath";
|
||||
this.tbVesamPath.Size = new System.Drawing.Size(353, 20);
|
||||
this.tbVesamPath.TabIndex = 66;
|
||||
@ -130,7 +155,7 @@ namespace DataLoader
|
||||
//
|
||||
// btnVesam
|
||||
//
|
||||
this.btnVesam.Location = new System.Drawing.Point(2, 148);
|
||||
this.btnVesam.Location = new System.Drawing.Point(2, 24);
|
||||
this.btnVesam.Name = "btnVesam";
|
||||
this.btnVesam.Size = new System.Drawing.Size(108, 21);
|
||||
this.btnVesam.TabIndex = 65;
|
||||
@ -140,9 +165,9 @@ namespace DataLoader
|
||||
//
|
||||
// btnLoadTreeCSLA
|
||||
//
|
||||
this.btnLoadTreeCSLA.Location = new System.Drawing.Point(295, 96);
|
||||
this.btnLoadTreeCSLA.Location = new System.Drawing.Point(123, 0);
|
||||
this.btnLoadTreeCSLA.Name = "btnLoadTreeCSLA";
|
||||
this.btnLoadTreeCSLA.Size = new System.Drawing.Size(144, 20);
|
||||
this.btnLoadTreeCSLA.Size = new System.Drawing.Size(119, 20);
|
||||
this.btnLoadTreeCSLA.TabIndex = 64;
|
||||
this.btnLoadTreeCSLA.Text = "Load Tree from CSLA";
|
||||
this.btnLoadTreeCSLA.UseVisualStyleBackColor = true;
|
||||
@ -153,7 +178,7 @@ namespace DataLoader
|
||||
this.cbLazy.AutoSize = true;
|
||||
this.cbLazy.Checked = true;
|
||||
this.cbLazy.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cbLazy.Location = new System.Drawing.Point(11, 126);
|
||||
this.cbLazy.Location = new System.Drawing.Point(478, 142);
|
||||
this.cbLazy.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cbLazy.Name = "cbLazy";
|
||||
this.cbLazy.Size = new System.Drawing.Size(75, 17);
|
||||
@ -163,23 +188,23 @@ namespace DataLoader
|
||||
//
|
||||
// btnConvertSelected
|
||||
//
|
||||
this.btnConvertSelected.Location = new System.Drawing.Point(170, 97);
|
||||
this.btnConvertSelected.Location = new System.Drawing.Point(2, 166);
|
||||
this.btnConvertSelected.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnConvertSelected.Name = "btnConvertSelected";
|
||||
this.btnConvertSelected.Size = new System.Drawing.Size(108, 19);
|
||||
this.btnConvertSelected.Size = new System.Drawing.Size(160, 19);
|
||||
this.btnConvertSelected.TabIndex = 62;
|
||||
this.btnConvertSelected.Text = "Convert Selected";
|
||||
this.btnConvertSelected.Text = "Convert Dbf Selected In Tree";
|
||||
this.btnConvertSelected.UseVisualStyleBackColor = true;
|
||||
this.btnConvertSelected.Click += new System.EventHandler(this.btnConvertSelected_Click);
|
||||
//
|
||||
// btnLoadTreeDB
|
||||
//
|
||||
this.btnLoadTreeDB.Location = new System.Drawing.Point(450, 97);
|
||||
this.btnLoadTreeDB.Location = new System.Drawing.Point(0, 0);
|
||||
this.btnLoadTreeDB.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnLoadTreeDB.Name = "btnLoadTreeDB";
|
||||
this.btnLoadTreeDB.Size = new System.Drawing.Size(124, 19);
|
||||
this.btnLoadTreeDB.Size = new System.Drawing.Size(118, 19);
|
||||
this.btnLoadTreeDB.TabIndex = 60;
|
||||
this.btnLoadTreeDB.Text = "Load Tree from dBase";
|
||||
this.btnLoadTreeDB.Text = "Convert Top Folders";
|
||||
this.btnLoadTreeDB.UseVisualStyleBackColor = true;
|
||||
this.btnLoadTreeDB.Click += new System.EventHandler(this.btnLoadTreeDB_Click);
|
||||
//
|
||||
@ -188,7 +213,7 @@ namespace DataLoader
|
||||
this.cbPurgeData.AutoSize = true;
|
||||
this.cbPurgeData.Checked = true;
|
||||
this.cbPurgeData.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cbPurgeData.Location = new System.Drawing.Point(479, 75);
|
||||
this.cbPurgeData.Location = new System.Drawing.Point(478, 121);
|
||||
this.cbPurgeData.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cbPurgeData.Name = "cbPurgeData";
|
||||
this.cbPurgeData.Size = new System.Drawing.Size(119, 17);
|
||||
@ -199,7 +224,7 @@ namespace DataLoader
|
||||
// lblTime
|
||||
//
|
||||
this.lblTime.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||
this.lblTime.Location = new System.Drawing.Point(70, 92);
|
||||
this.lblTime.Location = new System.Drawing.Point(70, 135);
|
||||
this.lblTime.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblTime.Name = "lblTime";
|
||||
this.lblTime.Size = new System.Drawing.Size(84, 20);
|
||||
@ -207,7 +232,7 @@ namespace DataLoader
|
||||
//
|
||||
// pbStep
|
||||
//
|
||||
this.pbStep.Location = new System.Drawing.Point(160, 76);
|
||||
this.pbStep.Location = new System.Drawing.Point(160, 119);
|
||||
this.pbStep.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pbStep.Name = "pbStep";
|
||||
this.pbStep.Size = new System.Drawing.Size(308, 15);
|
||||
@ -215,7 +240,7 @@ namespace DataLoader
|
||||
//
|
||||
// pbSect
|
||||
//
|
||||
this.pbSect.Location = new System.Drawing.Point(160, 56);
|
||||
this.pbSect.Location = new System.Drawing.Point(160, 99);
|
||||
this.pbSect.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pbSect.Name = "pbSect";
|
||||
this.pbSect.Size = new System.Drawing.Size(307, 15);
|
||||
@ -223,7 +248,7 @@ namespace DataLoader
|
||||
//
|
||||
// pbProc
|
||||
//
|
||||
this.pbProc.Location = new System.Drawing.Point(160, 37);
|
||||
this.pbProc.Location = new System.Drawing.Point(160, 80);
|
||||
this.pbProc.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pbProc.Name = "pbProc";
|
||||
this.pbProc.Size = new System.Drawing.Size(308, 15);
|
||||
@ -234,7 +259,7 @@ namespace DataLoader
|
||||
this.cbSaveDoc.AutoSize = true;
|
||||
this.cbSaveDoc.Checked = true;
|
||||
this.cbSaveDoc.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cbSaveDoc.Location = new System.Drawing.Point(480, 34);
|
||||
this.cbSaveDoc.Location = new System.Drawing.Point(479, 80);
|
||||
this.cbSaveDoc.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cbSaveDoc.Name = "cbSaveDoc";
|
||||
this.cbSaveDoc.Size = new System.Drawing.Size(77, 17);
|
||||
@ -246,7 +271,7 @@ namespace DataLoader
|
||||
// cbSaveRTF
|
||||
//
|
||||
this.cbSaveRTF.AutoSize = true;
|
||||
this.cbSaveRTF.Location = new System.Drawing.Point(480, 54);
|
||||
this.cbSaveRTF.Location = new System.Drawing.Point(479, 100);
|
||||
this.cbSaveRTF.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cbSaveRTF.Name = "cbSaveRTF";
|
||||
this.cbSaveRTF.Size = new System.Drawing.Size(75, 17);
|
||||
@ -257,7 +282,7 @@ namespace DataLoader
|
||||
//
|
||||
// btnBrowse
|
||||
//
|
||||
this.btnBrowse.Location = new System.Drawing.Point(479, 10);
|
||||
this.btnBrowse.Location = new System.Drawing.Point(479, 53);
|
||||
this.btnBrowse.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnBrowse.Name = "btnBrowse";
|
||||
this.btnBrowse.Size = new System.Drawing.Size(56, 19);
|
||||
@ -268,17 +293,18 @@ namespace DataLoader
|
||||
//
|
||||
// tbSource
|
||||
//
|
||||
this.tbSource.Location = new System.Drawing.Point(71, 10);
|
||||
this.tbSource.Location = new System.Drawing.Point(71, 53);
|
||||
this.tbSource.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.tbSource.Name = "tbSource";
|
||||
this.tbSource.Size = new System.Drawing.Size(397, 20);
|
||||
this.tbSource.TabIndex = 51;
|
||||
this.tbSource.Text = "i:\\vedata\\vewcnfp\\fp.prc";
|
||||
this.tbSource.TextChanged += new System.EventHandler(this.tbSource_TextChanged);
|
||||
//
|
||||
// lblStep
|
||||
//
|
||||
this.lblStep.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||
this.lblStep.Location = new System.Drawing.Point(70, 72);
|
||||
this.lblStep.Location = new System.Drawing.Point(70, 115);
|
||||
this.lblStep.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblStep.Name = "lblStep";
|
||||
this.lblStep.Size = new System.Drawing.Size(84, 20);
|
||||
@ -287,7 +313,7 @@ namespace DataLoader
|
||||
// lblSection
|
||||
//
|
||||
this.lblSection.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||
this.lblSection.Location = new System.Drawing.Point(70, 53);
|
||||
this.lblSection.Location = new System.Drawing.Point(70, 96);
|
||||
this.lblSection.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblSection.Name = "lblSection";
|
||||
this.lblSection.Size = new System.Drawing.Size(84, 19);
|
||||
@ -296,7 +322,7 @@ namespace DataLoader
|
||||
// lblProc
|
||||
//
|
||||
this.lblProc.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||
this.lblProc.Location = new System.Drawing.Point(70, 34);
|
||||
this.lblProc.Location = new System.Drawing.Point(70, 77);
|
||||
this.lblProc.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblProc.Name = "lblProc";
|
||||
this.lblProc.Size = new System.Drawing.Size(84, 19);
|
||||
@ -304,50 +330,62 @@ namespace DataLoader
|
||||
//
|
||||
// btnConvert
|
||||
//
|
||||
this.btnConvert.Location = new System.Drawing.Point(2, 9);
|
||||
this.btnConvert.Location = new System.Drawing.Point(2, 54);
|
||||
this.btnConvert.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnConvert.Name = "btnConvert";
|
||||
this.btnConvert.Size = new System.Drawing.Size(56, 19);
|
||||
this.btnConvert.Size = new System.Drawing.Size(56, 40);
|
||||
this.btnConvert.TabIndex = 46;
|
||||
this.btnConvert.Text = "Convert";
|
||||
this.btnConvert.Text = "Convert Dbf";
|
||||
this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
|
||||
//
|
||||
// tv
|
||||
//
|
||||
this.tv.CheckBoxes = true;
|
||||
this.tv.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.tv.Location = new System.Drawing.Point(0, 1);
|
||||
this.tv.Location = new System.Drawing.Point(0, -4);
|
||||
this.tv.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.tv.Name = "tv";
|
||||
this.tv.Size = new System.Drawing.Size(623, 237);
|
||||
this.tv.Size = new System.Drawing.Size(623, 224);
|
||||
this.tv.TabIndex = 24;
|
||||
this.tv.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tv_BeforeExpand);
|
||||
this.tv.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterSelect);
|
||||
//
|
||||
// btnGroup
|
||||
// statusStrip1
|
||||
//
|
||||
this.btnGroup.Location = new System.Drawing.Point(505, 118);
|
||||
this.btnGroup.Name = "btnGroup";
|
||||
this.btnGroup.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnGroup.TabIndex = 69;
|
||||
this.btnGroup.Text = "Group";
|
||||
this.btnGroup.UseVisualStyleBackColor = true;
|
||||
this.btnGroup.Click += new System.EventHandler(this.btnGroup_Click);
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabel1});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 391);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(623, 22);
|
||||
this.statusStrip1.TabIndex = 47;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabel1
|
||||
//
|
||||
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
|
||||
this.toolStripStatusLabel1.Size = new System.Drawing.Size(97, 17);
|
||||
this.toolStripStatusLabel1.Text = "Status Information";
|
||||
//
|
||||
// frmLoader
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(623, 413);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.sc);
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "frmLoader";
|
||||
this.Text = "frmLoader";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmLoader_FormClosing);
|
||||
this.Load += new System.EventHandler(this.frmLoader_Load);
|
||||
this.sc.Panel1.ResumeLayout(false);
|
||||
this.sc.Panel1.PerformLayout();
|
||||
this.sc.Panel2.ResumeLayout(false);
|
||||
this.sc.ResumeLayout(false);
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@ -378,5 +416,8 @@ namespace DataLoader
|
||||
private System.Windows.Forms.Button btnBrowseVesam;
|
||||
private System.Windows.Forms.Button btnVETree_CSLA;
|
||||
private System.Windows.Forms.Button btnGroup;
|
||||
private System.Windows.Forms.Button btnCtTok;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
|
||||
}
|
||||
}
|
@ -22,64 +22,49 @@ using System.Text;
|
||||
using Volian.MSWord;
|
||||
using vlnObjectLibrary;
|
||||
using vlnServerLibrary;
|
||||
using Volian.CSLA.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Config;
|
||||
|
||||
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
public partial class frmLoader : Form
|
||||
{
|
||||
private bool _Loading = true;
|
||||
|
||||
private FolderTreeNode _topnode;
|
||||
private bool UseVeTree = false;
|
||||
#region Log4Net
|
||||
public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region ClassProperties
|
||||
private int wms = 500;
|
||||
private static int EDDATA = 0x01;
|
||||
private static int PH = 0x02;
|
||||
private static int TOC = 0x04;
|
||||
private static int AUTOIND = 0x08;
|
||||
private static int AUTOGEN = 0x40;
|
||||
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; } }
|
||||
public int pbSectValue { get { return pbSect.Value; } set { pbSect.Value = value; } }
|
||||
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; } }
|
||||
|
||||
private static int STP_COMMENT = 0;
|
||||
private static int STP_MULT_CHGID = 1;
|
||||
private static int STP_LNK_SEQ = 2;
|
||||
private static int STP_OVR_TAB = 3;
|
||||
public string Status
|
||||
{
|
||||
get { return toolStripStatusLabel1.Text; }
|
||||
set
|
||||
{
|
||||
toolStripStatusLabel1.Text = value;
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private string ProcFileName;
|
||||
private string ProcNumber;
|
||||
private ROFST rofst;
|
||||
private int EditSectId;
|
||||
private Dictionary<string, int> dicLibDocRef;
|
||||
public string tbSourceText { get { return tbSource.Text; } set { tbSource.Text = value; } }
|
||||
|
||||
// have a few variables for storing the database id record & the system record.
|
||||
private Connection dbConn;
|
||||
private Folder sysFolder;
|
||||
FolderTreeNode _topnode;
|
||||
|
||||
// the following two dictionaries are used to handle migration of the
|
||||
// transitions... dicTrans_StrDone gets an entry for procnumber, sequence
|
||||
// number and the new structure id as a step or section is created (transitions
|
||||
// can go to steps or sections). When a transition is encountered, check this
|
||||
// dictionary to see if the step or section was migrated & use the structureid
|
||||
// for the step or section if it was migrated. When a transition is migrated where
|
||||
// the 'to' has not been migrated yet, check if an entry exists in dicTrans_StrIds,
|
||||
// if so, use the id listed here. If no entry exists in dicTrans_StrIds, create
|
||||
// a structure table record and use the id as part of the 'to', and add an entry to
|
||||
// dicTrans_StpIds to flag that the record was already created. As migrating sections
|
||||
// and steps, check this dicTrans_StrIds to see if the structure record has already
|
||||
// been create, if so use it and remove it from the dicTrans_StrIds dictionary,
|
||||
// otherwise, create a new structure record.
|
||||
private Dictionary<string, int> dicTrans_StrDone;
|
||||
private Dictionary<string, int> dicTrans_StrIds;
|
||||
private Dictionary<object, string> dicOldStepSequence;
|
||||
private Dictionary<TreeNode, TreeNode> dicNeedToLoad;
|
||||
private bool UseVeTree = false;
|
||||
#endregion
|
||||
public frmLoader()
|
||||
{
|
||||
ldr = new Loader(log, this);
|
||||
InitializeComponent();
|
||||
lblTime.Tag = DateTime.Now;
|
||||
switch (SystemInformation.ComputerName.ToUpper())
|
||||
@ -88,7 +73,7 @@ namespace DataLoader
|
||||
//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";// multiple change ids.
|
||||
tbSource.Text = "G:\\vewcnckl\\ckl.prc";// multiple change ids.
|
||||
break;
|
||||
case "RHMDESKTOP":
|
||||
//tbSource.Text = @"I:\UNZIPPED ACTIVE BASELINE DATA\vehlp\Procs"; // Sub-sections
|
||||
@ -97,7 +82,6 @@ namespace DataLoader
|
||||
default:
|
||||
throw new Exception("Not configured for " + SystemInformation.ComputerName);
|
||||
}
|
||||
dicNeedToLoad = new Dictionary<TreeNode, TreeNode>();
|
||||
}
|
||||
private void btnConvertSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -110,23 +94,18 @@ namespace DataLoader
|
||||
return;
|
||||
}
|
||||
object o = tn.VEObject;
|
||||
//object o = tn.Tag;
|
||||
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();
|
||||
int istr = MigrateDocVersion(v.Title);
|
||||
if (istr > 0)
|
||||
Item itm = ldr.MigrateDocVersion(v);
|
||||
if (itm != null)
|
||||
{
|
||||
|
||||
v.StructureID = istr;
|
||||
v.Title = "";
|
||||
v.Save(true); // true forces save.
|
||||
tn.Checked = true;
|
||||
//TODO: Walk up structure and set check boxes appropriately.
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -143,15 +122,10 @@ namespace DataLoader
|
||||
return;
|
||||
}
|
||||
DocVersion v = (DocVersion)o;
|
||||
int istr = MigrateDocVersion(v.Title);
|
||||
if (istr > 0)
|
||||
Item itm = ldr.MigrateDocVersion(v);
|
||||
if (itm != null)
|
||||
{
|
||||
|
||||
v.StructureID = istr;
|
||||
v.Title = "";
|
||||
v.Save(true); // true forces save.
|
||||
tn.Checked = true;
|
||||
//TODO: Walk up structure and set check boxes appropriately.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,8 +143,8 @@ namespace DataLoader
|
||||
{
|
||||
case "Volian.CSLA.Library.FolderInfo":
|
||||
FolderInfo fld = (FolderInfo)o;
|
||||
if (fld.DocVersionCount>0)
|
||||
tn.Checked = LoadChildren(fld, tn); // load docversions.
|
||||
if (fld.ChildFolderCount>0)
|
||||
tn.Checked = ldr.LoadChildren(fld, tn); // load docversions.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -186,61 +160,44 @@ namespace DataLoader
|
||||
if (o.GetType() == typeof(DocVersion)) tbSource.Text = ((DocVersion)o).Title;
|
||||
}
|
||||
|
||||
private bool LoadFolders()
|
||||
{
|
||||
try
|
||||
{
|
||||
// make the initial database connection record
|
||||
dbConn = Connection.MakeConnection("Default", "Default", "Data Source=.\\SQLEXPRESS;Initial Catalog=VEPROMS;Integrated Security=True", 1, null);
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
|
||||
|
||||
XmlDocument d = cfg.LoadSystemIni();
|
||||
sysFolder = Folder.MakeFolder(0, dbConn.DBID, "system", "system", d.InnerXml);
|
||||
|
||||
// This is to test the vln Libraries
|
||||
List<Folder> lfldr = vlnDataPathFolders();
|
||||
|
||||
List<vlnObject> dp2 = new List<vlnObject>();
|
||||
foreach (Folder fldr in lfldr)
|
||||
{
|
||||
TreeNode tn = 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();
|
||||
MigrateChildren(vb, vs, fldr.DBID, fldr.FolderID, tn);
|
||||
tn.Expand();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("Could not load data, error = {0}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void btnLoadTreeDB_Click(object sender, EventArgs e)
|
||||
{
|
||||
// When loading folders, i.e. the tree from dBase (old 16-bit)
|
||||
// always clear the data
|
||||
ClearData();
|
||||
bool suc = LoadFolders();
|
||||
ldr.ClearData();
|
||||
bool suc = ldr.LoadFolders();
|
||||
}
|
||||
|
||||
private void btnConvert_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
Database.LoggingInfo = false;
|
||||
bool success = true;
|
||||
// if purge data, purge it all & reload folders & security.
|
||||
if (cbPurgeData.Checked)
|
||||
{
|
||||
ClearData();
|
||||
success=LoadFolders();
|
||||
if (success)success=LoadSecurity();
|
||||
ldr.ClearData();
|
||||
success=ldr.LoadFolders();
|
||||
if (success) success = ldr.LoadSecurity(tbVesamPath.Text);
|
||||
}
|
||||
if (success) MigrateDocVersion(tbSource.Text);
|
||||
if (success)
|
||||
{
|
||||
DateTime tstart = DateTime.Now;
|
||||
DocVersionInfoList vl = DocVersionInfoList.Get();
|
||||
DocVersion v = null;
|
||||
foreach (DocVersionInfo vi in vl)
|
||||
{
|
||||
if (vi.Title.ToUpper() == tbSource.Text.ToUpper())
|
||||
{
|
||||
v = DocVersion.Get(vi.VersionID);
|
||||
Database.LogInfoFormat("Before MigrateDocVersion");
|
||||
Item itm = ldr.MigrateDocVersion(v);
|
||||
}
|
||||
private void UpdateLabels(int incPrc, int incSec, int incStp)
|
||||
}
|
||||
MessageBox.Show(string.Format("{0} seconds",TimeSpan.FromTicks(DateTime.Now.Ticks-tstart.Ticks).TotalSeconds));
|
||||
}
|
||||
}
|
||||
public void UpdateLabels(int incPrc, int incSec, int incStp)
|
||||
{
|
||||
if (incPrc == 0 && incSec == 0 && incStp == 0)//Reset
|
||||
{
|
||||
@ -262,6 +219,7 @@ namespace DataLoader
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
}
|
||||
}
|
||||
//Database.LoggingInfo = (pbProc.Value > 153 && pbSect.Value > 11 && pbStep.Value > 61);
|
||||
lblProc.Text = string.Format("{0} Procedures", pbProc.Value);
|
||||
lblSection.Text = string.Format("{0} Sections", pbSect.Value);
|
||||
lblStep.Text = string.Format("{0} Steps", pbStep.Value);
|
||||
@ -286,89 +244,8 @@ namespace DataLoader
|
||||
{
|
||||
if (cbSaveDoc.Checked) cbSaveRTF.Checked = false;
|
||||
}
|
||||
private void Wait(int n)
|
||||
{
|
||||
DateTime dtw = DateTime.Now.AddSeconds(n);
|
||||
while (DateTime.Now < dtw)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
private void WaitMS(int n)
|
||||
{
|
||||
DateTime dtw = DateTime.Now.AddMilliseconds(n);
|
||||
while (DateTime.Now < dtw)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
private void ClearData()
|
||||
{
|
||||
Database.PurgeData();
|
||||
}
|
||||
public static string MakeDate(string src)
|
||||
{
|
||||
if (src.Trim() == "") return null;
|
||||
int[] DateOffset ={ 4, 5, 47, 6, 7, 47, 0, 1, 2, 3 }; // 47 = '/'
|
||||
StringBuilder datebuff = new StringBuilder(10);
|
||||
for (int i = 0; i < DateOffset.Length; i++)
|
||||
{
|
||||
if (DateOffset[i] < 9)
|
||||
datebuff.Append(src[DateOffset[i]]);
|
||||
else
|
||||
datebuff.Append(System.Convert.ToChar(DateOffset[i]));
|
||||
}
|
||||
return datebuff.ToString();
|
||||
}
|
||||
private DateTime GetDTS(string date, string time)
|
||||
{
|
||||
// Set the date/time stamp. If there is no 'date', set the date
|
||||
// to 1/1/2000 (this can be changed!). If there is not 'time',
|
||||
// set the time to 0:0:0 (midnight).
|
||||
|
||||
DateTime dts = DateTime.Now;
|
||||
string month = "01";
|
||||
string day = "01";
|
||||
string year = "2000";
|
||||
string hour = "";
|
||||
string minute = "";
|
||||
try
|
||||
{
|
||||
if (date != null && date != "")
|
||||
{
|
||||
int indx1 = date.IndexOf("/");
|
||||
month = date.Substring(0, indx1);
|
||||
int indx2 = date.IndexOf("/", indx1 + 1);
|
||||
day = date.Substring(indx1 + 1, indx2 - indx1 - 1);
|
||||
year = date.Substring(indx2 + 1, 4);
|
||||
}
|
||||
if (time == null || time == "")
|
||||
{
|
||||
hour = "0";
|
||||
minute = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
hour = time.Substring(0, 2);
|
||||
int indxc = time.IndexOfAny(":A-".ToCharArray());
|
||||
if (indxc == time.Length - 1)
|
||||
minute = time.Substring(2, 2);
|
||||
else
|
||||
minute = time.Substring(indxc + 1, time.Length - indxc - 1);
|
||||
}
|
||||
dts = new DateTime(System.Convert.ToInt32(year), System.Convert.ToInt32(month), System.Convert.ToInt32(day),
|
||||
System.Convert.ToInt32(hour), System.Convert.ToInt32(minute), 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("DATE/TIME {0} {1}", date, time);
|
||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||
log.ErrorFormat(ex.StackTrace);
|
||||
return dts;
|
||||
}
|
||||
return dts;
|
||||
}
|
||||
private void btnLoadTreeCSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
_topnode = FolderTreeNode.BuildTreeList();
|
||||
@ -384,26 +261,21 @@ namespace DataLoader
|
||||
tbVesamPath.Text = fbd.SelectedPath;
|
||||
}
|
||||
|
||||
private bool LoadSecurity()
|
||||
{
|
||||
Security sec = new Security(tbVesamPath.Text);
|
||||
return sec.Migrate();
|
||||
}
|
||||
|
||||
private void btnVesam_Click(object sender, EventArgs e)
|
||||
{
|
||||
// if purge data, purge it all & reload folders.
|
||||
if (cbPurgeData.Checked)
|
||||
{
|
||||
ClearData();
|
||||
LoadFolders();
|
||||
ldr.ClearData();
|
||||
ldr.LoadFolders();
|
||||
}
|
||||
bool sec = LoadSecurity();
|
||||
bool sec = ldr.LoadSecurity(tbVesamPath.Text);
|
||||
}
|
||||
|
||||
private void btnVETree_CSLA_Click(object sender, EventArgs e)
|
||||
{
|
||||
tv.Nodes.Add(VEFolder.LoadTree());
|
||||
tv.Nodes.Add(VETreeNode.GetFolder(1));
|
||||
UseVeTree = true;
|
||||
}
|
||||
|
||||
@ -412,5 +284,69 @@ namespace DataLoader
|
||||
GroupProp f = new GroupProp();
|
||||
f.ShowDialog();
|
||||
}
|
||||
|
||||
private void tbSource_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnCtTok_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmCntTkn frm = new frmCntTkn();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
public void UpdateLabelsSetProc(int prc)
|
||||
{
|
||||
pbProc.Maximum = prc;
|
||||
}
|
||||
public void UpdateLabelsSetSect(int sec)
|
||||
{
|
||||
pbSect.Maximum = sec;
|
||||
}
|
||||
public void UpdateLabelsLibDocs(int incLib, int incUsages)
|
||||
{
|
||||
if (incLib == 0 && incUsages == 0)//Reset
|
||||
{
|
||||
lblTime.Tag = DateTime.Now;
|
||||
pbProc.Value = 0;
|
||||
pbSect.Value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pbProc.Value += incLib;
|
||||
pbSect.Value += incUsages;
|
||||
}
|
||||
lblProc.Text = string.Format("{0} Lib Docs", pbProc.Value);
|
||||
lblSection.Text = string.Format("{0} Usages", pbSect.Value);
|
||||
lblStep.Text = "";
|
||||
TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ((DateTime)lblTime.Tag).Ticks);
|
||||
lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
private void frmLoader_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Properties.Settings.Default["VeSamFilename"] != null)
|
||||
this.tbVesamPath.Text = Properties.Settings.Default.VeSamFilename;
|
||||
if (Properties.Settings.Default["DbfPathname"] != null)
|
||||
this.tbSource.Text = Properties.Settings.Default.DbfPathname;
|
||||
if (Properties.Settings.Default["LoadWordDoc"] != null)
|
||||
this.cbSaveDoc.CheckState = Properties.Settings.Default.LoadWordDoc;
|
||||
if (Properties.Settings.Default["PurgeData"] != null)
|
||||
this.cbPurgeData.CheckState = Properties.Settings.Default.PurgeData;
|
||||
if (Properties.Settings.Default["LoadRTFDoc"] != null)
|
||||
this.cbSaveRTF.CheckState = Properties.Settings.Default.LoadRTFDoc;
|
||||
_Loading = 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.Save();
|
||||
}
|
||||
}
|
||||
}
|
@ -120,4 +120,7 @@
|
||||
<metadata name="fbd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>84, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
x
Reference in New Issue
Block a user