Formats.cs - Update existing Formats

ContentExt.cs - Fixed logic to find RO value in procedure text
DisplayText.cs - Fixed logic to find Ro value in procedure text
This commit is contained in:
Rich
2011-07-19 16:40:50 +00:00
parent be814b9743
commit 7b177a88f6
3 changed files with 116 additions and 79 deletions

View File

@@ -28,57 +28,83 @@ namespace DataLoader
{
public string _FmtAllPath;
public string _GenmacAllPath;
private Format AddFormatToDB(Format parent, string format, bool issub, DateTime Dts, string Userid)
{
string fmtdata = null;
string genmacdata = null;
XmlDocument xd = null;
private FormatInfoList _AllFormats;
public FormatInfoList AllFormats
{
get
{
if (_AllFormats == null)
_AllFormats = FormatInfoList.Get();
return _AllFormats;
}
}
private Dictionary<string, int> _LookupFormats;
public Dictionary<string, int> LookupFormats
{
get
{
if (_LookupFormats == null)
{
_LookupFormats = new Dictionary<string, int>();
foreach (FormatInfo myFormat in AllFormats)
{
_LookupFormats.Add(myFormat.Name, myFormat.FormatID);
}
}
return _LookupFormats;
}
}
private Format AddFormatToDB(Format parent, string format, bool issub, DateTime Dts, string Userid)
{
string fmtdata = null;
string genmacdata = null;
XmlDocument xd = null;
//string path = "c:\\development\\fmtall\\" + format + "all.xml";
string path = _FmtAllPath + "\\" + format + "all.xml";
if (File.Exists(path))
{
try
{
StreamReader srf = new StreamReader(path);
xd = new XmlDocument();
xd.Load(srf);
//xd.Load(path);
fmtdata = xd.OuterXml;
}
catch(Exception ex)
{
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
return null;
}
}
// Do we need genmac - only if non-subformat
if (!issub)
{
if (File.Exists(path))
{
try
{
StreamReader srf = new StreamReader(path);
xd = new XmlDocument();
xd.Load(srf);
//xd.Load(path);
fmtdata = xd.OuterXml;
}
catch (Exception ex)
{
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
return null;
}
}
// Do we need genmac - only if non-subformat
if (!issub)
{
//path = "c:\\development\\genmacall\\" + format + ".svg";
path = _GenmacAllPath + "\\" + format + ".svg";
if (File.Exists(path))
{
try
{
StreamReader sr = new StreamReader(path);
XmlDocument xdg = new XmlDocument();
xdg.Load(sr);
//xdg.Load(path);
genmacdata = xdg.OuterXml;
}
catch (Exception ex)
{
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
return null;
}
}
}
// Get the name & then create the record.
if (Userid == null || Userid == "") Userid = "Migration";
path = _GenmacAllPath + "\\" + format + ".svg";
if (File.Exists(path))
{
try
{
StreamReader sr = new StreamReader(path);
XmlDocument xdg = new XmlDocument();
xdg.Load(sr);
//xdg.Load(path);
genmacdata = xdg.OuterXml;
}
catch (Exception ex)
{
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
return null;
}
}
}
// Get the name & then create the record.
if (Userid == null || Userid == "") Userid = "Migration";
string nmattr = "Default";
// use xpath to get name.
@@ -96,27 +122,24 @@ namespace DataLoader
Format rec = null;
try
{
rec = Format.MakeFormat(parent, fname, nmattr, fmtdata, genmacdata, Dts, Userid);
if (!LookupFormats.ContainsKey(fname))
{
rec = Format.MakeFormat(parent, fname, nmattr, fmtdata, genmacdata, Dts, Userid);
}
else
{
rec = Format.Get(LookupFormats[fname]);
rec.Data = fmtdata;
rec.GenMac = genmacdata;
rec = rec.Save();
}
}
catch (Exception ex)
{
FormatInfoList lst = FormatInfoList.Get();
foreach (FormatInfo fi in lst)
{
// if this is the format we're updating, update it and break.
if (fi.Name == fname)
{
Format f = Format.Get(fi.FormatID);
f.Data = fmtdata;
f.GenMac = genmacdata;
f.Save();
return f;
}
}
//frmMain.AddError(ex, "AddFormatToDB-make format('{0}','{1}')", parent.Name, path);
frmMain.AddError(ex, "AddFormatToDB-make format('{0}','{1}')", parent.Name, path);
}
return rec;
}
return rec;
}
public void LoadAllFormats()
{
Format basefmt = null;
@@ -215,6 +238,6 @@ namespace DataLoader
FormatInfo recInfo = FormatInfo.Get(rec.FormatID);
return recInfo;
}
}
}