This commit is contained in:
Kathy Ruffing 2012-09-27 10:26:36 +00:00
parent 747fd76f21
commit e8033fe6d4
2 changed files with 70 additions and 2 deletions

View File

@ -303,6 +303,59 @@ namespace DataLoader
} }
} }
ds.Dispose(); ds.Dispose();
// if there are any floating foldouts & associated steps, set config on steps for foldout association.
// the free the lists for the next procedure:
if (FoldoutStpSeq != null && FoldoutStpSeq.Count>0)
{
string cmd = "SELECT * FROM [tran] WHERE [FROMNUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [TYPE] ='R'";
OleDbDataAdapter da = new OleDbDataAdapter(cmd, cn);
// get transition records for this step.
ds = new DataSet();
try
{
da.Fill(ds);
DataTable dtt = ds.Tables[0];
dtt.CaseSensitive = true;
Dictionary<int, string> stpFoldSeq = new Dictionary<int,string>();
foreach (DataRow drt in dtt.Rows)
{
// get from/to seq, subtract off '0' to get stepnumber.
int fromStep = drt["FROMSEQUEN"].ToString()[1] - '0';
int toStep = drt["TOSEQUENCE"].ToString()[1] - '0';
string foldSeq = drt["OLDTO"].ToString().Substring(0, 2);
for (int istp = fromStep; istp <= toStep; istp++)
stpFoldSeq.Add(istp, foldSeq);
}
ds.Dispose();
da.Dispose();
// now read in the HLS's and set their config to the appropriate foldout:
int cnt = 1;
foreach (int hlsItemId in FloatingFoldoutHLS)
{
using (Item itmF = Item.Get(hlsItemId))
{
string fldstr = stpFoldSeq[cnt];
int fldItemId = FoldoutStpSeq[fldstr];
ConfigInfo ciFold = new ConfigInfo(itmF.MyContent.Config);
ciFold.AddItem("Step", "FloatingFoldout", fldItemId.ToString());
itmF.MyContent.Config = ciFold.ToString();
itmF.Save();
}
}
}
catch (Exception ex)
{
frmMain.AddError(ex, "Error resolving Floating Foldout Data '{0}'", ProcNumber);
log.Error("Error resolving Floating Foldout Data");
log.ErrorFormat("from number = {0}", ProcNumber);
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
ds.Dispose();
da.Dispose();
}
}
if (FoldoutStpSeq!=null) FoldoutStpSeq.Clear();
if (FloatingFoldoutHLS!=null) FloatingFoldoutHLS.Clear();
//Console.WriteLine("End MigrateProcedure number {0}", number); //Console.WriteLine("End MigrateProcedure number {0}", number);
//Console.WriteLine("End MigrateProcedure Item Key {0} List {1}", Item.CacheCountPrimaryKey, Item.CacheCountList); //Console.WriteLine("End MigrateProcedure Item Key {0} List {1}", Item.CacheCountPrimaryKey, Item.CacheCountList);
//Console.WriteLine("End MigrateProcedure ItemInfo Key {0} List {1}", ItemInfo.CacheCountPrimaryKey, ItemInfo.CacheCountList); //Console.WriteLine("End MigrateProcedure ItemInfo Key {0} List {1}", ItemInfo.CacheCountPrimaryKey, ItemInfo.CacheCountList);

View File

@ -394,7 +394,9 @@ namespace DataLoader
get { return Loader._OverrideColor; } get { return Loader._OverrideColor; }
set { Loader._OverrideColor = value; } set { Loader._OverrideColor = value; }
} }
private bool hasFloatingFoldouts = false;
private Dictionary<string, int> FoldoutStpSeq = null;
private List<int> FloatingFoldoutHLS = null;
private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool hasSubSection, string pth, DocVersion docver, FormatInfo activeFormat,Content cont) private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool hasSubSection, string pth, DocVersion docver, FormatInfo activeFormat,Content cont)
{ {
Int32 thesectid = 0; Int32 thesectid = 0;
@ -427,12 +429,14 @@ namespace DataLoader
{ {
ismulti = sectFormat.PlantFormat.FormatData.SectData.StepSectionData.UseMultiLineSectionTitle; ismulti = sectFormat.PlantFormat.FormatData.SectData.StepSectionData.UseMultiLineSectionTitle;
conv_caret = sectFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta; conv_caret = sectFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta;
hasFloatingFoldouts = sectFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout;
} }
if (fmt != null && fmt != "") if (fmt == docverFormat.Name) fmt = null; if (fmt != null && fmt != "") if (fmt == docverFormat.Name) fmt = null;
string title = SectTitle(cn, dr, ismulti, conv_caret); string title = SectTitle(cn, dr, ismulti, conv_caret);
string init = dr["initials"].ToString().Trim(); string init = dr["initials"].ToString().Trim();
string sequence = dr["CSequence"].ToString().PadRight(10); string sequence = dr["CSequence"].ToString().PadRight(10);
string step = dr["CStep"].ToString(); string step = dr["CStep"].ToString();
int libDocid = 0; int libDocid = 0;
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString()); DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
@ -563,6 +567,11 @@ namespace DataLoader
//Console.WriteLine("After AddSection"); //Console.WriteLine("After AddSection");
if (secitem == null) if (secitem == null)
throw (new Exception("Null parameter in AddSection")); throw (new Exception("Null parameter in AddSection"));
if (hasFloatingFoldouts)
{
if (FoldoutStpSeq == null) FoldoutStpSeq = new Dictionary<string, int>();
if (step[1] == 'F') FoldoutStpSeq.Add(step, secitem.ItemID);
}
if (cont != null) if (cont != null)
{ {
// ContentsParts.Add can use 'fromtype', item - fromtype here = 2, section // ContentsParts.Add can use 'fromtype', item - fromtype here = 2, section
@ -621,6 +630,11 @@ namespace DataLoader
foreach (DataRowView drv in dv) foreach (DataRowView drv in dv)
{ {
FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver, sectFormat, secitem, type); FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver, sectFormat, secitem, type);
if (hasFloatingFoldouts && (sequence[2] == 'x' || sequence[2] == 'X'))
{
if (FloatingFoldoutHLS == null) FloatingFoldoutHLS = new List<int>();
FloatingFoldoutHLS.Add(FrItem.ItemID);
}
type = 0; // Only add ContentPart for first child type = 0; // Only add ContentPart for first child
//if (secitem.MyContent.ContentParts.Count == 0) //if (secitem.MyContent.ContentParts.Count == 0)
//{ //{
@ -634,6 +648,7 @@ namespace DataLoader
} }
return secitem; return secitem;
} }
private void LoadSection(DataSet ds, OleDbDataAdapter da, string FileName) private void LoadSection(DataSet ds, OleDbDataAdapter da, string FileName)
{ {
try try
@ -648,13 +663,13 @@ namespace DataLoader
{ {
drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString()); drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString());
drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].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("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("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"); dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48");
dt.Columns.Add("locb", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,2,1),'System.Char'),'System.Int32')-48"); dt.Columns.Add("locb", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,2,1),'System.Char'),'System.Int32')-48");
} }
catch (Exception ex) catch (Exception ex)
{ {
FileInfo fi; FileInfo fi;