Use FormatInfo rather than Format object

This commit is contained in:
Rich 2009-10-08 14:24:34 +00:00
parent c5d2578ee9
commit 8804d367da
4 changed files with 38 additions and 32 deletions

View File

@ -121,7 +121,7 @@ namespace DataLoader
} }
} }
} }
public Format GetFormat(string format) public FormatInfo GetFormat(string format)
{ {
Format parent = null; Format parent = null;
Format rec = null; Format rec = null;
@ -153,7 +153,8 @@ namespace DataLoader
{ {
log.ErrorFormat("Error getting xml version of format {0}", ex.Message); log.ErrorFormat("Error getting xml version of format {0}", ex.Message);
} }
return rec; FormatInfo recInfo = FormatInfo.Get(rec.FormatID);
return recInfo;
} }
} }

View File

@ -98,14 +98,16 @@ namespace DataLoader
myReader.Close(); myReader.Close();
} }
Folder tmpfld = (Folder)parfld; Folder tmpfld = (Folder)parfld;
Format format = null; FormatInfo format = null;
if (defPlantFmt != null && defPlantFmt != "") if (defPlantFmt != null && defPlantFmt != "")
{ {
format = GetFormat(defPlantFmt); format = GetFormat(defPlantFmt);
} }
else else
format = Format.Get(1); format = FormatInfo.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"); DocVersion v;
using(Format fmt = format.Get())
v = DocVersion.MakeDocVersion(tmpfld, (int)DocVersionType(vb.Path.ToLower()), thetitle, vb.Path.ToLower(), null, fmt, fld_cfg == null ? null : fld_cfg.ToString(), DateTime.Now, "Migration");
tn.Tag = v; tn.Tag = v;
MigrateDocVersion(v, false); MigrateDocVersion(v, false);
return (object)v; return (object)v;

View File

@ -120,7 +120,7 @@ namespace DataLoader
EditSectId = 0; EditSectId = 0;
// See if no caret convert... // See if no caret convert...
Format docverFormat = docver.ActiveFormat; FormatInfo docverFormat = docver.MyDocVersionInfo.ActiveFormat;
bool do_cvt = docverFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta; bool do_cvt = 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)

View File

@ -33,7 +33,7 @@ namespace DataLoader
frmMain.UpdateLabels(0, 1, 0); frmMain.UpdateLabels(0, 1, 0);
try try
{ {
Format format = null; FormatInfo format = null;
// Tie the section to format used, this will add the format xml if it doesn't exist in // 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 // the database yet. Note that if there is no format at this level then none should
@ -81,7 +81,9 @@ namespace DataLoader
if (Userid == null || Userid == "") Userid = "Migration"; if (Userid == null || Userid == "") Userid = "Migration";
// test for performance // test for performance
Content cont = Content.New(Number, Title, 10000+docstyleindx, format, ci==null?null:ci.ToString(), Dts, Userid); Content cont;
using(Format fmt2 = format == null ? null : format.Get())
cont = Content.New(Number, Title, 10000+docstyleindx, fmt2, ci==null?null:ci.ToString(), Dts, Userid);
Entry entry = cont.MyEntry; Entry entry = cont.MyEntry;
if (needEntry) if (needEntry)
{ {
@ -186,7 +188,7 @@ namespace DataLoader
} }
return retval; return retval;
} }
private int GetDocStyleIndx(string dstyleindx, Format format, Item procitem, DocVersion docver) private int GetDocStyleIndx(string dstyleindx, FormatInfo format, Item procitem, DocVersion docver)
{ {
// get the format, if format is set, use it, otherwise walk // get the format, if format is set, use it, otherwise walk
if (format == null) if (format == null)
@ -200,29 +202,30 @@ namespace DataLoader
} }
return -1; return -1;
} }
private Format GetFormat(Item procitem, DocVersion docver) private FormatInfo GetFormat(Item procitem, DocVersion docver)
{ {
while (procitem.MyContent.MyFormat == null) return procitem.MyItemInfo.ActiveFormat;
{ //while (procitem.MyItemInfo.a .MyContent.MyFormat == null)
// find the first sibling //{
while (procitem.PreviousID != null) // // find the first sibling
procitem = procitem.MyPrevious; // while (procitem.PreviousID != null)
if (procitem.ItemPartCount == 0) return GetFormat(docver); // procitem = procitem.MyPrevious;
// find the parent node // if (procitem.ItemPartCount == 0) return docver.MyDocVersionInfo.ActiveFormat;
procitem = procitem.ItemParts[0].MyContent.ContentItems[0].MyItem; // // find the parent node
} // procitem = procitem.ItemParts[0].MyContent.ContentItems[0].MyItem;
return procitem.MyContent.MyFormat; //}
} //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 FormatInfo GetFormat(DocVersion docver)
//{
// if (docver.MyDocVersionInfo.MyFormat != null) return docver.MyDocVersionInfo.MyFormat;
// return GetFormat(docver.MyDocVersionInfo.MyFolder);
//}
//private FormatInfo GetFormat(FolderInfo folder)
//{
// if (folder.MyFormat != null) return folder.MyFolderInfo.MyFormat;
// return GetFormat(folder.MyParent);
//}
private string SectTitle(OleDbConnection cn, DataRowView dr, bool UseMultiLineSectionTitle, bool ConvertCaret) private string SectTitle(OleDbConnection cn, DataRowView dr, bool UseMultiLineSectionTitle, bool ConvertCaret)
{ {
string tbuff = null; string tbuff = null;
@ -310,8 +313,8 @@ namespace DataLoader
// Note that if the format is set for this section, check it against what the inherited // 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 // value would be (for example, what the format is for the set), if they are the same
// clear the format at the section level. // clear the format at the section level.
Format sectFormat = null; FormatInfo sectFormat = null;
Format docverFormat = docver.ActiveFormat; FormatInfo docverFormat = docver.MyDocVersionInfo.ActiveFormat;
if (fmt != null&& fmt !="") // Is there a long section title (from format flag) if (fmt != null&& fmt !="") // Is there a long section title (from format flag)
sectFormat = GetFormat(fmt); sectFormat = GetFormat(fmt);
else // either from this format, or the plant. else // either from this format, or the plant.