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

@@ -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());

View File

@@ -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;

View File

@@ -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<int, string> _ChangedContents;
public Dictionary<int, string> ChangedContents
private Dictionary<int, Int64> _ChangedContents;
public Dictionary<int, Int64> ChangedContents
{
get { return _ChangedContents; }
set { _ChangedContents = value; }
}
private Dictionary<int, Int64> _ChangedItems;
public Dictionary<int, Int64> ChangedItems
{
get { return _ChangedItems; }
set { _ChangedItems = value; }
}
public List<int> PingSession()
{
List<int> myList = new List<int>();
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<int, string> _ChangedContents;
public Dictionary<int, string> ChangedContents
private Dictionary<int,Int64> _ChangedContents;
public Dictionary<int, Int64> ChangedContents
{
get { return _ChangedContents; }
set { _ChangedContents = value; }
}
#region Factory Methods
public static Dictionary<int, string> Execute(string lastChanged)
public static Dictionary<int, Int64> Execute(Int64 lastContentChanged)
{
SessionChangedContents cmd = new SessionChangedContents();
cmd.LastChanged = lastChanged;
cmd.LastContentChange = lastContentChanged;
cmd = DataPortal.Execute<SessionChangedContents>(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<int, string>();
ChangedContents = new Dictionary<int, Int64>();
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<int, Int64> _ChangedItems;
public Dictionary<int, Int64> ChangedItems
{
get { return _ChangedItems; }
set { _ChangedItems = value; }
}
#region Factory Methods
public static Dictionary<int, Int64> Execute(Int64 lastContentChanged)
{
SessionChangedItems cmd = new SessionChangedItems();
cmd.LastContentChange = lastContentChanged;
cmd = DataPortal.Execute<SessionChangedItems>(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<int, Int64>();
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