Removed Debug Print

Moved code to add sections to Procedure parts
Moved code to add steps to Section parts
Moved code to add steps to Step parts
Changed Debug Print
Fixed a Format Flag conversion DontBreakOptEquipmentList
Changed GetItemFont so that parent items would not be left in the cache
Changed AddIncludedStepNumber to allow for ranges to sub levels.
Added a array reference to StepDataList by index.
This commit is contained in:
Rich 2010-06-17 18:42:06 +00:00
parent 332e35c484
commit 5af2c31559
9 changed files with 108 additions and 44 deletions

View File

@ -257,7 +257,7 @@ namespace DataLoader
private static string GetPartial(string path) private static string GetPartial(string path)
{ {
Console.WriteLine(string.Format("GetPartial path = {0}",path)); //Console.WriteLine(string.Format("GetPartial path = {0}",path));
if (path.Contains("\\")) if (path.Contains("\\"))
{ {
string[] parts = path.Split("\\".ToCharArray()); string[] parts = path.Split("\\".ToCharArray());

View File

@ -214,17 +214,18 @@ namespace DataLoader
{ {
//if (ProcNumber == "016-001") //"017-001") //"082-002AB") //if (ProcNumber == "016-001") //"017-001") //"082-002AB")
// Console.WriteLine("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); SectItm = MigrateSection(parentitem, ProcNumber, cn, drw, ds.Tables["Steps"], SectItm, dicSecCount.Count > 0 ? true : false, pth, docver, activeFormat,addpart ? cont :null);
// 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; 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; //FrType = 0;
dicSecParentItem[level] = SectItm; dicSecParentItem[level] = SectItm;
if (level > 0) if (level > 0)

View File

@ -303,7 +303,7 @@ namespace DataLoader
} }
return menustr; return menustr;
} }
private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool isSubSection, string pth, DocVersion docver, FormatInfo activeFormat) private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool isSubSection, string pth, DocVersion docver, FormatInfo activeFormat,Content cont)
{ {
Int32 thesectid = 0; Int32 thesectid = 0;
bool isautogen = false; bool isautogen = false;
@ -467,6 +467,14 @@ namespace DataLoader
Item secitem = AddSection(procitem, num, title, stype, dts, init, ci, step + sequence, fmt, libDocid, pth, FromItem, sectFormat); Item secitem = AddSection(procitem, num, title, stype, dts, init, ci, step + sequence, fmt, libDocid, pth, FromItem, sectFormat);
if (secitem == null) if (secitem == null)
throw (new Exception("Null parameter in AddSection")); throw (new Exception("Null parameter in AddSection"));
if (cont != null)
{
// ContentsParts.Add can use 'fromtype', item - fromtype here = 2, section
cont.ContentParts.Add(2, secitem);
if (cont.MyZContent.OldStepSequence == null || cont.MyZContent.OldStepSequence == "") cont.MyZContent.OldStepSequence = ProcNumber;
if (!cont.IsSavable) ErrorRpt.ErrorReport(cont);
cont.Save();
}
thesectid = secitem.ItemID; thesectid = secitem.ItemID;
// if the editsectid hasn't been set yet, set it to this section id, i.e. the first // if the editsectid hasn't been set yet, set it to this section id, i.e. the first
@ -500,16 +508,18 @@ namespace DataLoader
Item FrItem = null; Item FrItem = null;
frmMain.pbStepMaximum = dt.Rows.Count; frmMain.pbStepMaximum = dt.Rows.Count;
frmMain.pbStepValue = 0; frmMain.pbStepValue = 0;
int type = 6;
foreach (DataRowView drv in dv) foreach (DataRowView drv in dv)
{ {
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver,sectFormat); FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver, sectFormat, secitem, type);
if (secitem.MyContent.ContentParts.Count == 0) type = 0; // Only add ContentPart for first child
{ //if (secitem.MyContent.ContentParts.Count == 0)
// type 6 is step //{
secitem.MyContent.ContentParts.Add(6, FrItem); // // type 6 is step
if (!secitem.MyContent.IsSavable) ErrorRpt.ErrorReport(secitem.MyContent); // secitem.MyContent.ContentParts.Add(6, FrItem);
secitem.MyContent.Save(); // if (!secitem.MyContent.IsSavable) ErrorRpt.ErrorReport(secitem.MyContent);
} // secitem.MyContent.Save();
//}
} }
} }
return secitem; return secitem;

