Added code to support refreshing display based on changes made by another user
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,6 +68,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#region SessionInfo stuff
|
||||
public partial class SessionInfo
|
||||
{
|
||||
private string _LastChanged = string.Empty;
|
||||
public string LastChanged
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("LastChanged", true);
|
||||
return _LastChanged;
|
||||
}
|
||||
set { _LastChanged = value; }
|
||||
}
|
||||
public static SessionInfo BeginSession(string machineName, int processID)
|
||||
{
|
||||
try
|
||||
@@ -85,10 +96,26 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error on SessionInfo.BeginSession", ex);
|
||||
}
|
||||
}
|
||||
private Dictionary<int, string> _ChangedContents;
|
||||
public Dictionary<int, string> ChangedContents
|
||||
{
|
||||
get { return _ChangedContents; }
|
||||
set { _ChangedContents = 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);
|
||||
|
||||
OwnerInfoList oil = OwnerInfoList.GetBySessionID(this.SessionID);
|
||||
foreach (OwnerInfo oi in oil)
|
||||
myList.Add(oi.OwnerID);
|
||||
@@ -188,6 +215,7 @@ namespace VEPROMS.CSLA.Library
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
_LastChanged = Convert.ToBase64String(dr["LastChanged"] as byte[]);
|
||||
}
|
||||
}
|
||||
// removing of item only needed for local data portal
|
||||
@@ -572,6 +600,58 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class SessionChangedContents : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private string _LastChanged;
|
||||
public string LastChanged
|
||||
{
|
||||
get { return _LastChanged; }
|
||||
set { _LastChanged = value; }
|
||||
}
|
||||
private Dictionary<int, string> _ChangedContents;
|
||||
public Dictionary<int, string> ChangedContents
|
||||
{
|
||||
get { return _ChangedContents; }
|
||||
set { _ChangedContents = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static Dictionary<int, string> Execute(string lastChanged)
|
||||
{
|
||||
SessionChangedContents cmd = new SessionChangedContents();
|
||||
cmd.LastChanged = lastChanged;
|
||||
cmd = DataPortal.Execute<SessionChangedContents>(cmd);
|
||||
return cmd.ChangedContents;
|
||||
}
|
||||
#endregion
|
||||
#region Server-Side Code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_ListContentsAfterLastChanged2", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.Parameters.AddWithValue("@LastChanged", Convert.FromBase64String(LastChanged));
|
||||
cmd.Parameters.AddWithValue("@UserID", Volian.Base.Library.VlnSettings.UserID);
|
||||
SqlDataReader dr = cmd.ExecuteReader();
|
||||
ChangedContents = new Dictionary<int, string>();
|
||||
while (dr.Read())
|
||||
ChangedContents.Add(dr.GetInt32(0), Convert.ToBase64String(dr["LastChanged"] as byte[]));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionChangedContents Error", ex);
|
||||
throw new ApplicationException("Failure on SessionChangedContents", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
#region OwnerInfo stuff
|
||||
public partial class OwnerInfoList
|
||||
|
Reference in New Issue
Block a user