Bug B2015-126 Fixed
When Referenced Objects are updated, the RO values embedded in Step Text is updated. Word sections are "flagged" (the temporary PDF records are deleted) which will cause the ROs to be "refreshed" when the procedure is printed. Unfortunately, the process did not account for changes to RoImage content, with no change to the embedded "value." PROMs has been changed to identify the Referenced Objects (ROIDs) which have been impacted by changes to the ROImages. ROFSTs can be updated in one of two ways. When an RO.FST is created in the ROEditor, this is a "new" RO.FST which can be used to create a unique ROFST record in the PROMS database. When this happens, any "new" figures are also added to the PROMS database. So, the first time this RO.FST is associated with PROMS database all of the figures are also created. If you then associate the this RO.FST PROMS record with other procedure sets, the only change is the addition of an association record. The important thing to remember is that the temporary PDF files used to improve performance with MS Word sections, have to be deleted when changes are made to the information used to describe the section, which can include RO Values and the RO Image Files. This change automates the process of refreshing the temporary PDF
This commit is contained in:
parent
1d360b719e
commit
8567b1e7bf
@ -247,6 +247,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
Dictionary<string, int> myExistingROImages = BuildROImagesList(myROImages);
|
Dictionary<string, int> myExistingROImages = BuildROImagesList(myROImages);
|
||||||
List<int> myUnChangedROImages = new List<int>();
|
List<int> myUnChangedROImages = new List<int>();
|
||||||
List<string> myAddedROImages = new List<string>();
|
List<string> myAddedROImages = new List<string>();
|
||||||
|
List<string> MyChangedFigureROIDs = new List<string>();
|
||||||
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
|
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
|
||||||
// Hook this into the current docversion by replacing the rofstid field in the doc version
|
// Hook this into the current docversion by replacing the rofstid field in the doc version
|
||||||
// association object:
|
// association object:
|
||||||
@ -261,7 +262,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
|
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
|
||||||
{
|
{
|
||||||
rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages,myProgressBarRefresh);// TODO: Need to add MyImages
|
rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs, myProgressBarRefresh);// TODO: Need to add MyImages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,10 +295,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, rofstFI.LastWriteTimeUtc);
|
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, rofstFI.LastWriteTimeUtc);
|
||||||
if (rofst != null)
|
if (rofst != null)
|
||||||
{
|
{
|
||||||
|
// Get a list of figures which have changed content (DTS)
|
||||||
|
List<string> changedFigures = GetChangedFigureROIDs(origROFst, ROFstInfo.GetJustROFst(rofst.ROFstID),DocVersionInfo.Get(docver.VersionID));
|
||||||
docver.DocVersionAssociations[0].MyROFst = rofst;
|
docver.DocVersionAssociations[0].MyROFst = rofst;
|
||||||
docver.Save();
|
docver.Save();
|
||||||
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO"))
|
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO"))
|
||||||
UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID),myProgressBarRefresh);
|
UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID),myProgressBarRefresh,changedFigures);
|
||||||
return rofst;
|
return rofst;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +317,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
dva.MyROFst = rofst;
|
dva.MyROFst = rofst;
|
||||||
docver.Save();
|
docver.Save();
|
||||||
ROFSTLookup myLookup = ROFstInfo.GetJustROFst(rofst.ROFstID).GetROFSTLookup(DocVersionInfo.Get(docver.VersionID));
|
ROFSTLookup myLookup = ROFstInfo.GetJustROFst(rofst.ROFstID).GetROFSTLookup(DocVersionInfo.Get(docver.VersionID));
|
||||||
|
// Keep a list of ROIDs for Images that have changed.
|
||||||
|
List<string> MyChangedFigureROIDs = new List<string>();
|
||||||
// Now load any images in... type 8 - integrated graphics ro type
|
// Now load any images in... type 8 - integrated graphics ro type
|
||||||
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID))
|
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID))
|
||||||
{
|
{
|
||||||
@ -327,7 +332,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
|
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
|
||||||
if (myLookup.myHdr.myDbs[i].children != null)
|
if (myLookup.myHdr.myDbs[i].children != null)
|
||||||
{
|
{
|
||||||
rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages,myProgressBarRefresh);
|
rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs,myProgressBarRefresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,10 +343,91 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
|
// Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
|
||||||
// values, deleted ros, etc.
|
// values, deleted ros, etc.
|
||||||
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO"))
|
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO"))
|
||||||
UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID),myProgressBarRefresh);
|
UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID),myProgressBarRefresh, MyChangedFigureROIDs);
|
||||||
return rofst;
|
return rofst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Get a list of ROIDs for figures that have changed content. This is only used when the contents of a figure
|
||||||
|
/// is changed without changing the filename.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="origROFst">Original ROFST Object</param>
|
||||||
|
/// <param name="rofst">Current ROFST Object</param>
|
||||||
|
/// <param name="docver">DocVersion (Working Draft)</param>
|
||||||
|
/// <returns>List of ROIDs which can be used to refresh MSWord PDFs</returns>
|
||||||
|
private static List<string> GetChangedFigureROIDs(ROFstInfo origROFst, ROFstInfo rofst, DocVersionInfo docver)
|
||||||
|
{
|
||||||
|
// Need to create a list of ROIDs for figures which have changed
|
||||||
|
List<string> ChangedFiles = GetChangedFigures(origROFst, rofst);
|
||||||
|
// Get ROID associated with FileNames
|
||||||
|
List<string> ROIDs = GetROIDsFromLookup(rofst,ChangedFiles,docver);
|
||||||
|
return ROIDs;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Find all of the ROIDs associated with files that have changed
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rofst">Current ROFST Object</param>
|
||||||
|
/// <param name="ChangedFiles">List of Changed Files</param>
|
||||||
|
/// <param name="docver">DocVersion (Working Draft)</param>
|
||||||
|
/// <returns>List of FIleNames with changed content</returns>
|
||||||
|
private static List<string> GetROIDsFromLookup(ROFstInfo rofst, List<string> ChangedFiles, DocVersionInfo docver)
|
||||||
|
{
|
||||||
|
List<string> roids = new List<string>();
|
||||||
|
ROFSTLookup myLookup = rofst.GetROFSTLookup(docver);
|
||||||
|
for (int i = 0; i < myLookup.myHdr.myDbs.Length; i++)
|
||||||
|
{
|
||||||
|
if (myLookup.myHdr.myDbs[i].children != null)
|
||||||
|
{
|
||||||
|
FindChangedFiles(myLookup.myHdr.myDbs[i].children,ChangedFiles,roids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return roids;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Find the ROIDs in the ROLookup
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rochild">an RO or RO Group</param>
|
||||||
|
/// <param name="ChangedFiles">List of Files that have changed</param>
|
||||||
|
/// <param name="roids">List of ROIDs with changed figures</param>
|
||||||
|
private static void FindChangedFiles(ROFSTLookup.rochild[] rochild,List<string> ChangedFiles, List<string> roids)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rochild.Length; i++)
|
||||||
|
{
|
||||||
|
if (rochild[i].type == 8 && rochild[i].value != null)
|
||||||
|
{
|
||||||
|
string filename = rochild[i].value;
|
||||||
|
filename = filename.Substring(0, filename.IndexOf('\n'));
|
||||||
|
if(ChangedFiles.Contains(filename))
|
||||||
|
roids.Add(rochild[i].roid);
|
||||||
|
}
|
||||||
|
if (rochild[i].children != null) FindChangedFiles(rochild[i].children,ChangedFiles, roids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Get a List of figures which have changed
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="origROFst">Original ROFST Object</param>
|
||||||
|
/// <param name="rofst">Current ROFST Object</param>
|
||||||
|
/// <returns>List of Files which have changed (DTS)</returns>
|
||||||
|
private static List<string> GetChangedFigures(ROFstInfo origROFst, ROFstInfo rofst)
|
||||||
|
{
|
||||||
|
Dictionary<string,int> orig = new Dictionary<string,int>();
|
||||||
|
foreach (FigureInfo fi in origROFst.ROFstFigures)
|
||||||
|
{
|
||||||
|
string key = fi.MyROImage.FileName;
|
||||||
|
if (!orig.ContainsKey(key)) orig.Add(key, fi.ImageID);
|
||||||
|
}
|
||||||
|
foreach (FigureInfo fi in rofst.ROFstFigures)
|
||||||
|
{
|
||||||
|
string key = fi.MyROImage.FileName;
|
||||||
|
if (orig.ContainsKey(key) && orig[key] == fi.ImageID)
|
||||||
|
orig.Remove(key);
|
||||||
|
}
|
||||||
|
List<string> changedFigures = new List<string>();
|
||||||
|
foreach (string key in orig.Keys)
|
||||||
|
changedFigures.Add(key);
|
||||||
|
return changedFigures;
|
||||||
|
}
|
||||||
private static Dictionary<string,int> BuildROImagesList(ROImageInfoList myROImages)
|
private static Dictionary<string,int> BuildROImagesList(ROImageInfoList myROImages)
|
||||||
{
|
{
|
||||||
Dictionary<string,int> myRoImagesList = new Dictionary<string,int>();
|
Dictionary<string,int> myRoImagesList = new Dictionary<string,int>();
|
||||||
@ -364,7 +450,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst, DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh)
|
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst, DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh, List<string> MyChangedFigureROIDs)
|
||||||
{
|
{
|
||||||
if (myProgressBarRefresh != null) myProgressBarRefresh(0, 100, "Update Ro Values");
|
if (myProgressBarRefresh != null) myProgressBarRefresh(0, 100, "Update Ro Values");
|
||||||
string versionList = dvi.VersionID.ToString();
|
string versionList = dvi.VersionID.ToString();
|
||||||
@ -376,6 +462,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//dtLast = ShowDuration(dtLast, "newLU");
|
//dtLast = ShowDuration(dtLast, "newLU");
|
||||||
List<string> delList = new List<string>();
|
List<string> delList = new List<string>();
|
||||||
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
|
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
|
||||||
|
// Any figures which have been changed will be included in the list of values that have changed.
|
||||||
|
foreach (string roid in MyChangedFigureROIDs)
|
||||||
|
if (!chgList.Contains(roid))
|
||||||
|
chgList.Add(roid);
|
||||||
//dtLast = ShowDuration(dtLast, "chgList");
|
//dtLast = ShowDuration(dtLast, "chgList");
|
||||||
string RoidList = GetRoidList(newROFst.RODbID, chgList);
|
string RoidList = GetRoidList(newROFst.RODbID, chgList);
|
||||||
//dtLast = ShowDuration(dtLast, "RoidList");
|
//dtLast = ShowDuration(dtLast, "RoidList");
|
||||||
@ -662,16 +752,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
retval = string.Format("{0}_{1}", roName, iSuffix + 1);
|
retval = string.Format("{0}_{1}", roName, iSuffix + 1);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages, ROFstInfoProgressBarRefresh myProgressBarRefresh)
|
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages, List<string> MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rochild.Length; i++)
|
for (int i = 0; i < rochild.Length; i++)
|
||||||
{
|
{
|
||||||
if (rochild[i].type == 8)this.AddGraphic(rdi, rochild[i].value, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages,myProgressBarRefresh);
|
if (rochild[i].type == 8)this.AddGraphic(rdi, rochild[i], rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs,myProgressBarRefresh);
|
||||||
if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages,myProgressBarRefresh);
|
if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs,myProgressBarRefresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void AddGraphic(RODbInfo rdi, string p, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages, ROFstInfoProgressBarRefresh myProgressBarRefresh)
|
private void AddGraphic(RODbInfo rdi, ROFSTLookup.rochild myRO, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages, List<string> MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh)
|
||||||
{
|
{
|
||||||
|
string p = myRO.value;
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
string imgname = p.Substring(0, p.IndexOf('\n'));
|
string imgname = p.Substring(0, p.IndexOf('\n'));
|
||||||
int thedot = imgname.LastIndexOf('.');
|
int thedot = imgname.LastIndexOf('.');
|
||||||
@ -723,6 +814,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (figure != null) return;
|
if (figure != null) return;
|
||||||
Figure.MakeFigure(rofst, roImg, null).Dispose();
|
Figure.MakeFigure(rofst, roImg, null).Dispose();
|
||||||
myAddedROImages.Add(key);
|
myAddedROImages.Add(key);
|
||||||
|
MyChangedFigureROIDs.Add(myRO.roid); // Save the roid so that the related documents will be refeshed. (PDF will be deleted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user