Added code to support refreshing display based on changes made by another user

This commit is contained in:
Jim
2015-04-14 02:59:18 +00:00
parent 5282ef114d
commit 36518e7a82
3 changed files with 195 additions and 11 deletions

View File

@@ -554,6 +554,10 @@ namespace VEPROMS.CSLA.Library
}
public partial class ContentInfo
{
public static bool IsInCache(int contentID)
{
return _CacheByPrimaryKey.ContainsKey(contentID.ToString());
}
public static event StaticContentInfoEvent StaticContentInfoChange;
private static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
@@ -979,5 +983,66 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
public static ContentInfoList GetChangedList(byte[] lastChanged)
{
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ChangeListCriteria(lastChanged));
// ContentInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentInfoList.GetChangedList", ex);
}
}
[Serializable()]
private class ChangeListCriteria
{
private byte[] _LastChanged;
public byte[] LastChanged
{
get { return _LastChanged; }
set { _LastChanged = value; }
}
public ChangeListCriteria(byte[] lastChanged)
{
_LastChanged = lastChanged;
}
}
private void DataPortal_Fetch(ChangeListCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ListContentsAfterLastChanged";
cm.Parameters.AddWithValue("@LastChanged", criteria.LastChanged);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
}