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<EntryInfo> _AllList = new List<EntryInfo>();
private static Dictionary<string, EntryInfo> _AllByPrimaryKey = new Dictionary<string, EntryInfo>();
private static Dictionary<string, List<EntryInfo>> _AllByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
private static void ConvertListToDictionary()
{
List<EntryInfo> remove = new List<EntryInfo>();
foreach (EntryInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<EntryInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (EntryInfo 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);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
@@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
@@ -108,7 +112,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID",true);
CanReadProperty("DocID", true);
if (_MyDocument != null) _DocID = _MyDocument.DocID;
return _DocID;
}
@@ -119,7 +123,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocument",true);
CanReadProperty("MyDocument", true);
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
return _MyDocument;
}
@@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
CanReadProperty("DTS", true);
return _DTS;
}
}
@@ -140,7 +144,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
CanReadProperty("UserID", true);
return _UserID;
}
}
@@ -164,14 +168,25 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Factory Methods
private static int _EntryInfoUnique = 0;
private int _MyEntryInfoUnique;
public int MyEntryInfoUnique
{
get { return _MyEntryInfoUnique; }
}
private EntryInfo()
{/* require use of factory methods */
_MyEntryInfoUnique = ++_EntryInfoUnique;
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString());
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<EntryInfo> listEntryInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listEntryInfo.Remove(this); // Remove the item from the list
if (listEntryInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Entry Get()
{
@@ -179,9 +194,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(Entry tmp)
{
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Entry tmp)
{
@@ -189,9 +206,9 @@ namespace VEPROMS.CSLA.Library
{
MyDocument.RefreshDocumentEntries(); // Update List for old value
_DocID = tmp.DocID; // Update the value
_MyDocument = null; // Reset list so that the next line gets a new list
MyDocument.RefreshDocumentEntries(); // Update List for new value
}
_MyDocument = null; // Reset list so that the next line gets a new list
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
@@ -201,9 +218,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(DocumentEntry tmp)
{
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(DocumentEntry tmp)
{
@@ -224,7 +243,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
_AllList.Add(tmp);
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
@@ -241,14 +260,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal EntryInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
_MyEntryInfoUnique = ++_EntryInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.Constructor", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.Constructor", ex);
throw new DbCslaException("EntryInfo.Constructor", ex);
}
}
@@ -265,7 +285,7 @@ namespace VEPROMS.CSLA.Library
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
@@ -275,14 +295,14 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.ReadData", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -310,7 +330,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.DataPortal_Fetch", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex);
}
@@ -320,7 +340,7 @@ namespace VEPROMS.CSLA.Library
#region extension
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
[Serializable()]
partial class EntryInfoExtension : extensionBase {}
partial class EntryInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{