From 35c1cd151a6bb096771c994d4dd4e3b21f223d27 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 5 Oct 2022 20:29:06 +0000 Subject: [PATCH] C2022-028 Functions to spin through the procedures and call the functions that look for bad RO links --- .../Extension/ROFSTExt.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index a40123d5..27fb267a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -256,6 +256,58 @@ namespace VEPROMS.CSLA.Library return fixedROs; } + //C2022-028 for Admin tool to check for bad RO links + public static int DoCheckROLinksInProcedures(DocVersion docver, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus) + { + /**** commented out for now - keep in case we decide to try to fix some of the RO links + //ROFst rofst = null; + //rofst = docver.DocVersionAssociations[0].MyROFst; + ***/ + + DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID); + + int badROLinks = CheckROLinksInProcedures(dvi, myProgressBarRefresh, tbStatus); + + myProgressBarRefresh(100, 100, "Check RO Links Complete"); // update the progress bar + System.Windows.Forms.Application.DoEvents(); + + // pop up a message window telling the user the RO Check has completed and how many bad ROs were found + // if MessageList is not null, then append the results message to it. We are running via Admin tools and doing more than one procedure set + // and will diplay the messages once after all processing is completed + if (MessageList != null) + MessageList.AppendLine((badROLinks == 0 ? "No Bad RO Links Found for " : string.Format("{0} Bad RO Links Found in ", badROLinks)) + dvi.MyFolder.Name); + + return badROLinks; + } + public static int CheckROLinksInProcedures(DocVersionInfo dvi, ROFstInfoProgressBarRefresh myProgressBarRefresh, System.Windows.Forms.TextBox tbStatus) + { + int FoundBadROLinks = 0; + + if (dvi.DocVersionConfig.SelectedSlave <= 0) + { + int i = 0; + foreach (ProcedureInfo proc in dvi.Procedures) + { + DateTime start = DateTime.Now; + + ProcedureInfo.ResetCheckROLinkCounters(); + myProgressBarRefresh(++i, dvi.Procedures.Count, string.Format("{0} ({1}/{2} ROs)", proc.DisplayNumber, i, dvi.Procedures.Count)); + ProcedureInfo.CheckReferenceObjectsLinks(proc); + FoundBadROLinks += ProcedureInfo.BadROLinksCount; + + TimeSpan ts = DateTime.Now - start; + + if (tbStatus != null) + tbStatus.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects Links{0}, Found {3} Bad RO Links{0} Elapsed Seconds:{5}{0}{0}", Environment.NewLine, proc.DisplayNumber, ProcedureInfo.CheckROLinksCount, ProcedureInfo.BadROLinksCount, ProcedureInfo.FixedROLinksCount, ts.TotalSeconds)); + /*** keep for now - incase we decide to fix RO links later on, this will show the number of RO Links that we fixed + //tbStatus.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects Links{0}, Found {3} Bad RO Links{0}, Fixed {4} Bad RO Links{0} Elapsed Seconds:{5}{0}{0}", Environment.NewLine, proc.DisplayNumber, ProcedureInfo.CheckROLinksCount, ProcedureInfo.BadROLinksCount, ProcedureInfo.FixedROLinksCount, ts.TotalSeconds)); + ***/ + } + } + + return FoundBadROLinks; // return the total number of bad RO links (in step text only) for the entire procedure set + } + // 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) {