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:
John Jenko 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 System.IO;
using Volian.Controls.Library; using Volian.Controls.Library;
using DevComponents.DotNetBar; using DevComponents.DotNetBar;
using JR.Utils.GUI.Forms;
namespace VEPROMS namespace VEPROMS
{ {
@ -26,20 +27,21 @@ namespace VEPROMS
} }
private AdminTools adminToolsList; private AdminTools adminToolsList;
private AdminTool selectedAdminTool; 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() private void SetUpAdminTools()
{ {
adminToolsList = new AdminTools(); 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("Update RO Values"
adminToolsList.Add("Refresh Referenced Objects" , "Update RO Values Guidance"
, "Refresh Referenced Objects Guidance" , "This allows the user to update referenced objects values for multiple working drafts in a batch mode."
, "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." , "It is recommended that this be done during off hours."
, "If more than one procedure is selected, it is recommened that this be performed during off hours."
, "WARNING:" , "WARNING:"
, true // True means Exclude Procedures
, false , false
, false , UpdateROValues);
, RefreshReferencedObjects);
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 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("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" adminToolsList.Add("Identify Disconnected Items"
, "Identify Disconnected Items Guidance" , "Identify Disconnected Items Guidance"
@ -220,6 +222,9 @@ namespace VEPROMS
foreach (DocVersionInfo dvi in dvil) foreach (DocVersionInfo dvi in dvil)
dviq.Enqueue(dvi); dviq.Enqueue(dvi);
dvil.Clear(); 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) while (dviq.Count > 0)
{ {
string msg = string.Empty; string msg = string.Empty;
@ -231,13 +236,21 @@ namespace VEPROMS
} }
else else
{ {
ContentInfo.StaticContentInfoChange += new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
ProcessUpdateROValues(dq); ProcessUpdateROValues(dq);
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
pbProcess.PerformStep(); pbProcess.PerformStep();
Application.DoEvents(); 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; 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(); Application.DoEvents();
if (dvil.Count > 0) if (dvil.Count > 0)
{ {
@ -261,75 +274,6 @@ namespace VEPROMS
} }
} }
this.Cursor = Cursors.Default; 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() private void RefreshTransitions()
{ {
@ -399,75 +343,6 @@ namespace VEPROMS
this.Cursor = Cursors.Default; this.Cursor = Cursors.Default;
MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title)); 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() private void DeletePDFs()
{ {
this.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.WaitCursor;
@ -809,33 +684,11 @@ namespace VEPROMS
return; return;
} }
FileInfo fiRofst = new FileInfo(rofstPath); 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; Cursor = Cursors.WaitCursor;
using (DocVersion dv = DocVersion.Get(dq.VersionID)) using (DocVersion dv = DocVersion.Get(dq.VersionID))
{ {
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); 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); roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
} }
Cursor = Cursors.Default; Cursor = Cursors.Default;
@ -848,23 +701,6 @@ namespace VEPROMS
txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine);
return; 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) private void RefreshProcedureTransitions(ProcedureInfo pq)
{ {
DateTime start = DateTime.Now; DateTime start = DateTime.Now;
@ -872,10 +708,9 @@ namespace VEPROMS
ProcedureInfo.ResetTranCounters(); ProcedureInfo.ResetTranCounters();
ProcedureInfo.RefreshTransitions(pq);//, transitionsToDisconnected, transitionsToNonEditable); ProcedureInfo.RefreshTransitions(pq);//, transitionsToDisconnected, transitionsToNonEditable);
TimeSpan ts = DateTime.Now - start; 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) if (myFixes.Length > 0)
{ {
txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(myFixes.ToString()); txtResults.AppendText(myFixes.ToString());
txtResults.AppendText(Environment.NewLine); txtResults.AppendText(Environment.NewLine);
} }
@ -918,17 +753,22 @@ namespace VEPROMS
Application.DoEvents(); Application.DoEvents();
} }
StringBuilder myFixes; StringBuilder myFixes;
// show the changes made in the Results pannel, include the ItemId of the step element
void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args) void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{ {
if (args.Type == "TX") if (args.Type == "TX")
{ {
if (args.NewValue.StartsWith("Reason for Change:")) 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)); 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 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") 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) private void btnClear_Click(object sender, EventArgs e)
{ {
@ -978,8 +818,8 @@ namespace VEPROMS
private void DoProgressBarRefresh(int value, int max, string text) private void DoProgressBarRefresh(int value, int max, string text)
{ {
if (ProgressBar == null) return; if (ProgressBar == null) return;
ProgressBar.Value = value;
ProgressBar.Maximum = max; ProgressBar.Maximum = max;
ProgressBar.Value = value;
ProgressBar.Text = text; ProgressBar.Text = text;
Application.DoEvents(); Application.DoEvents();
} }
@ -988,8 +828,8 @@ namespace VEPROMS
set set
{ {
if (ProgressBar == null) return; if (ProgressBar == null) return;
ProgressBar.Value = 0;
ProgressBar.Maximum = 100; ProgressBar.Maximum = 100;
ProgressBar.Value = 0;
ProgressBar.Text = value; ProgressBar.Text = value;
txtProcess.AppendText(value); txtProcess.AppendText(value);
txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine);

View File

@ -391,7 +391,8 @@ namespace VEPROMS
ppBtnRoDbBrowse.Visible = cmbRoDb.Visible = _DocVersionConfig.MyDocVersion.DocVersionAssociationCount == 0; ppBtnRoDbBrowse.Visible = cmbRoDb.Visible = _DocVersionConfig.MyDocVersion.DocVersionAssociationCount == 0;
btnRoDbProperties.Visible = tbRoDb.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: // 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 // 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) if (dlgROProperties.ShowDialog() == DialogResult.OK)
{ {
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath); 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; break;
} }
Cursor = Cursors.WaitCursor; 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); 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); SelectedROFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ppBtnUpRoVals.Enabled = _DocVersionConfig.MyDocVersion.NewerRoFst; ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
FinalProgressBarMessage = "ROs values updated"; 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; private ProgressBarItem _ProgressBar = null;
public ProgressBarItem ProgressBar public ProgressBarItem ProgressBar
{ {
@ -1130,8 +1145,8 @@ namespace VEPROMS
private void DoProgressBarRefresh(int value, int max, string text) private void DoProgressBarRefresh(int value, int max, string text)
{ {
if (ProgressBar == null) return; if (ProgressBar == null) return;
ProgressBar.Value = value;
ProgressBar.Maximum = max; ProgressBar.Maximum = max;
ProgressBar.Value = value;
ProgressBar.Text = text; ProgressBar.Text = text;
Application.DoEvents(); Application.DoEvents();
} }
@ -1151,8 +1166,8 @@ namespace VEPROMS
set set
{ {
if (ProgressBar == null) return; if (ProgressBar == null) return;
ProgressBar.Value = 100;
ProgressBar.Maximum = 100; ProgressBar.Maximum = 100;
ProgressBar.Value = 100;
ProgressBar.Text = value; ProgressBar.Text = value;
Application.DoEvents(); Application.DoEvents();
} }
@ -1235,7 +1250,8 @@ namespace VEPROMS
if (dlgROProperties.ShowDialog() == DialogResult.OK) if (dlgROProperties.ShowDialog() == DialogResult.OK)
{ {
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath); 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 else
return; return;

View File

@ -73,23 +73,25 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("RODefaults_setpointprefix"); OnPropertyChanged("RODefaults_setpointprefix");
} }
} }
[Category("Referenced Objects")] #endregion
[DisplayName("Default Graphics Prefix")] #region ROUpdate
[Category("RO Update")]
[DisplayName("Last Completed")]
[RefreshProperties(RefreshProperties.All)] [RefreshProperties(RefreshProperties.All)]
[Description("Graphics Prefix")] [Description("Last RO Update Completed")]
public string RODefaults_graphicsprefix public string ROUpdate_LastCompleted
{ {
get get
{ {
string s = _Xp["RODefaults", "Graphics"];// get the saved value string s = _Xp["ROUpdate", "LastCompleted"];// get the saved value
return s; return s;
} }
set set
{ {
_Xp["RODefaults", "Graphics"] = value; // save selected value _Xp["ROUpdate", "LastCompleted"] = value; // save selected value
} }
} }
#endregion #endregion // ROUpdate
#region ToString #region ToString
public override string ToString() public override string ToString()
{ {

View File

@ -544,12 +544,26 @@ namespace VEPROMS.CSLA.Library
data = part1 + part2 + part3 + part4 + part5; data = part1 + part2 + part3 + part4 + part5;
return data; return data;
} }
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, bool saveAnnotation)
{
return FixContentText(rousg, value, rotype, origROFstInfo, null, "", saveAnnotation);
}
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo)
{ {
return FixContentText(rousg, value, rotype, origROFstInfo, null, ""); string filenameonly = null;
if (Text != null && Text.Length > 0)
{
if (ContentItems[0].MyItem.MyItemInfo.IsFigure)
filenameonly = value.Substring(0, value.IndexOf("\n"));
}
return FixContentText(rousg, value, rotype, origROFstInfo, filenameonly, "", false);
} }
// B2017-060 added roidFrmImportStep to pass in a ROID to use when rousg is null (import procedure uses this) // B2017-060 added roidFrmImportStep to pass in a ROID to use when rousg is null (import procedure uses this)
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, string fileNameOnly, string roidFrmImportStep) public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, string fileNameOnly, string roidFrmImportStep)
{
return FixContentText(rousg, value, rotype, origROFstInfo, fileNameOnly, roidFrmImportStep, false);
}
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, string fileNameOnly, string roidFrmImportStep, bool saveAnnotation)
{ {
string retval = null; string retval = null;
if (value == "?") if (value == "?")
@ -584,10 +598,20 @@ namespace VEPROMS.CSLA.Library
myLength += m.Groups[3].Length; myLength += m.Groups[3].Length;
} }
string gg = Text.Substring(myIndex,myLength); string gg = Text.Substring(myIndex,myLength);
if ((gg.Replace(@"\'b0", @"\'B0") != newvalue.Replace(@"\'b0", @"\'B0")) && ((fileNameOnly == null) || (gg != fileNameOnly))) if (((fileNameOnly == null) && (MakeConsistentFormat(gg) != MakeConsistentFormat(newvalue))) || ((fileNameOnly != null) && !(gg.Replace(@"\u8209?", "-").StartsWith(fileNameOnly) && newvalue.Replace(@"\u8209?", "-").StartsWith(fileNameOnly))))
{ {
retval = gg; retval = gg;
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength); Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
if (!saveAnnotation)
{
using (Item myitem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// B2016-225 (follow through) added more descriptive Annotation Type when RO is converted to text
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Verification Required"), "",
string.Format("Referenced Object (Change in RO Values: Old value = {0}, New value = {1}) Changed", FixValue(gg), FixValue(newvalue)), null);
}
}
break; // Text has been processed break; // Text has been processed
} }
} }
@ -665,6 +689,16 @@ namespace VEPROMS.CSLA.Library
} }
return retval; return retval;
} }
public static string MakeConsistentFormat(string gg)
{
// replace degree, bullet dash, hardspace
return ROFSTLookup.ConvertFortranFormatToScienctificNotation(gg).Replace("`", @"\'B0").Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ").Replace(@"\'a0", " ").Replace(@"\'A0", " ");
}
private string FixValue(string str)
{
return str.Replace(@"\u8209?", "-").Replace(@"\u160?", " "); //dash and hard space
}
} }
public delegate void StaticContentInfoEvent(object sender, StaticContentInfoEventArgs args); public delegate void StaticContentInfoEvent(object sender, StaticContentInfoEventArgs args);
public class StaticContentInfoEventArgs public class StaticContentInfoEventArgs
@ -894,6 +928,9 @@ namespace VEPROMS.CSLA.Library
} }
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, ItemInfo ii) // string newvalue) public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, ItemInfo ii) // string newvalue)
{ {
string fileNameOnly = null;
if (ii.IsFigure && Text != null && Text.Length > 0)
fileNameOnly = value.Substring(0,value.IndexOf("\n")).Replace(@"\u8209?","-"); // check only the file name of the RO figure
string newvalue = value; string newvalue = value;
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}"); newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
string findLink = @"<START\].*?\[END>"; string findLink = @"<START\].*?\[END>";
@ -914,8 +951,11 @@ namespace VEPROMS.CSLA.Library
myLength += m.Groups[3].Length; myLength += m.Groups[3].Length;
} }
string gg = Text.Substring(myIndex, myLength); string gg = Text.Substring(myIndex, myLength);
if ((gg.Replace(@"\'b0", @"\'B0") != newvalue.Replace(@"\'b0", @"\'B0"))) if (((fileNameOnly == null) && (Content.MakeConsistentFormat(gg) != Content.MakeConsistentFormat(newvalue))) || ((fileNameOnly != null) && !(gg.Replace(@"\u8209?", "-").StartsWith(fileNameOnly) && newvalue.Replace(@"\u8209?", "-").StartsWith(fileNameOnly))))
{ {
// Debug - jsj 5-19-2017 - left in for initial check-in
//string gg_org = gg;
//string newval_org = newvalue;
_Text = Text.Substring(0, myIndex) + newvalue + _Text.Substring(myIndex + myLength); _Text = Text.Substring(0, myIndex) + newvalue + _Text.Substring(myIndex + myLength);
if (newvalue == "?") if (newvalue == "?")
{ {
@ -932,6 +972,10 @@ namespace VEPROMS.CSLA.Library
{ {
gg = ItemInfo.ConvertToDisplayText(gg); gg = ItemInfo.ConvertToDisplayText(gg);
newvalue = ItemInfo.ConvertToDisplayText(newvalue); newvalue = ItemInfo.ConvertToDisplayText(newvalue);
// Debug - jsj 5-19-2017 - left in for initial check-in
//string xx_gg = gg_org.Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
//string xx_nv = newval_org.Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
//Console.WriteLine(xx_gg.CompareTo(xx_nv));
OnStaticContentInfoChange(ii, new StaticContentInfoEventArgs(gg, newvalue, "RO")); OnStaticContentInfoChange(ii, new StaticContentInfoEventArgs(gg, newvalue, "RO"));
break; // Text has been processed break; // Text has been processed
} }

View File

@ -16,6 +16,7 @@ using Csla.Data;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Xml;
//using VEPROMS.Properties; //using VEPROMS.Properties;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
@ -65,6 +66,27 @@ namespace VEPROMS.CSLA.Library
return ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length); return ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length);
} }
} }
public bool ROfstLastCompleted
{
get
{
if (DocVersionAssociations == null || DocVersionAssociationCount == 0) return true; // no ROs associated this will turn off the update ROs button
if (LastCompleted(DocVersionAssociations[0]) == string.Empty) return false;
return true;
}
}
// return the date/time of the last time the RO Update was done and ran all the way through completion
private string LastCompleted(DocVersionAssociation dva)
{
XmlDocument xd = new XmlDocument();
if (dva.Config == null || dva.Config.Length == 0) return string.Empty;
xd.LoadXml(dva.Config);
XmlNode xn = xd.DocumentElement.SelectSingleNode("//ROUpdate");
if (xn == null) return string.Empty;
XmlAttribute att = xn.Attributes["LastCompleted"];
if (att == null) return string.Empty;
return att.InnerText;
}
#region VersionType #region VersionType
public VersionTypeEnum eVersionType public VersionTypeEnum eVersionType
{ {
@ -233,7 +255,21 @@ namespace VEPROMS.CSLA.Library
return AddToRoFstLookup(key, ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length)); return AddToRoFstLookup(key, ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length));
} }
} }
public bool ROfstLastCompleted
{
get
{
if (DocVersionAssociations == null || DocVersionAssociationCount == 0) return true; // no ROs associated this will turn off the update ROs button
if (LastCompleted(DocVersionAssociations[0]) == string.Empty) return false; // the AssociatinoConfig does not have completed date for update ROs - this will turn on the update ROs button
return true;
}
}
// return the date/time of the last time the RO Update was done and ran all the way through completion
private string LastCompleted(AssociationInfo associationInfo)
{
AssociationConfig ac = new AssociationConfig(associationInfo);
return ac.ROUpdate_LastCompleted;
}
#region SearchPaths #region SearchPaths
public string _SearchDVPath; public string _SearchDVPath;
public string SearchDVPath public string SearchDVPath

