Modified code to support structure changes to treeview nodes

This commit is contained in:
Jim
2015-05-16 17:02:26 +00:00
parent f66cb15dd3
commit f005316849
9 changed files with 309 additions and 79 deletions

View File

@@ -72,7 +72,9 @@ namespace VEPROMS
this.lblItemID = new DevComponents.DotNetBar.LabelItem();
this.lblResolution = new DevComponents.DotNetBar.LabelItem();
this.lblUser = new DevComponents.DotNetBar.LabelItem();
this.lblLastChange = new DevComponents.DotNetBar.LabelItem();
//this.txtSearch = new DevComponents.DotNetBar.TextBoxItem(); // RHM20150506 Multiline ItemID TextBox
this.btnStepRTF = new DevComponents.DotNetBar.ButtonItem();
this.txtSearch = new System.Windows.Forms.TextBox();
this.btnPrevious = new System.Windows.Forms.Button();
this.btnPrint1 = new System.Windows.Forms.Button();
@@ -507,6 +509,8 @@ namespace VEPROMS
this.lblResolution,
this.btnEditItem,
this.lblUser,
this.lblLastChange,
this.btnStepRTF,
//this.txtSearch, // RHM20150506 Multiline ItemID TextBox
this.btnFixMSWord});
this.bottomBar.Location = new System.Drawing.Point(5, 569);
@@ -607,6 +611,19 @@ namespace VEPROMS
this.lblUser.Name = "lblUser";
this.lblUser.Text = "User";
//
// btnStepRTF
//
this.btnStepRTF.Name = "btnStepRTF";
this.btnStepRTF.Text = "Step RTF";
//this.btnStepRTF.Click += new System.EventHandler(btnStepRTF_Click);
//
// lblLastChange
//
this.lblLastChange.BackColor = System.Drawing.Color.Transparent;
this.lblLastChange.ForeColor = System.Drawing.SystemColors.MenuText;
this.lblLastChange.Name = "lblLastChange";
this.lblLastChange.Text = "LastChange";
//
// txtSearch
//
this.txtSearch.Name = "txtSearch";
@@ -1664,8 +1681,10 @@ namespace VEPROMS
private System.Windows.Forms.ComboBox cmbFont;
private DevComponents.DotNetBar.LabelItem lblResolution;
private DevComponents.DotNetBar.LabelItem lblUser;
private DevComponents.DotNetBar.LabelItem lblLastChange;
//private DevComponents.DotNetBar.TextBoxItem txtSearch; // RHM20150506 Multiline ItemID TextBox
private System.Windows.Forms.TextBox txtSearch;
private DevComponents.DotNetBar.ButtonItem btnStepRTF;
private System.Windows.Forms.Button btnPrevious;
private System.Windows.Forms.Button btnPrint1;
private System.Windows.Forms.CheckBox cbScrunch;

View File

