Outside transitions logic and annotations for unresolved transitions
This commit is contained in:
parent
3fa819494c
commit
efd8d900b2
@ -25,7 +25,11 @@ namespace DataLoader
|
|||||||
{
|
{
|
||||||
public partial class Loader
|
public partial class Loader
|
||||||
{
|
{
|
||||||
private Item MigrateProcedure(OleDbConnection cn, DataRow dr, Item FromItem, string pth, DocVersion docver)
|
#region Log4Net
|
||||||
|
public static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
//public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
private Item MigrateProcedure(OleDbConnection cn, DataRow dr, Item FromItem, string pth, DocVersion docver, bool convertProcedures)
|
||||||
{
|
{
|
||||||
dicOldStepSequence = new Dictionary<object, string>();
|
dicOldStepSequence = new Dictionary<object, string>();
|
||||||
Stack<int> SubSectLevels = new Stack<int>(); // levels of subsections
|
Stack<int> SubSectLevels = new Stack<int>(); // levels of subsections
|
||||||
@ -60,11 +64,12 @@ namespace DataLoader
|
|||||||
|
|
||||||
// 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";
|
||||||
if (File.Exists(fname))
|
string fname = pth + "\\" + dr["entry"] + ".dbf";
|
||||||
|
if (File.Exists(fname))
|
||||||
{
|
{
|
||||||
// if the dbt is bad, fix it.
|
// if the dbt is bad, fix it.
|
||||||
DbtOk(dr["entry"].ToString());
|
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);
|
||||||
try
|
try
|
||||||
@ -118,119 +123,150 @@ namespace DataLoader
|
|||||||
Format docverFormat = docver.ActiveFormat;
|
Format docverFormat = docver.ActiveFormat;
|
||||||
bool do_cvt = !(docverFormat.PlantFormat.FormatData.XtraOptions("DontConvertCarrotToDelta"));
|
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)
|
// 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);
|
|
||||||
|
|
||||||
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 ' ' 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)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
|
||||||
log.Error(ex.StackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
// dicSecCount is dictionary to track number of subsections for the parent at a level
|
// can we save itm.ItemID in a dictionary of outside trans? ex: otrans("vehlp\procs\0POP05-EO00",itm.ItemID)?
|
||||||
// dicSecID is the parent at that level
|
Content cont = null;
|
||||||
Dictionary<int, int> dicSecCount = new Dictionary<int, int>();
|
Item itm =null;
|
||||||
Dictionary<int, Item> dicSecParentItem = new Dictionary<int, Item>();
|
string number = TextConvert.ConvertText(dr["Number"].ToString());
|
||||||
frmMain.pbSectMaximum = ds.Tables["Sections"].Rows.Count;
|
frmMain.UpdateLabels(1, 0, 0);
|
||||||
frmMain.pbSectValue = 0;
|
if (!convertProcedures || docver.VersionType != (int)VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft)// TODO: if convertProcedures == False - create item and content
|
||||||
|
{
|
||||||
DataTable dtsect = ds.Tables["Sections"];
|
cont = Content.New(number, TextConvert.ConvertText(dr["Title"].ToString(),do_cvt), 0, null, ci == null ? null : ci.ToString(), dts, userid);
|
||||||
dtsect.CaseSensitive = true;
|
itm = Item.MakeItem(FromItem, cont, dts, userid);
|
||||||
DataView dv = new DataView(dtsect, "", "locb", DataViewRowState.CurrentRows);
|
}
|
||||||
Item SectItm = null;
|
else // TODO: if convertProcedures == True - Find existing item.
|
||||||
int level = 0;
|
{
|
||||||
bool addpart = true;
|
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
|
||||||
Item parentitem = itm;
|
foreach(ItemInfo ii in dvi.Procedures){
|
||||||
foreach (DataRowView drw in dv)
|
if (ii.MyContent.Number == number)
|
||||||
|
{
|
||||||
|
Console.WriteLine(number);
|
||||||
|
itm = ii.Get();
|
||||||
|
cont = ii.MyContent.Get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (convertProcedures /* && number == "0POP05-EO-EC00"*/)
|
||||||
{
|
{
|
||||||
SectItm = MigrateSection(parentitem, cont.Number, cn, drw, ds.Tables["Steps"], SectItm, dicSecCount.Count > 0 ? true : false, pth, docver);
|
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 ' ' 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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.Error(ex.StackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
// if no children, add first child (cont)
|
// dicSecCount is dictionary to track number of subsections for the parent at a level
|
||||||
if (addpart)
|
// dicSecID is the parent at that level
|
||||||
{
|
Dictionary<int, int> dicSecCount = new Dictionary<int, int>();
|
||||||
// ContentsParts.Add can use 'fromtype', item - fromtype here = 2, section
|
Dictionary<int, Item> dicSecParentItem = new Dictionary<int, Item>();
|
||||||
cont.ContentParts.Add(2,SectItm);
|
frmMain.pbSectMaximum = ds.Tables["Sections"].Rows.Count;
|
||||||
if (cont.MyZContent.OldStepSequence == null || cont.MyZContent.OldStepSequence == "") cont.MyZContent.OldStepSequence = ProcNumber;
|
frmMain.pbSectValue = 0;
|
||||||
if (!cont.IsSavable) ErrorRpt.ErrorReport(cont);
|
|
||||||
cont.Save();
|
DataTable dtsect = ds.Tables["Sections"];
|
||||||
addpart = false;
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//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();
|
|
||||||
}
|
|
||||||
return itm;
|
return itm;
|
||||||
}
|
}
|
||||||
private Item MigrateProcedures(OleDbConnection cn, string pth, DocVersion docver)
|
private Item MigrateProcedures(OleDbConnection cn, string pth, DocVersion docver, bool convertProcedures)
|
||||||
{
|
{
|
||||||
|
Item FirstItm = null;
|
||||||
// Loop through Set File for each Procedure
|
// Loop through Set File for each Procedure
|
||||||
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [set] where entry is not null", cn);
|
try
|
||||||
DataSet ds = new DataSet();
|
{
|
||||||
da.Fill(ds);
|
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [set] where entry is not null", cn);
|
||||||
Item FrItm = null;
|
DataSet ds = new DataSet();
|
||||||
Item FirstItm = null;
|
da.Fill(ds);
|
||||||
frmMain.pbProcMaximum = ds.Tables[0].Rows.Count;
|
Item FrItm = null;
|
||||||
frmMain.UpdateLabels(0, 0, 0);
|
frmMain.pbProcMaximum = ds.Tables[0].Rows.Count;
|
||||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
frmMain.UpdateLabels(0, 0, 0);
|
||||||
{
|
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||||
FrItm = MigrateProcedure(cn, dr, FrItm, pth, docver);
|
{
|
||||||
if (FirstItm == null) FirstItm = FrItm;
|
FrItm = MigrateProcedure(cn, dr, FrItm, pth, docver, convertProcedures);
|
||||||
}
|
if (FirstItm == null) FirstItm = FrItm;
|
||||||
da.Dispose();
|
}
|
||||||
|
da.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_MyLog.ErrorFormat("MigrateProcedures - {0} - {1}\r\n\r\n{2}", pth,ex.Message, ex.InnerException);
|
||||||
|
}
|
||||||
return FirstItm;
|
return FirstItm;
|
||||||
}
|
}
|
||||||
private void DbtOk(string fname)
|
private void DbtOk(string fname, string pth)
|
||||||
{
|
{
|
||||||
string dbtname = frmMain.tbSourceText + "\\" + fname + ".dbt";
|
//string dbtname = frmMain.tbSourceText + "\\" + fname + ".dbt";
|
||||||
if (File.Exists(dbtname))
|
string dbtname = pth + "\\" + fname + ".dbt";
|
||||||
|
if (File.Exists(dbtname))
|
||||||
{
|
{
|
||||||
// check if dbt is at least 512, if not append 508 bytes. This is to fix
|
// 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.
|
// a problem where dbts were created with only 4 bytes in the 16-bit code.
|
||||||
|
@ -110,6 +110,7 @@ namespace DataLoader
|
|||||||
if (!itm.IsSavable) ErrorRpt.ErrorReport(itm);
|
if (!itm.IsSavable) ErrorRpt.ErrorReport(itm);
|
||||||
itm.Save();
|
itm.Save();
|
||||||
dicTrans_ItemIds.Remove(ProcNumber + "|" + trstpseq);
|
dicTrans_ItemIds.Remove(ProcNumber + "|" + trstpseq);
|
||||||
|
dicTrans_MigrationErrors.Remove(ProcNumber + "|" + trstpseq);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
itm = Item.MakeItem(FromItem, cont, Dts, Userid);
|
itm = Item.MakeItem(FromItem, cont, Dts, Userid);
|
||||||
@ -483,7 +484,7 @@ namespace DataLoader
|
|||||||
frmMain.pbStepValue = 0;
|
frmMain.pbStepValue = 0;
|
||||||
foreach (DataRowView drv in dv)
|
foreach (DataRowView drv in dv)
|
||||||
{
|
{
|
||||||
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret);
|
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth);
|
||||||
if (secitem.MyContent.ContentParts.Count == 0)
|
if (secitem.MyContent.ContentParts.Count == 0)
|
||||||
{
|
{
|
||||||
// type 6 is step
|
// type 6 is step
|
||||||
|
Loading…
x
Reference in New Issue
Block a user