C2026-008 - Re-Architect RO.FST to include RO Modification date/time and use those when updating ROs from the RO.FST

This commit is contained in:
2026-04-28 09:13:17 -04:00
parent a544a5cd4f
commit 7f0d39b684
14 changed files with 712 additions and 495 deletions
@@ -97,7 +97,8 @@ namespace VEPROMS.CSLA.Library
public string appid;
public int ID;
public int ParentID;
public rochild[] children;
public DateTime? ModDateTime; //C2026-008 Re-Architect RO.FST to include RO Modification date/time
public rochild[] children;
};
[Serializable]
@@ -110,7 +111,8 @@ namespace VEPROMS.CSLA.Library
public string roid; // roid unique identifier
public string appid; // accessory page id - user specified unique id
public string value; // return value, can be multiple values
public rochild[] children;
public DateTime? ModDateTime; //C2026-008 Re-Architect RO.FST to include RO Modification date/time
public rochild[] children;
};
public class RoExtension
@@ -686,15 +688,19 @@ namespace VEPROMS.CSLA.Library
//return string.Format("{0,10:#####0.00}", TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalSeconds);
}
#endregion
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
//return new ROFstID if there is a newer ID that matches the same ROFSTDB
public int GetNewerFSTID() => RofstGetLatestID(RofstID);
#endregion
#endregion
#region Private Methods
#endregion
#region (Database Calls)
#region Private Methods
private bool RofstDataExists(int rofstID)
#region (Database Calls)
private bool RofstDataExists(int rofstID)
{
int headerStatusID = RofstDataGetHeaderLoadStatus(rofstID);
@@ -888,7 +894,7 @@ namespace VEPROMS.CSLA.Library
}
}
private void RofstChildInsert(int rofstID, int id, int parentID, int dbiID, int type, string title, string roid, string appid, string value)
private void RofstChildInsert(int rofstID, int id, int parentID, int dbiID, int type, string title, string roid, string appid, string value, DateTime? dt = null)
{
try
{
@@ -917,7 +923,10 @@ namespace VEPROMS.CSLA.Library
if (!string.IsNullOrEmpty(this.RoMissingDefaultValue))
cmd.Parameters.Add(new SqlParameter("@missingDefaultValue", SqlDbType.VarChar)).Value = this.RoMissingDefaultValue;
cmd.ExecuteNonQuery();
if (dt != null)
cmd.Parameters.Add(new SqlParameter("@ModDateTime", SqlDbType.DateTime)).Value = dt;
cmd.ExecuteNonQuery();
}
}
}
@@ -1299,11 +1308,37 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
//return new ROFstID if there is a newer ID that matches the same ROFSTDB
private int RofstGetLatestID(int rofstID)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = cn.CreateCommand())
{
cmd.CommandTimeout = 0;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT ISNULL((SELECT TOP 1 ROFsts.ROFstID FROM ROFsts INNER JOIN ROFsts curFST ON curFST.RODbID = ROFsts.RODbID WHERE curFST.ROFstID = @FSTid order by ROFsts.DTS desc),-1)";
#region (Core/Base logic for RO Values & UnitInfo RO Values)
cmd.Parameters.Add(new SqlParameter("@FSTid", SqlDbType.Int)).Value = rofstID;
private ROFSTLookup.rochild RofstDataGetChildByRoid(int rofstID, string roid, bool loadChildren = false, bool loadAllChildren = false)
return (int) cmd.ExecuteScalar();
}
}
}
catch (Exception ex)
{
throw new DbCslaException("RofstData.RofstGetLatestID", ex);
}
}
#endregion
#region (Core/Base logic for RO Values & UnitInfo RO Values)
private ROFSTLookup.rochild RofstDataGetChildByRoid(int rofstID, string roid, bool loadChildren = false, bool loadAllChildren = false)
{
try
{
@@ -1512,10 +1547,10 @@ namespace VEPROMS.CSLA.Library
int slen = StringLength(ab, myOffset + 6);
tmp.title = Encoding.Default.GetString(ab, myOffset + 6, slen);
myOffset += (7 + slen);
ROFSTLookup.rogrp tmpg = LoadGroup(ab, childOffset, tableID);
ROFSTLookup.rogrp tmpg = LoadGroup(ab, childOffset, tableID);
tmp.ID = tmpg.ID;
tmp.ParentID = tmpg.ParentID;
@@ -1523,8 +1558,12 @@ namespace VEPROMS.CSLA.Library
tmp.appid = tmpg.appid;
tmp.roid = tableID.ToString("X4") + tmp.ID.ToString("X8");
tmp.children = tmpg.children;
if (tmpg.ModDateTime != null)
{
tmp.ModDateTime = tmpg.ModDateTime;
}
int j;
int j;
for (j = i - 1; j >= 0 && tmp.ID < myGrp.children[j].ID; j--)
{
@@ -1542,7 +1581,13 @@ namespace VEPROMS.CSLA.Library
int slen2 = StringLength(ab, offset + 13 + slen);
myGrp.appid = Encoding.Default.GetString(ab, offset + 13 + slen, slen2);
_dbRoCnt++;
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
if (myGrp.value != "" && DateTime.TryParseExact(Encoding.Default.GetString(ab, offset + 14 + slen + slen2, 14), "yyyyMMddHHmmss", null, System.Globalization.DateTimeStyles.None, out DateTime dt))
{
myGrp.ModDateTime = dt;
}
_dbRoCnt++;
}
return myGrp;
@@ -1655,7 +1700,7 @@ namespace VEPROMS.CSLA.Library
private void LoadChild(int rofstID, int dbiID, ROFSTLookup.rochild child)
{
//Insert Rofst Child
RofstChildInsert(rofstID, child.ID, child.ParentID, dbiID, child.type, child.title, child.roid, child.appid, child.value);
RofstChildInsert(rofstID, child.ID, child.ParentID, dbiID, child.type, child.title, child.roid, child.appid, child.value, child.ModDateTime);
//Increment RO Count if RoChild has a return value
if (!string.IsNullOrEmpty(child.value)) _curRoCnt++;
+87 -28
View File
@@ -1093,8 +1093,17 @@ namespace VEPROMS.CSLA.Library
}
}
}
// B2022-026 RO Memory Reduction code - pass in ROFstInfo
internal static void MyRefreshReferenceObjects(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, ROFstInfo origROFst)
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
//Refresh at item level
public static void RefreshReferenceObjects(ItemInfo tmp, ROFstInfo origROFst)
{
if (tmp.MyDocVersion.DocVersionConfig.SelectedSlave <= 0)
MyRefreshReferenceObjects(tmp, null, tmp.GetSectionInfo(), tmp.MyDocVersion, origROFst);
}
// B2022-026 RO Memory Reduction code - pass in ROFstInfo
internal static void MyRefreshReferenceObjects(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, ROFstInfo origROFst)
{
if (itemInfo.MyContent.ContentPartCount > 0)
{
@@ -1219,31 +1228,47 @@ namespace VEPROMS.CSLA.Library
return true;
}
#region Debug Code
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
public static List<ItemInfo> GetItemInfoWithChangedROs(int docversionid, int origfstid, int newfstid)
{
List<ItemInfo> lst = new List<ItemInfo>();
//private static void ShowDifference(string oldText, string newText)
//{
// string nt = newText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
// string ot = oldText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
// ShowText("OldText", ot);
// ShowText("NewText", nt);
//}
//private static void ShowText(string title, string newText)
//{
// StringBuilder sb = new StringBuilder();
// foreach (char c in newText)
// {
// if(c<' ' || c> '\x7F')
// sb.Append(string.Format("\\x{0:X2}",((int) c)));
// else
// sb.Append(c);
// }
// Console.WriteLine("{0}='{1}'",title,sb.ToString());
//}
foreach (DataRow r in Data_GetItemsWithChangedROs(docversionid, origfstid, newfstid).Rows)
{
using (ItemInfo itm = Get((int)r["ItemID"]))
{
lst.Add(itm);
}
}
#endregion // debug
return lst;
}
internal static void SetParentSectionAndDocVersionPageNum(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
#region Debug Code
//private static void ShowDifference(string oldText, string newText)
//{
// string nt = newText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
// string ot = oldText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
// ShowText("OldText", ot);
// ShowText("NewText", nt);
//}
//private static void ShowText(string title, string newText)
//{
// StringBuilder sb = new StringBuilder();
// foreach (char c in newText)
// {
// if(c<' ' || c> '\x7F')
// sb.Append(string.Format("\\x{0:X2}",((int) c)));
// else
// sb.Append(c);
// }
// Console.WriteLine("{0}='{1}'",title,sb.ToString());
//}
#endregion // debug
internal static void SetParentSectionAndDocVersionPageNum(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
{
if (itemInfo.MyContent.ContentPartCount > 0)
{
@@ -1890,10 +1915,44 @@ namespace VEPROMS.CSLA.Library
foreach (ItemInfo itemInfo in partInfo.MyItems)
itemInfo.SpinThroughChildren();
}
#endregion
#region LoadAtOnce
// Method to Get Item and children
public static ItemInfo GetItemAndChildren(int? itemID, int? parentID)
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
private static DataTable Data_GetItemsWithChangedROs(int docversionid, int origfstid, int newfstid)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItemsWithNewROs";
cm.Parameters.AddWithValue("@VersionID", docversionid);
cm.Parameters.AddWithValue("@OrigFSTid", origfstid);
cm.Parameters.AddWithValue("@NewFSTid", newfstid);
cm.CommandTimeout = Database.DefaultTimeout;
using (SqlDataAdapter da = new SqlDataAdapter(cm))
{
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ItemInfoList.Data_GetItemsWithChangedROs", ex);
throw new DbCslaException("ItemInfoList.Data_GetItemsWithChangedROs", ex);
}
}
#endregion
#region LoadAtOnce
// Method to Get Item and children
public static ItemInfo GetItemAndChildren(int? itemID, int? parentID)
{
try
{
+40 -50
View File
@@ -61,57 +61,47 @@ 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);
}
}
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
// used to remove word section PDFs to force ROs to be updated when printed or saved
public static void DeleteDocVersionPDFsWithNewROs(int versionID, int origfstid, int newfstid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Pdf");
try
{
DeleteWithNewROs(versionID, origfstid, newfstid);
}
catch (Exception ex)
{
throw new DbCslaException("Error on Pdf.DeleteAllDocVersion", ex);
}
}
static private void DeleteWithNewROs(int docversionID, int origfstid, int newfstid)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "deleteDocVersionPdfsWithNewROs";
cm.Parameters.AddWithValue("@VersionID", docversionID);
cm.Parameters.AddWithValue("@OrigFSTid", origfstid);
cm.Parameters.AddWithValue("@NewFSTid", newfstid);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DeleteWithNewROs", ex);
throw new DbCslaException("Pdf.DeleteWithNewROs", ex);
}
}
}
public partial class PdfInfo
{
+41 -237
View File
@@ -225,41 +225,54 @@ namespace VEPROMS.CSLA.Library
}
}
// B2022-026 RO Memory Reduction code - pass in the ROFstInfo
public static int RefreshROFst(DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus, ROFstInfo origROFst)
{
int fixedROs = 0;
//C2026-008 Re-Architect RO.FST to include RO Modification date/time
// Refresh at item level
public static int RefreshROFstAtItemLevel(DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus, ROFstInfo localROFst, int origfstid, int newfstid)
{
int fixedROs = 0;
if (dvi.DocVersionConfig.SelectedSlave <= 0)
{
myProgressBarRefresh(1, 100, "Update MS Word ROs");
if (dvi.DocVersionConfig.SelectedSlave <= 0)
{
// remove word section PDFs to force update of RO values when printed
myProgressBarRefresh(1, 100, "Updating MS Word ROs In Progress");
Pdf.DeleteDocVersionPDFsWithNewROs(dvi.VersionID, origfstid, newfstid);
Pdf.DeleteAllDocVersion(dvi.VersionID); // remove word section PDFs to force update of RO values when printed
int i = 0;
//Loop Through ROs in this docversion that are different than the previous fst
myProgressBarRefresh(50, 100, "Updating ROs In PROMS Steps In Progress");
int i = 0;
List<ItemInfo> list = ItemInfo.GetItemInfoWithChangedROs(dvi.VersionID, origfstid, newfstid);
foreach (ItemInfo itm in list)
{
DateTime start = DateTime.Now;
foreach (ProcedureInfo proc in dvi.Procedures)
{
DateTime start = DateTime.Now;
ItemInfo.ResetROCounters();
myProgressBarRefresh(++i, list.Count, string.Format("{0} ({1}/{2} ROs {3})", itm.MyProcedure.DisplayNumber, i, list.Count, fixedROs));
ItemInfo.RefreshReferenceObjects(itm, localROFst);
fixedROs += ItemInfo.ROFixCount;
ProcedureInfo.ResetROCounters();
myProgressBarRefresh(++i, dvi.Procedures.Count, string.Format("{0} ({1}/{2} ROs {3})", proc.DisplayNumber, i, dvi.Procedures.Count, fixedROs));
ProcedureInfo.RefreshReferenceObjects(proc, origROFst);
fixedROs += ProcedureInfo.ROFixCount;
TimeSpan ts = DateTime.Now - start;
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, itm.MyProcedure.DisplayNumber, ItemInfo.ROCheckCount, ItemInfo.ROFixCount, ts.TotalSeconds));
}
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));
}
}
//Update the DocVersion Associations to link to the new RO FST id and current date/time
using (DocVersion dv = DocVersion.Get(dvi.VersionID))
{
if (dvi.DocVersionAssociations[0].MyROFst.ROFstID != newfstid)
{
dv.DocVersionAssociations[0].MyROFst = localROFst.GetJustROFst();
SetAssociationLastCompleted(dv, DateTime.Now.ToString());
}
}
}
return fixedROs;
}
return fixedROs;
}
//C2022-028 for Admin tool to check for bad RO links
//B2022-144 we now loop through checked procedures list from Admin Tools and call this method for each procedure we want to process
public static int CheckROLinksInThisProcedure(ProcedureInfo proc, System.Windows.Forms.TextBox tbStatus)
//C2022-028 for Admin tool to check for bad RO links
//B2022-144 we now loop through checked procedures list from Admin Tools and call this method for each procedure we want to process
public static int CheckROLinksInThisProcedure(ProcedureInfo proc, System.Windows.Forms.TextBox tbStatus)
{
int FoundBadROLinks = 0;
DocVersionInfo dvi = DocVersionInfo.Get(proc.MyDocVersion.VersionID);
@@ -291,34 +304,6 @@ namespace VEPROMS.CSLA.Library
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\ROUpdateReport_" + ValidFileName.FixFileName(dvi.MyFolder.Name.Replace(" ", "_") + "_" + DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss") + ".txt");
}
// B2022-026 RO Memory Reduction code - moved the call to UpdateROFst() to before we call RefreshROFst
// so that we used the correct ROFstInfo which as the needed event methods set when updated RO Table types
public static ROFst RefreshROFst(DocVersion docver, ROFstInfo origROFst, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus)
{
ROFst rofst = null;
rofst = docver.DocVersionAssociations[0].MyROFst;
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
SetAssociationLastCompleted(docver, string.Empty);
int fixedROs = RefreshROFst(dvi, myProgressBarRefresh, tbStatus, origROFst);
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 how 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)
FlexibleMessageBox.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;
}
/// <summary>
/// Updates an ro.fst into a sql database.
/// </summary>
@@ -670,188 +655,7 @@ namespace VEPROMS.CSLA.Library
return sb.ToString();
}
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst, DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh, List<string> MyChangedFigureROIDs)
{
if (myProgressBarRefresh != null) myProgressBarRefresh(0, 100, "Update Ro Values");
string versionList = dvi.VersionID.ToString();
ROFSTLookup origLookup = new ROFSTLookup(origROFstInfo.ROFstID, dvi);
ROFSTLookup newLookup = new ROFSTLookup(newROFst.ROFstID, dvi);
List<string> delList = new List<string>();
List<string> chgList = newLookup.GetValueDifferences(origROFstInfo.ROFstID, ref delList);
// Any figures which have been changed will be included in the list of values that have changed.
if (MyChangedFigureROIDs != null)
{
foreach (string roid in MyChangedFigureROIDs)
{
if (!chgList.Contains(roid)) chgList.Add(roid);
}
}
string RoidList = GetRoidList(newROFst.RODbID, chgList);
if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Getting List of ROs Used");
List<string> activeRoids = BuildActiveROIDsForRoUsages12(RoidList, versionList);
if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Updating RO Values");
int iCount = 0;
if (activeRoids.Count > 0)
{
foreach (string chg in chgList)
{
if (myProgressBarRefresh != null) myProgressBarRefresh(++iCount, chgList.Count, "Updating RO Values");
if (activeRoids.Contains(chg.Substring(0, 12)))
{
ROFSTLookup.rochild roch = newLookup.GetRoChild(chg);
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLookup.GetRoChild(chg).value, roch.value);
// roid's are stored in database as 16 characters long in the RoUsages table. They may be stored as 12 characters in the ro.fst.
// string padroid = chg.Length <= 12 ? chg + "0000" : chg;
// B2022-088: Find Doc Ro button not working in Word Sections
string padroid = ROFSTLookup.FormatRoidKey(chg, true);
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed", versionList))
{
foreach (RoUsageInfo roUsg in affected)
{
using (Content content = Content.Get(roUsg.MyContent.ContentID))
{
foreach (ItemInfo ii in roUsg.MyContent.ContentItems)
{
string val = newLookup.GetTranslatedRoValue(padroid, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, ii.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false, ii);
content.FixContentText(roUsg, val, roch.type, origROFstInfo, true);
if (content.IsDirty)
{
// Update UserID and DTS when RO Value is updated.
content.UserID = Volian.Base.Library.VlnSettings.UserID;
content.DTS = DateTime.Now;
content.Save();
if (content.MyGrid != null)
{
GridInfo.Refresh(content.MyGrid);
}
}
}
}
}
}
}
}
}
if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Getting List of ROs Used");
List<string> activeDRoids = BuildActiveROIDsForDRoUsages12(RoidList, versionList);
iCount = 0;
if (activeDRoids.Count > 0)
{
foreach (string chg in chgList)
{
// B2022-088: Find Doc Ro button not working in Word Sections
// string padroid = chg.Length <= 12 ? chg + "0000" : chg;
string padroid = ROFSTLookup.FormatRoidKey(chg, true);
if (myProgressBarRefresh != null) myProgressBarRefresh(++iCount, chgList.Count, "Updating RO Values");
if (activeDRoids.Contains(chg.Substring(0, 12)))
{
ROFSTLookup.rochild roch = newLookup.GetRoChild(chg);
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLookup.GetRoChild(chg).value, roch.value);
// roid's are stored in database as 16 characters long in the rousages table. They may be stored as 12 characters in the ro.fst.
using (DROUsageInfoList affected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed", versionList))
{
foreach (DROUsageInfo droUsg in affected)
{
Pdf.DeleteAll(droUsg.DocID);
}
}
}
}
}
iCount = 0;
string RoidDelList = GetRoidList(newROFst.RODbID, delList);
if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Getting List of ROs Used");
activeRoids = BuildActiveROIDsForRoUsages12(RoidDelList, versionList);
if (activeRoids.Count > 0)
{
foreach (string del in delList)
{
// B2022-088: Find Doc Ro button not working in Word Sections
//string padroiddel = del.Length <= 12 ? del + "0000" : del;
string padroiddel = ROFSTLookup.FormatRoidKey(del, true);
if (myProgressBarRefresh != null) myProgressBarRefresh(++iCount, chgList.Count, "Removing Old RO Values");
string desc = string.Format("Deleted RO: Value = {0}", origLookup.GetRoChild(del).value);
if (activeRoids.Contains(del.Substring(0, 12).ToUpper()))
{
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted", versionList))
{
foreach (RoUsageInfo roUsg in affected)
{
using (Content content = Content.Get(roUsg.MyContent.ContentID))
{
content.FixContentText(roUsg, "?", 0, origROFstInfo);
if (content.IsDirty)
{
// Update UserID and DTS when RO Value is updated.
content.UserID = Volian.Base.Library.VlnSettings.UserID;
content.DTS = DateTime.Now;
content.Save();
}
}
}
}
}
}
}
if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Getting List of ROs Used");
activeDRoids = BuildActiveROIDsForDRoUsages12(RoidDelList, versionList);
iCount = 0;
if (activeDRoids.Count > 0)
{
foreach (string del in delList)
{
// B2022-088: Find Doc Ro button not working in Word Sections
string padroiddel = ROFSTLookup.FormatRoidKey(del, true);
if (myProgressBarRefresh != null) myProgressBarRefresh(++iCount, chgList.Count, "Removing Old RO Values");
string desc = string.Format("Deleted RO: Value = {0}", origLookup.GetRoChild(del).value);
// If there's an issue then maybe try getting the RoChild with the Padded roid instead
//string desc = string.Format("Deleted RO: Value = {0}", origLookup.GetRoChild(padroiddel).value);
if (activeDRoids.Contains(del.Substring(0, 12).ToUpper()))
{
using (DROUsageInfoList Daffected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted", versionList))
{
foreach (DROUsageInfo droUsg in Daffected)
{
if (myProgressBarRefresh != null) myProgressBarRefresh(++iCount, chgList.Count, "Removing Old RO Values");
Pdf.DeleteAll(droUsg.DocID);
}
}
}
}
}
if (myProgressBarRefresh != null) myProgressBarRefresh(100, 100, "RO Values Updated");
}
private static DateTime ShowDuration(DateTime dtLast, string message)
private static DateTime ShowDuration(DateTime dtLast, string message)
{
DateTime dtNext = DateTime.Now;
Console.WriteLine("{0,10:#####0.00},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - dtLast.Ticks).TotalSeconds, message);