This commit is contained in:
parent
610f408c6d
commit
d0dba2aad4
@ -23,7 +23,7 @@ namespace VEPROMS.CSLA.Library
|
||||
public static List<AnnotationTypeInfo> AllList()
|
||||
{
|
||||
//return _AllList;
|
||||
return AnnotationTypeInfo._AllList;
|
||||
return AnnotationTypeInfo._CacheList;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ namespace VEPROMS.CSLA.Library
|
||||
try
|
||||
{
|
||||
ReadDataItemList(dr);
|
||||
_CacheList.Add(this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -96,9 +96,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return MyFolder;
|
||||
}
|
||||
}
|
||||
private Format _ActiveFormat = null;
|
||||
public Format ActiveFormat
|
||||
{
|
||||
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
|
||||
get
|
||||
{
|
||||
if (_ActiveFormat == null)
|
||||
_ActiveFormat = LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat;
|
||||
return _ActiveFormat;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ActiveFormat = null;
|
||||
}
|
||||
}
|
||||
public Format LocalFormat
|
||||
{
|
||||
@ -110,21 +120,26 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public partial class DocVersionInfo:IVEDrillDownReadOnly
|
||||
public partial class DocVersionInfo : IVEDrillDownReadOnly
|
||||
{
|
||||
#region DocVersion Config
|
||||
[NonSerialized]
|
||||
private DocVersionConfig _DocVersionConfig;
|
||||
public DocVersionConfig DocVersionConfig
|
||||
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this));} }
|
||||
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this)); } }
|
||||
private void DocVersionConfigRefresh()
|
||||
{
|
||||
_DocVersionConfig = null;
|
||||
}
|
||||
#endregion
|
||||
ItemInfoList _iil = null;
|
||||
|
||||
ItemInfoList _Procedures = null;
|
||||
public ItemInfoList Procedures
|
||||
{ get { return (_iil != null ? _iil: _iil = ItemInfoList.GetList(_ItemID,(int)E_FromType.Procedure)); } }
|
||||
{ get { return (_Procedures != null ? _Procedures : _Procedures = ItemInfoList.GetList(_ItemID, (int)E_FromType.Procedure)); } }
|
||||
public void ResetProcedures()
|
||||
{
|
||||
_Procedures = null;
|
||||
}
|
||||
#region IVEReadOnlyItem
|
||||
public System.Collections.IList GetChildren()
|
||||
{
|
||||
@ -196,6 +211,14 @@ namespace VEPROMS.CSLA.Library
|
||||
//{
|
||||
// return ToString();
|
||||
//}
|
||||
public ItemInfo LastChild()
|
||||
{
|
||||
return MyItem.LastSibling;
|
||||
}
|
||||
public ItemInfo FirstChild()
|
||||
{
|
||||
return MyItem;
|
||||
}
|
||||
#endregion
|
||||
#region Extension
|
||||
partial class DocVersionInfoExtension : extensionBase
|
||||
|
@ -2,6 +2,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@ -45,6 +49,69 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial class DocumentInfoList
|
||||
{
|
||||
public static DocumentInfoList GetLibraries()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_DocumentInfoList != null)
|
||||
return _DocumentInfoList;
|
||||
DocumentInfoList tmp = DataPortal.Fetch<DocumentInfoList>(new LibraryCriteria(true));
|
||||
DocumentInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
_DocumentInfoList = tmp;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on DocumentInfoList.Get", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class LibraryCriteria
|
||||
{
|
||||
private bool _IsLibrary;
|
||||
|
||||
public bool IsLibrary
|
||||
{
|
||||
get { return _IsLibrary; }
|
||||
set { _IsLibrary = value; }
|
||||
}
|
||||
public LibraryCriteria(bool islibrary)
|
||||
{
|
||||
_IsLibrary = islibrary;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(LibraryCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getLibraryDocuments";
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read()) this.Add(new DocumentInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
public class DSOFile : IDisposable
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
@ -17,6 +17,8 @@ using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@ -68,9 +70,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return MyParent;
|
||||
}
|
||||
}
|
||||
private Format _ActiveFormat = null;
|
||||
public Format ActiveFormat
|
||||
{
|
||||
get { return LocalFormat != null ? LocalFormat : (ActiveParent != null ? ActiveParent.ActiveFormat : null); }
|
||||
get
|
||||
{
|
||||
if (_ActiveFormat == null)
|
||||
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent != null ? ActiveParent.ActiveFormat : null);
|
||||
return _ActiveFormat;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ActiveFormat = null; // Reset
|
||||
}
|
||||
}
|
||||
public Format LocalFormat
|
||||
{
|
||||
@ -81,6 +93,16 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return FolderConfig; }
|
||||
}
|
||||
#endregion
|
||||
#region MakeFolders for ManualOrder
|
||||
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID)
|
||||
{
|
||||
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config, dts, usrID);
|
||||
}
|
||||
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config)
|
||||
{
|
||||
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public partial class FolderInfo:IVEDrillDownReadOnly
|
||||
{
|
||||
@ -96,11 +118,84 @@ namespace VEPROMS.CSLA.Library
|
||||
_FolderConfig = null;
|
||||
}
|
||||
#endregion
|
||||
#region SortingChildren
|
||||
public Csla.SortedBindingList<FolderInfo> _SortedChildFolders;
|
||||
public Csla.SortedBindingList<FolderInfo> SortedChildFolders
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ChildFolders != null)
|
||||
{
|
||||
if (_SortedChildFolders == null)
|
||||
{
|
||||
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
|
||||
//_SortedChildFolders.ApplySort("FolderID", ListSortDirection.Ascending);
|
||||
//_SortedChildFolders.ApplySort("Name", ListSortDirection.Ascending);
|
||||
}
|
||||
else if (_SortedChildFolders.Count != ChildFolders.Count)
|
||||
{
|
||||
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
|
||||
}
|
||||
_SortedChildFolders.ApplySort("ManualOrder", ListSortDirection.Ascending);
|
||||
}
|
||||
return _SortedChildFolders;
|
||||
}
|
||||
}
|
||||
public double? NewManualOrder(int index)
|
||||
{
|
||||
double? retval = 1;
|
||||
if (SortedChildFolders == null || SortedChildFolders.Count == 0)
|
||||
retval = 1; // First value
|
||||
else if (index == 0)
|
||||
{
|
||||
if (retval >= SortedChildFolders[index].ManualOrder) // If one is too big, then divide first value in half
|
||||
retval = SortedChildFolders[index].ManualOrder / 2;
|
||||
}
|
||||
else if (SortedChildFolders.Count > index)
|
||||
{
|
||||
retval += SortedChildFolders[index - 1].ManualOrder; // Just go to the next whole number
|
||||
if (retval >= SortedChildFolders[index].ManualOrder)
|
||||
retval = (SortedChildFolders[index - 1].ManualOrder + SortedChildFolders[index].ManualOrder) / 2;
|
||||
}
|
||||
else
|
||||
retval += SortedChildFolders[index - 1].ManualOrder;
|
||||
return retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// UniqueChildName will check the existing children to assure that the name is not a duplicate name.
|
||||
/// </summary>
|
||||
/// <param name="folderName"></param>
|
||||
/// <returns></returns>
|
||||
public string UniqueChildName(string folderName)
|
||||
{
|
||||
string retval = folderName;
|
||||
int iSuffix = -1;
|
||||
RefreshChildFolders();
|
||||
foreach (FolderInfo fi in ChildFolders)
|
||||
{
|
||||
if (fi.Name.StartsWith(folderName))
|
||||
{
|
||||
if (fi.Name == folderName)
|
||||
iSuffix = 0;
|
||||
else if (Regex.IsMatch(fi.Name, folderName + "[_][0-9]+"))
|
||||
{
|
||||
int ii = int.Parse(fi.Name.Substring(1 + folderName.Length));
|
||||
if (ii > iSuffix) iSuffix = ii;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iSuffix >= 0)
|
||||
retval = string.Format("{0}_{1}", folderName, iSuffix + 1);
|
||||
// Console.WriteLine("FolderName = '{0}'", retval);
|
||||
return retval;
|
||||
}
|
||||
#endregion
|
||||
#region IVEReadOnlyItem
|
||||
public System.Collections.IList GetChildren()
|
||||
{
|
||||
if(FolderDocVersionCount != 0)return FolderDocVersions;
|
||||
if (ChildFolderCount != 0) return ChildFolders;
|
||||
//if (ChildFolderCount != 0) return ChildFolders;
|
||||
if (ChildFolderCount != 0) return SortedChildFolders;
|
||||
return null;
|
||||
}
|
||||
//public bool ChildrenAreLoaded
|
||||
@ -178,4 +273,5 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,17 @@ using System.Drawing;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
#region Item
|
||||
public partial class Item:IVEDrillDown
|
||||
public partial class Item : IVEDrillDown
|
||||
{
|
||||
public static void ShowAllocated(string title)
|
||||
{
|
||||
Console.WriteLine("{0} - {1} Items in the dictionary", title, _CacheByPrimaryKey.Count);
|
||||
foreach (List<Item> itmlst in _CacheByPrimaryKey.Values)
|
||||
foreach(Item itm in itmlst)
|
||||
Console.WriteLine("Item {0} UniqueID {1}", itm.ItemID, itm.MyItemUnique);
|
||||
Console.WriteLine("- - - - - -");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim();
|
||||
@ -54,25 +63,29 @@ namespace VEPROMS.CSLA.Library
|
||||
_ActiveParent = this.ItemDocVersions[0].MyDocVersion;
|
||||
else
|
||||
{
|
||||
if (this.ItemParts == null || this.ItemPartCount == 0)
|
||||
if (this.ItemParts == null || this.ItemPartCount == 0)
|
||||
_ActiveParent = this;
|
||||
else
|
||||
_ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _ActiveParent==this ? null : _ActiveParent;
|
||||
return _ActiveParent == this ? null : _ActiveParent;
|
||||
}
|
||||
}
|
||||
private Format _ActiveFormat=null;// Added to cache ActiveFormat
|
||||
private Format _ActiveFormat = null;// Added to cache ActiveFormat
|
||||
public Format ActiveFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_ActiveFormat == null)
|
||||
if (_ActiveFormat == null)
|
||||
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
|
||||
return _ActiveFormat;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ActiveFormat = null; // Reset
|
||||
}
|
||||
}
|
||||
public Format LocalFormat
|
||||
{
|
||||
@ -83,18 +96,200 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return null; }
|
||||
}
|
||||
#endregion
|
||||
public void MoveItem(IVEDrillDownReadOnly pInfo, int index)
|
||||
{
|
||||
bool wasfirstchild = false;
|
||||
ItemInfo parentInfo = pInfo as ItemInfo;
|
||||
DocVersionInfo parentInfoDV = pInfo as DocVersionInfo;
|
||||
IList<ItemInfo> children = null;
|
||||
E_FromType partType = 0; // this is needed later to determine sub-group type.
|
||||
if (parentInfo != null)
|
||||
{
|
||||
// this may have subgroups, need to use part type to get children list...
|
||||
ItemInfo thisinfo = ItemInfo.Get(ItemID);
|
||||
partType = thisinfo.FirstSibling.ItemParts[0].PartType;
|
||||
children = (IList<ItemInfo>)parentInfo.Lookup((int)partType);
|
||||
}
|
||||
else
|
||||
children = (IList<ItemInfo>)parentInfoDV.GetChildren();
|
||||
int numChild = children.Count;
|
||||
|
||||
if (this.MyPrevious == null) wasfirstchild = true;
|
||||
Item origNextItem = null;
|
||||
|
||||
// First, remove from this item from its list. To do this, get the current item's next point and redirect it's myprevious
|
||||
// to this item's previous...
|
||||
if (NextItems != null && NextItems.Count > 0)
|
||||
{
|
||||
origNextItem = NextItems.Items[0];
|
||||
origNextItem.MyPrevious = this.MyPrevious;
|
||||
this.Save();
|
||||
}
|
||||
|
||||
// check to see if the item is being moved into the middle of some items. newPreviousItem is the item defined
|
||||
// by index-1, i.e. inserting below newPreviousItem.
|
||||
ItemInfo newPreviousInfo = (index == 0) ? null : children[index - 1];
|
||||
ItemInfo newNextInfo = (index == children.Count) ? null : children[index];
|
||||
|
||||
// Adjust the new next proc to be me.
|
||||
if (newNextInfo != null)
|
||||
{
|
||||
using (Item newNextItem = newNextInfo.Get())
|
||||
{
|
||||
newNextItem.MyPrevious = this;
|
||||
newNextItem.Save().Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// adjust the previous node, i.e. may either be at same level or, if first in list, adjust the parent...
|
||||
// if 'newPreviousItem' isn't null, then adding to the middle of the list.
|
||||
if (newPreviousInfo != null)
|
||||
{
|
||||
using (Item newPreviousItem = newPreviousInfo.Get())
|
||||
{
|
||||
MyPrevious = newPreviousItem;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
// newPreviousInfo == null if moving into first child, and wasfirstchild == true if moving out of first child.
|
||||
// This will require adjusting the DocVersion to point to the correct first child if a procedure is moved.
|
||||
if (newPreviousInfo == null || wasfirstchild)
|
||||
{
|
||||
if (parentInfo != null) // Moving Item within procedure, i.e. moving a section or step
|
||||
{
|
||||
using (Item parentItem = parentInfo.Get())
|
||||
{
|
||||
// moving first child out... reset parent to point to the original next item
|
||||
if (wasfirstchild)
|
||||
parentItem.MyContent.ContentParts[(int)partType].MyItem = origNextItem;
|
||||
else
|
||||
parentItem.MyContent.ContentParts[(int)partType].MyItem = this;
|
||||
parentItem.Save().Dispose();
|
||||
}
|
||||
}
|
||||
else if (parentInfoDV != null) // Moving Item (Procedure) within DocVersion
|
||||
{
|
||||
using (DocVersion parentItemDV = parentInfoDV.Get())
|
||||
{
|
||||
ItemInfo firstinfo = parentInfoDV.FirstChild();
|
||||
parentItemDV.MyItem = wasfirstchild?parentInfoDV.Procedures[1].Get():this;
|
||||
parentItemDV.Save().Dispose();
|
||||
if (!wasfirstchild && firstinfo != null)
|
||||
{
|
||||
using (Item firstchild = firstinfo.Get())
|
||||
{
|
||||
firstchild.MyPrevious = this;
|
||||
firstchild.Save().Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!wasfirstchild)
|
||||
{
|
||||
this.MyPrevious = null;
|
||||
this.Save();
|
||||
}
|
||||
if (origNextItem != null) origNextItem.Dispose();
|
||||
if (parentInfo != null)
|
||||
parentInfo.MyContent.RefreshContentParts();
|
||||
if (parentInfoDV != null)
|
||||
parentInfoDV.ResetProcedures();
|
||||
}
|
||||
|
||||
}
|
||||
protected static int MakeNewItem(IVEDrillDownReadOnly parentInfoDD, ItemInfo previousInfo, string number, string title, int type, E_FromType partType)
|
||||
{
|
||||
int newitemid = 0;
|
||||
if (parentInfoDD == null)
|
||||
parentInfoDD = previousInfo.ActiveParent;
|
||||
ItemInfo parentInfo = parentInfoDD as ItemInfo;
|
||||
DocVersionInfo parentInfoDV = parentInfoDD as DocVersionInfo;
|
||||
using (Content cont = Content.New(number, title, type, null, null))
|
||||
{
|
||||
using (Item fromitem = previousInfo == null ? null : previousInfo.Get())
|
||||
{
|
||||
ItemInfo nextInfo = null; // Check to see if the item is being inserted in the middle of some items.
|
||||
if (previousInfo != null && previousInfo.NextItems != null && previousInfo.NextItems.Count > 0)
|
||||
nextInfo = previousInfo.NextItems[0];
|
||||
using (Item itm = Item.MakeItem(fromitem, cont))
|
||||
{
|
||||
newitemid = itm.ItemID;
|
||||
if (nextInfo != null)
|
||||
{
|
||||
using (Item nextItem = nextInfo.Get())
|
||||
{
|
||||
nextItem.MyPrevious = itm;// Aim the next item back at the new item.
|
||||
nextItem.Save().Dispose();
|
||||
}
|
||||
}
|
||||
if (fromitem == null)
|
||||
{
|
||||
if (parentInfo != null) // Adding Item to Procedure, Section or Step
|
||||
{
|
||||
using (Item parentItem = parentInfo.Get())
|
||||
{
|
||||
ItemInfo firstinfo = parentInfo.FirstChild(partType);
|
||||
if (firstinfo != null)
|
||||
{
|
||||
using (Item firstchild = firstinfo.Get())
|
||||
{
|
||||
parentItem.MyContent.ContentParts[(int)partType].MyItem = itm;// First update the parent to point to the new first child
|
||||
parentItem.Save().Dispose();
|
||||
firstchild.MyPrevious = itm;// Aim the old first child to point to the new first child.
|
||||
firstchild.Save().Dispose();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem.MyContent.ContentParts.Add((int)partType, itm);// update the parent to point to the new first child
|
||||
parentItem.Save().Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parentInfoDV != null) // Adding Item (Procedure) to DocVersion
|
||||
{
|
||||
using (DocVersion parentItemDV = parentInfoDV.Get())
|
||||
{
|
||||
ItemInfo firstinfo = parentInfoDV.FirstChild();
|
||||
parentItemDV.MyItem = itm;// First update the parent to point to the new first child
|
||||
parentItemDV.Save().Dispose();
|
||||
if (firstinfo != null)
|
||||
{
|
||||
using (Item firstchild = firstinfo.Get())
|
||||
{
|
||||
firstchild.MyPrevious = itm;// Aim the old first child to point to the new first child.
|
||||
firstchild.Save().Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parentInfo != null)
|
||||
parentInfo.MyContent.RefreshContentParts();
|
||||
if (parentInfoDV != null)
|
||||
parentInfoDV.ResetProcedures();
|
||||
return newitemid;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region ItemInfo
|
||||
public partial class ItemInfo:IVEDrillDownReadOnly
|
||||
{
|
||||
protected void ExtensionRefreshFields(Item tmp)
|
||||
{
|
||||
_ActiveParent = null;
|
||||
}
|
||||
#region LoadAtOnce2
|
||||
public static ItemInfo GetItemAndChildren2(int? itemID)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria2(itemID));
|
||||
//_AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
@ -152,7 +347,7 @@ namespace VEPROMS.CSLA.Library
|
||||
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
_AllList.Remove(this);
|
||||
RemoveFromCache(this);
|
||||
}
|
||||
private void SpinThroughChildren()
|
||||
{
|
||||
@ -169,7 +364,7 @@ namespace VEPROMS.CSLA.Library
|
||||
try
|
||||
{
|
||||
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria(itemID,parentID));
|
||||
//_AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
@ -429,6 +624,27 @@ namespace VEPROMS.CSLA.Library
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
public ItemInfo LastSibling
|
||||
{
|
||||
get
|
||||
{
|
||||
ItemInfo temp = this;
|
||||
while (temp.NextItems[0] != null) temp = temp.NextItems[0];
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
public ItemInfo LastChild(E_FromType partType)
|
||||
{
|
||||
ItemInfoList myitems = Lookup((int)partType);
|
||||
if (myitems !=null) return myitems[myitems.Count-1];
|
||||
return null;
|
||||
}
|
||||
public ItemInfo FirstChild(E_FromType partType)
|
||||
{
|
||||
ItemInfoList myitems = Lookup((int)partType);
|
||||
if (myitems != null) return myitems[0];
|
||||
return null;
|
||||
}
|
||||
public bool IsSubStep
|
||||
{
|
||||
get
|
||||
@ -614,16 +830,39 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList)
|
||||
{
|
||||
if (itemInfoList != null) return itemInfoList;
|
||||
if (itemInfoList == null)
|
||||
itemInfoList = Lookup(fromType);
|
||||
return itemInfoList;
|
||||
}
|
||||
internal ItemInfoList Lookup(int fromType)
|
||||
{
|
||||
ItemInfoList itemInfoList = null;
|
||||
if (MyContent.ContentPartCount != 0)
|
||||
foreach (PartInfo partInfo in MyContent.ContentParts)
|
||||
if (partInfo.FromType == fromType)
|
||||
{
|
||||
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID,partInfo.FromType);
|
||||
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID, partInfo.FromType);
|
||||
return itemInfoList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void ResetParts(int itemID)
|
||||
{
|
||||
string key = itemID.ToString();
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (ItemInfo itm in _CacheByPrimaryKey[key])
|
||||
itm.ResetParts();
|
||||
}
|
||||
public void ResetParts()
|
||||
{
|
||||
_Procedures = null;
|
||||
_Sections = null;
|
||||
_Cautions = null;
|
||||
_Notes = null;
|
||||
_RNOs = null;
|
||||
_Steps = null;
|
||||
_Tables = null;
|
||||
}
|
||||
private ItemInfoList _Procedures;
|
||||
public ItemInfoList Procedures
|
||||
{ get { return Lookup(1,ref _Procedures); } }
|
||||
@ -740,6 +979,20 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get { return this.MyContent.ContentPartCount > 0; }
|
||||
}
|
||||
public bool HasWordContent
|
||||
{
|
||||
get { return this.MyContent.MyEntry != null; }
|
||||
}
|
||||
public bool HasStepContent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MyContent.ContentPartCount == 0) return false;
|
||||
if (MyContent.ContentPartCount == 1 && MyContent.ContentParts[0].PartType == E_FromType.Section) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemInfo MyProcedure
|
||||
{
|
||||
get
|
||||
@ -757,13 +1010,14 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
//if (_ActiveParent == this)_ActiveParent = null;
|
||||
if (_ActiveParent == null)
|
||||
{
|
||||
if (MyPrevious != null)
|
||||
_ActiveParent = _MyPrevious.ActiveParent;
|
||||
else
|
||||
{
|
||||
if (ItemDocVersionCount > 0)
|
||||
if (this.ItemDocVersions != null && this.ItemDocVersions.Count > 0)
|
||||
_ActiveParent = this.ItemDocVersions[0];
|
||||
else
|
||||
{
|
||||
@ -778,6 +1032,7 @@ namespace VEPROMS.CSLA.Library
|
||||
return _ActiveParent==this ? null : _ActiveParent;
|
||||
}
|
||||
internal set
|
||||
//set
|
||||
{
|
||||
_ActiveParent = value;
|
||||
}
|
||||
@ -813,7 +1068,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_ActiveFormat == null)
|
||||
if (_ActiveFormat == null)
|
||||
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
|
||||
return _ActiveFormat;
|
||||
}
|
||||
@ -982,11 +1237,44 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
|
||||
{
|
||||
protected override void RefreshFields(Item tmp)
|
||||
{
|
||||
base.RefreshFields(tmp);
|
||||
ExtensionRefreshFields(tmp);
|
||||
}
|
||||
#if ItemWithContent
|
||||
public ProcedureInfo(SafeDataReader dr) : base(dr, true) { }
|
||||
#else
|
||||
public ProcedureInfo(SafeDataReader dr) : base(dr) { }
|
||||
#endif
|
||||
private ProcedureInfo() : base() { ;}
|
||||
public new static ProcedureInfo Get(int itemID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||
try
|
||||
{
|
||||
ProcedureInfo tmp = GetCachedByPrimaryKey(itemID) as ProcedureInfo;
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<ProcedureInfo>(new PKCriteria(itemID));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on Item.Get", ex);
|
||||
}
|
||||
}
|
||||
public void MoveProcedure(IVEDrillDownReadOnly pInfo, int index)
|
||||
{
|
||||
using (Item ii = Item.Get(this.ItemID))
|
||||
{
|
||||
ii.MoveItem(pInfo, index);
|
||||
}
|
||||
}
|
||||
public new Procedure Get()
|
||||
{
|
||||
return (Procedure) (_Editable = Procedure.Get(ItemID));
|
||||
@ -1013,11 +1301,14 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||
try
|
||||
{
|
||||
Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
|
||||
Item itm = GetCachedByPrimaryKey(itemID);
|
||||
Procedure tmp = itm as Procedure;
|
||||
//Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
|
||||
if (tmp == null)
|
||||
{
|
||||
if (itm != null) Console.WriteLine("type = {0}", itm.GetType().Name);
|
||||
tmp = DataPortal.Fetch<Procedure>(new PKCriteria(itemID));
|
||||
_AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@ -1031,6 +1322,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
return (Procedure)base.Save();
|
||||
}
|
||||
public static Procedure MakeProcedure(IVEDrillDownReadOnly parentInfo, ItemInfo previousInfo, string procNumber, string procTitle, int procType)
|
||||
{
|
||||
int newitemid = MakeNewItem(parentInfo, previousInfo, procNumber, procTitle, procType, E_FromType.Procedure);
|
||||
return Procedure.Get(newitemid);
|
||||
}
|
||||
#region ProcedureConfig
|
||||
[NonSerialized]
|
||||
private ProcedureConfig _ProcedureConfig;
|
||||
@ -1057,15 +1353,49 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
|
||||
{
|
||||
protected override void RefreshFields(Item tmp)
|
||||
{
|
||||
base.RefreshFields(tmp);
|
||||
ExtensionRefreshFields(tmp);
|
||||
}
|
||||
#if ItemWithContent
|
||||
public SectionInfo(SafeDataReader dr) : base(dr, true) { }
|
||||
#else
|
||||
public SectionInfo(SafeDataReader dr) : base(dr) { }
|
||||
#endif
|
||||
private SectionInfo() : base() { ;}
|
||||
public new static SectionInfo Get(int itemID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||
try
|
||||
{
|
||||
SectionInfo tmp = GetCachedByPrimaryKey(itemID) as SectionInfo;
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<SectionInfo>(new PKCriteria(itemID));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on Item.Get", ex);
|
||||
}
|
||||
}
|
||||
public void MoveSection(IVEDrillDownReadOnly pInfo, int index)
|
||||
{
|
||||
using (Item ii = Item.Get(this.ItemID))
|
||||
{
|
||||
ii.MoveItem(pInfo, index);
|
||||
}
|
||||
}
|
||||
public new Section Get()
|
||||
{
|
||||
return (Section)(_Editable = Section.Get(ItemID));
|
||||
}
|
||||
|
||||
#region SectionConfig
|
||||
[NonSerialized]
|
||||
private SectionConfig _SectionConfig;
|
||||
@ -1088,11 +1418,11 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||
try
|
||||
{
|
||||
Section tmp = (Section)GetExistingByPrimaryKey(itemID);
|
||||
Section tmp = GetCachedByPrimaryKey(itemID) as Section;
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<Section>(new PKCriteria(itemID));
|
||||
_AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@ -1102,12 +1432,15 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error on Item.Get", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public new Section Save()
|
||||
{
|
||||
return (Section)base.Save();
|
||||
}
|
||||
|
||||
public static Section MakeSection(IVEDrillDownReadOnly parentInfo, ItemInfo previousInfo, string sectNumber, string sectTitle, int sectType)
|
||||
{
|
||||
int newitemid = MakeNewItem(parentInfo, previousInfo, sectNumber, sectTitle, sectType, E_FromType.Section);
|
||||
return Section.Get(newitemid);
|
||||
}
|
||||
#region SectionConfig
|
||||
[NonSerialized]
|
||||
private SectionConfig _SectionConfig;
|
||||
@ -1134,6 +1467,11 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
public partial class StepInfo : ItemInfo
|
||||
{
|
||||
protected override void RefreshFields(Item tmp)
|
||||
{
|
||||
base.RefreshFields(tmp);
|
||||
ExtensionRefreshFields(tmp);
|
||||
}
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return "Step " + base.ToString();
|
||||
@ -1143,6 +1481,34 @@ namespace VEPROMS.CSLA.Library
|
||||
#else
|
||||
public StepInfo(SafeDataReader dr) : base(dr) { }
|
||||
#endif
|
||||
private StepInfo() : base() { ;}
|
||||
public new static StepInfo Get(int itemID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||
try
|
||||
{
|
||||
StepInfo tmp = GetCachedByPrimaryKey(itemID) as StepInfo;
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<StepInfo>(new PKCriteria(itemID));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on Item.Get", ex);
|
||||
}
|
||||
}
|
||||
public void MoveStep(IVEDrillDownReadOnly pInfo, int index)
|
||||
{
|
||||
using (Item ii = Item.Get(this.ItemID))
|
||||
{
|
||||
ii.MoveItem(pInfo, index);
|
||||
}
|
||||
}
|
||||
public new Step Get()
|
||||
{
|
||||
return (Step)(_Editable = Step.Get(ItemID));
|
||||
@ -1162,11 +1528,11 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||
try
|
||||
{
|
||||
Step tmp = (Step)GetExistingByPrimaryKey(itemID);
|
||||
Step tmp = (Step)GetCachedByPrimaryKey(itemID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<Step>(new PKCriteria(itemID));
|
||||
_AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@ -1176,6 +1542,17 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error on Item.Get", ex);
|
||||
}
|
||||
}
|
||||
// TODO :MakeCaution;
|
||||
// TODO :MakeNote;
|
||||
// TODO :MakeRNO;
|
||||
// TODO :MakeSection;
|
||||
// TODO :MakeSubStep;
|
||||
// TODO :MakeTable;
|
||||
public static Step MakeStep(IVEDrillDownReadOnly parentInfo, ItemInfo previousInfo, string stepNumber, string stepTitle, int stepType, E_FromType fromType)
|
||||
{
|
||||
int newitemid = MakeNewItem(parentInfo, previousInfo, stepNumber, stepTitle, stepType, fromType);
|
||||
return Step.Get(newitemid);
|
||||
}
|
||||
//#region StepConfig
|
||||
//[NonSerialized]
|
||||
//private StepConfig _StepConfig;
|
||||
|
@ -82,6 +82,18 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region IsStepSection
|
||||
[Category("Miscellaneous")]
|
||||
[Description("Is a Step Section")]
|
||||
private LazyLoad<bool> _IsStepSection;
|
||||
public bool IsStepSection
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _IsStepSection, "@IsStepSection");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Oldtonew
|
||||
[Category("Miscellaneous")]
|
||||
[Description("Convert from old to new")]
|
||||
|
@ -325,6 +325,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public vlnFormatList(XmlNodeList xmlNodeList)
|
||||
{
|
||||
if (xmlNodeList == null) return;
|
||||
_XmlNodeList = xmlNodeList;
|
||||
foreach (XmlNode xn in _XmlNodeList)
|
||||
{
|
||||
|
@ -53,28 +53,36 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<Annotation> _AllList = new List<Annotation>();
|
||||
private static Dictionary<string, List<Annotation>> _AllByPrimaryKey = new Dictionary<string, List<Annotation>>();
|
||||
private static List<Annotation> _CacheList = new List<Annotation>();
|
||||
protected static void AddToCache(Annotation annotation)
|
||||
{
|
||||
if (!_CacheList.Contains(annotation)) _CacheList.Add(annotation); // In AddToCache
|
||||
}
|
||||
protected static void RemoveFromCache(Annotation annotation)
|
||||
{
|
||||
while (_CacheList.Contains(annotation)) _CacheList.Remove(annotation); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<Annotation>> _CacheByPrimaryKey = new Dictionary<string, List<Annotation>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<Annotation> remove = new List<Annotation>();
|
||||
foreach (Annotation tmp in _AllList)
|
||||
foreach (Annotation tmp in _CacheList)
|
||||
{
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List<Annotation>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[tmp.AnnotationID.ToString()] = new List<Annotation>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (Annotation tmp in remove)
|
||||
_AllList.Remove(tmp);
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
public static Annotation GetExistingByPrimaryKey(int annotationID)
|
||||
protected static Annotation GetCachedByPrimaryKey(int annotationID)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = annotationID.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@ -442,24 +450,29 @@ namespace VEPROMS.CSLA.Library
|
||||
public int CurrentEditLevel
|
||||
{ get { return EditLevel; } }
|
||||
private static int _AnnotationUnique = 0;
|
||||
private int _MyAnnotationUnique;
|
||||
protected static int AnnotationUnique
|
||||
{ get { return ++_AnnotationUnique; } }
|
||||
private int _MyAnnotationUnique = AnnotationUnique;
|
||||
public int MyAnnotationUnique
|
||||
{
|
||||
get { return _MyAnnotationUnique; }
|
||||
}
|
||||
{ get { return _MyAnnotationUnique; } }
|
||||
protected Annotation()
|
||||
{/* require use of factory methods */
|
||||
_MyAnnotationUnique = ++_AnnotationUnique;
|
||||
_AllList.Add(this);
|
||||
AddToCache(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
|
||||
List<Annotation> listAnnotation = _AllByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
|
||||
listAnnotation.Remove(this); // Remove the item from the list
|
||||
if (listAnnotation.Count == 0) //If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
|
||||
RemoveFromDictionaries();
|
||||
}
|
||||
private void RemoveFromDictionaries()
|
||||
{
|
||||
RemoveFromCache(this);
|
||||
if (_CacheByPrimaryKey.ContainsKey(AnnotationID.ToString()))
|
||||
{
|
||||
List<Annotation> listAnnotation = _CacheByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
|
||||
while (listAnnotation.Contains(this)) listAnnotation.Remove(this); // Remove the item from the list
|
||||
if (listAnnotation.Count == 0) //If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
|
||||
}
|
||||
}
|
||||
public static Annotation New()
|
||||
{
|
||||
@ -497,7 +510,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
Annotation tmp = Annotation.New(myItem, myAnnotationType, rtfText, searchText, config, dts, userID);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
{
|
||||
Annotation tmp2 = tmp;
|
||||
tmp = tmp2.Save();
|
||||
tmp2.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
@ -523,7 +540,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
Annotation tmp = Annotation.New(myItem, myAnnotationType, rtfText, searchText, config);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
{
|
||||
Annotation tmp2 = tmp;
|
||||
tmp = tmp2.Save();
|
||||
tmp2.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
@ -541,13 +562,17 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new System.Security.SecurityException("User not authorized to view a Annotation");
|
||||
try
|
||||
{
|
||||
Annotation tmp = GetExistingByPrimaryKey(annotationID);
|
||||
Annotation tmp = GetCachedByPrimaryKey(annotationID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<Annotation>(new PKCriteria(annotationID));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up Annotation
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -589,7 +614,8 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
BuildRefreshList();
|
||||
Annotation annotation = base.Save();
|
||||
_AllList.Add(annotation);//Refresh the item in AllList
|
||||
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
|
||||
AddToCache(annotation);//Refresh the item in AllList
|
||||
ProcessRefreshList();
|
||||
return annotation;
|
||||
}
|
||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<AnnotationInfo> _AllList = new List<AnnotationInfo>();
|
||||
private static Dictionary<string, List<AnnotationInfo>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
|
||||
private static List<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
|
||||
protected static void AddToCache(AnnotationInfo annotationInfo)
|
||||
{
|
||||
if (!_CacheList.Contains(annotationInfo)) _CacheList.Add(annotationInfo); // In AddToCache
|
||||
}
|
||||
protected static void RemoveFromCache(AnnotationInfo annotationInfo)
|
||||
{
|
||||
while (_CacheList.Contains(annotationInfo)) _CacheList.Remove(annotationInfo); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<AnnotationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<AnnotationInfo> remove = new List<AnnotationInfo>();
|
||||
foreach (AnnotationInfo tmp in _AllList)
|
||||
foreach (AnnotationInfo tmp in _CacheList)
|
||||
{
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (AnnotationInfo tmp in remove)
|
||||
_AllList.Remove(tmp);
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
internal static void AddList(AnnotationInfoList lst)
|
||||
{
|
||||
foreach (AnnotationInfo item in lst) _AllList.Add(item);
|
||||
foreach (AnnotationInfo item in lst) AddToCache(item);
|
||||
}
|
||||
public static AnnotationInfo GetExistingByPrimaryKey(int annotationID)
|
||||
protected static AnnotationInfo GetCachedByPrimaryKey(int annotationID)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = annotationID.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@ -208,24 +216,23 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _AnnotationInfoUnique = 0;
|
||||
private int _MyAnnotationInfoUnique;
|
||||
private static int AnnotationInfoUnique
|
||||
{ get { return ++_AnnotationInfoUnique; } }
|
||||
private int _MyAnnotationInfoUnique = AnnotationInfoUnique;
|
||||
public int MyAnnotationInfoUnique
|
||||
{
|
||||
get { return _MyAnnotationInfoUnique; }
|
||||
}
|
||||
private AnnotationInfo()
|
||||
{ get { return _MyAnnotationInfoUnique; } }
|
||||
protected AnnotationInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
|
||||
_AllList.Add(this);
|
||||
AddToCache(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
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
|
||||
RemoveFromCache(this);
|
||||
if (!_CacheByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
|
||||
List<AnnotationInfo> listAnnotationInfo = _CacheByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
|
||||
while (listAnnotationInfo.Contains(this)) 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
|
||||
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Annotation Get()
|
||||
{
|
||||
@ -235,22 +242,22 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AnnotationID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(Annotation tmp)
|
||||
protected virtual void RefreshFields(Annotation tmp)
|
||||
{
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
MyItem.RefreshItemAnnotations(); // Update List for old value
|
||||
if (MyItem != null) 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
|
||||
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
|
||||
if (_TypeID != tmp.TypeID)
|
||||
{
|
||||
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
|
||||
if (MyAnnotationType != null) 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
|
||||
@ -269,15 +276,15 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AnnotationID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(AnnotationTypeAnnotation tmp)
|
||||
protected virtual void RefreshFields(AnnotationTypeAnnotation tmp)
|
||||
{
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
MyItem.RefreshItemAnnotations(); // Update List for old value
|
||||
if (MyItem != null) 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
|
||||
@ -296,15 +303,15 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AnnotationID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ItemAnnotation tmp)
|
||||
protected virtual void RefreshFields(ItemAnnotation tmp)
|
||||
{
|
||||
if (_TypeID != tmp.TypeID)
|
||||
{
|
||||
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
|
||||
if (MyAnnotationType != null) 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
|
||||
@ -325,13 +332,17 @@ namespace VEPROMS.CSLA.Library
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
|
||||
try
|
||||
{
|
||||
AnnotationInfo tmp = GetExistingByPrimaryKey(annotationID);
|
||||
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationInfo
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -343,7 +354,6 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal AnnotationInfo(SafeDataReader dr)
|
||||
{
|
||||
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
|
@ -64,38 +64,46 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<AnnotationType> _AllList = new List<AnnotationType>();
|
||||
private static Dictionary<string, List<AnnotationType>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationType>>();
|
||||
private static Dictionary<string, List<AnnotationType>> _AllByName = new Dictionary<string, List<AnnotationType>>();
|
||||
private static List<AnnotationType> _CacheList = new List<AnnotationType>();
|
||||
protected static void AddToCache(AnnotationType annotationType)
|
||||
{
|
||||
if (!_CacheList.Contains(annotationType)) _CacheList.Add(annotationType); // In AddToCache
|
||||
}
|
||||
protected static void RemoveFromCache(AnnotationType annotationType)
|
||||
{
|
||||
while (_CacheList.Contains(annotationType)) _CacheList.Remove(annotationType); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<AnnotationType>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationType>>();
|
||||
private static Dictionary<string, List<AnnotationType>> _CacheByName = new Dictionary<string, List<AnnotationType>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<AnnotationType> remove = new List<AnnotationType>();
|
||||
foreach (AnnotationType tmp in _AllList)
|
||||
foreach (AnnotationType tmp in _CacheList)
|
||||
{
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationType>(); // Add new list for PrimaryKey
|
||||
_AllByName[tmp.Name.ToString()] = new List<AnnotationType>(); // Add new list for Name
|
||||
_CacheByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationType>(); // Add new list for PrimaryKey
|
||||
_CacheByName[tmp.Name.ToString()] = new List<AnnotationType>(); // Add new list for Name
|
||||
}
|
||||
_AllByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_AllByName[tmp.Name.ToString()].Add(tmp); // Unique Index
|
||||
_CacheByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByName[tmp.Name.ToString()].Add(tmp); // Unique Index
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (AnnotationType tmp in remove)
|
||||
_AllList.Remove(tmp);
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
public static AnnotationType GetExistingByPrimaryKey(int typeID)
|
||||
protected static AnnotationType GetCachedByPrimaryKey(int typeID)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = typeID.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
public static AnnotationType GetExistingByName(string name)
|
||||
protected static AnnotationType GetCachedByName(string name)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = name.ToString();
|
||||
if (_AllByName.ContainsKey(key)) return _AllByName[key][0];
|
||||
if (_CacheByName.ContainsKey(key)) return _CacheByName[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@ -394,28 +402,41 @@ namespace VEPROMS.CSLA.Library
|
||||
public int CurrentEditLevel
|
||||
{ get { return EditLevel; } }
|
||||
private static int _AnnotationTypeUnique = 0;
|
||||
private int _MyAnnotationTypeUnique;
|
||||
protected static int AnnotationTypeUnique
|
||||
{ get { return ++_AnnotationTypeUnique; } }
|
||||
private int _MyAnnotationTypeUnique = AnnotationTypeUnique;
|
||||
public int MyAnnotationTypeUnique
|
||||
{
|
||||
get { return _MyAnnotationTypeUnique; }
|
||||
}
|
||||
{ get { return _MyAnnotationTypeUnique; } }
|
||||
protected AnnotationType()
|
||||
{/* require use of factory methods */
|
||||
_MyAnnotationTypeUnique = ++_AnnotationTypeUnique;
|
||||
_AllList.Add(this);
|
||||
AddToCache(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return;
|
||||
List<AnnotationType> listAnnotationType = _AllByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
||||
listAnnotationType.Remove(this); // Remove the item from the list
|
||||
if (listAnnotationType.Count == 0) //If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
||||
listAnnotationType = _AllByName[TypeID.ToString()]; // Get the list of items
|
||||
listAnnotationType.Remove(this); // Remove the item from the list
|
||||
if (listAnnotationType.Count == 0) //If there are no items left in the list
|
||||
_AllByName.Remove(TypeID.ToString()); // remove the list
|
||||
RemoveFromDictionaries();
|
||||
}
|
||||
private void RemoveFromDictionaries()
|
||||
{
|
||||
RemoveFromCache(this);
|
||||
if (_CacheByPrimaryKey.ContainsKey(TypeID.ToString()))
|
||||
{
|
||||
List<AnnotationType> listAnnotationType = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
||||
while (listAnnotationType.Contains(this)) listAnnotationType.Remove(this); // Remove the item from the list
|
||||
if (listAnnotationType.Count == 0) //If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
||||
}
|
||||
string myKey;
|
||||
myKey = null;
|
||||
foreach (string key in _CacheByName.Keys)
|
||||
if (_CacheByName[key].Contains(this))
|
||||
myKey = key;
|
||||
if (myKey != null)
|
||||
{
|
||||
List<AnnotationType> listAnnotationType = _CacheByName[myKey]; // Get the list of items
|
||||
listAnnotationType.Remove(this); // Remove the item from the list
|
||||
if (listAnnotationType.Count == 0) //If there are no items left in the list
|
||||
_CacheByName.Remove(myKey); // remove the list
|
||||
}
|
||||
}
|
||||
public static AnnotationType New()
|
||||
{
|
||||
@ -449,7 +470,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
AnnotationType tmp = AnnotationType.New(name, config, dts, userID);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
{
|
||||
AnnotationType tmp2 = tmp;
|
||||
tmp = tmp2.Save();
|
||||
tmp2.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
@ -472,7 +497,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
AnnotationType tmp = AnnotationType.New(name, config);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
{
|
||||
AnnotationType tmp2 = tmp;
|
||||
tmp = tmp2.Save();
|
||||
tmp2.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
@ -490,13 +519,17 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||
try
|
||||
{
|
||||
AnnotationType tmp = GetExistingByPrimaryKey(typeID);
|
||||
AnnotationType tmp = GetCachedByPrimaryKey(typeID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AnnotationType>(new PKCriteria(typeID));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationType
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -504,19 +537,23 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error on AnnotationType.Get", ex);
|
||||
}
|
||||
}
|
||||
private static AnnotationType GetByName(string name)
|
||||
public static AnnotationType GetByName(string name)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||
try
|
||||
{
|
||||
AnnotationType tmp = GetExistingByName(name);
|
||||
AnnotationType tmp = GetCachedByName(name);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AnnotationType>(new NameCriteria(name));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationType
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -558,7 +595,8 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
BuildRefreshList();
|
||||
AnnotationType annotationType = base.Save();
|
||||
_AllList.Add(annotationType);//Refresh the item in AllList
|
||||
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
|
||||
AddToCache(annotationType);//Refresh the item in AllList
|
||||
ProcessRefreshList();
|
||||
return annotationType;
|
||||
}
|
||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<AnnotationTypeInfo> _AllList = new List<AnnotationTypeInfo>();
|
||||
private static Dictionary<string, List<AnnotationTypeInfo>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
|
||||
private static List<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
|
||||
protected static void AddToCache(AnnotationTypeInfo annotationTypeInfo)
|
||||
{
|
||||
if (!_CacheList.Contains(annotationTypeInfo)) _CacheList.Add(annotationTypeInfo); // In AddToCache
|
||||
}
|
||||
protected static void RemoveFromCache(AnnotationTypeInfo annotationTypeInfo)
|
||||
{
|
||||
while (_CacheList.Contains(annotationTypeInfo)) _CacheList.Remove(annotationTypeInfo); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<AnnotationTypeInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
|
||||
foreach (AnnotationTypeInfo tmp in _AllList)
|
||||
foreach (AnnotationTypeInfo tmp in _CacheList)
|
||||
{
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationTypeInfo>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationTypeInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (AnnotationTypeInfo tmp in remove)
|
||||
_AllList.Remove(tmp);
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
internal static void AddList(AnnotationTypeInfoList lst)
|
||||
{
|
||||
foreach (AnnotationTypeInfo item in lst) _AllList.Add(item);
|
||||
foreach (AnnotationTypeInfo item in lst) AddToCache(item);
|
||||
}
|
||||
public static AnnotationTypeInfo GetExistingByPrimaryKey(int typeID)
|
||||
protected static AnnotationTypeInfo GetCachedByPrimaryKey(int typeID)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = typeID.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@ -161,11 +169,11 @@ namespace VEPROMS.CSLA.Library
|
||||
return _AnnotationTypeAnnotations;
|
||||
}
|
||||
}
|
||||
internal void RefreshAnnotationTypeAnnotations()
|
||||
public void RefreshAnnotationTypeAnnotations()
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(_TypeID.ToString()))
|
||||
foreach (AnnotationTypeInfo tmp in _AllByPrimaryKey[_TypeID.ToString()])
|
||||
if (_CacheByPrimaryKey.ContainsKey(_TypeID.ToString()))
|
||||
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
|
||||
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
|
||||
@ -189,24 +197,23 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _AnnotationTypeInfoUnique = 0;
|
||||
private int _MyAnnotationTypeInfoUnique;
|
||||
private static int AnnotationTypeInfoUnique
|
||||
{ get { return ++_AnnotationTypeInfoUnique; } }
|
||||
private int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
|
||||
public int MyAnnotationTypeInfoUnique
|
||||
{
|
||||
get { return _MyAnnotationTypeInfoUnique; }
|
||||
}
|
||||
private AnnotationTypeInfo()
|
||||
{ get { return _MyAnnotationTypeInfoUnique; } }
|
||||
protected AnnotationTypeInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique;
|
||||
_AllList.Add(this);
|
||||
AddToCache(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return;
|
||||
List<AnnotationTypeInfo> listAnnotationTypeInfo = _AllByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
||||
listAnnotationTypeInfo.Remove(this); // Remove the item from the list
|
||||
RemoveFromCache(this);
|
||||
if (!_CacheByPrimaryKey.ContainsKey(TypeID.ToString())) return;
|
||||
List<AnnotationTypeInfo> listAnnotationTypeInfo = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
||||
while (listAnnotationTypeInfo.Contains(this)) listAnnotationTypeInfo.Remove(this); // Remove the item from the list
|
||||
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
||||
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
||||
}
|
||||
public virtual AnnotationType Get()
|
||||
{
|
||||
@ -216,11 +223,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.TypeID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationTypeInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AnnotationTypeInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(AnnotationType tmp)
|
||||
protected virtual void RefreshFields(AnnotationType tmp)
|
||||
{
|
||||
_Name = tmp.Name;
|
||||
_Config = tmp.Config;
|
||||
@ -235,13 +242,17 @@ namespace VEPROMS.CSLA.Library
|
||||
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||
try
|
||||
{
|
||||
AnnotationTypeInfo tmp = GetExistingByPrimaryKey(typeID);
|
||||
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationTypeInfo
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -253,7 +264,6 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal AnnotationTypeInfo(SafeDataReader dr)
|
||||
{
|
||||
_MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
|
@ -54,28 +54,36 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<Assignment> _AllList = new List<Assignment>();
|
||||
private static Dictionary<string, List<Assignment>> _AllByPrimaryKey = new Dictionary<string, List<Assignment>>();
|
||||
private static List<Assignment> _CacheList = new List<Assignment>();
|
||||
protected static void AddToCache(Assignment assignment)
|
||||
{
|
||||
if (!_CacheList.Contains(assignment)) _CacheList.Add(assignment); // In AddToCache
|
||||
}
|
||||
protected static void RemoveFromCache(Assignment assignment)
|
||||
{
|
||||
while (_CacheList.Contains(assignment)) _CacheList.Remove(assignment); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<Assignment>> _CacheByPrimaryKey = new Dictionary<string, List<Assignment>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<Assignment> remove = new List<Assignment>();
|
||||
foreach (Assignment tmp in _AllList)
|
||||
foreach (Assignment tmp in _CacheList)
|
||||
{
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString()))
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.AID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.AID.ToString()] = new List<Assignment>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[tmp.AID.ToString()] = new List<Assignment>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (Assignment tmp in remove)
|
||||
_AllList.Remove(tmp);
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
public static Assignment GetExistingByPrimaryKey(int aid)
|
||||
protected static Assignment GetCachedByPrimaryKey(int aid)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = aid.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@ -504,24 +512,29 @@ namespace VEPROMS.CSLA.Library
|
||||
public int CurrentEditLevel
|
||||
{ get { return EditLevel; } }
|
||||
private static int _AssignmentUnique = 0;
|
||||
private int _MyAssignmentUnique;
|
||||
protected static int AssignmentUnique
|
||||
{ get { return ++_AssignmentUnique; } }
|
||||
private int _MyAssignmentUnique = AssignmentUnique;
|
||||
public int MyAssignmentUnique
|
||||
{
|
||||
get { return _MyAssignmentUnique; }
|
||||
}
|
||||
{ get { return _MyAssignmentUnique; } }
|
||||
protected Assignment()
|
||||
{/* require use of factory methods */
|
||||
_MyAssignmentUnique = ++_AssignmentUnique;
|
||||
_AllList.Add(this);
|
||||
AddToCache(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
|
||||
List<Assignment> listAssignment = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
|
||||
listAssignment.Remove(this); // Remove the item from the list
|
||||
if (listAssignment.Count == 0) //If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(AID.ToString()); // remove the list
|
||||
RemoveFromDictionaries();
|
||||
}
|
||||
private void RemoveFromDictionaries()
|
||||
{
|
||||
RemoveFromCache(this);
|
||||
if (_CacheByPrimaryKey.ContainsKey(AID.ToString()))
|
||||
{
|
||||
List<Assignment> listAssignment = _CacheByPrimaryKey[AID.ToString()]; // Get the list of items
|
||||
while (listAssignment.Contains(this)) listAssignment.Remove(this); // Remove the item from the list
|
||||
if (listAssignment.Count == 0) //If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(AID.ToString()); // remove the list
|
||||
}
|
||||
}
|
||||
public static Assignment New()
|
||||
{
|
||||
@ -560,7 +573,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
Assignment tmp = Assignment.New(myGroup, myRole, myFolder, startDate, endDate, dts, usrID);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
{
|
||||
Assignment tmp2 = tmp;
|
||||
tmp = tmp2.Save();
|
||||
tmp2.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
@ -585,7 +602,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
Assignment tmp = Assignment.New(myGroup, myRole, myFolder, endDate);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
{
|
||||
Assignment tmp2 = tmp;
|
||||
tmp = tmp2.Save();
|
||||
tmp2.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
@ -603,13 +624,17 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new System.Security.SecurityException("User not authorized to view a Assignment");
|
||||
try
|
||||
{
|
||||
Assignment tmp = GetExistingByPrimaryKey(aid);
|
||||
Assignment tmp = GetCachedByPrimaryKey(aid);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<Assignment>(new PKCriteria(aid));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up Assignment
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -651,7 +676,8 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
BuildRefreshList();
|
||||
Assignment assignment = base.Save();
|
||||
_AllList.Add(assignment);//Refresh the item in AllList
|
||||
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
|
||||
AddToCache(assignment);//Refresh the item in AllList
|
||||
ProcessRefreshList();
|
||||
return assignment;
|
||||
}
|
||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<AssignmentInfo> _AllList = new List<AssignmentInfo>();
|
||||
private static Dictionary<string, List<AssignmentInfo>> _AllByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
|
||||
private static List<AssignmentInfo> _CacheList = new List<AssignmentInfo>();
|
||||
protected static void AddToCache(AssignmentInfo assignmentInfo)
|
||||
{
|
||||
if (!_CacheList.Contains(assignmentInfo)) _CacheList.Add(assignmentInfo); // In AddToCache
|
||||
}
|
||||
protected static void RemoveFromCache(AssignmentInfo assignmentInfo)
|
||||
{
|
||||
while (_CacheList.Contains(assignmentInfo)) _CacheList.Remove(assignmentInfo); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<AssignmentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<AssignmentInfo> remove = new List<AssignmentInfo>();
|
||||
foreach (AssignmentInfo tmp in _AllList)
|
||||
foreach (AssignmentInfo tmp in _CacheList)
|
||||
{
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString()))
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.AID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.AID.ToString()] = new List<AssignmentInfo>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[tmp.AID.ToString()] = new List<AssignmentInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (AssignmentInfo tmp in remove)
|
||||
_AllList.Remove(tmp);
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
internal static void AddList(AssignmentInfoList lst)
|
||||
{
|
||||
foreach (AssignmentInfo item in lst) _AllList.Add(item);
|
||||
foreach (AssignmentInfo item in lst) AddToCache(item);
|
||||
}
|
||||
public static AssignmentInfo GetExistingByPrimaryKey(int aid)
|
||||
protected static AssignmentInfo GetCachedByPrimaryKey(int aid)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = aid.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@ -220,24 +228,23 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _AssignmentInfoUnique = 0;
|
||||
private int _MyAssignmentInfoUnique;
|
||||
private static int AssignmentInfoUnique
|
||||
{ get { return ++_AssignmentInfoUnique; } }
|
||||
private int _MyAssignmentInfoUnique = AssignmentInfoUnique;
|
||||
public int MyAssignmentInfoUnique
|
||||
{
|
||||
get { return _MyAssignmentInfoUnique; }
|
||||
}
|
||||
private AssignmentInfo()
|
||||
{ get { return _MyAssignmentInfoUnique; } }
|
||||
protected AssignmentInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
|
||||
_AllList.Add(this);
|
||||
AddToCache(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
|
||||
List<AssignmentInfo> listAssignmentInfo = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
|
||||
listAssignmentInfo.Remove(this); // Remove the item from the list
|
||||
RemoveFromCache(this);
|
||||
if (!_CacheByPrimaryKey.ContainsKey(AID.ToString())) return;
|
||||
List<AssignmentInfo> listAssignmentInfo = _CacheByPrimaryKey[AID.ToString()]; // Get the list of items
|
||||
while (listAssignmentInfo.Contains(this)) listAssignmentInfo.Remove(this); // Remove the item from the list
|
||||
if (listAssignmentInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(AID.ToString()); // remove the list
|
||||
_CacheByPrimaryKey.Remove(AID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Assignment Get()
|
||||
{
|
||||
@ -247,29 +254,29 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(Assignment tmp)
|
||||
protected virtual void RefreshFields(Assignment tmp)
|
||||
{
|
||||
if (_GID != tmp.GID)
|
||||
{
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
if (_RID != tmp.RID)
|
||||
{
|
||||
MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
_RID = tmp.RID; // Update the value
|
||||
}
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
@ -288,22 +295,22 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(FolderAssignment tmp)
|
||||
protected virtual void RefreshFields(FolderAssignment tmp)
|
||||
{
|
||||
if (_GID != tmp.GID)
|
||||
{
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
if (_RID != tmp.RID)
|
||||
{
|
||||
MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
_RID = tmp.RID; // Update the value
|
||||
}
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
@ -322,22 +329,22 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(GroupAssignment tmp)
|
||||
protected virtual void RefreshFields(GroupAssignment tmp)
|
||||
{
|
||||
if (_RID != tmp.RID)
|
||||
{
|
||||
MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
_RID = tmp.RID; // Update the value
|
||||
}
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
@ -356,22 +363,22 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(RoleAssignment tmp)
|
||||
protected virtual void RefreshFields(RoleAssignment tmp)
|
||||
{
|
||||
if (_GID != tmp.GID)
|
||||
{
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
@ -392,13 +399,17 @@ namespace VEPROMS.CSLA.Library
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Assignment");
|
||||
try
|
||||
{
|
||||
AssignmentInfo tmp = GetExistingByPrimaryKey(aid);
|
||||
AssignmentInfo tmp = GetCachedByPrimaryKey(aid);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid));
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AssignmentInfo
|
||||
tmp = null;
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -410,7 +421,6 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal AssignmentInfo(SafeDataReader dr)
|
||||
{
|
||||
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user