Added Progress Bar output

This commit is contained in:
Rich 2015-02-10 15:51:38 +00:00
parent 2cfc430128
commit 313cb28327
2 changed files with 110 additions and 26 deletions

View File

@ -10,6 +10,7 @@ using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Accentra.Controls; using Accentra.Controls;
using Volian.Base.Library; using Volian.Base.Library;
using DevComponents.DotNetBar;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
@ -1893,10 +1894,12 @@ namespace Volian.Controls.Library
private void btnUpdROVal_Click(object sender, EventArgs e) private void btnUpdROVal_Click(object sender, EventArgs e)
{ {
InitialProgressBarMessage = "Updating ROs";
// use rodb directory path of the first rofst for the this document version. Later, will need // use rodb directory path of the first rofst for the this document version. Later, will need
// to modify code to get which one (when there is more than one) // to modify code to get which one (when there is more than one)
if (MyDVI.DocVersionAssociations.Count < 1) if (MyDVI.DocVersionAssociations.Count < 1)
{ {
FinalProgressBarMessage = "No ROs associated";
MessageBox.Show("Error Updating ro.fst. No associated ro.fst"); MessageBox.Show("Error Updating ro.fst. No associated ro.fst");
return; return;
} }
@ -1905,17 +1908,20 @@ namespace Volian.Controls.Library
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst"; string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) if (!File.Exists(rofstPath))
{ {
FinalProgressBarMessage = "No existing RO.FST";
MessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path"); MessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path");
return; return;
} }
FileInfo fiRofst = new FileInfo(rofstPath); FileInfo fiRofst = new FileInfo(rofstPath);
if (roFstInfo.DTS == fiRofst.LastWriteTimeUtc) 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"); MessageBox.Show("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
return; return;
} }
if (roFstInfo.DTS > fiRofst.LastWriteTimeUtc) 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"); MessageBox.Show("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
return; return;
} }
@ -1924,13 +1930,50 @@ namespace Volian.Controls.Library
using (DocVersion dv = DocVersion.Get(MyDVI.VersionID)) using (DocVersion dv = DocVersion.Get(MyDVI.VersionID))
{ {
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo); ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh);
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST"); StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args); MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
btnUpdROVal.Enabled = false; btnUpdROVal.Enabled = false;
} }
Cursor = Cursors.Default; Cursor = Cursors.Default;
FinalProgressBarMessage = "ROs values updated";
}
private ProgressBarItem _ProgressBar = null;
public ProgressBarItem ProgressBar
{
get { return _ProgressBar; }
set { _ProgressBar = value; }
}
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;
Application.DoEvents();
}
}
private string FinalProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 100;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
} }
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args) public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)

View File

