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:
parent
be814b9743
commit
7b177a88f6
@ -28,57 +28,83 @@ namespace DataLoader
|
|||||||
{
|
{
|
||||||
public string _FmtAllPath;
|
public string _FmtAllPath;
|
||||||
public string _GenmacAllPath;
|
public string _GenmacAllPath;
|
||||||
|
private FormatInfoList _AllFormats;
|
||||||
private Format AddFormatToDB(Format parent, string format, bool issub, DateTime Dts, string Userid)
|
|
||||||
{
|
public FormatInfoList AllFormats
|
||||||
string fmtdata = null;
|
{
|
||||||
string genmacdata = null;
|
get
|
||||||
XmlDocument xd = null;
|
{
|
||||||
|
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 = "c:\\development\\fmtall\\" + format + "all.xml";
|
||||||
string path = _FmtAllPath + "\\" + format + "all.xml";
|
string path = _FmtAllPath + "\\" + format + "all.xml";
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
StreamReader srf = new StreamReader(path);
|
StreamReader srf = new StreamReader(path);
|
||||||
xd = new XmlDocument();
|
xd = new XmlDocument();
|
||||||
xd.Load(srf);
|
xd.Load(srf);
|
||||||
//xd.Load(path);
|
//xd.Load(path);
|
||||||
fmtdata = xd.OuterXml;
|
fmtdata = xd.OuterXml;
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
|
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we need genmac - only if non-subformat
|
// Do we need genmac - only if non-subformat
|
||||||
if (!issub)
|
if (!issub)
|
||||||
{
|
{
|
||||||
//path = "c:\\development\\genmacall\\" + format + ".svg";
|
//path = "c:\\development\\genmacall\\" + format + ".svg";
|
||||||
path = _GenmacAllPath + "\\" + format + ".svg";
|
path = _GenmacAllPath + "\\" + format + ".svg";
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
StreamReader sr = new StreamReader(path);
|
StreamReader sr = new StreamReader(path);
|
||||||
XmlDocument xdg = new XmlDocument();
|
XmlDocument xdg = new XmlDocument();
|
||||||
xdg.Load(sr);
|
xdg.Load(sr);
|
||||||
//xdg.Load(path);
|
//xdg.Load(path);
|
||||||
genmacdata = xdg.OuterXml;
|
genmacdata = xdg.OuterXml;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
|
frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get the name & then create the record.
|
// Get the name & then create the record.
|
||||||
if (Userid == null || Userid == "") Userid = "Migration";
|
if (Userid == null || Userid == "") Userid = "Migration";
|
||||||
|
|
||||||
string nmattr = "Default";
|
string nmattr = "Default";
|
||||||
|
|
||||||
// use xpath to get name.
|
// use xpath to get name.
|
||||||
@ -96,27 +122,24 @@ namespace DataLoader
|
|||||||
Format rec = null;
|
Format rec = null;
|
||||||
try
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FormatInfoList lst = FormatInfoList.Get();
|
frmMain.AddError(ex, "AddFormatToDB-make format('{0}','{1}')", parent.Name, path);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
public void LoadAllFormats()
|
public void LoadAllFormats()
|
||||||
{
|
{
|
||||||
Format basefmt = null;
|
Format basefmt = null;
|
||||||
@ -215,6 +238,6 @@ namespace DataLoader
|
|||||||
FormatInfo recInfo = FormatInfo.Get(rec.FormatID);
|
FormatInfo recInfo = FormatInfo.Get(rec.FormatID);
|
||||||
return recInfo;
|
return recInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -44,13 +44,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public void FixContentText(RoUsageInfo rousg, ROFSTLookup.rochild roch, ROFstInfo origROFstInfo) // string newvalue)
|
public void FixContentText(RoUsageInfo rousg, ROFSTLookup.rochild roch, ROFstInfo origROFstInfo) // string newvalue)
|
||||||
{
|
{
|
||||||
string newvalue = roch.value;
|
string newvalue = roch.value;
|
||||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^\[]*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
string findLink = @"<START\].*?\[END>";
|
||||||
Match m = Regex.Match(Text, lookFor,RegexOptions.Singleline);
|
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||||
if (m != null && m.Groups.Count > 1)
|
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
foreach (Match mm in ms)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
int offset = mm.Index;
|
||||||
if (g.ToString() != newvalue)
|
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||||
Text = Text.Substring(0, g.Index) + newvalue + Text.Substring(g.Index + g.Length);
|
if (m != null && m.Groups.Count > 1)
|
||||||
|
{
|
||||||
|
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||||
|
if (g.ToString() != newvalue)
|
||||||
|
{
|
||||||
|
Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
|
||||||
|
break; // Text has been processed
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// see if there is a grid to update too.
|
// see if there is a grid to update too.
|
||||||
if (rousg.MyContent.MyGrid != null)
|
if (rousg.MyContent.MyGrid != null)
|
||||||
@ -58,20 +67,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (roch.type == (int)E_ROValueType.Table) // if change in rotable data...
|
if (roch.type == (int)E_ROValueType.Table) // if change in rotable data...
|
||||||
{
|
{
|
||||||
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||||
if (Text != retlist[0])Text = retlist[0];
|
if (Text != retlist[0]) Text = retlist[0];
|
||||||
if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
|
if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||||
|
string findLinkXml = @"<START\].*?\[END>";
|
||||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
foreach (Match mmg in msg)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
int offset = mmg.Index;
|
||||||
if (g.ToString() != newvalue)
|
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||||
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + newvalue + MyGrid.Data.Substring(g.Index + g.Length);
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
|
{
|
||||||
|
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||||
|
if (g.ToString() != newvalue)
|
||||||
|
MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ namespace Volian.Controls.Library
|
|||||||
// (\\[^v' \\]+)* --> look for rtf commands but exclude \' before the \v
|
// (\\[^v' \\]+)* --> look for rtf commands but exclude \' before the \v
|
||||||
// \\v(\\[^v \\]+)* --> look for rtf commands after the \v
|
// \\v(\\[^v \\]+)* --> look for rtf commands after the \v
|
||||||
// if it turns out that if ro's have any embedded unicode characters this needs expanded, such as /u8209? (hard hyphen)
|
// if it turns out that if ro's have any embedded unicode characters this needs expanded, such as /u8209? (hard hyphen)
|
||||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v' \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):.*?\[END>");
|
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):.*?\[END>");
|
||||||
MatchCollection matches = Regex.Matches(text, lookFor);
|
MatchCollection matches = Regex.Matches(text, lookFor);
|
||||||
for (int i = matches.Count - 1; i >= 0; i--)
|
for (int i = matches.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user