View File

@ -792,8 +792,9 @@ namespace VEPROMS.CSLA.Library
ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID); ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
itemInfo.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, itemInfo); itemInfo.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, itemInfo);
string newText = itemInfo.MyContent.Text; string newText = itemInfo.MyContent.Text;
if (newText != oldText) if (DifferentROtext(newText,oldText))
{ {
//ShowDifference(oldText, newText); // debug - display in Visual Studio Output window
ROFixCount++; ROFixCount++;
Content content = Content.Get(itemInfo.MyContent.ContentID); Content content = Content.Get(itemInfo.MyContent.ContentID);
if (roval == "?") if (roval == "?")
@ -807,13 +808,48 @@ namespace VEPROMS.CSLA.Library
} }
} }
else else
{
content.FixContentText(rousage, roval, roch.type, rofstinfo); content.FixContentText(rousage, roval, roch.type, rofstinfo);
}
content.UserID = Volian.Base.Library.VlnSettings.UserID;
content.DTS = DateTime.Now;
content.Save(); content.Save();
} }
} }
} }
} }
} }
private static bool DifferentROtext(string newText, string oldText)
{
string nt = newText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
string ot = oldText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
if (nt.Equals(ot))
return false;
return true;
}
#region debug
//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) internal static void SetParentSectionAndDocVersionPageNum(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
{ {
if (itemInfo.MyContent.ContentPartCount > 0) if (itemInfo.MyContent.ContentPartCount > 0)