diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/PdfExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/PdfExt.cs
index 91dbaf38..99ca0a52 100644
--- a/PROMS/VEPROMS.CSLA.Library/Extension/PdfExt.cs
+++ b/PROMS/VEPROMS.CSLA.Library/Extension/PdfExt.cs
@@ -21,7 +21,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
- throw new DbCslaException("Error on Pdf.Delete", ex);
+ throw new DbCslaException("Error on Pdf.DeleteAll", ex);
}
}
[Serializable()]
@@ -60,6 +60,56 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Pdf.DataPortal_Delete", ex);
}
}
+ // used to remove word section PDFs to force ROs to be updated when printed or saved
+ public static void DeleteAllDocVersion(int versionID)
+ {
+ if (!CanDeleteObject())
+ throw new System.Security.SecurityException("User not authorized to remove a Pdf");
+ try
+ {
+ DataPortal.Delete(new VersionIDCriteria(versionID));
+ }
+ catch (Exception ex)
+ {
+ throw new DbCslaException("Error on Pdf.DeleteAllDocVersion", ex);
+ }
+ }
+ [Serializable()]
+ protected class VersionIDCriteria
+ {
+ private int _VersionID;
+ public int VersionID
+ { get { return _VersionID; } }
+ public VersionIDCriteria(int versionID)
+ {
+ _VersionID = versionID;
+ }
+ }
+ [Transactional(TransactionalTypes.TransactionScope)]
+ private void DataPortal_Delete(VersionIDCriteria criteria)
+ {
+ if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.DataPortal_Delete", GetHashCode());
+ try
+ {
+ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
+ {
+ using (SqlCommand cm = cn.CreateCommand())
+ {
+ cm.CommandType = CommandType.StoredProcedure;
+ cm.CommandTimeout = Database.SQLTimeout;
+ cm.CommandText = "deleteAllDocVersionPdfs";
+ cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
+ cm.ExecuteNonQuery();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DataPortal_Delete", ex);
+ _ErrorMessage = ex.Message;
+ throw new DbCslaException("Pdf.DataPortal_Delete", ex);
+ }
+ }
}
public partial class PdfInfo
diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs
index b366dfa1..05ed3228 100644
--- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs
+++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs
@@ -262,7 +262,9 @@ namespace VEPROMS.CSLA.Library
{
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
{
- rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs, myProgressBarRefresh);// TODO: Need to add MyImages
+ int cnt = rfi.CountRoFstGraphics(myLookup.myHdr.myDbs[i].children); // get the total number of RO figures
+ int curCnt = 0;
+ rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs, myProgressBarRefresh, cnt, ref curCnt);// TODO: Need to add MyImages
}
}
}
@@ -274,6 +276,76 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Update Ro Values
+ public static int RefreshROFst(DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus)
+ {
+ int fixedROs = 0;
+ if (dvi.DocVersionConfig.SelectedSlave <= 0)
+ {
+ myProgressBarRefresh(1, 100, "Update MS Word ROs");
+ Pdf.DeleteAllDocVersion(dvi.VersionID); // remove word section PDFs to force upate of RO values when printed
+ int i = 0;
+ foreach (ProcedureInfo proc in dvi.Procedures)
+ {
+ DateTime start = DateTime.Now;
+ ProcedureInfo.ResetROCounters();
+ myProgressBarRefresh(++i, dvi.Procedures.Count, string.Format("{0} ({1}/{2} ROs {3})",proc.DisplayNumber,i,dvi.Procedures.Count,fixedROs));
+ ProcedureInfo.RefreshReferenceObjects(proc);
+ fixedROs += ProcedureInfo.ROFixCount;
+ TimeSpan ts = DateTime.Now - start;
+ if (tbStatus != null)
+ tbStatus.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects{0}, Fixed {3} Referenced Objects{0}, Elapsed Seconds:{4}{0}{0}", Environment.NewLine, proc.DisplayNumber, ProcedureInfo.ROCheckCount, ProcedureInfo.ROFixCount, ts.TotalSeconds));
+ }
+ }
+ return fixedROs;
+ }
+ // returns the path and file name with Proc Set Name and the completed date/time (used for all update RO calls except for Amin Tool from the V button)
+ public static string ROUpdateResultsPath (DocVersionInfo dvi)
+ {
+ return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\ROUpdateReport_" + dvi.MyFolder.Name.Replace(" ", "_") + "_" + DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss") +".txt";
+ }
+ public static ROFst RefreshROFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus)
+ {
+ ROFst rofst = null;
+ if (docver.NewerRoFst)
+ {
+ // only load the RO.fst
+ Volian.Base.Library.VlnSettings.DoUpdateRO = false;
+ rofst = ROFstInfo.UpdateRoFst(rdi, dva, docver, origROFst, myProgressBarRefresh);
+ Volian.Base.Library.VlnSettings.DoUpdateRO = true;
+ }
+ else
+ rofst = docver.DocVersionAssociations[0].MyROFst;
+ DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
+ SetAssociationLastCompleted(docver,string.Empty);
+ int fixedROs = RefreshROFst(dvi, myProgressBarRefresh, tbStatus);
+ SetAssociationLastCompleted(docver, DateTime.Now.ToString()); // RO Update completed successfully and un-interrupted, save the date/time to the Doc Version Association config
+ myProgressBarRefresh(100, 100, "RO Update Complete"); // update the progress bar
+ System.Windows.Forms.Application.DoEvents();
+ // pop up a message window telling the user the RO Update has completed and now many ROs were updated
+ // If we are updating RO from the Admin Tools (from the V button) and we are updating more than on procedure set, then just append the "RO Update Complete" text
+ // To the MessageList. Once completed will all procedure sets, Admin Tools will display one message box with all the results in it.
+ if (MessageList == null)
+ System.Windows.Forms.MessageBox.Show(fixedROs == 0 ? "No ROs Required Updating" : string.Format("{0} ROs Updated for {1}", fixedROs, dvi.MyFolder.Name), "RO Update Complete");
+ else
+ MessageList.AppendLine((fixedROs == 0 ? "No ROs Required Updating for " : string.Format("{0} ROs Updated for ", fixedROs)) + dvi.MyFolder.Name);
+
+ return rofst;
+ }
+
+ // this is used by the frmBatchRefresh which is the Adim Tools so that one message is display for a group of procedure sets processed
+ public static StringBuilder MessageList = null;
+
+ // Place the date/time of the completed RO Update in the DocVersion association config
+ // this witll tell us if the RO Update was completed, interrupted, or just needs done and whether to make the Update ROs button available
+ private static void SetAssociationLastCompleted(DocVersion docver, string value)
+ {
+ //Association asc = dva.MyAssociation;
+ string cfg = docver.DocVersionAssociations[0].Config;
+ AssociationConfig ac = new AssociationConfig((cfg== null || cfg.Length == 0) ? "" : cfg);
+ ac.ROUpdate_LastCompleted = value;
+ docver.DocVersionAssociations[0].Config = ac.ToString();
+ docver.Save();
+ }
///
/// Updates an ro.fst into a sql database.
///
@@ -296,10 +368,10 @@ namespace VEPROMS.CSLA.Library
if (rofst != null)
{
// Get a list of figures which have changed content (DTS)
- List changedFigures = GetChangedFigureROIDs(origROFst, ROFstInfo.GetJustROFst(rofst.ROFstID),DocVersionInfo.Get(docver.VersionID));
+ List changedFigures = GetChangedFigureROIDs(origROFst, ROFstInfo.GetJustROFst(rofst.ROFstID),DocVersionInfo.Get(docver.VersionID), myProgressBarRefresh);
docver.DocVersionAssociations[0].MyROFst = rofst;
docver.Save();
- if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO"))
+ if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO") && Volian.Base.Library.VlnSettings.DoUpdateRO)
UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID),myProgressBarRefresh,changedFigures);
return rofst;
}
@@ -332,7 +404,9 @@ namespace VEPROMS.CSLA.Library
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
if (myLookup.myHdr.myDbs[i].children != null)
{
- rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs,myProgressBarRefresh);
+ int cnt = rfi.CountRoFstGraphics(myLookup.myHdr.myDbs[i].children); // get the total number of RO figures
+ int curCnt = 0;
+ rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs,myProgressBarRefresh,cnt,ref curCnt);
}
}
}
@@ -342,7 +416,7 @@ namespace VEPROMS.CSLA.Library
}
// Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
// values, deleted ros, etc.
- if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO"))
+ if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOUPDATERO") && Volian.Base.Library.VlnSettings.DoUpdateRO)
UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID),myProgressBarRefresh, MyChangedFigureROIDs);
return rofst;
}
@@ -355,10 +429,10 @@ namespace VEPROMS.CSLA.Library
/// Current ROFST Object
/// DocVersion (Working Draft)
/// List of ROIDs which can be used to refresh MSWord PDFs
- private static List GetChangedFigureROIDs(ROFstInfo origROFst, ROFstInfo rofst, DocVersionInfo docver)
+ private static List GetChangedFigureROIDs(ROFstInfo origROFst, ROFstInfo rofst, DocVersionInfo docver, ROFstInfoProgressBarRefresh myProgressBarRefresh)
{
// Need to create a list of ROIDs for figures which have changed
- List ChangedFiles = GetChangedFigures(origROFst, rofst);
+ List ChangedFiles = GetChangedFigures(origROFst, rofst, myProgressBarRefresh);
// Get ROID associated with FileNames
List ROIDs = GetROIDsFromLookup(rofst,ChangedFiles,docver);
return ROIDs;
@@ -412,24 +486,32 @@ namespace VEPROMS.CSLA.Library
/// Original ROFST Object
/// Current ROFST Object
/// List of Files which have changed (DTS)
- private static List GetChangedFigures(ROFstInfo origROFst, ROFstInfo rofst)
+ private static List GetChangedFigures(ROFstInfo origROFst, ROFstInfo rofst, ROFstInfoProgressBarRefresh myProgressBarRefresh)
{
if (origROFst.ROFstFigures == null) return null;
Dictionary orig = new Dictionary();
+ int i = 0;
foreach (FigureInfo fi in origROFst.ROFstFigures)
{
- string key = fi.MyROImage.FileName;
+ string key = fi.ROImage_FileName ?? fi.MyROImage.FileName;
+ myProgressBarRefresh(++i, origROFst.ROFstFigures.Count, "Original " + key);
if (!orig.ContainsKey(key)) orig.Add(key, fi.ImageID);
}
+ i = 0;
foreach (FigureInfo fi in rofst.ROFstFigures)
{
- string key = fi.MyROImage.FileName;
+ string key = fi.ROImage_FileName ?? fi.MyROImage.FileName;
+ myProgressBarRefresh(++i, rofst.ROFstFigures.Count, "Current " + key);
if (orig.ContainsKey(key) && orig[key] == fi.ImageID)
orig.Remove(key);
}
List changedFigures = new List();
+ i = 0;
foreach (string key in orig.Keys)
+ {
+ myProgressBarRefresh(++i, orig.Count, "Compare " + key);
changedFigures.Add(key);
+ }
return changedFigures;
}
private static Dictionary BuildROImagesList(ROImageInfoList myROImages)
@@ -500,7 +582,7 @@ namespace VEPROMS.CSLA.Library
foreach (ItemInfo ii in roUsg.MyContent.ContentItems)
{
string val = newLU.GetTranslatedRoValue(padroid, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
- content.FixContentText(roUsg, val, roch.type, origROFstInfo);
+ content.FixContentText(roUsg, val, roch.type, origROFstInfo, true);
if (content.IsDirty)
{
// Update UserID and DTS when RO Value is updated.
@@ -759,15 +841,29 @@ namespace VEPROMS.CSLA.Library
retval = string.Format("{0}_{1}", roName, iSuffix + 1);
return retval;
}
- private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary myExistingROImages, List myUnChangedROImages, List myAddedROImages, List MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh)
+ private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary myExistingROImages, List myUnChangedROImages, List myAddedROImages, List MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh, int cnt, ref int curCnt)
{
for (int i = 0; i < rochild.Length; i++)
{
- 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, MyChangedFigureROIDs,myProgressBarRefresh);
+ if (rochild[i].type == 8)
+ {
+ this.AddGraphic(rdi, rochild[i], rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs, myProgressBarRefresh, cnt, curCnt);
+ curCnt++;
+ }
+ if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages, MyChangedFigureROIDs, myProgressBarRefresh, cnt, ref curCnt);
}
}
- private void AddGraphic(RODbInfo rdi, ROFSTLookup.rochild myRO, RODb rodb, ROFst rofst, Dictionary myExistingROImages, List myUnChangedROImages, List myAddedROImages, List MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh)
+ private int CountRoFstGraphics(ROFSTLookup.rochild[] rochild)
+ {
+ int cnt = 0;
+ for (int i = 0; i < rochild.Length; i++)
+ {
+ if (rochild[i].type == 8) cnt++;
+ if (rochild[i].children != null) cnt += this.CountRoFstGraphics(rochild[i].children);
+ }
+ return cnt;
+ }
+ private void AddGraphic(RODbInfo rdi, ROFSTLookup.rochild myRO, RODb rodb, ROFst rofst, Dictionary myExistingROImages, List myUnChangedROImages, List myAddedROImages, List MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh, int cnt, int curCnt)
{
string p = myRO.value;
if (p == null) return;
@@ -798,7 +894,7 @@ namespace VEPROMS.CSLA.Library
{
if (!myAddedROImages.Contains(key))
{
- myProgressBarRefresh(0, 100, "Loading " + imgname);
+ myProgressBarRefresh(curCnt, cnt, "Loading " + imgname); // show progress of loading images
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader r = new BinaryReader(fsIn);
byte[] ab = r.ReadBytes((int)fsIn.Length);
diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FigureInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FigureInfo.cs
index 2daba117..f28c751f 100644
--- a/PROMS/VEPROMS.CSLA.Library/Generated/FigureInfo.cs
+++ b/PROMS/VEPROMS.CSLA.Library/Generated/FigureInfo.cs
@@ -363,6 +363,16 @@ namespace VEPROMS.CSLA.Library
_FigureID = figureID;
}
}
+ private string _ROImage_FileName = string.Empty;
+ public string ROImage_FileName
+ {
+ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ get
+ {
+ CanReadProperty("ROImage_FileName", true);
+ return _ROImage_FileName;
+ }
+ }
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.ReadData", GetHashCode());
@@ -374,6 +384,11 @@ namespace VEPROMS.CSLA.Library
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
+ for (int i = 0; i < dr.FieldCount; i++)
+ {
+ if (dr.GetName(i) == "ROImage_FileName")
+ _ROImage_FileName = dr.GetString("ROImage_FileName");
+ }
}
catch (Exception ex)
{