@@ -39,7 +39,16 @@ namespace VEPROMS
StepTabPanel _SelectedStepTabPanel = null;
public FindReplace dlgFindReplace = null;
public VlnSpellCheck SpellChecker = null;
private Int64 _LastContentChange;
public Int64 LastContentChange
{
get { return _LastContentChange; }
set { _LastContentChange = value; }
}
public void RefreshLastChange()
{
lblLastChange.Text = string.Format("Last Change: {0}", MySessionInfo.LastContentChange - this.LastContentChange);
}
public StepTabPanel SelectedStepTabPanel
{
get
@@ -450,7 +459,8 @@ namespace VEPROMS
{
log4net.Appender.FileAppender fApp = (log4net.Appender.FileAppender)iApp;
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
fApp.File = folderPath + @"\VEPROMS\" + (Volian.Base.Library.VlnSettings.GetCommand("U","") + "_").TrimStart("_".ToCharArray()) + NewFilename;
//fApp.File = folderPath + @"\VEPROMS\" + (Volian.Base.Library.VlnSettings.GetCommand("U","") + "_").TrimStart("_".ToCharArray()) + NewFilename;
fApp.File = folderPath + @"\VEPROMS\" + (Volian.Base.Library.VlnSettings.GetCommand("prefix", "") + "_").TrimStart("_".ToCharArray()) + NewFilename;
ErrorLogFileName = fApp.File;
fApp.ActivateOptions();
return true; // Appender found and name changed to NewFilename
@@ -886,16 +896,8 @@ namespace VEPROMS
{
get { return _MyCloseTabList; }
}
private int myCounterPingSession = 0;
private int myCounterRefreshChanged = 0;
private void PingSession(Object obj)
{
myCounterPingSession++;
if (myCounterPingSession > 10)
{
_MyLog.InfoFormat("Ping Session at: {0} with LastChanged of: {1}", DateTime.Now.ToString("yyyyMMdd HHmmssnnn"), MySessionInfo.LastChanged);
myCounterPingSession = 0;
}
MySemaphore.WaitOne();
List<int> myList = MySessionInfo.PingSession();
foreach (DisplayTabItem dti in tc.MyBar.Items)
@@ -905,31 +907,72 @@ namespace VEPROMS
}
MySemaphore.Release();
}
WindowsFormsSynchronizationContext mUIContext = new WindowsFormsSynchronizationContext();
public void MyFindNodeAndExpand(object obj)
{
int id = (int)obj;
ItemInfo ii = ItemInfo.Get(id);
ii.ResetParts();
using (Item i = Item.Get(id))
ItemInfo.Refresh(i);
tv.RefreshRelatedNode(ii);
}
private void RefreshChanged(Object obj)
{
myCounterRefreshChanged++;
if (myCounterRefreshChanged > 10)
{
_MyLog.InfoFormat("RefreshChanged at: {0} with LastChanged of: {1}", DateTime.Now.ToString("yyyyMMdd HHmmssnnn"), MySessionInfo.LastChanged);
myCounterRefreshChanged = 0;
}
MySemaphore.WaitOne();
string lastChanged = string.Empty;
foreach (int id in MySessionInfo.ChangedContents.Keys)
try
{
using (Content c = Content.Get(id))
Int64 lastChanged = 0;
if (MySessionInfo.ChangedItems.Count > 0)
{
_MyLog.InfoFormat("Text of contentid: {0} is {1}", id, c.Text);
ContentInfo.Refresh(c);
foreach (int id in MySessionInfo.ChangedItems.Keys)
{
if (ItemInfo.IsInCache(id))
mUIContext.Post(MyFindNodeAndExpand, id);
}
}
if (MySessionInfo.ChangedContents.Count > 0)
foreach (int id in MySessionInfo.ChangedContents.Keys)
{
if (ContentInfo.IsInCache(id))
{
ContentInfo ci = ContentInfo.Get(id);
//if (ci.LastChangedInt64 > MySessionInfo.LastChangedInt64)
if (MySessionInfo.LastContentChange >= ci.LastChangedInt64)
{
using (Content c = Content.Get(id))
{
ContentInfo.Refresh(c);
}
}
}
lastChanged = MySessionInfo.ChangedContents[id];
_MyLog.InfoFormat("Refreshing contentid: {0} with LastChanged of {1}", id, lastChanged);
}
MySessionInfo.ChangedItems.Clear();
MySessionInfo.ChangedContents.Clear();
if (lastChanged > 0)
{
MySessionInfo.LastContentChange = lastChanged;
RefreshLastChange();
}
}
MySessionInfo.ChangedContents.Clear();
if(lastChanged != string.Empty)
MySessionInfo.LastChanged = lastChanged;
catch
{
}
MySemaphore.Release();
}
private bool ByteArrayIsEmpty(byte[] myArray)
{
for (int i = 0; i < myArray.Length; i++)
{
if (myArray[i] != 0)
return false;
}
return true;
}
public ContentInfo ci1;
public ContentInfo ci2;
public ContentInfo ci3;
public Timer tmrCloseTabItems;
public System.Threading.Semaphore MySemaphore = new System.Threading.Semaphore(1, 1);
private void frmVEPROMS_Load(object sender, EventArgs e)
@@ -979,17 +1022,19 @@ namespace VEPROMS
tmrCloseTabItems.Tick += new EventHandler(tmrCloseTabItems_Tick);
tmrCloseTabItems.Enabled = true;
MySessionInfo = SessionInfo.BeginSession(Environment.MachineName, System.Diagnostics.Process.GetCurrentProcess().Id);
if (MySessionInfo == null)
{
MessageBox.Show("This database is locked by the Administrator. Please try again later", "PROMS is Locked");
Application.Exit();
}
this.LastContentChange = MySessionInfo.LastContentChange;
RefreshLastChange();
if (MySessionInfo == null)
{
MessageBox.Show("This database is locked by the Administrator. Please try again later", "PROMS is Locked");
Application.Exit();
}
tc.MySessionInfo = MySessionInfo;
tv.MySessionInfo = MySessionInfo;
System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false);
//System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(MySessionInfo.PingSession);
//System.Diagnostics.Process xyzzy = System.Diagnostics.Process.GetCurrentProcess();
if(!System.Diagnostics.Debugger.IsAttached)
if (!System.Diagnostics.Debugger.IsAttached)
{
System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(this.PingSession);
MyActivityTimer = new System.Threading.Timer(timerDelegate, autoEvent, 10000, 10000);
@@ -1003,7 +1048,7 @@ namespace VEPROMS
// get the saved location and size of the VE-PROMS appication for this user
this.txtSearch.KeyPress += new KeyPressEventHandler(txtSearch_KeyPress);
this.txtSearch.KeyUp += txtSearch_KeyUp; // RHM20150506 Multiline ItemID TextBox
this.txtSearch.TextChanged+=txtSearch_TextChanged; // RHM20150506 Multiline ItemID TextBox
this.txtSearch.TextChanged += txtSearch_TextChanged; // RHM20150506 Multiline ItemID TextBox
this.btnNext.Click += btnNext_Click; // RHM20150506 Multiline ItemID TextBox
this.btnPrint1.Click += btnPrint1_Click; // RHM20150506 Multiline ItemID TextBox
this.cbScrunch.Click += cbScrunch_Click; // RHM20150506 Multiline ItemID TextBox
@@ -1015,7 +1060,7 @@ namespace VEPROMS
// if the Procedures panel was left open from the last session, then open it
epProcedures.Expanded = Settings.Default.TreeviewExpanded;
if (Settings.Default["QATItems"] != null) ribbonControl1.QatLayout = Settings.Default.QATItems;
// See if any database 'changes' need done and do them:
MakeDatabaseChanges();
@@ -1042,7 +1087,7 @@ namespace VEPROMS
ctrlAnnotationDetails.SetupAnnotations(displaySearch1);
SetupButtons();
displayBookMarks.MyDisplayTabControl = tc; // allows bookmark selection to bring up steps/docs
office2007StartButton1.MouseDown +=new MouseEventHandler(office2007StartButton1_MouseDown);
office2007StartButton1.MouseDown += new MouseEventHandler(office2007StartButton1_MouseDown);
//displayRO.EnabledChanged += new EventHandler(displayRO_EnabledChanged);
tc.Enter += new EventHandler(tc_Enter);
tc.Leave += new EventHandler(tc_Leave);
@@ -1068,7 +1113,7 @@ namespace VEPROMS
// btnAdmin.Visible = false;
StepTabRibbon.PasteNoReturnsSetting = Properties.Settings.Default.PasteNoReturns;
StepTabRibbon.PastePlainTextSetting = Properties.Settings.Default.PastePlainText;
Activate();
Activate();
//FolderInfo fi = FolderInfo.Get(1);
//FormatInfo frmI = FormatInfo.Get(fi.FormatID ?? 1);
//if (frmI.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds)
@@ -1076,8 +1121,8 @@ namespace VEPROMS
// dlgChgId dlgCI = new dlgChgId(tc);
// dlgCI.ShowDialog(this);
//}
// RHM20150506 Multiline ItemID TextBox
this.txtSearch.Text = Volian.Base.Library.VlnSettings.GetCommand("ItemIDs", "").Replace(",","\r\n");
// RHM20150506 Multiline ItemID TextBox
this.txtSearch.Text = Volian.Base.Library.VlnSettings.GetCommand("ItemIDs", "").Replace(",", "\r\n");
}
void cbScrunch_Click(object sender, EventArgs e) // RHM20150506 Multiline ItemID TextBox
{
@@ -1090,11 +1135,11 @@ namespace VEPROMS
foreach (string id in ids)
{
if(id != "")
{
{
ItemInfo ii = GetItemInfoFromString(id);
if (!dicProcs.ContainsKey(ii.MyProcedure.ItemID))
dicProcs.Add(ii.MyProcedure.ItemID, ii.MyProcedure);
}
}
}
DialogResult dr = System.Windows.Forms.DialogResult.Yes;
//dr = MessageBox.Show("Do you want all of the PDFs to be opened?", "Open After Create", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
@@ -1228,22 +1273,22 @@ namespace VEPROMS
}
}
if (e.KeyChar == 1 || e.KeyChar==22)
{
{
e.Handled = true;
}
}
}
private void OpenMyItem(string str) // RHM20150506 Multiline ItemID TextBox
{
ItemInfo ii = GetItemInfoFromString(str); // RHM20150506 Multiline ItemID TextBox
if (ii != null)
{
tc.OpenItem(ii);
tv.AdjustTree(ii);
}
else
MessageBox.Show("No item found");
}
if (ii != null)
{
tc.OpenItem(ii);
tv.AdjustTree(ii);
}
else
MessageBox.Show("No item found");
}
private static ItemInfo GetItemInfoFromString(string str) // RHM20150506 Multiline ItemID TextBox
{
@@ -1886,7 +1931,7 @@ namespace VEPROMS
this.Cursor = Cursors.Default;
return DialogResult.None;
}
int ownerID = MySessionInfo.CheckOutItem(args.ProcedureConfig.MyProcedure.ItemID, 0);
int ownerID = MySessionInfo.CheckOutItem(args.ProcedureConfig.MyProcedure.ItemID, CheckOutType.Procedure);
frmProcedureProperties frmproc = new frmProcedureProperties(args.ProcedureConfig);
dr = frmproc.ShowDialog();
MySessionInfo.CheckInItem(ownerID);
@@ -1902,12 +1947,25 @@ namespace VEPROMS
//}
frmSectionProperties frmsec = new frmSectionProperties(args.SectionConfig);
string message = string.Empty;
if (!MySessionInfo.CanCheckOutItem(args.SectionConfig.MySection.MySectionInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message))
{
MessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.Cursor = Cursors.Default;
return DialogResult.None;
}
int ownerID;
if (args.SectionConfig.MySection.MyContent.MyEntry.MyDocument == null)
ownerID = MySessionInfo.CheckOutItem(args.SectionConfig.MySection.MySectionInfo.MyProcedure.ItemID, CheckOutType.Procedure);
else
ownerID = MySessionInfo.CheckOutItem(args.SectionConfig.MySection.MyContent.MyEntry.MyDocument.DocID, CheckOutType.Document);
dr = frmsec.ShowDialog();
if (dr == DialogResult.OK && displayLibDocs.LibDocList != null)
{
displayLibDocs.LibDocListFillIn(tc);
displayLibDocs.SetSelectedLibDoc();
}
MySessionInfo.CheckInItem(ownerID);
}
}
this.Cursor = Cursors.Default;