This commit is contained in:
parent
d739a72c7b
commit
a9da618d54
@ -42,19 +42,19 @@ namespace DataLoader
|
|||||||
ProcNumber = dr["Number"].ToString();
|
ProcNumber = dr["Number"].ToString();
|
||||||
frmMain.Status = "Processing Procedure " + ProcNumber + " - " + ProcFileName;
|
frmMain.Status = "Processing Procedure " + ProcNumber + " - " + ProcFileName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
|
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
|
||||||
string userid = dr["initials"].ToString().Trim();
|
string userid = dr["initials"].ToString().Trim();
|
||||||
if (userid == null || userid == "") userid = "Migration";
|
if (userid == null || userid == "") userid = "Migration";
|
||||||
|
|
||||||
ConfigInfo ci = null;
|
ConfigInfo ci = null;
|
||||||
string tstr = dr["Proccode"].ToString();
|
string tstr = dr["Proccode"].ToString();
|
||||||
if (tstr != null && tstr != "")
|
if (tstr != null && tstr != "")
|
||||||
{
|
{
|
||||||
ci = new ConfigInfo(null);
|
ci = new ConfigInfo(null);
|
||||||
ci.AddItem("Procedure", "ProcCode", tstr);
|
ci.AddItem("Procedure", "ProcCode", tstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to load in fix file data:
|
// try to load in fix file data:
|
||||||
FileInfo fi = new FileInfo(pth + @"\" + ProcFileName + @".fix");
|
FileInfo fi = new FileInfo(pth + @"\" + ProcFileName + @".fix");
|
||||||
@ -64,35 +64,35 @@ namespace DataLoader
|
|||||||
if (fixItems.Count > 0)
|
if (fixItems.Count > 0)
|
||||||
{
|
{
|
||||||
if (ci == null) ci = new ConfigInfo(null);
|
if (ci == null) ci = new ConfigInfo(null);
|
||||||
if (fixItems[0].Rev!= null && fixItems[0].Rev !="")ci.AddItem("Procedure", "Rev", fixItems[0].Rev);
|
if (fixItems[0].Rev != null && fixItems[0].Rev != "") ci.AddItem("Procedure", "Rev", fixItems[0].Rev);
|
||||||
if (fixItems[0].RevDate != null && fixItems[0].RevDate != "") ci.AddItem("Procedure", "RevDate", fixItems[0].RevDate);
|
if (fixItems[0].RevDate != null && fixItems[0].RevDate != "") ci.AddItem("Procedure", "RevDate", fixItems[0].RevDate);
|
||||||
if (fixItems[0].ReviewDate != null && fixItems[0].ReviewDate != "") ci.AddItem("Procedure", "ReviewDate", fixItems[0].ReviewDate);
|
if (fixItems[0].ReviewDate != null && fixItems[0].ReviewDate != "") ci.AddItem("Procedure", "ReviewDate", fixItems[0].ReviewDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check that there is a "Series" column, i.e. the 10th column, some datasets
|
// check that there is a "Series" column, i.e. the 10th column, some datasets
|
||||||
// may not have it, for example vetuec\master.sl1
|
// may not have it, for example vetuec\master.sl1
|
||||||
if (dr.ItemArray.Length > 10)
|
if (dr.ItemArray.Length > 10)
|
||||||
{
|
{
|
||||||
tstr = dr["Series"].ToString();
|
tstr = dr["Series"].ToString();
|
||||||
if (tstr != null && tstr != "")
|
if (tstr != null && tstr != "")
|
||||||
{
|
{
|
||||||
if (ci == null) ci = new ConfigInfo(null);
|
if (ci == null) ci = new ConfigInfo(null);
|
||||||
ci.AddItem("Procedure", "Series", tstr);
|
ci.AddItem("Procedure", "Series", tstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSet ds = new DataSet();
|
DataSet ds = new DataSet();
|
||||||
DataTable dt = null;
|
DataTable dt = null;
|
||||||
|
|
||||||
// check that file exists, i.e. if proc file doesn't exist but has entry in set
|
// check that file exists, i.e. if proc file doesn't exist but has entry in set
|
||||||
// file, flag error, but continue.
|
// file, flag error, but continue.
|
||||||
//string fname = frmMain.tbSourceText +"\\"+ dr["entry"] + ".dbf";
|
//string fname = frmMain.tbSourceText +"\\"+ dr["entry"] + ".dbf";
|
||||||
string fname = pth + "\\" + dr["entry"] + ".dbf";
|
string fname = pth + "\\" + dr["entry"] + ".dbf";
|
||||||
if (File.Exists(fname))
|
if (File.Exists(fname))
|
||||||
{
|
{
|
||||||
// if the dbt is bad, fix it.
|
// if the dbt is bad, fix it.
|
||||||
DbtOk(dr["entry"].ToString(),pth);
|
DbtOk(dr["entry"].ToString(), pth);
|
||||||
// See if there is PSI and if so, add it to the xml.
|
// 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);
|
OleDbDataAdapter dapsi = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where [STEP] is null", cn);
|
||||||
int handleBefore = HandleCount;
|
int handleBefore = HandleCount;
|
||||||
TryToLoadDataSet(ds, fname, dapsi);
|
TryToLoadDataSet(ds, fname, dapsi);
|
||||||
@ -104,7 +104,7 @@ namespace DataLoader
|
|||||||
{
|
{
|
||||||
msg += "\r\n\r\nThis is most likely because dB2K is installed." +
|
msg += "\r\n\r\nThis is most likely because dB2K is installed." +
|
||||||
"\r\n\r\nUninstall dB2K and run again.";
|
"\r\n\r\nUninstall dB2K and run again.";
|
||||||
if (MessageBox.Show(msg + "\r\n\r\nDo you want to continue?", "Run with dB2K",
|
if (MessageBox.Show(msg + "\r\n\r\nDo you want to continue?", "Run with dB2K",
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
RunWithDB2K = true;
|
RunWithDB2K = true;
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ namespace DataLoader
|
|||||||
{
|
{
|
||||||
msg += "\r\n\r\nCall Volian for support.";
|
msg += "\r\n\r\nCall Volian for support.";
|
||||||
}
|
}
|
||||||
if (!RunWithDB2K)throw new Exception(msg);
|
if (!RunWithDB2K) throw new Exception(msg);
|
||||||
}
|
}
|
||||||
dt = ds.Tables[0];
|
dt = ds.Tables[0];
|
||||||
|
|
||||||
@ -143,34 +143,36 @@ namespace DataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dapsi.Dispose();
|
dapsi.Dispose();
|
||||||
}
|
}
|
||||||
else // log an error
|
else // log an error
|
||||||
{
|
{
|
||||||
log.ErrorFormat("Missing DBF: {0}", fname);
|
log.ErrorFormat("Missing DBF: {0}", fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note, for now the data from the format field will be saved. Later, xpath, ??
|
// Note, for now the data from the format field will be saved. Later, xpath, ??
|
||||||
EditSectId = 0;
|
EditSectId = 0;
|
||||||
|
|
||||||
// See if no caret convert...
|
// See if no caret convert...
|
||||||
//FormatInfo docverFormat = docver.MyDocVersionInfo.ActiveFormat;
|
//FormatInfo docverFormat = docver.MyDocVersionInfo.ActiveFormat;
|
||||||
bool do_cvt = activeFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta;//docverFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta;
|
bool do_cvt = activeFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta;//docverFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta;
|
||||||
// pass in a 0 on MakeContent for type of procedure, i.e. procedure = 0 (on type field)
|
// pass in a 0 on MakeContent for type of procedure, i.e. procedure = 0 (on type field)
|
||||||
|
|
||||||
// can we save itm.ItemID in a dictionary of outside trans? ex: otrans("vehlp\procs\0POP05-EO00",itm.ItemID)?
|
// can we save itm.ItemID in a dictionary of outside trans? ex: otrans("vehlp\procs\0POP05-EO00",itm.ItemID)?
|
||||||
Content cont = null;
|
Content cont = null;
|
||||||
Item itm =null;
|
Item itm = null;
|
||||||
|
string dicNumber = dr["Number"].ToString();
|
||||||
string number = TextConvert.ConvertText(dr["Number"].ToString());
|
string number = TextConvert.ConvertText(dr["Number"].ToString());
|
||||||
frmMain.UpdateLabels(1, 0, 0);
|
frmMain.UpdateLabels(1, 0, 0);
|
||||||
if (!convertProcedures || (docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft && docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.Approved))
|
if (!convertProcedures || (docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft && docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.Approved))
|
||||||
{
|
{
|
||||||
cont = Content.New(number, TextConvert.ConvertText(dr["Title"].ToString(),do_cvt), 0, null, ci == null ? null : ci.ToString(), dts, userid);
|
cont = Content.New(number, TextConvert.ConvertText(dr["Title"].ToString(), do_cvt), 0, null, ci == null ? null : ci.ToString(), dts, userid);
|
||||||
itm = Item.MakeItem(FromItem, cont, dts, userid);
|
itm = Item.MakeItem(FromItem, cont, dts, userid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
|
||||||
|
foreach (ItemInfo ii in dvi.Procedures)
|
||||||
{
|
{
|
||||||
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
|
|
||||||
foreach(ItemInfo ii in dvi.Procedures){
|
|
||||||
if (ii.MyContent.Number == number)
|
if (ii.MyContent.Number == number)
|
||||||
{
|
{
|
||||||
//Console.WriteLine(number);
|
//Console.WriteLine(number);
|
||||||
@ -178,102 +180,103 @@ namespace DataLoader
|
|||||||
cont = ii.MyContent.Get();
|
cont = ii.MyContent.Get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (convertProcedures /* && number == "001\\u8209?007"/* && number == "0POP05-EO-EC00"*/)
|
if (convertProcedures /* && number == "001\\u8209?007"/* && number == "0POP05-EO-EC00"*/)
|
||||||
{
|
{
|
||||||
OleDbDataAdapter da = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where sequence like ' %'", cn);
|
OleDbDataAdapter da = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where sequence like ' %'", cn);
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
dicTrans_ItemDone[dicNumber] = itm; // will be null if only doing procs & no sections, etc.
|
||||||
|
LoadSection(ds, da, dr["entry"].ToString());
|
||||||
|
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;
|
||||||
|
ds.Tables["Steps"].CaseSensitive = true;
|
||||||
|
dt.Columns.Add("CStep", System.Type.GetType("System.String"));
|
||||||
|
dt.Columns.Add("CSequence", System.Type.GetType("System.String"));
|
||||||
|
// set the cstep & csequence - couldn't do it in the add because it needed a sql function
|
||||||
|
foreach (DataRow drw in ds.Tables["Steps"].Rows)
|
||||||
{
|
{
|
||||||
LoadSection(ds, da, dr["entry"].ToString());
|
drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString());
|
||||||
da.SelectCommand.CommandText = "select * from [" + dr["entry"] + "] where step not like ' ' and step not like '%~'";
|
drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString());
|
||||||
da.Fill(ds, "Steps");
|
|
||||||
dt = ds.Tables["Steps"];
|
|
||||||
dt.CaseSensitive = true;
|
|
||||||
ds.Tables["Steps"].CaseSensitive = true;
|
|
||||||
dt.Columns.Add("CStep", System.Type.GetType("System.String"));
|
|
||||||
dt.Columns.Add("CSequence", System.Type.GetType("System.String"));
|
|
||||||
// set the cstep & csequence - couldn't do it in the add because it needed a sql function
|
|
||||||
foreach (DataRow drw in ds.Tables["Steps"].Rows)
|
|
||||||
{
|
|
||||||
drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString());
|
|
||||||
drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString());
|
|
||||||
}
|
|
||||||
dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48");
|
|
||||||
dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)");
|
|
||||||
dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48");
|
||||||
{
|
dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)");
|
||||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48");
|
||||||
log.Error(ex.StackTrace);
|
|
||||||
frmMain.AddError(ex, "MigrateProcedure - {0}", ProcFileName);
|
|
||||||
}
|
|
||||||
da.Dispose();
|
|
||||||
|
|
||||||
// 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, 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;
|
|
||||||
//if (ProcNumber == "001-002")
|
|
||||||
// Console.WriteLine("proc 001-002");
|
|
||||||
foreach (DataRowView drw in dv)
|
|
||||||
{
|
|
||||||
//if (ProcNumber == "016-001") //"017-001") //"082-002AB")
|
|
||||||
// Console.WriteLine("016-001"); //("017-001"); //"082-002AB");
|
|
||||||
SectItm = MigrateSection(parentitem, ProcNumber, cn, drw, ds.Tables["Steps"], SectItm, dicSecCount.Count > 0 ? true : false, pth, docver, activeFormat,addpart ? cont :null);
|
|
||||||
addpart = false;
|
|
||||||
// if no children, add first child (cont)
|
|
||||||
//if (addpart)
|
|
||||||
//{
|
|
||||||
// // 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;
|
|
||||||
dicSecParentItem[level] = SectItm;
|
|
||||||
if (level > 0)
|
|
||||||
{
|
|
||||||
if ((dicSecCount[level]) == 1)
|
|
||||||
// shift up a level, i.e. give me the parent for the previous level
|
|
||||||
SectItm = dicSecParentItem[--level];
|
|
||||||
else
|
|
||||||
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[++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)
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ds.Dispose();
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.Error(ex.StackTrace);
|
||||||
|
frmMain.AddError(ex, "MigrateProcedure - {0}", ProcFileName);
|
||||||
|
}
|
||||||
|
da.Dispose();
|
||||||
|
|
||||||
|
// 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, 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;
|
||||||
|
//if (ProcNumber == "001-002")
|
||||||
|
// Console.WriteLine("proc 001-002");
|
||||||
|
foreach (DataRowView drw in dv)
|
||||||
|
{
|
||||||
|
//if (ProcNumber == "016-001") //"017-001") //"082-002AB")
|
||||||
|
// Console.WriteLine("016-001"); //("017-001"); //"082-002AB");
|
||||||
|
SectItm = MigrateSection(parentitem, ProcNumber, cn, drw, ds.Tables["Steps"], SectItm, dicSecCount.Count > 0 ? true : false, pth, docver, activeFormat, addpart ? cont : null);
|
||||||
|
addpart = false;
|
||||||
|
// if no children, add first child (cont)
|
||||||
|
//if (addpart)
|
||||||
|
//{
|
||||||
|
// // 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;
|
||||||
|
dicSecParentItem[level] = SectItm;
|
||||||
|
if (level > 0)
|
||||||
|
{
|
||||||
|
if ((dicSecCount[level]) == 1)
|
||||||
|
// shift up a level, i.e. give me the parent for the previous level
|
||||||
|
SectItm = dicSecParentItem[--level];
|
||||||
|
else
|
||||||
|
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[++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)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ds.Dispose();
|
||||||
return itm;
|
return itm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user