This commit is contained in:
Jsj
2008-05-16 18:07:47 +00:00
parent 9d0b3cd543
commit cda0291dbd
116 changed files with 4257 additions and 3382 deletions

View File

@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Collection
protected static List<ContentInfo> _AllList = new List<ContentInfo>();
private static Dictionary<string, ContentInfo> _AllByPrimaryKey = new Dictionary<string, ContentInfo>();
private static Dictionary<string, List<ContentInfo>> _AllByPrimaryKey = new Dictionary<string, List<ContentInfo>>();
private static void ConvertListToDictionary()
{
List<ContentInfo> remove = new List<ContentInfo>();
foreach (ContentInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<ContentInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ContentInfo tmp in remove)
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null;
}
#endregion
@@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID",true);
CanReadProperty("ContentID", true);
return _ContentID;
}
}
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Number",true);
CanReadProperty("Number", true);
return _Number;
}
}
@@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text",true);
CanReadProperty("Text", true);
return _Text;
}
}
@@ -118,7 +122,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Type",true);
CanReadProperty("Type", true);
return _Type;
}
}
@@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
@@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat;
}
@@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
CanReadProperty("Config", true);
return _Config;
}
}
@@ -160,7 +164,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
CanReadProperty("DTS", true);
return _DTS;
}
}
@@ -170,7 +174,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
CanReadProperty("UserID", true);
return _UserID;
}
}
@@ -183,7 +187,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentDetailCount",true);
CanReadProperty("ContentDetailCount", true);
return _ContentDetailCount;
}
}
@@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentDetails",true);
CanReadProperty("ContentDetails", true);
if (_ContentDetailCount < 0 || (_ContentDetailCount > 0 && _ContentDetails == null))
_ContentDetails = DetailInfoList.GetByContentID(_ContentID);
if (_ContentDetailCount < 0)
@@ -204,7 +208,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshContentDetails()
{
_ContentDetailCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentDetailCount = -1; // This will cause the data to be requeried
}
private int _ContentEntryCount = 0;
/// <summary>
@@ -215,7 +222,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentEntryCount",true);
CanReadProperty("ContentEntryCount", true);
return _ContentEntryCount;
}
}
@@ -226,7 +233,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyEntry",true);
CanReadProperty("MyEntry", true);
if (_ContentEntryCount > 0 && _MyEntry == null)
_MyEntry = EntryInfo.Get(_ContentID);
return _MyEntry;
@@ -241,7 +248,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentItemCount",true);
CanReadProperty("ContentItemCount", true);
return _ContentItemCount;
}
}
@@ -252,7 +259,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentItems",true);
CanReadProperty("ContentItems", true);
if (_ContentItemCount < 0 || (_ContentItemCount > 0 && _ContentItems == null))
_ContentItems = ItemInfoList.GetByContentID(_ContentID);
if (_ContentItemCount < 0)
@@ -262,7 +269,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshContentItems()
{
_ContentItemCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentItemCount = -1; // This will cause the data to be requeried
}
private int _ContentPartCount = 0;
/// <summary>
@@ -273,7 +283,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentPartCount",true);
CanReadProperty("ContentPartCount", true);
return _ContentPartCount;
}
}
@@ -284,7 +294,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentParts",true);
CanReadProperty("ContentParts", true);
if (_ContentPartCount < 0 || (_ContentPartCount > 0 && _ContentParts == null))
_ContentParts = PartInfoList.GetByContentID(_ContentID);
if (_ContentPartCount < 0)
@@ -294,7 +304,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshContentParts()
{
_ContentPartCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentPartCount = -1; // This will cause the data to be requeried
}
private int _ContentRoUsageCount = 0;
/// <summary>
@@ -305,7 +318,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentRoUsageCount",true);
CanReadProperty("ContentRoUsageCount", true);
return _ContentRoUsageCount;
}
}
@@ -316,7 +329,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentRoUsages",true);
CanReadProperty("ContentRoUsages", true);
if (_ContentRoUsageCount < 0 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null))
_ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID);
if (_ContentRoUsageCount < 0)
@@ -326,7 +339,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshContentRoUsages()
{
_ContentRoUsageCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentRoUsageCount = -1; // This will cause the data to be requeried
}
private int _ContentTransitionCount = 0;
/// <summary>
@@ -337,7 +353,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentTransitionCount",true);
CanReadProperty("ContentTransitionCount", true);
return _ContentTransitionCount;
}
}
@@ -348,7 +364,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentTransitions",true);
CanReadProperty("ContentTransitions", true);
if (_ContentTransitionCount < 0 || (_ContentTransitionCount > 0 && _ContentTransitions == null))
_ContentTransitions = TransitionInfoList.GetByFromID(_ContentID);
if (_ContentTransitionCount < 0)
@@ -358,7 +374,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshContentTransitions()
{
_ContentTransitionCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentTransitionCount = -1; // This will cause the data to be requeried
}
private int _ContentZContentCount = 0;
/// <summary>
@@ -369,7 +388,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentZContentCount",true);
CanReadProperty("ContentZContentCount", true);
return _ContentZContentCount;
}
}
@@ -380,7 +399,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyZContent",true);
CanReadProperty("MyZContent", true);
if (_ContentZContentCount > 0 && _MyZContent == null)
_MyZContent = ZContentInfo.Get(_ContentID);
return _MyZContent;
@@ -406,14 +425,25 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Factory Methods
private static int _ContentInfoUnique = 0;
private int _MyContentInfoUnique;
public int MyContentInfoUnique
{
get { return _MyContentInfoUnique; }
}
private ContentInfo()
{/* require use of factory methods */
_MyContentInfoUnique = ++_ContentInfoUnique;
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString());
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ContentInfo> listContentInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listContentInfo.Remove(this); // Remove the item from the list
if (listContentInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Content Get()
{
@@ -421,9 +451,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(Content tmp)
{
ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Content tmp)
{
@@ -434,9 +466,9 @@ namespace VEPROMS.CSLA.Library
{
MyFormat.RefreshFormatContents(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatContents(); // Update List for new value
}
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -448,9 +480,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(FormatContent tmp)
{
ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FormatContent tmp)
{
@@ -476,7 +510,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null)
{
tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
_AllList.Add(tmp);
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -490,14 +524,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal ContentInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
_MyContentInfoUnique = ++_ContentInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.Constructor", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
throw new DbCslaException("ContentInfo.Constructor", ex);
}
}
@@ -514,7 +549,7 @@ namespace VEPROMS.CSLA.Library
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
@@ -535,14 +570,14 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.ReadData", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.DataPortal_Fetch", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -570,7 +605,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.DataPortal_Fetch", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentInfo.DataPortal_Fetch", ex);
}
@@ -580,7 +615,7 @@ namespace VEPROMS.CSLA.Library
#region extension
ContentInfoExtension _ContentInfoExtension = new ContentInfoExtension();
[Serializable()]
partial class ContentInfoExtension : extensionBase {}
partial class ContentInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{