This commit is contained in:
parent
610f408c6d
commit
d0dba2aad4
@ -23,7 +23,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public static List<AnnotationTypeInfo> AllList()
|
public static List<AnnotationTypeInfo> AllList()
|
||||||
{
|
{
|
||||||
//return _AllList;
|
//return _AllList;
|
||||||
return AnnotationTypeInfo._AllList;
|
return AnnotationTypeInfo._CacheList;
|
||||||
}
|
}
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ReadDataItemList(dr);
|
ReadDataItemList(dr);
|
||||||
|
_CacheList.Add(this);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -96,9 +96,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return MyFolder;
|
return MyFolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private Format _ActiveFormat = null;
|
||||||
public Format ActiveFormat
|
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
|
public Format LocalFormat
|
||||||
{
|
{
|
||||||
@ -110,21 +120,26 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
public partial class DocVersionInfo:IVEDrillDownReadOnly
|
public partial class DocVersionInfo : IVEDrillDownReadOnly
|
||||||
{
|
{
|
||||||
#region DocVersion Config
|
#region DocVersion Config
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private DocVersionConfig _DocVersionConfig;
|
private DocVersionConfig _DocVersionConfig;
|
||||||
public 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()
|
private void DocVersionConfigRefresh()
|
||||||
{
|
{
|
||||||
_DocVersionConfig = null;
|
_DocVersionConfig = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
ItemInfoList _iil = null;
|
|
||||||
|
ItemInfoList _Procedures = null;
|
||||||
public ItemInfoList Procedures
|
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
|
#region IVEReadOnlyItem
|
||||||
public System.Collections.IList GetChildren()
|
public System.Collections.IList GetChildren()
|
||||||
{
|
{
|
||||||
@ -196,6 +211,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//{
|
//{
|
||||||
// return ToString();
|
// return ToString();
|
||||||
//}
|
//}
|
||||||
|
public ItemInfo LastChild()
|
||||||
|
{
|
||||||
|
return MyItem.LastSibling;
|
||||||
|
}
|
||||||
|
public ItemInfo FirstChild()
|
||||||
|
{
|
||||||
|
return MyItem;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Extension
|
#region Extension
|
||||||
partial class DocVersionInfoExtension : extensionBase
|
partial class DocVersionInfoExtension : extensionBase
|
||||||
|
@ -2,6 +2,10 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Csla;
|
||||||
|
using Csla.Data;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace VEPROMS.CSLA.Library
|
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
|
public class DSOFile : IDisposable
|
||||||
{
|
{
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
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.IO;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
{
|
{
|
||||||
@ -68,9 +70,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return MyParent;
|
return MyParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private Format _ActiveFormat = null;
|
||||||
public Format ActiveFormat
|
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
|
public Format LocalFormat
|
||||||
{
|
{
|
||||||
@ -81,6 +93,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get { return FolderConfig; }
|
get { return FolderConfig; }
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
public partial class FolderInfo:IVEDrillDownReadOnly
|
||||||
{
|
{
|
||||||
@ -96,11 +118,84 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_FolderConfig = null;
|
_FolderConfig = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
#region IVEReadOnlyItem
|
||||||
public System.Collections.IList GetChildren()
|
public System.Collections.IList GetChildren()
|
||||||
{
|
{
|
||||||
if(FolderDocVersionCount != 0)return FolderDocVersions;
|
if(FolderDocVersionCount != 0)return FolderDocVersions;
|
||||||
if (ChildFolderCount != 0) return ChildFolders;
|
//if (ChildFolderCount != 0) return ChildFolders;
|
||||||
|
if (ChildFolderCount != 0) return SortedChildFolders;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//public bool ChildrenAreLoaded
|
//public bool ChildrenAreLoaded
|
||||||
@ -178,4 +273,5 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,17 @@ using System.Drawing;
|
|||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
{
|
{
|
||||||
#region Item
|
#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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim();
|
return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim();
|
||||||
@ -61,18 +70,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
public Format ActiveFormat
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(_ActiveFormat == null)
|
if (_ActiveFormat == null)
|
||||||
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
|
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
|
||||||
return _ActiveFormat;
|
return _ActiveFormat;
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_ActiveFormat = null; // Reset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public Format LocalFormat
|
public Format LocalFormat
|
||||||
{
|
{
|
||||||
@ -83,18 +96,200 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get { return null; }
|
get { return null; }
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
#endregion
|
||||||
#region ItemInfo
|
#region ItemInfo
|
||||||
public partial class ItemInfo:IVEDrillDownReadOnly
|
public partial class ItemInfo:IVEDrillDownReadOnly
|
||||||
{
|
{
|
||||||
|
protected void ExtensionRefreshFields(Item tmp)
|
||||||
|
{
|
||||||
|
_ActiveParent = null;
|
||||||
|
}
|
||||||
#region LoadAtOnce2
|
#region LoadAtOnce2
|
||||||
public static ItemInfo GetItemAndChildren2(int? itemID)
|
public static ItemInfo GetItemAndChildren2(int? itemID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria2(itemID));
|
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria2(itemID));
|
||||||
//_AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -152,7 +347,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
|
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
|
||||||
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
_AllList.Remove(this);
|
RemoveFromCache(this);
|
||||||
}
|
}
|
||||||
private void SpinThroughChildren()
|
private void SpinThroughChildren()
|
||||||
{
|
{
|
||||||
@ -169,7 +364,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria(itemID,parentID));
|
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria(itemID,parentID));
|
||||||
//_AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -429,6 +624,27 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return temp;
|
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
|
public bool IsSubStep
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -614,16 +830,39 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList)
|
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)
|
if (MyContent.ContentPartCount != 0)
|
||||||
foreach (PartInfo partInfo in MyContent.ContentParts)
|
foreach (PartInfo partInfo in MyContent.ContentParts)
|
||||||
if (partInfo.FromType == fromType)
|
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 itemInfoList;
|
||||||
}
|
}
|
||||||
return null;
|
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;
|
private ItemInfoList _Procedures;
|
||||||
public ItemInfoList Procedures
|
public ItemInfoList Procedures
|
||||||
{ get { return Lookup(1,ref _Procedures); } }
|
{ get { return Lookup(1,ref _Procedures); } }
|
||||||
@ -740,6 +979,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
get { return this.MyContent.ContentPartCount > 0; }
|
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
|
public ItemInfo MyProcedure
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -757,13 +1010,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
//if (_ActiveParent == this)_ActiveParent = null;
|
||||||
if (_ActiveParent == null)
|
if (_ActiveParent == null)
|
||||||
{
|
{
|
||||||
if (MyPrevious != null)
|
if (MyPrevious != null)
|
||||||
_ActiveParent = _MyPrevious.ActiveParent;
|
_ActiveParent = _MyPrevious.ActiveParent;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ItemDocVersionCount > 0)
|
if (this.ItemDocVersions != null && this.ItemDocVersions.Count > 0)
|
||||||
_ActiveParent = this.ItemDocVersions[0];
|
_ActiveParent = this.ItemDocVersions[0];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -778,6 +1032,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ActiveParent==this ? null : _ActiveParent;
|
return _ActiveParent==this ? null : _ActiveParent;
|
||||||
}
|
}
|
||||||
internal set
|
internal set
|
||||||
|
//set
|
||||||
{
|
{
|
||||||
_ActiveParent = value;
|
_ActiveParent = value;
|
||||||
}
|
}
|
||||||
@ -813,7 +1068,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(_ActiveFormat == null)
|
if (_ActiveFormat == null)
|
||||||
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
|
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
|
||||||
return _ActiveFormat;
|
return _ActiveFormat;
|
||||||
}
|
}
|
||||||
@ -982,11 +1237,44 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
|
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
|
||||||
{
|
{
|
||||||
|
protected override void RefreshFields(Item tmp)
|
||||||
|
{
|
||||||
|
base.RefreshFields(tmp);
|
||||||
|
ExtensionRefreshFields(tmp);
|
||||||
|
}
|
||||||
#if ItemWithContent
|
#if ItemWithContent
|
||||||
public ProcedureInfo(SafeDataReader dr) : base(dr, true) { }
|
public ProcedureInfo(SafeDataReader dr) : base(dr, true) { }
|
||||||
#else
|
#else
|
||||||
public ProcedureInfo(SafeDataReader dr) : base(dr) { }
|
public ProcedureInfo(SafeDataReader dr) : base(dr) { }
|
||||||
#endif
|
#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()
|
public new Procedure Get()
|
||||||
{
|
{
|
||||||
return (Procedure) (_Editable = Procedure.Get(ItemID));
|
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");
|
throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
|
Item itm = GetCachedByPrimaryKey(itemID);
|
||||||
|
Procedure tmp = itm as Procedure;
|
||||||
|
//Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
|
if (itm != null) Console.WriteLine("type = {0}", itm.GetType().Name);
|
||||||
tmp = DataPortal.Fetch<Procedure>(new PKCriteria(itemID));
|
tmp = DataPortal.Fetch<Procedure>(new PKCriteria(itemID));
|
||||||
_AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
}
|
}
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -1031,6 +1322,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
return (Procedure)base.Save();
|
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
|
#region ProcedureConfig
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private ProcedureConfig _ProcedureConfig;
|
private ProcedureConfig _ProcedureConfig;
|
||||||
@ -1057,15 +1353,49 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
|
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
|
||||||
{
|
{
|
||||||
|
protected override void RefreshFields(Item tmp)
|
||||||
|
{
|
||||||
|
base.RefreshFields(tmp);
|
||||||
|
ExtensionRefreshFields(tmp);
|
||||||
|
}
|
||||||
#if ItemWithContent
|
#if ItemWithContent
|
||||||
public SectionInfo(SafeDataReader dr) : base(dr, true) { }
|
public SectionInfo(SafeDataReader dr) : base(dr, true) { }
|
||||||
#else
|
#else
|
||||||
public SectionInfo(SafeDataReader dr) : base(dr) { }
|
public SectionInfo(SafeDataReader dr) : base(dr) { }
|
||||||
#endif
|
#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()
|
public new Section Get()
|
||||||
{
|
{
|
||||||
return (Section)(_Editable = Section.Get(ItemID));
|
return (Section)(_Editable = Section.Get(ItemID));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region SectionConfig
|
#region SectionConfig
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private SectionConfig _SectionConfig;
|
private SectionConfig _SectionConfig;
|
||||||
@ -1088,11 +1418,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new System.Security.SecurityException("User not authorized to view a Item");
|
throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Section tmp = (Section)GetExistingByPrimaryKey(itemID);
|
Section tmp = GetCachedByPrimaryKey(itemID) as Section;
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<Section>(new PKCriteria(itemID));
|
tmp = DataPortal.Fetch<Section>(new PKCriteria(itemID));
|
||||||
_AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
}
|
}
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -1102,12 +1432,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on Item.Get", ex);
|
throw new DbCslaException("Error on Item.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public new Section Save()
|
public new Section Save()
|
||||||
{
|
{
|
||||||
return (Section)base.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
|
#region SectionConfig
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private SectionConfig _SectionConfig;
|
private SectionConfig _SectionConfig;
|
||||||
@ -1134,6 +1467,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
public partial class StepInfo : ItemInfo
|
public partial class StepInfo : ItemInfo
|
||||||
{
|
{
|
||||||
|
protected override void RefreshFields(Item tmp)
|
||||||
|
{
|
||||||
|
base.RefreshFields(tmp);
|
||||||
|
ExtensionRefreshFields(tmp);
|
||||||
|
}
|
||||||
//public override string ToString()
|
//public override string ToString()
|
||||||
//{
|
//{
|
||||||
// return "Step " + base.ToString();
|
// return "Step " + base.ToString();
|
||||||
@ -1143,6 +1481,34 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#else
|
#else
|
||||||
public StepInfo(SafeDataReader dr) : base(dr) { }
|
public StepInfo(SafeDataReader dr) : base(dr) { }
|
||||||
#endif
|
#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()
|
public new Step Get()
|
||||||
{
|
{
|
||||||
return (Step)(_Editable = Step.Get(ItemID));
|
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");
|
throw new System.Security.SecurityException("User not authorized to view a Item");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Step tmp = (Step)GetExistingByPrimaryKey(itemID);
|
Step tmp = (Step)GetCachedByPrimaryKey(itemID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<Step>(new PKCriteria(itemID));
|
tmp = DataPortal.Fetch<Step>(new PKCriteria(itemID));
|
||||||
_AllList.Add(tmp);
|
AddToCache(tmp);
|
||||||
}
|
}
|
||||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -1176,6 +1542,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on Item.Get", ex);
|
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
|
//#region StepConfig
|
||||||
//[NonSerialized]
|
//[NonSerialized]
|
||||||
//private StepConfig _StepConfig;
|
//private StepConfig _StepConfig;
|
||||||
|
@ -82,6 +82,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
#region Oldtonew
|
||||||
[Category("Miscellaneous")]
|
[Category("Miscellaneous")]
|
||||||
[Description("Convert from old to new")]
|
[Description("Convert from old to new")]
|
||||||
|
@ -325,6 +325,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public vlnFormatList(XmlNodeList xmlNodeList)
|
public vlnFormatList(XmlNodeList xmlNodeList)
|
||||||
{
|
{
|
||||||
|
if (xmlNodeList == null) return;
|
||||||
_XmlNodeList = xmlNodeList;
|
_XmlNodeList = xmlNodeList;
|
||||||
foreach (XmlNode xn in _XmlNodeList)
|
foreach (XmlNode xn in _XmlNodeList)
|
||||||
{
|
{
|
||||||
|
@ -53,28 +53,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<Annotation> _AllList = new List<Annotation>();
|
private static List<Annotation> _CacheList = new List<Annotation>();
|
||||||
private static Dictionary<string, List<Annotation>> _AllByPrimaryKey = new Dictionary<string, 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()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<Annotation> remove = new List<Annotation>();
|
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);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (Annotation tmp in remove)
|
foreach (Annotation tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
public static Annotation GetExistingByPrimaryKey(int annotationID)
|
protected static Annotation GetCachedByPrimaryKey(int annotationID)
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
string key = annotationID.ToString();
|
string key = annotationID.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -442,24 +450,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public int CurrentEditLevel
|
public int CurrentEditLevel
|
||||||
{ get { return EditLevel; } }
|
{ get { return EditLevel; } }
|
||||||
private static int _AnnotationUnique = 0;
|
private static int _AnnotationUnique = 0;
|
||||||
private int _MyAnnotationUnique;
|
protected static int AnnotationUnique
|
||||||
|
{ get { return ++_AnnotationUnique; } }
|
||||||
|
private int _MyAnnotationUnique = AnnotationUnique;
|
||||||
public int MyAnnotationUnique
|
public int MyAnnotationUnique
|
||||||
{
|
{ get { return _MyAnnotationUnique; } }
|
||||||
get { return _MyAnnotationUnique; }
|
|
||||||
}
|
|
||||||
protected Annotation()
|
protected Annotation()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyAnnotationUnique = ++_AnnotationUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromDictionaries();
|
||||||
if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
|
}
|
||||||
List<Annotation> listAnnotation = _AllByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
|
private void RemoveFromDictionaries()
|
||||||
listAnnotation.Remove(this); // Remove the item from the list
|
{
|
||||||
if (listAnnotation.Count == 0) //If there are no items left in the list
|
RemoveFromCache(this);
|
||||||
_AllByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
|
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()
|
public static Annotation New()
|
||||||
{
|
{
|
||||||
@ -497,7 +510,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Annotation tmp = Annotation.New(myItem, myAnnotationType, rtfText, searchText, config, dts, userID);
|
Annotation tmp = Annotation.New(myItem, myAnnotationType, rtfText, searchText, config, dts, userID);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
Annotation tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||||
@ -523,7 +540,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Annotation tmp = Annotation.New(myItem, myAnnotationType, rtfText, searchText, config);
|
Annotation tmp = Annotation.New(myItem, myAnnotationType, rtfText, searchText, config);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
Annotation tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
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");
|
throw new System.Security.SecurityException("User not authorized to view a Annotation");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Annotation tmp = GetExistingByPrimaryKey(annotationID);
|
Annotation tmp = GetCachedByPrimaryKey(annotationID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<Annotation>(new PKCriteria(annotationID));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -589,7 +614,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
Annotation annotation = base.Save();
|
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();
|
ProcessRefreshList();
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<AnnotationInfo> _AllList = new List<AnnotationInfo>();
|
private static List<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
|
||||||
private static Dictionary<string, List<AnnotationInfo>> _AllByPrimaryKey = new Dictionary<string, 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()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<AnnotationInfo> remove = new List<AnnotationInfo>();
|
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);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (AnnotationInfo tmp in remove)
|
foreach (AnnotationInfo tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
internal static void AddList(AnnotationInfoList lst)
|
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();
|
ConvertListToDictionary();
|
||||||
string key = annotationID.ToString();
|
string key = annotationID.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -208,24 +216,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _AnnotationInfoUnique = 0;
|
private static int _AnnotationInfoUnique = 0;
|
||||||
private int _MyAnnotationInfoUnique;
|
private static int AnnotationInfoUnique
|
||||||
|
{ get { return ++_AnnotationInfoUnique; } }
|
||||||
|
private int _MyAnnotationInfoUnique = AnnotationInfoUnique;
|
||||||
public int MyAnnotationInfoUnique
|
public int MyAnnotationInfoUnique
|
||||||
{
|
{ get { return _MyAnnotationInfoUnique; } }
|
||||||
get { return _MyAnnotationInfoUnique; }
|
protected AnnotationInfo()
|
||||||
}
|
|
||||||
private AnnotationInfo()
|
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromCache(this);
|
||||||
if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
|
if (!_CacheByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
|
||||||
List<AnnotationInfo> listAnnotationInfo = _AllByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
|
List<AnnotationInfo> listAnnotationInfo = _CacheByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
|
||||||
listAnnotationInfo.Remove(this); // Remove the item from the list
|
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
|
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()
|
public virtual Annotation Get()
|
||||||
{
|
{
|
||||||
@ -235,22 +242,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
string key = tmp.AnnotationID.ToString();
|
string key = tmp.AnnotationID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(Annotation tmp)
|
protected virtual void RefreshFields(Annotation tmp)
|
||||||
{
|
{
|
||||||
if (_ItemID != tmp.ItemID)
|
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
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_MyItem = null; // Reset list so that the next line gets a new list
|
||||||
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
|
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
|
||||||
if (_TypeID != tmp.TypeID)
|
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
|
_TypeID = tmp.TypeID; // Update the value
|
||||||
}
|
}
|
||||||
_MyAnnotationType = null; // Reset list so that the next line gets a new list
|
_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();
|
string key = tmp.AnnotationID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(AnnotationTypeAnnotation tmp)
|
protected virtual void RefreshFields(AnnotationTypeAnnotation tmp)
|
||||||
{
|
{
|
||||||
if (_ItemID != tmp.ItemID)
|
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
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_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();
|
string key = tmp.AnnotationID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(ItemAnnotation tmp)
|
protected virtual void RefreshFields(ItemAnnotation tmp)
|
||||||
{
|
{
|
||||||
if (_TypeID != tmp.TypeID)
|
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
|
_TypeID = tmp.TypeID; // Update the value
|
||||||
}
|
}
|
||||||
_MyAnnotationType = null; // Reset list so that the next line gets a new list
|
_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");
|
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationInfo tmp = GetExistingByPrimaryKey(annotationID);
|
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -343,7 +354,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
internal AnnotationInfo(SafeDataReader dr)
|
internal AnnotationInfo(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
|
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -64,38 +64,46 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<AnnotationType> _AllList = new List<AnnotationType>();
|
private static List<AnnotationType> _CacheList = new List<AnnotationType>();
|
||||||
private static Dictionary<string, List<AnnotationType>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationType>>();
|
protected static void AddToCache(AnnotationType annotationType)
|
||||||
private static Dictionary<string, List<AnnotationType>> _AllByName = new Dictionary<string, List<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()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<AnnotationType> remove = new List<AnnotationType>();
|
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
|
_CacheByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationType>(); // Add new list for PrimaryKey
|
||||||
_AllByName[tmp.Name.ToString()] = new List<AnnotationType>(); // Add new list for Name
|
_CacheByName[tmp.Name.ToString()] = new List<AnnotationType>(); // Add new list for Name
|
||||||
}
|
}
|
||||||
_AllByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
|
_CacheByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
|
||||||
_AllByName[tmp.Name.ToString()].Add(tmp); // Unique Index
|
_CacheByName[tmp.Name.ToString()].Add(tmp); // Unique Index
|
||||||
remove.Add(tmp);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (AnnotationType tmp in remove)
|
foreach (AnnotationType tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
public static AnnotationType GetExistingByPrimaryKey(int typeID)
|
protected static AnnotationType GetCachedByPrimaryKey(int typeID)
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
string key = typeID.ToString();
|
string key = typeID.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static AnnotationType GetExistingByName(string name)
|
protected static AnnotationType GetCachedByName(string name)
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
string key = name.ToString();
|
string key = name.ToString();
|
||||||
if (_AllByName.ContainsKey(key)) return _AllByName[key][0];
|
if (_CacheByName.ContainsKey(key)) return _CacheByName[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -394,28 +402,41 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public int CurrentEditLevel
|
public int CurrentEditLevel
|
||||||
{ get { return EditLevel; } }
|
{ get { return EditLevel; } }
|
||||||
private static int _AnnotationTypeUnique = 0;
|
private static int _AnnotationTypeUnique = 0;
|
||||||
private int _MyAnnotationTypeUnique;
|
protected static int AnnotationTypeUnique
|
||||||
|
{ get { return ++_AnnotationTypeUnique; } }
|
||||||
|
private int _MyAnnotationTypeUnique = AnnotationTypeUnique;
|
||||||
public int MyAnnotationTypeUnique
|
public int MyAnnotationTypeUnique
|
||||||
{
|
{ get { return _MyAnnotationTypeUnique; } }
|
||||||
get { return _MyAnnotationTypeUnique; }
|
|
||||||
}
|
|
||||||
protected AnnotationType()
|
protected AnnotationType()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyAnnotationTypeUnique = ++_AnnotationTypeUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromDictionaries();
|
||||||
if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return;
|
}
|
||||||
List<AnnotationType> listAnnotationType = _AllByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
private void RemoveFromDictionaries()
|
||||||
listAnnotationType.Remove(this); // Remove the item from the list
|
{
|
||||||
if (listAnnotationType.Count == 0) //If there are no items left in the list
|
RemoveFromCache(this);
|
||||||
_AllByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
if (_CacheByPrimaryKey.ContainsKey(TypeID.ToString()))
|
||||||
listAnnotationType = _AllByName[TypeID.ToString()]; // Get the list of items
|
{
|
||||||
listAnnotationType.Remove(this); // Remove the item from the list
|
List<AnnotationType> listAnnotationType = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
||||||
if (listAnnotationType.Count == 0) //If there are no items left in the list
|
while (listAnnotationType.Contains(this)) listAnnotationType.Remove(this); // Remove the item from the list
|
||||||
_AllByName.Remove(TypeID.ToString()); // remove 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()
|
public static AnnotationType New()
|
||||||
{
|
{
|
||||||
@ -449,7 +470,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
AnnotationType tmp = AnnotationType.New(name, config, dts, userID);
|
AnnotationType tmp = AnnotationType.New(name, config, dts, userID);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
AnnotationType tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||||
@ -472,7 +497,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
AnnotationType tmp = AnnotationType.New(name, config);
|
AnnotationType tmp = AnnotationType.New(name, config);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
AnnotationType tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
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");
|
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationType tmp = GetExistingByPrimaryKey(typeID);
|
AnnotationType tmp = GetCachedByPrimaryKey(typeID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<AnnotationType>(new PKCriteria(typeID));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -504,19 +537,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on AnnotationType.Get", ex);
|
throw new DbCslaException("Error on AnnotationType.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static AnnotationType GetByName(string name)
|
public static AnnotationType GetByName(string name)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
if (!CanGetObject())
|
||||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationType tmp = GetExistingByName(name);
|
AnnotationType tmp = GetCachedByName(name);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<AnnotationType>(new NameCriteria(name));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -558,7 +595,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
AnnotationType annotationType = base.Save();
|
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();
|
ProcessRefreshList();
|
||||||
return annotationType;
|
return annotationType;
|
||||||
}
|
}
|
||||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<AnnotationTypeInfo> _AllList = new List<AnnotationTypeInfo>();
|
private static List<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
|
||||||
private static Dictionary<string, List<AnnotationTypeInfo>> _AllByPrimaryKey = new Dictionary<string, 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()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
|
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);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (AnnotationTypeInfo tmp in remove)
|
foreach (AnnotationTypeInfo tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
internal static void AddList(AnnotationTypeInfoList lst)
|
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();
|
ConvertListToDictionary();
|
||||||
string key = typeID.ToString();
|
string key = typeID.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -161,11 +169,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _AnnotationTypeAnnotations;
|
return _AnnotationTypeAnnotations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void RefreshAnnotationTypeAnnotations()
|
public void RefreshAnnotationTypeAnnotations()
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(_TypeID.ToString()))
|
if (_CacheByPrimaryKey.ContainsKey(_TypeID.ToString()))
|
||||||
foreach (AnnotationTypeInfo tmp in _AllByPrimaryKey[_TypeID.ToString()])
|
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
|
||||||
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
|
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
|
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
|
||||||
@ -189,24 +197,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _AnnotationTypeInfoUnique = 0;
|
private static int _AnnotationTypeInfoUnique = 0;
|
||||||
private int _MyAnnotationTypeInfoUnique;
|
private static int AnnotationTypeInfoUnique
|
||||||
|
{ get { return ++_AnnotationTypeInfoUnique; } }
|
||||||
|
private int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
|
||||||
public int MyAnnotationTypeInfoUnique
|
public int MyAnnotationTypeInfoUnique
|
||||||
{
|
{ get { return _MyAnnotationTypeInfoUnique; } }
|
||||||
get { return _MyAnnotationTypeInfoUnique; }
|
protected AnnotationTypeInfo()
|
||||||
}
|
|
||||||
private AnnotationTypeInfo()
|
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromCache(this);
|
||||||
if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return;
|
if (!_CacheByPrimaryKey.ContainsKey(TypeID.ToString())) return;
|
||||||
List<AnnotationTypeInfo> listAnnotationTypeInfo = _AllByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
List<AnnotationTypeInfo> listAnnotationTypeInfo = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
|
||||||
listAnnotationTypeInfo.Remove(this); // Remove the item from the list
|
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
|
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()
|
public virtual AnnotationType Get()
|
||||||
{
|
{
|
||||||
@ -216,11 +223,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
string key = tmp.TypeID.ToString();
|
string key = tmp.TypeID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AnnotationTypeInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AnnotationTypeInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(AnnotationType tmp)
|
protected virtual void RefreshFields(AnnotationType tmp)
|
||||||
{
|
{
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
@ -235,13 +242,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationTypeInfo tmp = GetExistingByPrimaryKey(typeID);
|
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -253,7 +264,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
internal AnnotationTypeInfo(SafeDataReader dr)
|
internal AnnotationTypeInfo(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
_MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique;
|
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -54,28 +54,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<Assignment> _AllList = new List<Assignment>();
|
private static List<Assignment> _CacheList = new List<Assignment>();
|
||||||
private static Dictionary<string, List<Assignment>> _AllByPrimaryKey = new Dictionary<string, 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()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<Assignment> remove = new List<Assignment>();
|
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);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (Assignment tmp in remove)
|
foreach (Assignment tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
public static Assignment GetExistingByPrimaryKey(int aid)
|
protected static Assignment GetCachedByPrimaryKey(int aid)
|
||||||
{
|
{
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
string key = aid.ToString();
|
string key = aid.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -504,24 +512,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public int CurrentEditLevel
|
public int CurrentEditLevel
|
||||||
{ get { return EditLevel; } }
|
{ get { return EditLevel; } }
|
||||||
private static int _AssignmentUnique = 0;
|
private static int _AssignmentUnique = 0;
|
||||||
private int _MyAssignmentUnique;
|
protected static int AssignmentUnique
|
||||||
|
{ get { return ++_AssignmentUnique; } }
|
||||||
|
private int _MyAssignmentUnique = AssignmentUnique;
|
||||||
public int MyAssignmentUnique
|
public int MyAssignmentUnique
|
||||||
{
|
{ get { return _MyAssignmentUnique; } }
|
||||||
get { return _MyAssignmentUnique; }
|
|
||||||
}
|
|
||||||
protected Assignment()
|
protected Assignment()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyAssignmentUnique = ++_AssignmentUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromDictionaries();
|
||||||
if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
|
}
|
||||||
List<Assignment> listAssignment = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
|
private void RemoveFromDictionaries()
|
||||||
listAssignment.Remove(this); // Remove the item from the list
|
{
|
||||||
if (listAssignment.Count == 0) //If there are no items left in the list
|
RemoveFromCache(this);
|
||||||
_AllByPrimaryKey.Remove(AID.ToString()); // remove the list
|
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()
|
public static Assignment New()
|
||||||
{
|
{
|
||||||
@ -560,7 +573,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Assignment tmp = Assignment.New(myGroup, myRole, myFolder, startDate, endDate, dts, usrID);
|
Assignment tmp = Assignment.New(myGroup, myRole, myFolder, startDate, endDate, dts, usrID);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
Assignment tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||||
@ -585,7 +602,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Assignment tmp = Assignment.New(myGroup, myRole, myFolder, endDate);
|
Assignment tmp = Assignment.New(myGroup, myRole, myFolder, endDate);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
tmp = tmp.Save();
|
{
|
||||||
|
Assignment tmp2 = tmp;
|
||||||
|
tmp = tmp2.Save();
|
||||||
|
tmp2.Dispose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
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");
|
throw new System.Security.SecurityException("User not authorized to view a Assignment");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Assignment tmp = GetExistingByPrimaryKey(aid);
|
Assignment tmp = GetCachedByPrimaryKey(aid);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<Assignment>(new PKCriteria(aid));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -651,7 +676,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
Assignment assignment = base.Save();
|
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();
|
ProcessRefreshList();
|
||||||
return assignment;
|
return assignment;
|
||||||
}
|
}
|
||||||
|
@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
protected static List<AssignmentInfo> _AllList = new List<AssignmentInfo>();
|
private static List<AssignmentInfo> _CacheList = new List<AssignmentInfo>();
|
||||||
private static Dictionary<string, List<AssignmentInfo>> _AllByPrimaryKey = new Dictionary<string, 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()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
List<AssignmentInfo> remove = new List<AssignmentInfo>();
|
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);
|
remove.Add(tmp);
|
||||||
}
|
}
|
||||||
foreach (AssignmentInfo tmp in remove)
|
foreach (AssignmentInfo tmp in remove)
|
||||||
_AllList.Remove(tmp);
|
RemoveFromCache(tmp);
|
||||||
}
|
}
|
||||||
internal static void AddList(AssignmentInfoList lst)
|
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();
|
ConvertListToDictionary();
|
||||||
string key = aid.ToString();
|
string key = aid.ToString();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -220,24 +228,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _AssignmentInfoUnique = 0;
|
private static int _AssignmentInfoUnique = 0;
|
||||||
private int _MyAssignmentInfoUnique;
|
private static int AssignmentInfoUnique
|
||||||
|
{ get { return ++_AssignmentInfoUnique; } }
|
||||||
|
private int _MyAssignmentInfoUnique = AssignmentInfoUnique;
|
||||||
public int MyAssignmentInfoUnique
|
public int MyAssignmentInfoUnique
|
||||||
{
|
{ get { return _MyAssignmentInfoUnique; } }
|
||||||
get { return _MyAssignmentInfoUnique; }
|
protected AssignmentInfo()
|
||||||
}
|
|
||||||
private AssignmentInfo()
|
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
|
AddToCache(this);
|
||||||
_AllList.Add(this);
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_AllList.Remove(this);
|
RemoveFromCache(this);
|
||||||
if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
|
if (!_CacheByPrimaryKey.ContainsKey(AID.ToString())) return;
|
||||||
List<AssignmentInfo> listAssignmentInfo = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
|
List<AssignmentInfo> listAssignmentInfo = _CacheByPrimaryKey[AID.ToString()]; // Get the list of items
|
||||||
listAssignmentInfo.Remove(this); // Remove the item from the list
|
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
|
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()
|
public virtual Assignment Get()
|
||||||
{
|
{
|
||||||
@ -247,29 +254,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
string key = tmp.AID.ToString();
|
string key = tmp.AID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(Assignment tmp)
|
protected virtual void RefreshFields(Assignment tmp)
|
||||||
{
|
{
|
||||||
if (_GID != tmp.GID)
|
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
|
_GID = tmp.GID; // Update the value
|
||||||
}
|
}
|
||||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||||
if (_RID != tmp.RID)
|
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
|
_RID = tmp.RID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRole = null; // Reset list so that the next line gets a new list
|
_MyRole = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||||
if (_FolderID != tmp.FolderID)
|
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
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_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();
|
string key = tmp.AID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(FolderAssignment tmp)
|
protected virtual void RefreshFields(FolderAssignment tmp)
|
||||||
{
|
{
|
||||||
if (_GID != tmp.GID)
|
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
|
_GID = tmp.GID; // Update the value
|
||||||
}
|
}
|
||||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||||
if (_RID != tmp.RID)
|
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
|
_RID = tmp.RID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRole = null; // Reset list so that the next line gets a new list
|
_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();
|
string key = tmp.AID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(GroupAssignment tmp)
|
protected virtual void RefreshFields(GroupAssignment tmp)
|
||||||
{
|
{
|
||||||
if (_RID != tmp.RID)
|
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
|
_RID = tmp.RID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRole = null; // Reset list so that the next line gets a new list
|
_MyRole = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||||
if (_FolderID != tmp.FolderID)
|
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
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_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();
|
string key = tmp.AID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
if (_AllByPrimaryKey.ContainsKey(key))
|
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||||
tmpInfo.RefreshFields(tmp);
|
tmpInfo.RefreshFields(tmp);
|
||||||
}
|
}
|
||||||
private void RefreshFields(RoleAssignment tmp)
|
protected virtual void RefreshFields(RoleAssignment tmp)
|
||||||
{
|
{
|
||||||
if (_GID != tmp.GID)
|
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
|
_GID = tmp.GID; // Update the value
|
||||||
}
|
}
|
||||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||||
if (_FolderID != tmp.FolderID)
|
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
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_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");
|
// throw new System.Security.SecurityException("User not authorized to view a Assignment");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AssignmentInfo tmp = GetExistingByPrimaryKey(aid);
|
AssignmentInfo tmp = GetCachedByPrimaryKey(aid);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid));
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -410,7 +421,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
internal AssignmentInfo(SafeDataReader dr)
|
internal AssignmentInfo(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
|
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user