C2025-024 Electronic Procedures Phase 2 - XML Export

Multi-Unit Resolution, and Fix RO Annotation resolution in Text
This commit is contained in:
2025-07-30 13:47:25 -04:00
parent 8c32d18aec
commit 44025c3978
2 changed files with 47 additions and 32 deletions

View File

@@ -128,10 +128,6 @@ namespace VEPROMS
MyProcedure = procedureInfo;
InitializeComponent();
this.Text = mode + " Dialog for " + procedureInfo.DisplayNumber;
//Preset path for single procedures.
PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database;
txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, MyProcedure.DisplayNumber.Replace("/", "_").Replace("\\", "_"));
_UnitIndex = unitIndex;
if (_UnitIndex > 0)
@@ -140,6 +136,10 @@ namespace VEPROMS
MyProcedure.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex;
FormClosed += RemoveUnit_OnClose;
}
//Preset path for single procedures.
PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database;
txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, MyProcedure.DisplayNumber.Replace("/", "_").Replace("\\", "_"));
}
private void dlgExportImport_Load(object sender, EventArgs e)
{
@@ -1972,39 +1972,46 @@ namespace VEPROMS
private string ResolveMultiUnitROs(ContentInfo ci)
{
string ciText = ci.Text;
if (_UnitIndex != 0 && ci.ContentRoUsageCount > 0)
DocVersionInfo docver = null;
if (MyProcedure?.MyDocVersion != null)
{
ROFSTLookup lookup = null;
if (MyProcedure?.MyDocVersion != null)
{
lookup = MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyProcedure.MyDocVersion);
}
else if (MyDocVersion != null)
{
lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion);
}
else if (MyFolder.FolderDocVersions != null && MyFolder.FolderDocVersions.Count > 0)
{
lookup = MyFolder.FolderDocVersions[0].DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyFolder.FolderDocVersions[0]);
}
docver = MyProcedure.MyDocVersion;
}
else if (MyDocVersion != null)
{
docver = MyDocVersion;
}
else if (MyFolder.FolderDocVersions != null && MyFolder.FolderDocVersions.Count > 0)
{
docver = MyFolder.FolderDocVersions[0];
}
if (lookup != null)
if (_UnitIndex != 0 && docver != null)
{
ciText = DisplayText.ResolveUnitSpecific(docver, ciText);
if (ci.ContentRoUsageCount > 0)
{
foreach (var RO in ci.ContentRoUsages)
ROFSTLookup lookup = docver.DocVersionAssociations[0].MyROFst.GetROFSTLookup(docver);
if (lookup != null)
{
string roid = ROFSTLookup.FormatRoidKey(RO.ROID, true);
ROFSTLookup.rochild roc = lookup.GetRoChild(roid);
//need to search / replace in content info
string lookFor = string.Format(@"(<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~]))(.*?)((\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>)", RO.ROUsageID);
Match m = Regex.Match(ciText, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
foreach (var RO in ci.ContentRoUsages)
{
ciText = ciText.Replace($"{m.Groups[1].Value}{m.Groups[5].Value}{m.Groups[6].Value}", $"{m.Groups[1].Value}{roc.value}{m.Groups[6].Value}");
string roid = ROFSTLookup.FormatRoidKey(RO.ROID, true);
ROFSTLookup.rochild roc = lookup.GetRoChild(roid);
//need to search / replace in content info
string lookFor = string.Format(@"(<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~]))(.*?)((\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>)", RO.ROUsageID);
Match m = Regex.Match(ciText, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
ciText = ciText.Replace($"{m.Groups[1].Value}{m.Groups[5].Value}{m.Groups[6].Value}", $"{m.Groups[1].Value}{roc.value}{m.Groups[6].Value}");
}
}
}
}
}
}

View File

@@ -115,6 +115,12 @@ namespace VEPROMS
if (epexportblank || !string.IsNullOrEmpty(val))
{
if (_UnitIndex != 0)
{
val = DisplayText.ResolveUnitSpecific(ii.MyDocVersion, val);
}
XmlElement xindivid = xe.OwnerDocument.CreateElement(EP.name);
//need to resolve ROs ROSingle, ROMulti, in text
@@ -140,14 +146,14 @@ namespace VEPROMS
//XML element with the same xml name as the AccID
foreach (Match m in matches)
{
ROFSTLookup.rochild roc = lookup.GetROChildByAccPageID(m.Groups[1].Value);
ROFSTLookup.rochild roc = lookup.GetROChildByAccPageID(m.Groups[0].Value);
// Exclude replacing Images since are binary - for those, add a sub item
if (Enumerable.Range(8, 15).Contains(roc.type))
{
xindivid.InnerText = val;
XmlElement xroid = AddGraphic(xindivid, m.Groups[1].Value, roc, myRODB, roc.type != 8);
XmlElement xroid = AddGraphic(xindivid, m.Groups[0].Value, roc, myRODB, roc.type != 8);
xindivid.AppendChild(xroid);
}
@@ -159,7 +165,7 @@ namespace VEPROMS
rocvalue = rocvalue.Replace("\xF8", "\xB0");
rocvalue = rocvalue.Replace("\x7F", "\x394"); //delta
if (convertCaretToDeltaSymbol) rocvalue = rocvalue.Replace("^", "\x394"); // delta
val = val.Replace($"<{m.Groups[1].Value}>", rocvalue);
val = val.Replace($"{m.Groups[0].Value}", rocvalue);
xindivid.InnerText = val;
}
}
@@ -288,6 +294,8 @@ namespace VEPROMS
// - that has an attribute designating the location of the image file
private XmlElement AddGraphic(XmlElement xindivid, string Name, ROFSTLookup.rochild roc, RODbInfo rodb, bool isMulti)
{
Name = Name.Replace("<", "").Replace(">", "");
XmlElement xroid = xindivid.OwnerDocument.CreateElement(Name);
string imgfile = GetROImageFileLocation(roc, rodb, isMulti);