This commit is contained in:
@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<DocVersionInfo> _AllList = new List<DocVersionInfo>();
|
||||
private static Dictionary<string, DocVersionInfo> _AllByPrimaryKey = new Dictionary<string, DocVersionInfo>();
|
||||
private static Dictionary<string, List<DocVersionInfo>> _AllByPrimaryKey = new Dictionary<string, List<DocVersionInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<DocVersionInfo> remove = new List<DocVersionInfo>();
|
||||
foreach (DocVersionInfo tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.VersionID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.VersionID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.VersionID.ToString()] = new List<DocVersionInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.VersionID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (DocVersionInfo tmp in remove)
|
||||
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = versionID.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("VersionID",true);
|
||||
CanReadProperty("VersionID", true);
|
||||
return _VersionID;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("FolderID",true);
|
||||
CanReadProperty("FolderID", true);
|
||||
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
|
||||
return _FolderID;
|
||||
}
|
||||
@@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyFolder",true);
|
||||
CanReadProperty("MyFolder", true);
|
||||
if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID);
|
||||
return _MyFolder;
|
||||
}
|
||||
@@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("VersionType",true);
|
||||
CanReadProperty("VersionType", true);
|
||||
return _VersionType;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Name",true);
|
||||
CanReadProperty("Name", true);
|
||||
return _Name;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +144,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Title",true);
|
||||
CanReadProperty("Title", true);
|
||||
return _Title;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +154,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;
|
||||
}
|
||||
@@ -161,7 +165,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 != null) _MyItem = ItemInfo.Get((int)_ItemID);
|
||||
return _MyItem;
|
||||
}
|
||||
@@ -172,7 +176,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;
|
||||
}
|
||||
@@ -183,7 +187,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;
|
||||
}
|
||||
@@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Config",true);
|
||||
CanReadProperty("Config", true);
|
||||
return _Config;
|
||||
}
|
||||
}
|
||||
@@ -204,7 +208,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DTS",true);
|
||||
CanReadProperty("DTS", true);
|
||||
return _DTS;
|
||||
}
|
||||
}
|
||||
@@ -214,7 +218,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UserID",true);
|
||||
CanReadProperty("UserID", true);
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
@@ -238,14 +242,25 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _DocVersionInfoUnique = 0;
|
||||
private int _MyDocVersionInfoUnique;
|
||||
public int MyDocVersionInfoUnique
|
||||
{
|
||||
get { return _MyDocVersionInfoUnique; }
|
||||
}
|
||||
private DocVersionInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyDocVersionInfoUnique = ++_DocVersionInfoUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(VersionID.ToString());
|
||||
if (!_AllByPrimaryKey.ContainsKey(VersionID.ToString())) return;
|
||||
List<DocVersionInfo> listDocVersionInfo = _AllByPrimaryKey[VersionID.ToString()]; // Get the list of items
|
||||
listDocVersionInfo.Remove(this); // Remove the item from the list
|
||||
if (listDocVersionInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(VersionID.ToString()); // remove the list
|
||||
}
|
||||
public virtual DocVersion Get()
|
||||
{
|
||||
@@ -253,9 +268,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(DocVersion tmp)
|
||||
{
|
||||
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.VersionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(DocVersion tmp)
|
||||
{
|
||||
@@ -263,9 +280,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
_VersionType = tmp.VersionType;
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
@@ -273,16 +290,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyItem.RefreshItemDocVersions(); // 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.RefreshItemDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
MyFormat.RefreshFormatDocVersions(); // 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.RefreshFormatDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -294,9 +311,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(FolderDocVersion tmp)
|
||||
{
|
||||
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.VersionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(FolderDocVersion tmp)
|
||||
{
|
||||
@@ -307,16 +326,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyItem.RefreshItemDocVersions(); // 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.RefreshItemDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
MyFormat.RefreshFormatDocVersions(); // 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.RefreshFormatDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -328,9 +347,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(FormatDocVersion tmp)
|
||||
{
|
||||
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.VersionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(FormatDocVersion tmp)
|
||||
{
|
||||
@@ -338,9 +359,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
_VersionType = tmp.VersionType;
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
@@ -348,9 +369,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyItem.RefreshItemDocVersions(); // 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.RefreshItemDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -362,9 +383,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(ItemDocVersion tmp)
|
||||
{
|
||||
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.VersionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ItemDocVersion tmp)
|
||||
{
|
||||
@@ -372,9 +395,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
_VersionType = tmp.VersionType;
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
@@ -382,9 +405,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyFormat.RefreshFormatDocVersions(); // 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.RefreshFormatDocVersions(); // Update List for new value
|
||||
}
|
||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -404,7 +427,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<DocVersionInfo>(new PKCriteria(versionID));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@@ -418,14 +441,15 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal DocVersionInfo(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.Constructor", GetHashCode());
|
||||
_MyDocVersionInfoUnique = ++_DocVersionInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.Constructor", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.Constructor", ex);
|
||||
throw new DbCslaException("DocVersionInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
@@ -442,7 +466,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_VersionID = dr.GetInt32("VersionID");
|
||||
@@ -458,14 +482,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("DocVersionInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -493,7 +517,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("DocVersionInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -503,7 +527,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#region extension
|
||||
DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
|
||||
[Serializable()]
|
||||
partial class DocVersionInfoExtension : extensionBase {}
|
||||
partial class DocVersionInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user