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<AnnotationInfo> _AllList = new List<AnnotationInfo>();
private static Dictionary<string, AnnotationInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationInfo>();
private static Dictionary<string, List<AnnotationInfo>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key
if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
{
_AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationInfo tmp in remove)
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{
ConvertListToDictionary();
string key = annotationID.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("AnnotationID",true);
CanReadProperty("AnnotationID", true);
return _AnnotationID;
}
}
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
@@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
@@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID",true);
CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
@@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotationType",true);
CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType;
}
@@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText",true);
CanReadProperty("RtfText", true);
return _RtfText;
}
}
@@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText",true);
CanReadProperty("SearchText", true);
return _SearchText;
}
}
@@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
CanReadProperty("Config", true);
return _Config;
}
}
@@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
CanReadProperty("DTS", true);
return _DTS;
}
}
@@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
CanReadProperty("UserID", true);
return _UserID;
}
}
@@ -203,14 +207,25 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Factory Methods
private static int _AnnotationInfoUnique = 0;
private int _MyAnnotationInfoUnique;
public int MyAnnotationInfoUnique
{
get { return _MyAnnotationInfoUnique; }
}
private AnnotationInfo()
{/* require use of factory methods */
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(AnnotationID.ToString());
if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
List<AnnotationInfo> listAnnotationInfo = _AllByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
listAnnotationInfo.Remove(this); // Remove the item from the list
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
}
public virtual Annotation Get()
{
@@ -218,9 +233,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(Annotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Annotation tmp)
{
@@ -228,16 +245,16 @@ namespace VEPROMS.CSLA.Library
{
MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemAnnotations(); // Update List for new value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
if (_TypeID != tmp.TypeID)
{
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
_MyAnnotationType = null; // Reset list so that the next line gets a new list
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
@@ -250,9 +267,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(AnnotationTypeAnnotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(AnnotationTypeAnnotation tmp)
{
@@ -260,9 +279,9 @@ namespace VEPROMS.CSLA.Library
{
MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemAnnotations(); // Update List for new value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
@@ -275,9 +294,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(ItemAnnotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemAnnotation tmp)
{
@@ -285,9 +306,9 @@ namespace VEPROMS.CSLA.Library
{
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
_MyAnnotationType = null; // Reset list so that the next line gets a new list
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
@@ -308,7 +329,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
_AllList.Add(tmp);
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -322,14 +343,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal AnnotationInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.Constructor", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.Constructor", ex);
throw new DbCslaException("AnnotationInfo.Constructor", ex);
}
}
@@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
@@ -360,14 +382,14 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.ReadData", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.DataPortal_Fetch", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -395,7 +417,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
}
@@ -405,7 +427,7 @@ namespace VEPROMS.CSLA.Library
#region extension
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
[Serializable()]
partial class AnnotationInfoExtension : extensionBase {}
partial class AnnotationInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{