Added code to support Updating RO Values for multiple working drafts as a batch process

Added code to support feedback on updating of RO values during the batch process
This commit is contained in:
Rich 2015-02-12 03:24:02 +00:00
parent bcfd5578c1
commit f24b475f7c
2 changed files with 202 additions and 50 deletions

View File

@ -8,6 +8,7 @@ using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using System.IO; using System.IO;
using Volian.Controls.Library; using Volian.Controls.Library;
using DevComponents.DotNetBar;
namespace VEPROMS namespace VEPROMS
{ {
@ -37,13 +38,15 @@ namespace VEPROMS
btBatch.SetBalloonText(rbNow, "When the button below is pressed the process option selected (as indicated the the title of the button below) will be performed immediately. If during the process a procedure selected to be processed is checked out to a user, you will be notified." + Environment.NewLine + Environment.NewLine + "You will then be given the option of terminating the process without processing the procedures checked out or contacting the appropriate users to check in the procedures and then continue the process to completion."); btBatch.SetBalloonText(rbNow, "When the button below is pressed the process option selected (as indicated the the title of the button below) will be performed immediately. If during the process a procedure selected to be processed is checked out to a user, you will be notified." + Environment.NewLine + Environment.NewLine + "You will then be given the option of terminating the process without processing the procedures checked out or contacting the appropriate users to check in the procedures and then continue the process to completion.");
btBatch.SetBalloonCaption(rbLater, "Process Later Guidance"); btBatch.SetBalloonCaption(rbLater, "Process Later Guidance");
btBatch.SetBalloonText(rbLater, "NOTE: It is highly recommended that this function be used on off hours" + Environment.NewLine + Environment.NewLine + "When the button below is pressed the process option selected (as indicated the the title of the button below) will be performed when the date and time set has arrived." + Environment.NewLine + Environment.NewLine + "If during the process a procedure selected to be processed is checked out to a user, the procedures will be forced checked in and the process will be allowed to complete."); btBatch.SetBalloonText(rbLater, "NOTE: It is highly recommended that this function be used on off hours" + Environment.NewLine + Environment.NewLine + "When the button below is pressed the process option selected (as indicated the the title of the button below) will be performed when the date and time set has arrived." + Environment.NewLine + Environment.NewLine + "If during the process a procedure selected to be processed is checked out to a user, the procedures will be forced checked in and the process will be allowed to complete.");
btBatch.SetBalloonCaption(rbUpdate, "Update RO Values");
btBatch.SetBalloonText(rbUpdate, "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.");
} }
//private DocVersionInfoList myDVIL; //private DocVersionInfoList myDVIL;
private Dictionary<TreeNode, ProcedureInfo> myProcedures = new Dictionary<TreeNode, ProcedureInfo>(); private Dictionary<TreeNode, ProcedureInfo> myProcedures = new Dictionary<TreeNode, ProcedureInfo>();
private Dictionary<TreeNode, DocVersionInfo> myDocVersions = new Dictionary<TreeNode, DocVersionInfo>(); private Dictionary<TreeNode, DocVersionInfo> myDocVersions = new Dictionary<TreeNode, DocVersionInfo>();
private void frmBatchRefresh_Load(object sender, EventArgs e) private void frmBatchRefresh_Load(object sender, EventArgs e)
{ {
rbUpdate.Visible = false; //rbUpdate.Visible = false;
//Options_Changed(rbTransition, e); //Options_Changed(rbTransition, e);
//ResetTV(); //ResetTV();
} }
@ -149,52 +152,13 @@ namespace VEPROMS
} }
else else
{ {
//InitialProgressBarMessage = "Updating ROs"; ProcessUpdateROValues(dq);
if (dq.DocVersionAssociationCount < 1)
{
//FinalProgressBarMessage = "No ROs associated";
MessageBox.Show("Error Updating ro.fst. No associated ro.fst");
return;
}
ROFstInfo roFstInfo = dq.DocVersionAssociations[0].MyROFst;
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath))
{
//FinalProgressBarMessage = "No existing RO.FST";
MessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path");
return;
}
FileInfo fiRofst = new FileInfo(rofstPath);
if (roFstInfo.DTS == fiRofst.LastWriteTimeUtc)
{
//FinalProgressBarMessage = "RO.FST up to date";
MessageBox.Show("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
return;
}
if (roFstInfo.DTS > fiRofst.LastWriteTimeUtc)
{
//FinalProgressBarMessage = "RO.FST is older";
MessageBox.Show("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
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, null);// DoProgressBarRefresh);
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";
pbProcess.PerformStep(); pbProcess.PerformStep();
Application.DoEvents(); Application.DoEvents();
} }
} }
DateTime pEnd = DateTime.Now; DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("mm/dd/yyyy @ HH:mm")); txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
Application.DoEvents(); Application.DoEvents();
if (dvil.Count > 0) if (dvil.Count > 0)
{ {
@ -271,7 +235,7 @@ namespace VEPROMS
} }
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange); ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
DateTime pEnd = DateTime.Now; DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("mm/dd/yyyy @ HH:mm")); txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
Application.DoEvents(); Application.DoEvents();
if (pil.Count > 0) if (pil.Count > 0)
{ {
@ -311,6 +275,65 @@ namespace VEPROMS
} }
if (rbUpdate.Checked) if (rbUpdate.Checked)
{ {
List<DocVersionInfo> dvil = new List<DocVersionInfo>();
foreach (TreeNode tn in myDocVersions.Keys)
if (tn.Checked)
dvil.Add(myDocVersions[tn]);
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 = dvil.Count;
pbProcess.Step = 1;
while (dvil.Count > 0)
{
StringBuilder sbDocVersions = new StringBuilder();
Queue<DocVersionInfo> dviq = new Queue<DocVersionInfo>();
foreach (DocVersionInfo dvi in dvil)
dviq.Enqueue(dvi);
dvil.Clear();
while (dviq.Count > 0)
{
string msg = string.Empty;
DocVersionInfo dq = dviq.Dequeue();
if (!MySessionInfo.CanCheckOutItem(dq.VersionID, CheckOutType.DocVersion, ref msg))
{
dvil.Add(dq);
sbDocVersions.AppendLine(msg);
}
else
{
ProcessUpdateROValues(dq);
pbProcess.PerformStep();
Application.DoEvents();
}
}
DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
Application.DoEvents();
if (dvil.Count > 0)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The batch update process was not usccessful for all working drafts selected.");
sb.AppendLine("The following working drafts were not able to be refreshed...");
sb.AppendLine();
sb.AppendLine(sbDocVersions.ToString());
sb.AppendLine();
sb.AppendLine("If you want to update these working drafts, please contact the respective users and have them close any procedures in the working draft.");
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 = dvil;
frmCO.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - frmCO.Width, Screen.PrimaryScreen.WorkingArea.Height - frmCO.Height);
frmCO.Show(this);
while (!this.Visible)
Application.DoEvents();
}
}
} }
else else
{ {
@ -365,7 +388,7 @@ namespace VEPROMS
} }
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange); ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
DateTime pEnd = DateTime.Now; DateTime pEnd = DateTime.Now;
txtProcess.AppendText(pEnd.ToString("mm/dd/yyyy @ HH:mm")); txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm"));
Application.DoEvents(); Application.DoEvents();
if (pil.Count > 0) if (pil.Count > 0)
{ {
@ -393,6 +416,74 @@ namespace VEPROMS
MessageBox.Show("Batch Refresh Process Completed", "Batch Refresh Complete"); MessageBox.Show("Batch Refresh Process Completed", "Batch Refresh Complete");
} }
private void ProcessUpdateROValues(DocVersionInfo dq)
{
InitialProgressBarMessage = string.Format("Updating ROs for {0}", dq.MyFolder.Name);
if (dq.DocVersionAssociationCount < 1)
{
ProgressBar.ColorTable = eProgressBarItemColor.Error;
FinalProgressBarMessage = "No ROs associated";
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText("Error Updating ro.fst. No associated ro.fst");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
return;
}
ROFstInfo roFstInfo = dq.DocVersionAssociations[0].MyROFst;
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath))
{
ProgressBar.ColorTable = eProgressBarItemColor.Error;
FinalProgressBarMessage = "No existing RO.FST";
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
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);
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
}
Cursor = Cursors.Default;
ProgressBar.ColorTable = eProgressBarItemColor.Normal;
FinalProgressBarMessage = "ROs values updated";
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText("ROs values updated");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
return;
}
private void RefreshProcedureReferencedObjects(ProcedureInfo pq) private void RefreshProcedureReferencedObjects(ProcedureInfo pq)
{ {
DateTime start = DateTime.Now; DateTime start = DateTime.Now;
@ -401,9 +492,12 @@ namespace VEPROMS
ProcedureInfo.RefreshReferenceObjects(pq); ProcedureInfo.RefreshReferenceObjects(pq);
TimeSpan ts = DateTime.Now - start; 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)); 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));
txtProcess.AppendText(Environment.NewLine); if (myFixes.Length > 0)
txtResults.AppendText(myFixes.ToString()); {
txtResults.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(myFixes.ToString());
txtResults.AppendText(Environment.NewLine);
}
} }
private TransitionInfoList transitionsToDisconnected; private TransitionInfoList transitionsToDisconnected;
private TransitionInfoList transitionsToNonEditable; private TransitionInfoList transitionsToNonEditable;
@ -415,9 +509,12 @@ namespace VEPROMS
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}", Environment.NewLine, pq.DisplayNumber, ProcedureInfo.TranCheckCount, ProcedureInfo.TranFixCount, ts.TotalSeconds));
txtProcess.AppendText(Environment.NewLine); if (myFixes.Length > 0)
txtResults.AppendText(myFixes.ToString()); {
txtResults.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(myFixes.ToString());
txtResults.AppendText(Environment.NewLine);
}
} }
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args) public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{ {
@ -517,6 +614,52 @@ namespace VEPROMS
pnlLater.Enabled = rbLater.Checked; pnlLater.Enabled = rbLater.Checked;
} }
private ProgressBarItem _ProgressBar = null;
public ProgressBarItem ProgressBar
{
get { return _ProgressBar; }
set
{
_ProgressBar = value;
_ProgressBar.TextVisible = true;
}
}
private void DoProgressBarRefresh(int value, int max, string text)
{
if (ProgressBar == null) return;
ProgressBar.Value = value;
ProgressBar.Maximum = max;
ProgressBar.Text = text;
Application.DoEvents();
}
private string InitialProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 0;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
txtProcess.AppendText(value);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
}
}
private string FinalProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 100;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
txtProcess.AppendText(value);
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
}
}
private void btBatch_BalloonDisplaying(object sender, EventArgs e) private void btBatch_BalloonDisplaying(object sender, EventArgs e)
{ {
Point p = Control.MousePosition; Point p = Control.MousePosition;

View File

@ -174,6 +174,8 @@ namespace VEPROMS
} }
InitializeComponent(); InitializeComponent();
bottomProgBar.ValueChanged += new EventHandler(bottomProgBar_ValueChanged);
// When creating an XY Plot, a System.Drawing.Graphics is needed and it requires a form. Use the main // When creating an XY Plot, a System.Drawing.Graphics is needed and it requires a form. Use the main
// form. // form.
if (VlnSettings.DebugMode) if (VlnSettings.DebugMode)
@ -287,6 +289,12 @@ namespace VEPROMS
tv.PrintTransitionReport += new vlnTreeViewEvent(tv_PrintTransitionReport); tv.PrintTransitionReport += new vlnTreeViewEvent(tv_PrintTransitionReport);
} }
void bottomProgBar_ValueChanged(object sender, EventArgs e)
{
if (bottomProgBar.Value < 10 && bottomProgBar.ColorTable != eProgressBarItemColor.Normal)
bottomProgBar.ColorTable = eProgressBarItemColor.Normal;
}
string tv_GetChangeId(object sender, vlnTreeItemInfoEventArgs args) string tv_GetChangeId(object sender, vlnTreeItemInfoEventArgs args)
{ {
tc.HandleChangeId(args.MyItemInfo, null); tc.HandleChangeId(args.MyItemInfo, null);
@ -1029,6 +1037,7 @@ namespace VEPROMS
void btnBatchRefresh_Click(object sender, EventArgs e) void btnBatchRefresh_Click(object sender, EventArgs e)
{ {
frmBatchRefresh frm = new frmBatchRefresh(); frmBatchRefresh frm = new frmBatchRefresh();
frm.ProgressBar = bottomProgBar;
frm.MySessionInfo = MySessionInfo; frm.MySessionInfo = MySessionInfo;
frm.Show(this); frm.Show(this);
} }