@ -13,6 +13,7 @@ using Csla.Validation;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using System.IO; using System.IO;
using Volian.Base.Library; using Volian.Base.Library;
using DevComponents.DotNetBar;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
@ -517,7 +518,6 @@ namespace Volian.Controls.Library
{ {
if (e.Button == MouseButtons.Right) if (e.Button == MouseButtons.Right)
{ {
Console.WriteLine("dts mouse down; {0}", DateTime.Now.ToLongTimeString());
OwnerInfoList oil = null; OwnerInfoList oil = null;
OwnerInfo oi = null; OwnerInfo oi = null;
VETreeNode tn = this.GetNodeAt(new Point(e.X, e.Y)) as VETreeNode; VETreeNode tn = this.GetNodeAt(new Point(e.X, e.Y)) as VETreeNode;
@ -649,7 +649,6 @@ namespace Volian.Controls.Library
if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi)) if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi))
{ {
MenuItem urv = cm.MenuItems.Add("Update RO Values", new EventHandler(mi_Click)); MenuItem urv = cm.MenuItems.Add("Update RO Values", new EventHandler(mi_Click));
Console.WriteLine("dts mouse down NewerRoFst; {0}", DateTime.Now.ToLongTimeString());
urv.Enabled = dvi.NewerRoFst; urv.Enabled = dvi.NewerRoFst;
} }
} }
@ -1095,9 +1094,9 @@ namespace Volian.Controls.Library
{ {
#region MenuPaste #region MenuPaste
// Find what's in paste buffer & determine whether the paste can occur for the selected node. // Find what's in paste buffer & determine whether the paste can occur for the selected node.
ItemInfo iiClipboard = OnClipboardStatus(this,new vlnTreeEventArgs(tn)); ItemInfo iiClipboard = OnClipboardStatus(this, new vlnTreeEventArgs(tn));
if(iiClipboard != null) if (iiClipboard != null)
{ {
// can it be pasted at current node. // can it be pasted at current node.
if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc
{ {
@ -1106,15 +1105,15 @@ namespace Volian.Controls.Library
else else
{ {
ItemInfo iiPasteHere = tn.VEObject as ItemInfo; ItemInfo iiPasteHere = tn.VEObject as ItemInfo;
if (iiPasteHere == null) return; if (iiPasteHere == null) return;
bool okToReplace = iiClipboard.ItemID != iiPasteHere.ItemID; bool okToReplace = iiClipboard.ItemID != iiPasteHere.ItemID;
if (iiPasteHere != null) if (iiPasteHere != null)
{ {
SectionInfo si = (tn.VEObject as SectionInfo != null) ? tn.VEObject as SectionInfo : null; SectionInfo si = (tn.VEObject as SectionInfo != null) ? tn.VEObject as SectionInfo : null;
if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after
{ {
cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click)); cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click));
if (okToReplace) cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click)); if (okToReplace) cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click));
cm.MenuItems.Add("Paste Procedure After", new EventHandler(mi_Click)); cm.MenuItems.Add("Paste Procedure After", new EventHandler(mi_Click));
} }
else if (iiPasteHere.IsProcedure && iiClipboard.IsSection) // procedure must have sections only else if (iiPasteHere.IsProcedure && iiClipboard.IsSection) // procedure must have sections only
@ -1122,7 +1121,7 @@ namespace Volian.Controls.Library
else if (iiPasteHere.IsSection && iiClipboard.IsSection) else if (iiPasteHere.IsSection && iiClipboard.IsSection)
{ {
cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click)); cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click));
if (okToReplace) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click)); if (okToReplace) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
cm.MenuItems.Add("Paste Section After", new EventHandler(mi_Click)); cm.MenuItems.Add("Paste Section After", new EventHandler(mi_Click));
if (si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections && iiPasteHere.IsStepSection && iiClipboard.IsStepSection) if (si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections && iiPasteHere.IsStepSection && iiClipboard.IsStepSection)
{ {
@ -1137,7 +1136,7 @@ namespace Volian.Controls.Library
else if (iiPasteHere.IsStep && iiClipboard.IsStep) else if (iiPasteHere.IsStep && iiClipboard.IsStep)
{ {
if (AddToInsertMenu(iiPasteHere, 0)) cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click)); if (AddToInsertMenu(iiPasteHere, 0)) cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click));
if (okToReplace) cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click)); if (okToReplace) cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
if (AddToInsertMenu(iiPasteHere, 1)) cm.MenuItems.Add("Paste Step After", new EventHandler(mi_Click)); if (AddToInsertMenu(iiPasteHere, 1)) cm.MenuItems.Add("Paste Step After", new EventHandler(mi_Click));
} }
} }
@ -1378,31 +1377,35 @@ namespace Volian.Controls.Library
private void UpdateROValues(VETreeNode tn) private void UpdateROValues(VETreeNode tn)
{ {
InitialProgressBarMessage = "Updating ROs";
DocVersionInfo MyDVI = tn.VEObject as DocVersionInfo; DocVersionInfo MyDVI = tn.VEObject as DocVersionInfo;
// use rodb directory path of the first rofst for the this document version. Later, will need // use rodb directory path of the first rofst for the this document version. Later, will need
// to modify code to get which one (when there is more than one) // to modify code to get which one (when there is more than one)
if (MyDVI.DocVersionAssociations.Count < 1) if (MyDVI.DocVersionAssociations.Count < 1)
{ {
MessageBox.Show("Error Updating ro.fst. No associated ro.fst"); MessageBox.Show("Error Updating ro.fst. No associated ro.fst");
FinalProgressBarMessage = "No ROs associated";
return; return;
} }
ROFstInfo roFstInfo = MyDVI.DocVersionAssociations[0].MyROFst; ROFstInfo roFstInfo = MyDVI.DocVersionAssociations[0].MyROFst;
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst"; string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) if (!File.Exists(rofstPath))
{ {
MessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path"); MessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path");
FinalProgressBarMessage = "No existing RO.FST";
return; return;
} }
FileInfo fiRofst = new FileInfo(rofstPath); FileInfo fiRofst = new FileInfo(rofstPath);
if (roFstInfo.DTS == fiRofst.LastWriteTimeUtc) if (roFstInfo.DTS == fiRofst.LastWriteTimeUtc)
{ {
MessageBox.Show("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done"); MessageBox.Show("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
FinalProgressBarMessage = "RO.FST up to date";
return; return;
} }
if (roFstInfo.DTS > fiRofst.LastWriteTimeUtc) if (roFstInfo.DTS > fiRofst.LastWriteTimeUtc)
{ {
MessageBox.Show("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done"); MessageBox.Show("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done");
FinalProgressBarMessage = "Older RO.FST";
return; return;
} }
Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
@ -1410,18 +1413,56 @@ namespace Volian.Controls.Library
if (!MySessionInfo.CanCheckOutItem(MyDVI.VersionID, CheckOutType.DocVersion, ref message)) if (!MySessionInfo.CanCheckOutItem(MyDVI.VersionID, CheckOutType.DocVersion, ref message))
{ {
MessageBox.Show(this, message, "Working Draft Has Items Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show(this, message, "Working Draft Has Items Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
FinalProgressBarMessage = "Cannot check-out Working Draft";
return; return;
} }
int ownerid = MySessionInfo.CheckOutItem(MyDVI.VersionID, CheckOutType.DocVersion); int ownerid = MySessionInfo.CheckOutItem(MyDVI.VersionID, CheckOutType.DocVersion);
using (DocVersion dv = DocVersion.Get(MyDVI.VersionID)) using (DocVersion dv = DocVersion.Get(MyDVI.VersionID))
{ {
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo); ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh);
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST"); StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST");
} }
MySessionInfo.CheckInItem(ownerid); MySessionInfo.CheckInItem(ownerid);
Cursor = Cursors.Default; Cursor = Cursors.Default;
FinalProgressBarMessage = "ROs values updated";
}
private ProgressBarItem _ProgressBar=null;
public ProgressBarItem ProgressBar
{
get { return _ProgressBar; }
set { _ProgressBar = value; }
}
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;
Application.DoEvents();
}
}
private string FinalProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 100;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
} }
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args) public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{ {
@ -1514,8 +1555,8 @@ namespace Volian.Controls.Library
} }
private void tv_NodePaste(string p) private void tv_NodePaste(string p)
{ {
ItemInfo iiClipboard = OnClipboardStatus(this, null); ItemInfo iiClipboard = OnClipboardStatus(this, null);
if (iiClipboard == null) return; if (iiClipboard == null) return;
string message = string.Empty; string message = string.Empty;
if (iiClipboard.MyContent.MyEntry == null) if (iiClipboard.MyContent.MyEntry == null)
{ {
@ -1557,23 +1598,23 @@ namespace Volian.Controls.Library
this.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.WaitCursor;
PasteAsDocVersionChild(tn, iiClipboard.ItemID); PasteAsDocVersionChild(tn, iiClipboard.ItemID);
this.Cursor = Cursors.Default; this.Cursor = Cursors.Default;
return; return;
} }
} }
ItemInfo iiPaste = tn.VEObject as ItemInfo; ItemInfo iiPaste = tn.VEObject as ItemInfo;
if (iiPaste == null) return; if (iiPaste == null) return;
this.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.WaitCursor;
if (p.IndexOf("Before") > -1) if (p.IndexOf("Before") > -1)
PasteBeforeOrAfter(MenuSelections.StepBefore, tn, iiClipboard.ItemID); PasteBeforeOrAfter(MenuSelections.StepBefore, tn, iiClipboard.ItemID);
else if (p.IndexOf("After") > -1) else if (p.IndexOf("After") > -1)
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID); PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
else if (p.IndexOf("Replace") > -1) else if (p.IndexOf("Replace") > -1)
PasteReplace(tn, iiClipboard.ItemID); PasteReplace(tn, iiClipboard.ItemID);
else // paste as child else // paste as child
PasteAsChild(tn, iiClipboard.ItemID); PasteAsChild(tn, iiClipboard.ItemID);
this.Cursor = Cursors.Default; this.Cursor = Cursors.Default;
} }
private void PasteAsDocVersionChild(VETreeNode tn, int copyStartID) private void PasteAsDocVersionChild(VETreeNode tn, int copyStartID)
{ {