View File

@ -17,7 +17,7 @@ namespace DataLoader
{ {
public partial class Loader public partial class Loader
{ {
private Item AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, Item FromItem, DateTime dts, string userid, bool conv_caret, string pth, DocVersion docver, FormatInfo fmt) private Item AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, Item FromItem, DateTime dts, string userid, bool conv_caret, string pth, DocVersion docver, FormatInfo fmt,Item parentItem, int frType)
{ {
//if (ProcNumber + "|" + stpseq == "082-002CD|A=S") //if (ProcNumber + "|" + stpseq == "082-002CD|A=S")
// Console.WriteLine("here"); // Console.WriteLine("here");
@ -133,6 +133,13 @@ namespace DataLoader
else else
item = Item.MakeItem(FromItem, content, content.DTS, content.UserID); item = Item.MakeItem(FromItem, content, content.DTS, content.UserID);
if (frType > 0)
{
parentItem.MyContent.ContentParts.Add(frType, item);
if (!parentItem.MyContent.IsSavable) ErrorRpt.ErrorReport(parentItem.MyContent);
parentItem.MyContent.Save();
}
// Remove styles that user entered but are automatically done via the format // Remove styles that user entered but are automatically done via the format
string tstr = null; string tstr = null;
using (ItemInfo myInfo = item.MyItemInfo) // do this so that ItemInfo doesn't stay in cashe using (ItemInfo myInfo = item.MyItemInfo) // do this so that ItemInfo doesn't stay in cashe
@ -336,7 +343,7 @@ namespace DataLoader
} }
return retval; return retval;
} }
private Item MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Item FromItem, bool conv_caret, string pth, DocVersion docver, FormatInfo fmt) private Item MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Item FromItem, bool conv_caret, string pth, DocVersion docver, FormatInfo fmt, Item parentItem, int frTypeParam)
{ {
try try
{ {
@ -344,7 +351,8 @@ namespace DataLoader
Item item = AddStep(cn, drv["Type"].ToString() Item item = AddStep(cn, drv["Type"].ToString()
, (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString()) , (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString())
, drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", FromItem // was str , 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, pth, docver, fmt); , GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString(), conv_caret, pth, docver, fmt, parentItem, frTypeParam);
//Content cont = Content.MakeContent(null,(drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString()),drv["Type"]+20000,null,null, //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()); // GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
//Item item = Item.MakeItem(FromItem, cont, cont.DTS, cont.UserID); //Item item = Item.MakeItem(FromItem, cont, cont.DTS, cont.UserID);
@ -397,14 +405,14 @@ namespace DataLoader
, (drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString()) , (drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString())
, drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString() , drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString()
, GetStructType(drvs["sequence"].ToString()), FrItem , GetStructType(drvs["sequence"].ToString()), FrItem
, GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString(), conv_caret, pth, docver, fmt); , GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString(), conv_caret, pth, docver, fmt, itemp, FrType);
if (FrType > 0 ) //if (FrType > 0 )
{ //{
itemp.MyContent.ContentParts.Add(FrType, itemc); // itemp.MyContent.ContentParts.Add(FrType, itemc);
if (!itemp.MyContent.IsSavable) ErrorRpt.ErrorReport(itemp.MyContent); // if (!itemp.MyContent.IsSavable) ErrorRpt.ErrorReport(itemp.MyContent);
itemp.MyContent.Save(); // itemp.MyContent.Save();
} //}
dicStr[sType] = itemc; dicStr[sType] = itemc;
dicStruct[drvs["CSequence"].ToString()] = new Dictionary<string, Item>(); dicStruct[drvs["CSequence"].ToString()] = new Dictionary<string, Item>();
dicStep[drvs["CSequence"].ToString()] = itemc; dicStep[drvs["CSequence"].ToString()] = itemc;

View File

@ -179,7 +179,7 @@ namespace DataLoader
//if the dash is preceeded byte a token remove the space following the token //if the dash is preceeded byte a token remove the space following the token
#if DEBUG #if DEBUG
if (s2.Contains(@"\super ")) if (s2.Contains(@"\super "))
Console.WriteLine("Here"); Console.WriteLine("RTF Super token");
#endif #endif
s2 = Regex.Replace(s2, @"(\\[^ \\?]*) \-", @"$1\u8209?"); s2 = Regex.Replace(s2, @"(\\[^ \\?]*) \-", @"$1\u8209?");
s2 = s2.Replace("-", @"\u8209?"); s2 = s2.Replace("-", @"\u8209?");

View File

@ -1099,7 +1099,7 @@ namespace VEPROMS.CSLA.Library
case 2: // step types case 2: // step types
int typindx = type - 20000; // what to do for other types rather than steps int typindx = type - 20000; // what to do for other types rather than steps
font = format.PlantFormat.FormatData.StepDataList[typindx].Font; font = format.PlantFormat.FormatData.StepDataList[typindx].Font;
if (IsParagraph) font = AdjustForTextSubFollowsTextStyle(font); if (typindx == _ParagraphType) font = AdjustForTextSubFollowsTextStyle(format,typindx,font);
break; break;
} }
} }
@ -1109,14 +1109,20 @@ namespace VEPROMS.CSLA.Library
} }
return font; return font;
} }
private const int _ParagraphType=24;
protected VE_Font AdjustForTextSubFollowsTextStyle(VE_Font font) protected VE_Font AdjustForTextSubFollowsTextStyle(VE_Font font)
{ {
if (FormatStepData.TextSubFollowsTextStyle && ParentNoteOrCaution != null) return AdjustForTextSubFollowsTextStyle(ActiveFormat, this.FormatStepType, font);
}
private VE_Font AdjustForTextSubFollowsTextStyle(FormatInfo format, int typindx, VE_Font font)
{ {
bool isBold = (FormatStepData.Font.Style & E_Style.Bold) > 0; StepData myFormatStepData = format.PlantFormat.FormatData.StepDataList[typindx];
bool isMmBold = (FormatStepData.Font.Style & E_Style.MmBold) > 0; if (myFormatStepData.TextSubFollowsTextStyle && ParentNoteOrCaution != null)
font = ParentNoteOrCaution.FormatStepData.Font; {
bool isBold = (myFormatStepData.Font.Style & E_Style.Bold) > 0;
bool isMmBold = (myFormatStepData.Font.Style & E_Style.MmBold) > 0;
myFormatStepData = format.PlantFormat.FormatData.StepDataList[ParentNoteOrCaution.FormatStepType];
font = myFormatStepData.Font;
E_Style myStyle = (E_Style) font.Style; E_Style myStyle = (E_Style) font.Style;
myStyle ^= (myStyle & E_Style.Bold); myStyle ^= (myStyle & E_Style.Bold);
myStyle ^= (myStyle & E_Style.MmBold); myStyle ^= (myStyle & E_Style.MmBold);
@ -1947,7 +1953,7 @@ namespace VEPROMS.CSLA.Library
{ {
if (parent.IsCautionPart || parent.IsNotePart) if (parent.IsCautionPart || parent.IsNotePart)
_ParentNoteOrCaution = parent; _ParentNoteOrCaution = parent;
else else if(!parent.IsHigh)
{ {
_ParentNoteOrCaution = parent.ParentNoteOrCaution; _ParentNoteOrCaution = parent.ParentNoteOrCaution;
} }

View File

@ -31,6 +31,11 @@ namespace VEPROMS.CSLA.Library
public string ResolvePathTo() public string ResolvePathTo()
{ {
ItemInfo item = MyContent.ContentItems[0]; ItemInfo item = MyContent.ContentItems[0];
//Console.WriteLine("Format = {0}", item.ActiveFormat);
//Console.WriteLine("item = {0}", item.ItemID);
//Console.WriteLine("TranType = {0}", TranType);
//Console.WriteLine("MyItemToID = {0}", MyItemToID);
//Console.WriteLine("MyItemRangeID = {0}", MyItemRangeID);
return ResolvePathTo(item.ActiveFormat, item, TranType, MyItemToID, MyItemRangeID); return ResolvePathTo(item.ActiveFormat, item, TranType, MyItemToID, MyItemRangeID);
} }
} }
@ -290,6 +295,7 @@ namespace VEPROMS.CSLA.Library
public int _TranType; public int _TranType;
public ItemInfo _ToItem; public ItemInfo _ToItem;
public ItemInfo _RangeItem; public ItemInfo _RangeItem;
public bool _UsedRangeAncestor;
} }
private static Dictionary<string, TransitionAppendFunction> _AppendMethods; private static Dictionary<string, TransitionAppendFunction> _AppendMethods;
private static void SetupMethods() private static void SetupMethods()
@ -321,13 +327,14 @@ namespace VEPROMS.CSLA.Library
} }
private static TransitionBuilder SetupTransitionBuilder(FormatInfo formatInfo, ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem) private static TransitionBuilder SetupTransitionBuilder(FormatInfo formatInfo, ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem)
{ {
TransitionBuilder tb; TransitionBuilder tb = new TransitionBuilder();
tb._Results = new StringBuilder(); tb._Results = new StringBuilder();
tb._FormatData = formatInfo.PlantFormat.FormatData; tb._FormatData = formatInfo.PlantFormat.FormatData;
// get the format of the transition string based on this transition's index into the TransData part of // get the format of the transition string based on this transition's index into the TransData part of
// format.... // format....
if (tranType > tb._FormatData.TransData.TransTypeList.Count) if (tranType > tb._FormatData.TransData.TransTypeList.Count)
tranType = 0; tranType = 0;
// Replace 3 tokens ", {.}, {.}, {.}" with a single token "{.}"
tb._TransFormat = tb._FormatData.TransData.TransTypeList[tranType].TransFormat.Replace(", {.}, {.}, {.}", "{.}"); tb._TransFormat = tb._FormatData.TransData.TransTypeList[tranType].TransFormat.Replace(", {.}, {.}, {.}", "{.}");
tb._TransUI = (E_TransUI)tb._FormatData.TransData.TransTypeList[tranType].TransUI; tb._TransUI = (E_TransUI)tb._FormatData.TransData.TransTypeList[tranType].TransUI;
tb._FromItem = fromInfo; tb._FromItem = fromInfo;
@ -498,18 +505,34 @@ namespace VEPROMS.CSLA.Library
} }
private static bool AddIncludedStepNumber(bool textAdded, TransitionBuilder tb, string token, string nonToken) private static bool AddIncludedStepNumber(bool textAdded, TransitionBuilder tb, string token, string nonToken)
{ {
Dictionary<int, ItemInfo> rangeAncestors = GetAncestors(tb._RangeItem);
if (textAdded) Append(tb, nonToken, false); if (textAdded) Append(tb, nonToken, false);
ItemInfo next = GetNextItem(tb._ToItem); bool usedRangeAncestor = false;
ItemInfo next = GetNextItem(tb._ToItem, rangeAncestors, ref usedRangeAncestor);
while (next.ItemID != tb._RangeItem.ItemID) while (next.ItemID != tb._RangeItem.ItemID)
{ {
Append(tb, ", " + Tab(next), true); // TODO: Intermediate Range. Append(tb, ", " + Tab(next), true); // TODO: Intermediate Range.
next = GetNextItem(next); next = GetNextItem(next, rangeAncestors, ref usedRangeAncestor);
} }
textAdded = true; textAdded = true;
tb._UsedRangeAncestor = usedRangeAncestor;
return textAdded; return textAdded;
} }
private static ItemInfo GetNextItem(ItemInfo next) private static Dictionary<int, ItemInfo> GetAncestors(ItemInfo itemInfo)
{ {
Dictionary<int, ItemInfo> retval = new Dictionary<int,ItemInfo>();
while (!itemInfo.IsHigh)
{
ItemInfo parent = itemInfo.MyActiveParent as ItemInfo;
retval.Add(parent.ItemID, itemInfo.FirstSibling);
itemInfo = parent;
}
return retval;
}
private static ItemInfo GetNextItem(ItemInfo next, Dictionary<int, ItemInfo> rangeAncestors, ref bool usedRangeAncestor)
{
if (rangeAncestors.ContainsKey(next.ItemID))
return rangeAncestors[next.ItemID];
while (next.NextItem == null) while (next.NextItem == null)
next = next.ActiveParent as ItemInfo; next = next.ActiveParent as ItemInfo;
return next.NextItem; return next.NextItem;

View File

@ -3699,7 +3699,16 @@ namespace VEPROMS.CSLA.Library
return null; return null;
} }
} }
public StepDataList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList,myFormat) { } public StepData this[int index]
{
get
{
foreach (StepData stepData in this)
if (stepData.Index == index) return stepData;
return null;
}
}
public StepDataList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) : base(xmlNodeList, myFormat) { }
private StepData _HLS; private StepData _HLS;
public StepData HLS public StepData HLS
{ {

View File

@ -2016,7 +2016,8 @@ namespace fmtxml
if ((flg & DOSECTIONSEPARATORLINE) > 0) XtraFlags.DoSectionSeparatorLine = true.ToString(); if ((flg & DOSECTIONSEPARATORLINE) > 0) XtraFlags.DoSectionSeparatorLine = true.ToString();
if ((flg & PARENSONEXTPAGENUMTRANS) > 0) XtraFlags.ParensOnExtPagenumTrans = true.ToString(); if ((flg & PARENSONEXTPAGENUMTRANS) > 0) XtraFlags.ParensOnExtPagenumTrans = true.ToString();
if ((flg & ATLEASTTWODIGITSFORHLS) > 0) XtraFlags.AtLeastTwoDigitsForHLS = true.ToString(); if ((flg & ATLEASTTWODIGITSFORHLS) > 0) XtraFlags.AtLeastTwoDigitsForHLS = true.ToString();
if ((flg & DONTBREAKOPTEQUIPMENTLIST) > 0) XtraFlags.DontBreakEquipmentList = true.ToString(); if ((flg & DONTBREAKOPTEQUIPMENTLIST) > 0)
XtraFlags.DontBreakOptEquipmentList = true.ToString();
if ((flg & PAGELISTCHANGEIDSWITHCOMMAS) > 0) XtraFlags.PagelistChangeIDsWithCommas = true.ToString(); if ((flg & PAGELISTCHANGEIDSWITHCOMMAS) > 0) XtraFlags.PagelistChangeIDsWithCommas = true.ToString();
if ((flg & DONTSTARTLINEWITHDASH) > 0) XtraFlags.DontStartLineWithDash = true.ToString(); if ((flg & DONTSTARTLINEWITHDASH) > 0) XtraFlags.DontStartLineWithDash = true.ToString();
if ((flg & NOBLANKLINEBEFORESUBSTEP) > 0) XtraFlags.NoBlankLineBeforeSubstep = true.ToString(); if ((flg & NOBLANKLINEBEFORESUBSTEP) > 0) XtraFlags.NoBlankLineBeforeSubstep = true.ToString();
@ -3532,6 +3533,12 @@ namespace fmtxml
// All EquipmentOpt get this thru inheritance // All EquipmentOpt get this thru inheritance
if (XtraFlags.QuotedSubsteps == "True") fmtdata.StepData[i].Quoted = "True"; if (XtraFlags.QuotedSubsteps == "True") fmtdata.StepData[i].Quoted = "True";
else fmtdata.StepData[i].Quoted = "False"; else fmtdata.StepData[i].Quoted = "False";
// Note that only opt equipment lists (and wblank) get this - no inherit - must be done in code!
if (XtraFlags.DontBreakOptEquipmentList == "True")
fmtdata.StepData[i].BreakEquipmentList = "False";
else
fmtdata.StepData[i].BreakEquipmentList = "True";
} }
else if (i == 31) // EquipmentOptWBlank else if (i == 31) // EquipmentOptWBlank
{ {