This commit is contained in:
John Jenko 2010-03-31 16:49:11 +00:00
parent bf33f71a1a
commit eaba85067c
2 changed files with 30 additions and 27 deletions

View File

@ -28,12 +28,12 @@ namespace DataLoader
public partial class Loader
{
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)
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, FormatInfo activeFormat)
{
frmMain.UpdateLabels(0, 1, 0);
try
{
FormatInfo format = null;
FormatInfo format = activeFormat;
// 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
@ -43,7 +43,8 @@ namespace DataLoader
// 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,Number,Title);
//int docstyleindx = GetDocStyleIndx(dstyleindx, format, procitem, docver,Number,Title);
int docstyleindx = GetDocStyleIndx(dstyleindx, format, procitem, Number, Title);
// tack on the column mode - add to config xml for node.
if (stpseq != null && stpseq.Substring(1, 1) == "0" && stpseq.Substring(5, 1) != " ")
@ -189,13 +190,13 @@ namespace DataLoader
}
return retval;
}
private int GetDocStyleIndx(string dstyleindx, FormatInfo format, Item procitem, DocVersion docver, string Number, string Title)
private int GetDocStyleIndx(string dstyleindx, FormatInfo format, Item procitem, /* DocVersion docver,*/ string Number, string Title)
{
// get the format, if format is set, use it, otherwise walk
if (format == null)
{
format = GetFormat(procitem, docver);
}
//if (format == null)
//{
//format = GetFormat(procitem, docver);
//}
int docstyle = LookupOldToNew(dstyleindx);
foreach (DocStyle ds in format.PlantFormat.DocStyles.DocStyleList)
{
@ -205,20 +206,20 @@ namespace DataLoader
procitem.DisplayNumber, (Number ?? "") == "" ? Title : Number, dstyleindx, format, docstyle);
return 0; // Default is Zero
}
private FormatInfo GetFormat(Item procitem, DocVersion docver)
{
return procitem.MyItemInfo.ActiveFormat;
//while (procitem.MyItemInfo.a .MyContent.MyFormat == null)
//{
// // find the first sibling
// while (procitem.PreviousID != null)
// procitem = procitem.MyPrevious;
// if (procitem.ItemPartCount == 0) return docver.MyDocVersionInfo.ActiveFormat;
// // find the parent node
// procitem = procitem.ItemParts[0].MyContent.ContentItems[0].MyItem;
//}
//return procitem.MyContent.MyFormat;
}
//private FormatInfo GetFormat(Item procitem, DocVersion docver)
//{
// return procitem.MyItemInfo.ActiveFormat;
// //while (procitem.MyItemInfo.a .MyContent.MyFormat == null)
// //{
// // // find the first sibling
// // while (procitem.PreviousID != null)
// // procitem = procitem.MyPrevious;
// // if (procitem.ItemPartCount == 0) return docver.MyDocVersionInfo.ActiveFormat;
// // // find the parent node
// // procitem = procitem.ItemParts[0].MyContent.ContentItems[0].MyItem;
// //}
// //return procitem.MyContent.MyFormat;
//}
//private FormatInfo GetFormat(DocVersion docver)
//{
// if (docver.MyDocVersionInfo.MyFormat != null) return docver.MyDocVersionInfo.MyFormat;
@ -302,7 +303,7 @@ namespace DataLoader
}
return menustr;
}
private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool isSubSection, string pth, DocVersion docver)
private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool isSubSection, string pth, DocVersion docver, FormatInfo activeFormat)
{
Int32 thesectid = 0;
bool isautogen = false;
@ -319,7 +320,7 @@ namespace DataLoader
// value would be (for example, what the format is for the set), if they are the same
// clear the format at the section level.
FormatInfo sectFormat = null;
FormatInfo docverFormat = docver.MyDocVersionInfo.ActiveFormat;
FormatInfo docverFormat = activeFormat;//docver.MyDocVersionInfo.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.
@ -451,7 +452,7 @@ namespace DataLoader
libDocid = dicLibDocRef[thekey];
}
}
Item secitem = AddSection(procitem, num, title, stype, dts, init, ci, step + sequence, fmt, libDocid, pth, FromItem, docver);
Item secitem = AddSection(procitem, num, title, stype, dts, init, ci, step + sequence, fmt, libDocid, pth, FromItem, sectFormat);
thesectid = secitem.ItemID;
// if the editsectid hasn't been set yet, set it to this section id, i.e. the first
@ -487,7 +488,7 @@ namespace DataLoader
frmMain.pbStepValue = 0;
foreach (DataRowView drv in dv)
{
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver,secitem.MyItemInfo.ActiveFormat);
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver,sectFormat);
if (secitem.MyContent.ContentParts.Count == 0)
{
// type 6 is step

View File

@ -134,7 +134,9 @@ namespace DataLoader
item = Item.MakeItem(FromItem, content, content.DTS, content.UserID);
// Remove styles that user entered but are automatically done via the format
string tstr = item.MyItemInfo.RemoveRtfStyles(content.Text,fmt);
string tstr = null;
using (ItemInfo myInfo = item.MyItemInfo) // do this so that ItemInfo doesn't stay in cashe
tstr = myInfo.RemoveRtfStyles(content.Text, fmt);
if (tstr != content.Text)
{
item.MyContent.Text = tstr;