Added DoUpdateRO flag for use in the new Update RO logic

Better feedback when updating RO values, also save list of updated ROs in text file in Documents\VEPROMS
This commit is contained in:
John Jenko 2017-06-20 16:28:45 +00:00
parent 16133ccab1
commit d20ec450ce
3 changed files with 39 additions and 7 deletions

View File

@ -17,6 +17,12 @@ namespace Volian.Base.Library
// <add key ="OperatingMode" value ="Debug"|"Demo"|"Production"/>
// For DataLoader, this is set via the Debug checkbox on the form.
private static bool WasLoaded = false;
private static bool _DoUpdateRO = true;
public static bool DoUpdateRO
{
get { return VlnSettings._DoUpdateRO; }
set { VlnSettings._DoUpdateRO = value; }
}
private static bool _DebugPagination = false;
public static bool DebugPagination
{

View File

@ -2873,15 +2873,26 @@ namespace Volian.Controls.Library
using (DocVersion dv = DocVersion.Get(Mydvi.VersionID))
{
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh);
swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(Mydvi));// RO changes placed in file in the Documents\VEPROMS folder
ContentInfo.StaticContentInfoChange += ContentInfo_StaticContentInfoChange; // write changes to a text file
ROFst newrofst = ROFstInfo.RefreshROFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh, null);
swROUpdate.Close();
ContentInfo.StaticContentInfoChange -= ContentInfo_StaticContentInfoChange;
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
btnUpdROVal.Enabled = false;
}
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
{
@ -2891,8 +2902,8 @@ namespace Volian.Controls.Library
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();
}
@ -2979,7 +2990,8 @@ namespace Volian.Controls.Library
public bool NewerRoFst()
{
if (_Mydvi == null)return false;
return _Mydvi.NewerRoFst;
// only allow update if association, and the RO update was not done and/or not completed
return !_Mydvi.ROfstLastCompleted || _Mydvi.NewerRoFst;
}
public void SetUpdRoValBtn(bool en)
{

View File

@ -764,7 +764,8 @@ namespace Volian.Controls.Library
{
//_MyLog.WarnFormat("Context Menu 1h - {0}", GC.GetTotalMemory(true));
MenuItem urv = cm.MenuItems.Add("Update RO Values", new EventHandler(mi_Click));
urv.Enabled = dvi.NewerRoFst;
// only allow update if association, and the RO update was not done and/or not completed
urv.Enabled = !dvi.ROfstLastCompleted || dvi.NewerRoFst;
}
}
else if (tn.VEObject as ProcedureInfo != null) // Procs can only contain sections
@ -1823,7 +1824,11 @@ namespace Volian.Controls.Library
using (DocVersion dv = DocVersion.Get(MyDVI.VersionID))
{
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh);
swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(MyDVI)); // RO changes placed in file in the Documents\VEPROMS folder
ContentInfo.StaticContentInfoChange += ContentInfo_StaticContentInfoChange; // write changes to a text file
ROFst newrofst = ROFstInfo.RefreshROFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh, null);
swROUpdate.Close();
ContentInfo.StaticContentInfoChange -= ContentInfo_StaticContentInfoChange;
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
OnTabDisplay(this, new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST"));
}
@ -1831,6 +1836,15 @@ namespace Volian.Controls.Library
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
{
@ -1840,8 +1854,8 @@ namespace Volian.Controls.Library
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();
}