From f0053168497e2ef17002801eb02e4a9b5272409e Mon Sep 17 00:00:00 2001 From: Jim Date: Sat, 16 May 2015 17:02:26 +0000 Subject: [PATCH] Modified code to support structure changes to treeview nodes --- .../frmVEPROMS.Designer.cs | 19 +++ PROMS/VEPROMS User Interface/frmVEPROMS.cs | 158 ++++++++++++------ .../Extension/ContentExt.cs | 22 +++ .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 11 +- .../Extension/MultiUserExt.cs | 115 ++++++++++--- .../VEPROMS.CSLA.Library/Generated/Content.cs | 10 ++ .../Generated/ContentInfo.cs | 14 ++ .../Generated/SessionInfo.cs | 2 + PROMS/Volian.Controls.Library/vlnTreeView.cs | 37 ++++ 9 files changed, 309 insertions(+), 79 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs index d38ff883..20db69f5 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs @@ -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; diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index b3b1f43f..00d45dec 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -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 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; diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs index 6a77b4b3..fefbbad2 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs @@ -12,6 +12,10 @@ namespace VEPROMS.CSLA.Library { public partial class Content { + public string LastChangedString + { + get { return ContentInfo.FormatByteArray(_LastChanged); } + } public override string ToString() { return string.Format("{0} {1}", Number, Text); @@ -554,6 +558,24 @@ namespace VEPROMS.CSLA.Library } public partial class ContentInfo { + public static string FormatByteArray(byte[] myArray) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < myArray.Length; i++) + { + sb.Append(string.Format("{0:x2}", myArray[i])); + } + return sb.ToString(); + } + public string LastChangedString + { + get { return ContentInfo.FormatByteArray(_LastChanged); } + } + //Convert.ToInt64( ByteArrayToHexString(_ts), 16 ) ) + public Int64 LastChangedInt64 + { + get { return Convert.ToInt64(LastChangedString, 16); } + } public static bool IsInCache(int contentID) { return _CacheByPrimaryKey.ContainsKey(contentID.ToString()); diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 0077bc9e..2ac3afc0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -352,6 +352,10 @@ namespace VEPROMS.CSLA.Library if (id == ItemID) return true; return false; } + public static bool IsInCache(int itemID) + { + return _CacheByPrimaryKey.ContainsKey(itemID.ToString()); + } public void SetHeader(VE_Font myFont, string myText) { _MyHeader = new MetaTag(myFont); @@ -2588,6 +2592,7 @@ namespace VEPROMS.CSLA.Library #region Lookups and More Related private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList) { + Console.WriteLine(itemInfoList); if (itemInfoList == null) itemInfoList = Lookup(fromType); return itemInfoList; @@ -3863,9 +3868,9 @@ namespace VEPROMS.CSLA.Library (MyPrevious != null && MyPrevious.MyContent.Type == MyContent.Type) || (NextItem != null && nextItem.MyContent.Type == MyContent.Type)) { - tbformat = tbformat + ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB; - TabToIdentBAdjustFont(); - } + tbformat = tbformat + ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB; + TabToIdentBAdjustFont(); + } } else if (FormatStepData.TabData.IsTransition) return tbformat; diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs index 4ff4475b..26357580 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs @@ -68,8 +68,14 @@ namespace VEPROMS.CSLA.Library #region SessionInfo stuff public partial class SessionInfo { - private string _LastChanged = string.Empty; - public string LastChanged + private Int64 _LastContentChange; + public Int64 LastContentChange + { + get { return _LastContentChange; } + set { _LastContentChange = value; } + } + private byte[] _LastChanged = new byte[8]; + public byte[] LastChanged { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get @@ -79,6 +85,14 @@ namespace VEPROMS.CSLA.Library } set { _LastChanged = value; } } + public string LastChangedString + { + get { return ContentInfo.FormatByteArray(_LastChanged); } + } + public Int64 LastChangedInt64 + { + get { return Convert.ToInt64(LastChangedString, 16); } + } public static SessionInfo BeginSession(string machineName, int processID) { try @@ -96,26 +110,24 @@ namespace VEPROMS.CSLA.Library throw new DbCslaException("Error on SessionInfo.BeginSession", ex); } } - private Dictionary _ChangedContents; - public Dictionary ChangedContents + private Dictionary _ChangedContents; + public Dictionary ChangedContents { get { return _ChangedContents; } set { _ChangedContents = value; } } + private Dictionary _ChangedItems; + public Dictionary ChangedItems + { + get { return _ChangedItems; } + set { _ChangedItems = value; } + } public List PingSession() { List myList = new List(); SessionPing.Execute(this.SessionID); - ChangedContents = SessionChangedContents.Execute(this.LastChanged); - //ContentInfoList cil = ContentInfoList.GetChangedList(Convert.FromBase64String(this.LastChanged)); - //foreach (ContentInfo ci in cil) - // if (!ChangedContentIDs.ContainsKey(ci.ContentID)) - // ChangedContentIDs.Add(ci.ContentID, false); - //foreach(ContentInfo ci in cil) - // if(ContentInfo.IsInCache(ci.ContentID)) - // using (Content cc = ci.Get()) - // ContentInfo.Refresh(cc); - + ChangedContents = SessionChangedContents.Execute(this.LastContentChange); + ChangedItems = SessionChangedItems.Execute(this.LastContentChange); OwnerInfoList oil = OwnerInfoList.GetBySessionID(this.SessionID); foreach (OwnerInfo oi in oil) myList.Add(oi.OwnerID); @@ -234,7 +246,6 @@ namespace VEPROMS.CSLA.Library return; } ReadData(dr); - _LastChanged = Convert.ToBase64String(dr["LastChanged"] as byte[]); } } // removing of item only needed for local data portal @@ -622,23 +633,23 @@ namespace VEPROMS.CSLA.Library public class SessionChangedContents : CommandBase { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private string _LastChanged; - public string LastChanged + private Int64 _LastContentChange; + public Int64 LastContentChange { - get { return _LastChanged; } - set { _LastChanged = value; } + get { return _LastContentChange; } + set { _LastContentChange = value; } } - private Dictionary _ChangedContents; - public Dictionary ChangedContents + private Dictionary _ChangedContents; + public Dictionary ChangedContents { get { return _ChangedContents; } set { _ChangedContents = value; } } #region Factory Methods - public static Dictionary Execute(string lastChanged) + public static Dictionary Execute(Int64 lastContentChanged) { SessionChangedContents cmd = new SessionChangedContents(); - cmd.LastChanged = lastChanged; + cmd.LastContentChange = lastContentChanged; cmd = DataPortal.Execute(cmd); return cmd.ChangedContents; } @@ -654,12 +665,12 @@ namespace VEPROMS.CSLA.Library { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; - cmd.Parameters.AddWithValue("@LastChanged", Convert.FromBase64String(LastChanged)); + cmd.Parameters.AddWithValue("@LastChanged", LastContentChange); cmd.Parameters.AddWithValue("@UserID", Volian.Base.Library.VlnSettings.UserID); SqlDataReader dr = cmd.ExecuteReader(); - ChangedContents = new Dictionary(); + ChangedContents = new Dictionary(); while (dr.Read()) - ChangedContents.Add(dr.GetInt32(0), Convert.ToBase64String(dr["LastChanged"] as byte[])); + ChangedContents.Add(dr.GetInt32(0), (Int64)dr.GetSqlInt64(1)); } } } @@ -671,6 +682,58 @@ namespace VEPROMS.CSLA.Library } #endregion } + public class SessionChangedItems : CommandBase + { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private Int64 _LastContentChange; + public Int64 LastContentChange + { + get { return _LastContentChange; } + set { _LastContentChange = value; } + } + private Dictionary _ChangedItems; + public Dictionary ChangedItems + { + get { return _ChangedItems; } + set { _ChangedItems = value; } + } + #region Factory Methods + public static Dictionary Execute(Int64 lastContentChanged) + { + SessionChangedItems cmd = new SessionChangedItems(); + cmd.LastContentChange = lastContentChanged; + cmd = DataPortal.Execute(cmd); + return cmd.ChangedItems; + } + #endregion + #region Server-Side Code + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cmd = new SqlCommand("vesp_ListItemsAfterLastChanged", cn)) + { + cmd.CommandType = CommandType.StoredProcedure; + cmd.CommandTimeout = 0; + cmd.Parameters.AddWithValue("@LastChanged", LastContentChange); + cmd.Parameters.AddWithValue("@UserID", Volian.Base.Library.VlnSettings.UserID); + SqlDataReader dr = cmd.ExecuteReader(); + ChangedItems = new Dictionary(); + while (dr.Read()) + ChangedItems.Add(dr.GetInt32(0), (Int64)dr.GetSqlInt64(1)); + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionChangedItems Error", ex); + throw new ApplicationException("Failure on SessionChangedItems", ex); + } + } + #endregion + } #endregion #region OwnerInfo stuff public partial class OwnerInfoList diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs index 8e04fc1a..4b0baae2 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs @@ -345,6 +345,16 @@ namespace VEPROMS.CSLA.Library } } private byte[] _LastChanged = new byte[8];//timestamp + public byte[] LastChanged + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("LastChanged", true); + return _LastChanged; + } + set { _LastChanged = value; } + } private int _ContentDetailCount = 0; /// /// Count of ContentDetails for this Content diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs index 5eb859df..a9a2a7c2 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs @@ -117,6 +117,18 @@ namespace VEPROMS.CSLA.Library return _ContentID; } } + private byte[] _LastChanged = new byte[8];//timestamp + public byte[] LastChanged + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("LastChanged", true); + return _LastChanged; + } + set { _LastChanged = value; } + } + private string _Number = string.Empty; /// /// Increased from 30 to 256 to support RTF symbols @@ -631,6 +643,7 @@ namespace VEPROMS.CSLA.Library _Config = tmp.Config; _DTS = tmp.DTS; _UserID = tmp.UserID; + _LastChanged = tmp.LastChanged; _ContentInfoExtension.Refresh(this); _ContentEntryCount = -1;// Reset Count _ContentGridCount = -1;// Reset Count @@ -724,6 +737,7 @@ namespace VEPROMS.CSLA.Library _Config = dr.GetString("Config"); _DTS = dr.GetDateTime("DTS"); _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); _ContentDetailCount = dr.GetInt32("DetailCount"); _ContentEntryCount = dr.GetInt32("EntryCount"); _ContentGridCount = dr.GetInt32("GridCount"); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/SessionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/SessionInfo.cs index 857d80b9..7d57ff78 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/SessionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/SessionInfo.cs @@ -304,6 +304,8 @@ namespace VEPROMS.CSLA.Library _DTSActivity = dr.GetDateTime("DTSActivity"); _MachineName = dr.GetString("MachineName"); _ProcessID = dr.GetInt32("ProcessID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + _LastContentChange = dr.GetInt64("LastContentChange"); } catch (Exception ex) { diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 4bb474b6..e79496a9 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -2909,6 +2909,43 @@ namespace Volian.Controls.Library if (parent == null) return null; if (!parent.IsExpanded) parent.Expand(); + VETreeNode child = GetChildNode(selectedItem, parent); + if (child != null) + return child; + parent.ChildrenLoaded = false; + parent.RefreshNode(); + child = GetChildNode(selectedItem, parent); + return child; + } + public VETreeNode FindNode(IVEDrillDownReadOnly selectedItem, TreeNodeCollection tnc) + { + foreach (TreeNode tn in tnc) + if (tn is VETreeNode) + { + if ((tn as VETreeNode).VEObject is ItemInfo && ((tn as VETreeNode).VEObject as ItemInfo).ItemID == (selectedItem as ItemInfo).ItemID) + return tn as VETreeNode; + else + { + VETreeNode cn = FindNode(selectedItem, tn.Nodes); + if (cn != null) + return cn; + } + } + return null; + } + public VETreeNode RefreshRelatedNode(IVEDrillDownReadOnly selectedItem) + { + VETreeNode child = FindNode(selectedItem, this.Nodes); + if (child == null) return null; + if (!child.IsExpanded) + child.Expand(); + child.ChildrenLoaded = false; + child.RefreshNode(); + return child; + } + + private VETreeNode GetChildNode(IVEDrillDownReadOnly selectedItem, VETreeNode parent) + { foreach (TreeNode childNode in parent.Nodes) { VETreeNode child = childNode as VETreeNode;