This commit is contained in:
parent
0c505e9455
commit
f42f176ae9
@ -117,28 +117,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<Content> _AllList = new List<Content>();
|
private static List<Content> _CacheList = new List<Content>();
|
||||||
private static Dictionary<string, List<Content>> _AllByPrimaryKey = new Dictionary<string, List<Content>>();
|
protected static void AddToCache(Content content)
|
||||||
|
{
|
||||||
|
if (!_CacheList.Contains(content)) _CacheList.Add(content); // In AddToCache
|
||||||
|
}
|
||||||
|
protected static void RemoveFromCache(Content content)
|
||||||
|
{
|
||||||
|
while (_CacheList.Contains(content)) _CacheList.Remove(content); // In RemoveFromCache
|
||||||
|
}
|
||||||
|
private static Dictionary<string, List<Content>> _CacheByPrimaryKey = new Dictionary<string, List<Content>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<Content> remove = new List<Content>();
|
List<Content> remove = new List<Content>();
|
||||||
foreach (Content tmp in _AllList)
|
foreach (Content tmp in _CacheList)
|
||||||
{
|
{
|
||||||
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
|
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
|
||||||
{
|
{
|
||||||
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<Content>(); // Add new list for PrimaryKey
|
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<Content>(); // Add new list for PrimaryKey
|
||||||
}
|
}
|
||||||
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
|
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
|
||||||
remove.Add(tmp);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (Content tmp in remove)
|
foreach (Content tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
public static Content GetExistingByPrimaryKey(int contentID)
|
protected static Content GetCachedByPrimaryKey(int contentID)
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
string key = contentID.ToString();
|
string key = contentID.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -254,7 +262,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
CanWriteProperty("MyFormat", true);
|
CanWriteProperty("MyFormat", true);
|
||||||
if (_MyFormat != value)
|
if ((_MyFormat == null ? _FormatID : (int?)_MyFormat.FormatID) != (value == null ? null : (int?)value.FormatID))
|
||||||
{
|
{
|
||||||
_MyFormat = value;
|
_MyFormat = value;
|
||||||
_FormatID = (value == null ? null : (int?)value.FormatID);
|
_FormatID = (value == null ? null : (int?)value.FormatID);
|
||||||
@ -714,24 +722,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public int CurrentEditLevel
|
public int CurrentEditLevel
|
||||||
{ get { return EditLevel; } }
|
{ get { return EditLevel; } }
|
||||||
private static int _ContentUnique = 0;
|
private static int _ContentUnique = 0;
|
||||||
private int _MyContentUnique;
|
protected static int ContentUnique
|
||||||
|
{ get { return ++_ContentUnique; } }
|
||||||
|
private int _MyContentUnique = ContentUnique;
|
||||||
public int MyContentUnique
|
public int MyContentUnique
|
||||||
{
|
{ get { return _MyContentUnique; } }
|
||||||
get { return _MyContentUnique; }
|
|
||||||
}
|
|
||||||
protected Content()
|
protected Content()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyContentUnique = ++_ContentUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromDictionaries();
|
||||||
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
|
}
|
||||||
List<Content> listContent = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
|
private void RemoveFromDictionaries()
|
||||||
listContent.Remove(this); // Remove the item from the list
|
{
|
||||||
if (listContent.Count == 0) //If there are no items left in the list
|
RemoveFromCache(this);
|
||||||
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
|
if (_CacheByPrimaryKey.ContainsKey(ContentID.ToString()))
|
||||||
|
{
|
||||||
|
List<Content> listContent = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
|
||||||
|
while (listContent.Contains(this)) listContent.Remove(this); // Remove the item from the list
|
||||||
|
if (listContent.Count == 0) //If there are no items left in the list
|
||||||
|
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static Content New()
|
public static Content New()
|
||||||
{
|
{
|
||||||
@ -762,7 +775,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Content tmp = Content.New(number, text, type, myFormat, config, dts, userID);
|
Content tmp = Content.New(number, text, type, myFormat, config, dts, userID);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
Content tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||||
@ -788,7 +805,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Content tmp = Content.New(number, text, type, myFormat, config);
|
Content tmp = Content.New(number, text, type, myFormat, config);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
Content tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||||
@ -806,13 +827,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new System.Security.SecurityException("User not authorized to view a Content");
|
throw new System.Security.SecurityException("User not authorized to view a Content");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Content tmp = GetExistingByPrimaryKey(contentID);
|
Content tmp = GetCachedByPrimaryKey(contentID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<Content>(new PKCriteria(contentID));
|
tmp = DataPortal.Fetch<Content>(new PKCriteria(contentID));
|
||||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
|
}
|
||||||
|
if (tmp.ErrorMessage == "No Record Found")
|
||||||
|
{
|
||||||
|
tmp.Dispose(); // Clean-up Content
|
||||||
|
tmp = null;
|
||||||
}
|
}
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -854,7 +879,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
Content content = base.Save();
|
Content content = base.Save();
|
||||||
_AllList.Add(content);//Refresh the item in AllList
|
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
|
||||||
|
AddToCache(content);//Refresh the item in AllList
|
||||||
ProcessRefreshList();
|
ProcessRefreshList();
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<ContentInfo> _AllList = new List<ContentInfo>();
|
private static List<ContentInfo> _CacheList = new List<ContentInfo>();
|
||||||
private static Dictionary<string, List<ContentInfo>> _AllByPrimaryKey = new Dictionary<string, List<ContentInfo>>();
|
protected static void AddToCache(ContentInfo contentInfo)
|
||||||
|
{
|
||||||
|
if (!_CacheList.Contains(contentInfo)) _CacheList.Add(contentInfo); // In AddToCache
|
||||||
|
}
|
||||||
|
protected static void RemoveFromCache(ContentInfo contentInfo)
|
||||||
|
{
|
||||||
|
while (_CacheList.Contains(contentInfo)) _CacheList.Remove(contentInfo); // In RemoveFromCache
|
||||||
|
}
|
||||||
|
private static Dictionary<string, List<ContentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<ContentInfo> remove = new List<ContentInfo>();
|
List<ContentInfo> remove = new List<ContentInfo>();
|
||||||
foreach (ContentInfo tmp in _AllList)
|
foreach (ContentInfo tmp in _CacheList)
|
||||||
{
|
{
|
||||||
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
|
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
|
||||||
{
|
{
|
||||||
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<ContentInfo>(); // Add new list for PrimaryKey
|
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<ContentInfo>(); // Add new list for PrimaryKey
|
||||||
}
|
}
|
||||||
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
|
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
|
||||||
remove.Add(tmp);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (ContentInfo tmp in remove)
|
foreach (ContentInfo tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
internal static void AddList(ContentInfoList lst)
|
internal static void AddList(ContentInfoList lst)
|
||||||
{
|
{
|
||||||
foreach (ContentInfo item in lst) _AllList.Add(item);
|
foreach (ContentInfo item in lst) AddToCache(item);
|
||||||
}
|
}
|
||||||
public static ContentInfo GetExistingByPrimaryKey(int contentID)
|
protected static ContentInfo GetCachedByPrimaryKey(int contentID)
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
string key = contentID.ToString();
|
string key = contentID.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -206,11 +214,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ContentDetails;
|
return _ContentDetails;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void RefreshContentDetails()
|
public void RefreshContentDetails()
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
||||||
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
|
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
|
||||||
tmp._ContentDetailCount = -1; // This will cause the data to be requeried
|
tmp._ContentDetailCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
private int _ContentEntryCount = 0;
|
private int _ContentEntryCount = 0;
|
||||||
@ -234,8 +242,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
CanReadProperty("MyEntry", true);
|
CanReadProperty("MyEntry", true);
|
||||||
if (_ContentEntryCount > 0 && _MyEntry == null)
|
if (_ContentEntryCount != 0 && _MyEntry == null)
|
||||||
|
{
|
||||||
_MyEntry = EntryInfo.Get(_ContentID);
|
_MyEntry = EntryInfo.Get(_ContentID);
|
||||||
|
_ContentEntryCount = _MyEntry == null ? 0 : 1;
|
||||||
|
}
|
||||||
return _MyEntry;
|
return _MyEntry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,11 +278,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ContentItems;
|
return _ContentItems;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void RefreshContentItems()
|
public void RefreshContentItems()
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
||||||
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
|
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
|
||||||
tmp._ContentItemCount = -1; // This will cause the data to be requeried
|
tmp._ContentItemCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
private int _ContentPartCount = 0;
|
private int _ContentPartCount = 0;
|
||||||
@ -302,11 +313,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ContentParts;
|
return _ContentParts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void RefreshContentParts()
|
public void RefreshContentParts()
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
||||||
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
|
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
|
||||||
tmp._ContentPartCount = -1; // This will cause the data to be requeried
|
tmp._ContentPartCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
private int _ContentRoUsageCount = 0;
|
private int _ContentRoUsageCount = 0;
|
||||||
@ -337,11 +348,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ContentRoUsages;
|
return _ContentRoUsages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void RefreshContentRoUsages()
|
public void RefreshContentRoUsages()
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
||||||
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
|
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
|
||||||
tmp._ContentRoUsageCount = -1; // This will cause the data to be requeried
|
tmp._ContentRoUsageCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
private int _ContentTransitionCount = 0;
|
private int _ContentTransitionCount = 0;
|
||||||
@ -372,11 +383,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ContentTransitions;
|
return _ContentTransitions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void RefreshContentTransitions()
|
public void RefreshContentTransitions()
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
|
||||||
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
|
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
|
||||||
tmp._ContentTransitionCount = -1; // This will cause the data to be requeried
|
tmp._ContentTransitionCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
private int _ContentZContentCount = 0;
|
private int _ContentZContentCount = 0;
|
||||||
@ -400,8 +411,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
CanReadProperty("MyZContent", true);
|
CanReadProperty("MyZContent", true);
|
||||||
if (_ContentZContentCount > 0 && _MyZContent == null)
|
if (_ContentZContentCount != 0 && _MyZContent == null)
|
||||||
|
{
|
||||||
_MyZContent = ZContentInfo.Get(_ContentID);
|
_MyZContent = ZContentInfo.Get(_ContentID);
|
||||||
|
_ContentZContentCount = _MyZContent == null ? 0 : 1;
|
||||||
|
}
|
||||||
return _MyZContent;
|
return _MyZContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,24 +440,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _ContentInfoUnique = 0;
|
private static int _ContentInfoUnique = 0;
|
||||||
private int _MyContentInfoUnique;
|
private static int ContentInfoUnique
|
||||||
|
{ get { return ++_ContentInfoUnique; } }
|
||||||
|
private int _MyContentInfoUnique = ContentInfoUnique;
|
||||||
public int MyContentInfoUnique
|
public int MyContentInfoUnique
|
||||||
{
|
{ get { return _MyContentInfoUnique; } }
|
||||||
get { return _MyContentInfoUnique; }
|
protected ContentInfo()
|
||||||
}
|
|
||||||
private ContentInfo()
|
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyContentInfoUnique = ++_ContentInfoUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromCache(this);
|
||||||
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
|
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
|
||||||
List<ContentInfo> listContentInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
|
List<ContentInfo> listContentInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
|
||||||
listContentInfo.Remove(this); // Remove the item from the list
|
while (listContentInfo.Contains(this)) listContentInfo.Remove(this); // Remove the item from the list
|
||||||
if (listContentInfo.Count == 0) // If there are no items left in the list
|
if (listContentInfo.Count == 0) // If there are no items left in the list
|
||||||
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Content Get()
|
public virtual Content Get()
|
||||||
{
|
{
|
||||||
@ -453,18 +466,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
string key = tmp.ContentID.ToString();
|
string key = tmp.ContentID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (ContentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(Content tmp)
|
protected virtual void RefreshFields(Content tmp)
|
||||||
{
|
{
|
||||||
_Number = tmp.Number;
|
_Number = tmp.Number;
|
||||||
_Text = tmp.Text;
|
_Text = tmp.Text;
|
||||||
_Type = tmp.Type;
|
_Type = tmp.Type;
|
||||||
if (_FormatID != tmp.FormatID)
|
if (_FormatID != tmp.FormatID)
|
||||||
{
|
{
|
||||||
MyFormat.RefreshFormatContents(); // Update List for old value
|
if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for old value
|
||||||
_FormatID = tmp.FormatID; // Update the value
|
_FormatID = tmp.FormatID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||||
@ -474,19 +487,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
_ContentInfoExtension.Refresh(this);
|
_ContentInfoExtension.Refresh(this);
|
||||||
_MyFormat = null;
|
_MyFormat = null;
|
||||||
_MyEntry = null;//
|
_MyEntry = null;// Reset related value
|
||||||
_MyZContent = null;//
|
_ContentEntryCount = -1;// Reset Count
|
||||||
|
_MyZContent = null;// Reset related value
|
||||||
|
_ContentZContentCount = -1;// Reset Count
|
||||||
OnChange();// raise an event
|
OnChange();// raise an event
|
||||||
}
|
}
|
||||||
public static void Refresh(FormatContent tmp)
|
public static void Refresh(FormatContent tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.ContentID.ToString();
|
string key = tmp.ContentID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (ContentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(FormatContent tmp)
|
protected virtual void RefreshFields(FormatContent tmp)
|
||||||
{
|
{
|
||||||
_Number = tmp.Number;
|
_Number = tmp.Number;
|
||||||
_Text = tmp.Text;
|
_Text = tmp.Text;
|
||||||
@ -496,8 +511,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
_ContentInfoExtension.Refresh(this);
|
_ContentInfoExtension.Refresh(this);
|
||||||
_MyFormat = null;
|
_MyFormat = null;
|
||||||
_MyEntry = null;//
|
_MyEntry = null;// Reset related value
|
||||||
_MyZContent = null;//
|
_ContentEntryCount = -1;// Reset Count
|
||||||
|
_MyZContent = null;// Reset related value
|
||||||
|
_ContentZContentCount = -1;// Reset Count
|
||||||
OnChange();// raise an event
|
OnChange();// raise an event
|
||||||
}
|
}
|
||||||
public static ContentInfo Get(int contentID)
|
public static ContentInfo Get(int contentID)
|
||||||
@ -506,13 +523,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// throw new System.Security.SecurityException("User not authorized to view a Content");
|
// throw new System.Security.SecurityException("User not authorized to view a Content");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ContentInfo tmp = GetExistingByPrimaryKey(contentID);
|
ContentInfo tmp = GetCachedByPrimaryKey(contentID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
|
tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
|
||||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
|
}
|
||||||
|
if (tmp.ErrorMessage == "No Record Found")
|
||||||
|
{
|
||||||
|
tmp.Dispose(); // Clean-up ContentInfo
|
||||||
|
tmp = null;
|
||||||
}
|
}
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -524,7 +545,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
internal ContentInfo(SafeDataReader dr)
|
internal ContentInfo(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
_MyContentInfoUnique = ++_ContentInfoUnique;
|
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
CanWriteProperty("MyPrevious", true);
|
CanWriteProperty("MyPrevious", true);
|
||||||
if (_MyPrevious != value)
|
if ((_MyPrevious == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID))
|
||||||
{
|
{
|
||||||
_MyPrevious = value;
|
_MyPrevious = value;
|
||||||
_PreviousID = (value == null ? null : (int?)value.ItemID);
|
_PreviousID = (value == null ? null : (int?)value.ItemID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user