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<FolderInfo> _AllList = new List<FolderInfo>();
private static Dictionary<string, FolderInfo> _AllByPrimaryKey = new Dictionary<string, FolderInfo>();
private static Dictionary<string, List<FolderInfo>> _AllByPrimaryKey = new Dictionary<string, List<FolderInfo>>();
private static void ConvertListToDictionary()
{
List<FolderInfo> remove = new List<FolderInfo>();
foreach (FolderInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.FolderID.ToString()]=tmp; // Primary Key
if (!_AllByPrimaryKey.ContainsKey(tmp.FolderID.ToString()))
{
_AllByPrimaryKey[tmp.FolderID.ToString()] = new List<FolderInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.FolderID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (FolderInfo tmp in remove)
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{
ConvertListToDictionary();
string key = folderID.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("FolderID",true);
CanReadProperty("FolderID", true);
return _FolderID;
}
}
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ParentID",true);
CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID;
}
@@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyParent",true);
CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = FolderInfo.Get(_ParentID);
return _MyParent;
}
@@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBID",true);
CanReadProperty("DBID", true);
if (_MyConnection != null) _DBID = _MyConnection.DBID;
return _DBID;
}
@@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyConnection",true);
CanReadProperty("MyConnection", true);
if (_MyConnection == null && _DBID != 0) _MyConnection = ConnectionInfo.Get(_DBID);
return _MyConnection;
}
@@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
CanReadProperty("Name", true);
return _Name;
}
}
@@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
CanReadProperty("Title", true);
return _Title;
}
}
@@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ShortName",true);
CanReadProperty("ShortName", true);
return _ShortName;
}
}
@@ -169,7 +173,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;
}
@@ -180,7 +184,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;
}
@@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
CanReadProperty("Config", true);
return _Config;
}
}
@@ -201,7 +205,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
CanReadProperty("DTS", true);
return _DTS;
}
}
@@ -211,7 +215,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
CanReadProperty("UsrID", true);
return _UsrID;
}
}
@@ -224,7 +228,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderAssignmentCount",true);
CanReadProperty("FolderAssignmentCount", true);
return _FolderAssignmentCount;
}
}
@@ -235,7 +239,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderAssignments",true);
CanReadProperty("FolderAssignments", true);
if (_FolderAssignmentCount < 0 || (_FolderAssignmentCount > 0 && _FolderAssignments == null))
_FolderAssignments = AssignmentInfoList.GetByFolderID(_FolderID);
if (_FolderAssignmentCount < 0)
@@ -245,7 +249,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshFolderAssignments()
{
_FolderAssignmentCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FolderID.ToString()))
foreach (FolderInfo tmp in _AllByPrimaryKey[_FolderID.ToString()])
tmp._FolderAssignmentCount = -1; // This will cause the data to be requeried
}
private int _FolderDocVersionCount = 0;
/// <summary>
@@ -256,7 +263,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderDocVersionCount",true);
CanReadProperty("FolderDocVersionCount", true);
return _FolderDocVersionCount;
}
}
@@ -267,7 +274,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderDocVersions",true);
CanReadProperty("FolderDocVersions", true);
if (_FolderDocVersionCount < 0 || (_FolderDocVersionCount > 0 && _FolderDocVersions == null))
_FolderDocVersions = DocVersionInfoList.GetByFolderID(_FolderID);
if (_FolderDocVersionCount < 0)
@@ -277,7 +284,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshFolderDocVersions()
{
_FolderDocVersionCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FolderID.ToString()))
foreach (FolderInfo tmp in _AllByPrimaryKey[_FolderID.ToString()])
tmp._FolderDocVersionCount = -1; // This will cause the data to be requeried
}
private int _ChildFolderCount = 0;
/// <summary>
@@ -288,7 +298,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ChildFolderCount",true);
CanReadProperty("ChildFolderCount", true);
return _ChildFolderCount;
}
}
@@ -299,7 +309,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ChildFolders",true);
CanReadProperty("ChildFolders", true);
if (_ChildFolderCount < 0 || (_ChildFolderCount > 0 && _ChildFolders == null))
_ChildFolders = FolderInfoList.GetChildren(_FolderID);
if (_ChildFolderCount < 0)
@@ -309,7 +319,10 @@ namespace VEPROMS.CSLA.Library
}
internal void RefreshChildFolders()
{
_ChildFolderCount = -1; // This will cause the data to be requeried
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FolderID.ToString()))
foreach (FolderInfo tmp in _AllByPrimaryKey[_FolderID.ToString()])
tmp._ChildFolderCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base FolderInfo.ToString function as necessary
/// <summary>
@@ -331,14 +344,25 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Factory Methods
private static int _FolderInfoUnique = 0;
private int _MyFolderInfoUnique;
public int MyFolderInfoUnique
{
get { return _MyFolderInfoUnique; }
}
private FolderInfo()
{/* require use of factory methods */
_MyFolderInfoUnique = ++_FolderInfoUnique;
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(FolderID.ToString());
if (!_AllByPrimaryKey.ContainsKey(FolderID.ToString())) return;
List<FolderInfo> listFolderInfo = _AllByPrimaryKey[FolderID.ToString()]; // Get the list of items
listFolderInfo.Remove(this); // Remove the item from the list
if (listFolderInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(FolderID.ToString()); // remove the list
}
public virtual Folder Get()
{
@@ -346,9 +370,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(Folder tmp)
{
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.FolderID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Folder tmp)
{
@@ -356,16 +382,16 @@ namespace VEPROMS.CSLA.Library
{
MyParent.RefreshChildFolders(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFolders(); // Update List for new value
}
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
if (_DBID != tmp.DBID)
{
MyConnection.RefreshConnectionFolders(); // Update List for old value
_DBID = tmp.DBID; // Update the value
_MyConnection = null; // Reset list so that the next line gets a new list
MyConnection.RefreshConnectionFolders(); // Update List for new value
}
_MyConnection = null; // Reset list so that the next line gets a new list
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
_Name = tmp.Name;
_Title = tmp.Title;
_ShortName = tmp.ShortName;
@@ -373,9 +399,9 @@ namespace VEPROMS.CSLA.Library
{
MyFormat.RefreshFormatFolders(); // 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.RefreshFormatFolders(); // Update List for new value
}
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
@@ -387,9 +413,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(ConnectionFolder tmp)
{
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.FolderID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ConnectionFolder tmp)
{
@@ -397,9 +425,9 @@ namespace VEPROMS.CSLA.Library
{
MyParent.RefreshChildFolders(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFolders(); // Update List for new value
}
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
_Name = tmp.Name;
_Title = tmp.Title;
_ShortName = tmp.ShortName;
@@ -407,9 +435,9 @@ namespace VEPROMS.CSLA.Library
{
MyFormat.RefreshFormatFolders(); // 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.RefreshFormatFolders(); // Update List for new value
}
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
@@ -421,9 +449,11 @@ namespace VEPROMS.CSLA.Library
}
public static void Refresh(FormatFolder tmp)
{
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
string key = tmp.FolderID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FormatFolder tmp)
{
@@ -431,16 +461,16 @@ namespace VEPROMS.CSLA.Library
{
MyParent.RefreshChildFolders(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFolders(); // Update List for new value
}
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
if (_DBID != tmp.DBID)
{
MyConnection.RefreshConnectionFolders(); // Update List for old value
_DBID = tmp.DBID; // Update the value
_MyConnection = null; // Reset list so that the next line gets a new list
MyConnection.RefreshConnectionFolders(); // Update List for new value
}
_MyConnection = null; // Reset list so that the next line gets a new list
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
_Name = tmp.Name;
_Title = tmp.Title;
_ShortName = tmp.ShortName;
@@ -463,7 +493,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null)
{
tmp = DataPortal.Fetch<FolderInfo>(new PKCriteria(folderID));
_AllList.Add(tmp);
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -477,14 +507,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal FolderInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.Constructor", GetHashCode());
_MyFolderInfoUnique = ++_FolderInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.Constructor", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.Constructor", ex);
throw new DbCslaException("FolderInfo.Constructor", ex);
}
}
@@ -501,7 +532,7 @@ namespace VEPROMS.CSLA.Library
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode());
try
{
_FolderID = dr.GetInt32("FolderID");
@@ -520,14 +551,14 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.ReadData", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.DataPortal_Fetch", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -555,7 +586,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.DataPortal_Fetch", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.DataPortal_Fetch", ex);
}
@@ -565,7 +596,7 @@ namespace VEPROMS.CSLA.Library
#region extension
FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
[Serializable()]
partial class FolderInfoExtension : extensionBase {}
partial class FolderInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{