B2017-079, B2017-053, B2017-049, improved the speed and logic of updating ROs. The Refresh ROs logic is now merged into the Update ROs logic. Also annotations are added when ROs are updated. The Refresh ROs options were removed from the tool list.

Better feedback when updating RO values, also save list of updated ROs in text file in Documents\VEPROMS
Save the date/time of the last successfully completed RO Values Update
Add annotations for updated RO values, better logic in updating RO figures so they are needlessly updated, better logic in determining if an RO needs to be updated
Logic to save the date/time of the last successfully completed RO Update
Better logic to determine if an RO value needs updated.
This commit is contained in:
2017-06-20 16:26:04 +00:00
parent b7bffda9de
commit f5dbfa12fb
6 changed files with 190 additions and 216 deletions

View File

@@ -9,6 +9,7 @@ using VEPROMS.CSLA.Library;
using System.IO;
using Volian.Controls.Library;
using DevComponents.DotNetBar;
using JR.Utils.GUI.Forms;
namespace VEPROMS
{
@@ -26,20 +27,21 @@ namespace VEPROMS
}
private AdminTools adminToolsList;
private AdminTool selectedAdminTool;
// removed the Refresh ROs and Refresh Transitions and ROs options (now only Transitions can be refreshed)
// the Update ROs and Refresh ROs logic was merged together. The Update ROs will functionally do both
// also annotations will be placed on step elements that have RO changes
private void SetUpAdminTools()
{
adminToolsList = new AdminTools();
adminToolsList.Add("Update RO Values", "Update RO Values Guidance", "This allows the user to update referenced objects values for multiple working drafts in a batch mode.", "It is recommended that this be done during off hours.", "WARNING:", true, false, UpdateROValues);
adminToolsList.Add("Refresh Referenced Objects"
, "Refresh Referenced Objects Guidance"
, "Occasionally, referenced objects do not get updated. One cause of this is a failure to allow the RO update to complete.\r\n\r\nThis function will refresh referenced objects (based on the current ROFst) in all procedures selected below whether they were selected individually or as a group via a procedure set."
, "If more than one procedure is selected, it is recommened that this be performed during off hours."
adminToolsList.Add("Update RO Values"
, "Update RO Values Guidance"
, "This allows the user to update referenced objects values for multiple working drafts in a batch mode."
, "It is recommended that this be done during off hours."
, "WARNING:"
, true // True means Exclude Procedures
, false
, false
, RefreshReferencedObjects);
, UpdateROValues);
adminToolsList.Add("Refresh Transitions", "Refresh Transitions Guidance", "Occasionally, transitions do not get updated.\r\n\r\nThis function will refresh transitions in all procedures selected below whether they were selected individually or as a group via a procedure set.", "If more than one procedure is selected, it is recommened that this be performed during off hours.", "WARNING:", false, false, RefreshTransitions);
adminToolsList.Add("Refresh Referenced Objects and Transitions", "Referenced Objects and Transitions Guidance", "Occasionally, referenced objects and transitions do not get updated." + Environment.NewLine + Environment.NewLine + "This function will refresh referenced objects and transitions (based on the current ROFst) in all procedures selected below whether they were selected individually or as a group via a procedure set.", "If more than one procedure is selected, it is recommened that this be performed during off hours.", "WARNING:", false, false, RefreshReferencedObjectsAndTransitions);
adminToolsList.Add("Delete PDFs", "Delete PDFs Guidance", "It is sometimes desirable to clean up the database by removing extra pdf files. This process allows for this to occur", "", "", true, true, "vesp_DeletePDFs", DeletePDFs);
adminToolsList.Add("Identify Disconnected Items"
, "Identify Disconnected Items Guidance"
@@ -220,6 +222,9 @@ namespace VEPROMS
foreach (DocVersionInfo dvi in dvil)
dviq.Enqueue(dvi);
dvil.Clear();
// if we are processing more than one procedure set, use MessageList to hold the summary results for each set
if (dviq.Count > 1)
ROFstInfo.MessageList = new StringBuilder();
while (dviq.Count > 0)
{
string msg = string.Empty;
@@ -231,13 +236,21 @@ namespace VEPROMS
}
else
{
ContentInfo.StaticContentInfoChange += new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
ProcessUpdateROValues(dq);
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
pbProcess.PerformStep();
Application.DoEvents();
}
}
// when processing more than one procedure set, display only one completed message after all are processed
if (ROFstInfo.MessageList != null)
{
FlexibleMessageBox.Show(ROFstInfo.MessageList.ToString(), "RO Update Complete");
ROFstInfo.MessageList = null;
}
DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
txtProcess.AppendText(string.Format("{0} {1} Seconds Elapsed", pEnd.ToString("MM/dd/yyyy @ HH:mm"), TimeSpan.FromTicks(pEnd.Ticks - pStart.Ticks).TotalSeconds));
Application.DoEvents();
if (dvil.Count > 0)
{
@@ -261,75 +274,6 @@ namespace VEPROMS
}
}
this.Cursor = Cursors.Default;
MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title));
}
private void RefreshReferencedObjects()
{
this.Cursor = Cursors.WaitCursor;
List<ProcedureInfo> pil = new List<ProcedureInfo>();
foreach (TreeNode tn in myProcedures.Keys)
if (tn.Checked)
pil.Add(myProcedures[tn]);
//PopulateTransitionInfoLists(pil);
DateTime pStart = DateTime.Now;
txtProcess.AppendText(pStart.ToString("MM/dd/yyyy @ HH:mm"));
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
pbProcess.Minimum = 0;
pbProcess.Maximum = pil.Count;
pbProcess.Step = 1;
while (pil.Count > 0)
{
ContentInfo.StaticContentInfoChange += new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
StringBuilder sbProcs = new StringBuilder();
Queue<ProcedureInfo> piq = new Queue<ProcedureInfo>();
foreach (ProcedureInfo pi in pil)
piq.Enqueue(pi);
pil.Clear();
while (piq.Count > 0)
{
string msg = string.Empty;
ProcedureInfo pq = piq.Dequeue();
if (!MySessionInfo.CanCheckOutItem(pq.ItemID, CheckOutType.Procedure, ref msg))
{
pil.Add(pq);
sbProcs.AppendLine(msg);
}
else
{
RefreshProcedureReferencedObjects(pq);
pbProcess.PerformStep();
Application.DoEvents();
}
}
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
Application.DoEvents();
if (pil.Count > 0)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The batch refresh process was not usccessful for all procedures selected.");
sb.AppendLine("The following procedures were not able to be refreshed...");
sb.AppendLine();
sb.AppendLine(sbProcs.ToString());
sb.AppendLine();
sb.AppendLine("If you want to refresh these prcoedures, please contact the respective users and have them close the procedures.");
sb.AppendLine("Once this is complete you can continue the process otherwise you may terminate the process immediately.");
sb.AppendLine();
sb.AppendLine("Have you requested the users to close the procedures and do you want to continue the process?");
frmBatchRefreshCheckedOut frmCO = new frmBatchRefreshCheckedOut();
frmCO.MySessionInfo = MySessionInfo;
frmCO.CheckedOutProcedures = pil;
frmCO.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - frmCO.Width, Screen.PrimaryScreen.WorkingArea.Height - frmCO.Height);
frmCO.Show(this);
while (!this.Visible)
Application.DoEvents();
}
}
this.Cursor = Cursors.Default;
MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title));
}
private void RefreshTransitions()
{
@@ -399,75 +343,6 @@ namespace VEPROMS
this.Cursor = Cursors.Default;
MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title));
}
private void RefreshReferencedObjectsAndTransitions()
{
this.Cursor = Cursors.WaitCursor;
List<ProcedureInfo> pil = new List<ProcedureInfo>();
foreach (TreeNode tn in myProcedures.Keys)
if (tn.Checked)
pil.Add(myProcedures[tn]);
//PopulateTransitionInfoLists(pil);
DateTime pStart = DateTime.Now;
txtProcess.AppendText(pStart.ToString("MM/dd/yyyy @ HH:mm"));
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
pbProcess.Minimum = 0;
pbProcess.Maximum = pil.Count;
pbProcess.Step = 1;
while (pil.Count > 0)
{
ContentInfo.StaticContentInfoChange += new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
StringBuilder sbProcs = new StringBuilder();
Queue<ProcedureInfo> piq = new Queue<ProcedureInfo>();
foreach (ProcedureInfo pi in pil)
piq.Enqueue(pi);
pil.Clear();
while (piq.Count > 0)
{
string msg = string.Empty;
ProcedureInfo pq = piq.Dequeue();
if (!MySessionInfo.CanCheckOutItem(pq.ItemID, CheckOutType.Procedure, ref msg))
{
pil.Add(pq);
sbProcs.AppendLine(msg);
}
else
{
RefreshProcedureTransitions(pq);
RefreshProcedureReferencedObjects(pq);
pbProcess.PerformStep();
Application.DoEvents();
}
}
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
Application.DoEvents();
if (pil.Count > 0)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The batch refresh process was not usccessful for all procedures selected.");
sb.AppendLine("The following procedures were not able to be refreshed...");
sb.AppendLine();
sb.AppendLine(sbProcs.ToString());
sb.AppendLine();
sb.AppendLine("If you want to refresh these prcoedures, please contact the respective users and have them close the procedures.");
sb.AppendLine("Once this is complete you can continue the process otherwise you may terminate the process immediately.");
sb.AppendLine();
sb.AppendLine("Have you requested the users to close the procedures and do you want to continue the process?");
frmBatchRefreshCheckedOut frmCO = new frmBatchRefreshCheckedOut();
frmCO.MySessionInfo = MySessionInfo;
frmCO.CheckedOutProcedures = pil;
frmCO.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - frmCO.Width, Screen.PrimaryScreen.WorkingArea.Height - frmCO.Height);
frmCO.Show(this);
while (!this.Visible)
Application.DoEvents();
}
}
this.Cursor = Cursors.Default;
MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title));
}
private void DeletePDFs()
{
this.Cursor = Cursors.WaitCursor;
@@ -809,33 +684,11 @@ namespace VEPROMS
return;
}
FileInfo fiRofst = new FileInfo(rofstPath);
if (roFstInfo.DTS == fiRofst.LastWriteTimeUtc)
{
ProgressBar.ColorTable = eProgressBarItemColor.Paused;
FinalProgressBarMessage = "RO.FST up to date";
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
return;
}
if (roFstInfo.DTS > fiRofst.LastWriteTimeUtc)
{
ProgressBar.ColorTable = eProgressBarItemColor.Error;
FinalProgressBarMessage = "RO.FST is older";
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
return;
}
Cursor = Cursors.WaitCursor;
using (DocVersion dv = DocVersion.Get(dq.VersionID))
{
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh);
ROFst newrofst = ROFstInfo.RefreshROFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh, txtProcess);
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
}
Cursor = Cursors.Default;
@@ -848,23 +701,6 @@ namespace VEPROMS
txtProcess.AppendText(Environment.NewLine);
return;
}
private void RefreshProcedureReferencedObjects(ProcedureInfo pq)
{
DateTime start = DateTime.Now;
myFixes = new StringBuilder();
ProcedureInfo.ResetROCounters();
ProcedureInfo.RefreshReferenceObjects(pq);
TimeSpan ts = DateTime.Now - start;
txtProcess.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects{0}, Fixed {3} Referenced Objects{0}, Elapsed Seconds:{4}{0}", Environment.NewLine, pq.DisplayNumber, ProcedureInfo.ROCheckCount, ProcedureInfo.ROFixCount, ts.TotalSeconds));
if (myFixes.Length > 0)
{
txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(myFixes.ToString());
txtResults.AppendText(Environment.NewLine);
}
}
//private TransitionInfoList transitionsToDisconnected;
//private TransitionInfoList transitionsToNonEditable;
private void RefreshProcedureTransitions(ProcedureInfo pq)
{
DateTime start = DateTime.Now;
@@ -872,10 +708,9 @@ namespace VEPROMS
ProcedureInfo.ResetTranCounters();
ProcedureInfo.RefreshTransitions(pq);//, transitionsToDisconnected, transitionsToNonEditable);
TimeSpan ts = DateTime.Now - start;
txtProcess.AppendText(string.Format("Procedure: {1}{0}Checked {2} Transitions{0}Fixed {3} Transitions{0}Elapsed Seconds:{4}{0}", Environment.NewLine, pq.DisplayNumber, ProcedureInfo.TranCheckCount, ProcedureInfo.TranFixCount, ts.TotalSeconds));
txtProcess.AppendText(string.Format("Procedure: {1}{0}Checked {2} Transitions{0}Fixed {3} Transitions{0}Elapsed Seconds:{4}{0}{0}", Environment.NewLine, pq.DisplayNumber, ProcedureInfo.TranCheckCount, ProcedureInfo.TranFixCount, ts.TotalSeconds));
if (myFixes.Length > 0)
{
txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(myFixes.ToString());
txtResults.AppendText(Environment.NewLine);
}
@@ -918,17 +753,22 @@ namespace VEPROMS
Application.DoEvents();
}
StringBuilder myFixes;
// show the changes made in the Results pannel, include the ItemId of the step element
void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (args.Type == "TX")
{
if(args.NewValue.StartsWith("Reason for Change:"))
myFixes.AppendLine(string.Format("Fixed Transition for {1}{0}Old Text: {2}{0}{3}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue));
if (args.NewValue.StartsWith("Reason for Change:"))
myFixes.AppendLine(string.Format("Fixed Transition for {1}({4}){0}Old Text: {2}{0}{3}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID));
else
myFixes.AppendLine(string.Format("Fixed Transition for {1}{0}Old Text: {2}{0}New Text: {3}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue));
myFixes.AppendLine(string.Format("Fixed Transition for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID));
}
else if (args.Type == "RO")
myFixes.AppendLine(string.Format("Fixed Referenced Object for {1}{0}Old Text: {2}{0}New Text: {3}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue));
{
txtResults.AppendText(string.Format("Fixed Referenced Object for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue,(sender as ItemInfo).ItemID));
Application.DoEvents();
//myFixes.AppendLine(string.Format("Fixed Referenced Object for {1}{0}Old Text: {2}{0}New Text: {3}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue));
}
}
private void btnClear_Click(object sender, EventArgs e)
{
@@ -978,8 +818,8 @@ namespace VEPROMS
private void DoProgressBarRefresh(int value, int max, string text)
{
if (ProgressBar == null) return;
ProgressBar.Value = value;
ProgressBar.Maximum = max;
ProgressBar.Value = value;
ProgressBar.Text = text;
Application.DoEvents();
}
@@ -988,8 +828,8 @@ namespace VEPROMS
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 0;
ProgressBar.Maximum = 100;
ProgressBar.Value = 0;
ProgressBar.Text = value;
txtProcess.AppendText(value);
txtProcess.AppendText(Environment.NewLine);

View File

@@ -391,7 +391,8 @@ namespace VEPROMS
ppBtnRoDbBrowse.Visible = cmbRoDb.Visible = _DocVersionConfig.MyDocVersion.DocVersionAssociationCount == 0;
btnRoDbProperties.Visible = tbRoDb.Visible = !(_DocVersionConfig.MyDocVersion.DocVersionAssociationCount == 0);
ppBtnUpRoVals.Enabled = _DocVersionConfig.MyDocVersion.NewerRoFst; // only allow update if association
// only allow update if association, and the RO update was not done and/or not completed
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
// Set the auto duplex controls based on whether the format allows this:
// Note that the controls' visibility would not set correctly using the following two lines of code. That
@@ -1072,7 +1073,8 @@ namespace VEPROMS
if (dlgROProperties.ShowDialog() == DialogResult.OK)
{
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath);
ppBtnUpRoVals.Enabled = _DocVersionConfig.MyDocVersion.NewerRoFst; // only allow update if association
// only allow update if association, and the RO update was not done and/or not completed
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
}
}
@@ -1113,14 +1115,27 @@ namespace VEPROMS
break;
}
Cursor = Cursors.WaitCursor;
swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(_DocVersionConfig.MyDocVersion.MyDocVersionInfo)); // RO changes placed in file in the Documents\VEPROMS folder
ContentInfo.StaticContentInfoChange += ContentInfo_StaticContentInfoChange; // write changes to a text file
SelectedROFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(rdi, dva, _DocVersionConfig.MyDocVersion, SelectedROFst, DoProgressBarRefresh);
ROFst newrofst = ROFstInfo.RefreshROFst(rdi, dva, _DocVersionConfig.MyDocVersion, SelectedROFst, DoProgressBarRefresh, null);
swROUpdate.Close();
ContentInfo.StaticContentInfoChange -= ContentInfo_StaticContentInfoChange;
SelectedROFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ppBtnUpRoVals.Enabled = _DocVersionConfig.MyDocVersion.NewerRoFst;
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
Cursor = Cursors.Default;
}
FinalProgressBarMessage = "ROs values updated";
}
private System.IO.StreamWriter swROUpdate;
// write the RO reference changes to a text file, include the old/new text, location, and the itemid of the step element
void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (args.Type == "RO")
swROUpdate.Write(string.Format("Fixed Referenced Object for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID));
}
private ProgressBarItem _ProgressBar = null;
public ProgressBarItem ProgressBar
{
@@ -1130,8 +1145,8 @@ namespace VEPROMS
private void DoProgressBarRefresh(int value, int max, string text)
{
if (ProgressBar == null) return;
ProgressBar.Value = value;
ProgressBar.Maximum = max;
ProgressBar.Value = value;
ProgressBar.Text = text;
Application.DoEvents();
}
@@ -1151,8 +1166,8 @@ namespace VEPROMS
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 100;
ProgressBar.Maximum = 100;
ProgressBar.Value = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
@@ -1235,7 +1250,8 @@ namespace VEPROMS
if (dlgROProperties.ShowDialog() == DialogResult.OK)
{
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath);
ppBtnUpRoVals.Enabled = _DocVersionConfig.MyDocVersion.NewerRoFst; // only allow update if association
// only allow update if association, and the RO update was not done and/or not completed
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
}
else
return;