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,7 +28,33 @@ namespace DataLoader
|
|||||||
{
|
{
|
||||||
public string _FmtAllPath;
|
public string _FmtAllPath;
|
||||||
public string _GenmacAllPath;
|
public string _GenmacAllPath;
|
||||||
|
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)
|
private Format AddFormatToDB(Format parent, string format, bool issub, DateTime Dts, string Userid)
|
||||||
{
|
{
|
||||||
string fmtdata = null;
|
string fmtdata = null;
|
||||||
@ -47,7 +73,7 @@ namespace DataLoader
|
|||||||
//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;
|
||||||
@ -95,25 +121,22 @@ namespace DataLoader
|
|||||||
string fname = issub ? format.Replace("_", "") : format;
|
string fname = issub ? format.Replace("_", "") : format;
|
||||||
Format rec = null;
|
Format rec = null;
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
if (!LookupFormats.ContainsKey(fname))
|
||||||
{
|
{
|
||||||
rec = Format.MakeFormat(parent, fname, nmattr, fmtdata, genmacdata, Dts, Userid);
|
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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
foreach (Match mm in ms)
|
||||||
|
{
|
||||||
|
int offset = mm.Index;
|
||||||
|
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||||
if (m != null && m.Groups.Count > 1)
|
if (m != null && m.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||||
if (g.ToString() != newvalue)
|
if (g.ToString() != newvalue)
|
||||||
Text = Text.Substring(0, g.Index) + newvalue + Text.Substring(g.Index + g.Length);
|
{
|
||||||
|
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);
|
||||||
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
|
foreach (Match mmg in msg)
|
||||||
|
{
|
||||||
|
int offset = mmg.Index;
|
||||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||||
if (g.ToString() != newvalue)
|
if (g.ToString() != newvalue)
|
||||||
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + newvalue + MyGrid.Data.Substring(g.Index + g.Length);
|
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