This commit is contained in:
2008-08-12 11:21:19 +00:00
parent 610f408c6d
commit d0dba2aad4
14 changed files with 937 additions and 240 deletions

View File

@@ -23,7 +23,7 @@ namespace VEPROMS.CSLA.Library
public static List<AnnotationTypeInfo> AllList()
{
//return _AllList;
return AnnotationTypeInfo._AllList;
return AnnotationTypeInfo._CacheList;
}
public override string ToString()
{

View File

@@ -54,6 +54,7 @@ namespace VEPROMS.CSLA.Library
try
{
ReadDataItemList(dr);
_CacheList.Add(this);
}
catch (Exception ex)
{

View File

@@ -96,9 +96,19 @@ namespace VEPROMS.CSLA.Library
return MyFolder;
}
}
private Format _ActiveFormat = null;
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
get
{
if (_ActiveFormat == null)
_ActiveFormat = LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat;
return _ActiveFormat;
}
set
{
_ActiveFormat = null;
}
}
public Format LocalFormat
{
@@ -110,21 +120,26 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
public partial class DocVersionInfo:IVEDrillDownReadOnly
public partial class DocVersionInfo : IVEDrillDownReadOnly
{
#region DocVersion Config
[NonSerialized]
private DocVersionConfig _DocVersionConfig;
public DocVersionConfig DocVersionConfig
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this));} }
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this)); } }
private void DocVersionConfigRefresh()
{
_DocVersionConfig = null;
}
#endregion
ItemInfoList _iil = null;
ItemInfoList _Procedures = null;
public ItemInfoList Procedures
{ get { return (_iil != null ? _iil: _iil = ItemInfoList.GetList(_ItemID,(int)E_FromType.Procedure)); } }
{ get { return (_Procedures != null ? _Procedures : _Procedures = ItemInfoList.GetList(_ItemID, (int)E_FromType.Procedure)); } }
public void ResetProcedures()
{
_Procedures = null;
}
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
@@ -196,6 +211,14 @@ namespace VEPROMS.CSLA.Library
//{
// return ToString();
//}
public ItemInfo LastChild()
{
return MyItem.LastSibling;
}
public ItemInfo FirstChild()
{
return MyItem;
}
#endregion
#region Extension
partial class DocVersionInfoExtension : extensionBase

View File

@@ -2,6 +2,10 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Csla;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
namespace VEPROMS.CSLA.Library
{
@@ -45,6 +49,69 @@ namespace VEPROMS.CSLA.Library
}
}
}
public partial class DocumentInfoList
{
public static DocumentInfoList GetLibraries()
{
try
{
if (_DocumentInfoList != null)
return _DocumentInfoList;
DocumentInfoList tmp = DataPortal.Fetch<DocumentInfoList>(new LibraryCriteria(true));
DocumentInfo.AddList(tmp);
tmp.AddEvents();
_DocumentInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentInfoList.Get", ex);
}
}
[Serializable()]
protected class LibraryCriteria
{
private bool _IsLibrary;
public bool IsLibrary
{
get { return _IsLibrary; }
set { _IsLibrary = value; }
}
public LibraryCriteria(bool islibrary)
{
_IsLibrary = islibrary;
}
}
private void DataPortal_Fetch(LibraryCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getLibraryDocuments";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new DocumentInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
public class DSOFile : IDisposable
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

View File

@@ -17,6 +17,8 @@ using System.Configuration;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library
{
@@ -68,9 +70,19 @@ namespace VEPROMS.CSLA.Library
return MyParent;
}
}
private Format _ActiveFormat = null;
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : (ActiveParent != null ? ActiveParent.ActiveFormat : null); }
get
{
if (_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent != null ? ActiveParent.ActiveFormat : null);
return _ActiveFormat;
}
set
{
_ActiveFormat = null; // Reset
}
}
public Format LocalFormat
{
@@ -81,6 +93,16 @@ namespace VEPROMS.CSLA.Library
get { return FolderConfig; }
}
#endregion
#region MakeFolders for ManualOrder
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID)
{
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config, dts, usrID);
}
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config)
{
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config);
}
#endregion
}
public partial class FolderInfo:IVEDrillDownReadOnly
{
@@ -96,11 +118,84 @@ namespace VEPROMS.CSLA.Library
_FolderConfig = null;
}
#endregion
#region SortingChildren
public Csla.SortedBindingList<FolderInfo> _SortedChildFolders;
public Csla.SortedBindingList<FolderInfo> SortedChildFolders
{
get
{
if (ChildFolders != null)
{
if (_SortedChildFolders == null)
{
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
//_SortedChildFolders.ApplySort("FolderID", ListSortDirection.Ascending);
//_SortedChildFolders.ApplySort("Name", ListSortDirection.Ascending);
}
else if (_SortedChildFolders.Count != ChildFolders.Count)
{
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
}
_SortedChildFolders.ApplySort("ManualOrder", ListSortDirection.Ascending);
}
return _SortedChildFolders;
}
}
public double? NewManualOrder(int index)
{
double? retval = 1;
if (SortedChildFolders == null || SortedChildFolders.Count == 0)
retval = 1; // First value
else if (index == 0)
{
if (retval >= SortedChildFolders[index].ManualOrder) // If one is too big, then divide first value in half
retval = SortedChildFolders[index].ManualOrder / 2;
}
else if (SortedChildFolders.Count > index)
{
retval += SortedChildFolders[index - 1].ManualOrder; // Just go to the next whole number
if (retval >= SortedChildFolders[index].ManualOrder)
retval = (SortedChildFolders[index - 1].ManualOrder + SortedChildFolders[index].ManualOrder) / 2;
}
else
retval += SortedChildFolders[index - 1].ManualOrder;
return retval;
}
/// <summary>
/// UniqueChildName will check the existing children to assure that the name is not a duplicate name.
/// </summary>
/// <param name="folderName"></param>
/// <returns></returns>
public string UniqueChildName(string folderName)
{
string retval = folderName;
int iSuffix = -1;
RefreshChildFolders();
foreach (FolderInfo fi in ChildFolders)
{
if (fi.Name.StartsWith(folderName))
{
if (fi.Name == folderName)
iSuffix = 0;
else if (Regex.IsMatch(fi.Name, folderName + "[_][0-9]+"))
{
int ii = int.Parse(fi.Name.Substring(1 + folderName.Length));
if (ii > iSuffix) iSuffix = ii;
}
}
}
if (iSuffix >= 0)
retval = string.Format("{0}_{1}", folderName, iSuffix + 1);
// Console.WriteLine("FolderName = '{0}'", retval);
return retval;
}
#endregion
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
if(FolderDocVersionCount != 0)return FolderDocVersions;
if (ChildFolderCount != 0) return ChildFolders;
//if (ChildFolderCount != 0) return ChildFolders;
if (ChildFolderCount != 0) return SortedChildFolders;
return null;
}
//public bool ChildrenAreLoaded
@@ -178,4 +273,5 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
}

View File

@@ -13,8 +13,17 @@ using System.Drawing;
namespace VEPROMS.CSLA.Library
{
#region Item
public partial class Item:IVEDrillDown
public partial class Item : IVEDrillDown
{
public static void ShowAllocated(string title)
{
Console.WriteLine("{0} - {1} Items in the dictionary", title, _CacheByPrimaryKey.Count);
foreach (List<Item> itmlst in _CacheByPrimaryKey.Values)
foreach(Item itm in itmlst)
Console.WriteLine("Item {0} UniqueID {1}", itm.ItemID, itm.MyItemUnique);
Console.WriteLine("- - - - - -");
}
public override string ToString()
{
return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim();
@@ -54,25 +63,29 @@ namespace VEPROMS.CSLA.Library
_ActiveParent = this.ItemDocVersions[0].MyDocVersion;
else
{
if (this.ItemParts == null || this.ItemPartCount == 0)
if (this.ItemParts == null || this.ItemPartCount == 0)
_ActiveParent = this;
else
_ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem;
}
}
}
return _ActiveParent==this ? null : _ActiveParent;
return _ActiveParent == this ? null : _ActiveParent;
}
}
private Format _ActiveFormat=null;// Added to cache ActiveFormat
private Format _ActiveFormat = null;// Added to cache ActiveFormat
public Format ActiveFormat
{
get
{
if(_ActiveFormat == null)
if (_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
return _ActiveFormat;
}
set
{
_ActiveFormat = null; // Reset
}
}
public Format LocalFormat
{
@@ -83,18 +96,200 @@ namespace VEPROMS.CSLA.Library
get { return null; }
}
#endregion
public void MoveItem(IVEDrillDownReadOnly pInfo, int index)
{
bool wasfirstchild = false;
ItemInfo parentInfo = pInfo as ItemInfo;
DocVersionInfo parentInfoDV = pInfo as DocVersionInfo;
IList<ItemInfo> children = null;
E_FromType partType = 0; // this is needed later to determine sub-group type.
if (parentInfo != null)
{
// this may have subgroups, need to use part type to get children list...
ItemInfo thisinfo = ItemInfo.Get(ItemID);
partType = thisinfo.FirstSibling.ItemParts[0].PartType;
children = (IList<ItemInfo>)parentInfo.Lookup((int)partType);
}
else
children = (IList<ItemInfo>)parentInfoDV.GetChildren();
int numChild = children.Count;
if (this.MyPrevious == null) wasfirstchild = true;
Item origNextItem = null;
// First, remove from this item from its list. To do this, get the current item's next point and redirect it's myprevious
// to this item's previous...
if (NextItems != null && NextItems.Count > 0)
{
origNextItem = NextItems.Items[0];
origNextItem.MyPrevious = this.MyPrevious;
this.Save();
}
// check to see if the item is being moved into the middle of some items. newPreviousItem is the item defined
// by index-1, i.e. inserting below newPreviousItem.
ItemInfo newPreviousInfo = (index == 0) ? null : children[index - 1];
ItemInfo newNextInfo = (index == children.Count) ? null : children[index];
// Adjust the new next proc to be me.
if (newNextInfo != null)
{
using (Item newNextItem = newNextInfo.Get())
{
newNextItem.MyPrevious = this;
newNextItem.Save().Dispose();
}
}
// adjust the previous node, i.e. may either be at same level or, if first in list, adjust the parent...
// if 'newPreviousItem' isn't null, then adding to the middle of the list.
if (newPreviousInfo != null)
{
using (Item newPreviousItem = newPreviousInfo.Get())
{
MyPrevious = newPreviousItem;
Save();
}
}
// newPreviousInfo == null if moving into first child, and wasfirstchild == true if moving out of first child.
// This will require adjusting the DocVersion to point to the correct first child if a procedure is moved.
if (newPreviousInfo == null || wasfirstchild)
{
if (parentInfo != null) // Moving Item within procedure, i.e. moving a section or step
{
using (Item parentItem = parentInfo.Get())
{
// moving first child out... reset parent to point to the original next item
if (wasfirstchild)
parentItem.MyContent.ContentParts[(int)partType].MyItem = origNextItem;
else
parentItem.MyContent.ContentParts[(int)partType].MyItem = this;
parentItem.Save().Dispose();
}
}
else if (parentInfoDV != null) // Moving Item (Procedure) within DocVersion
{
using (DocVersion parentItemDV = parentInfoDV.Get())
{
ItemInfo firstinfo = parentInfoDV.FirstChild();
parentItemDV.MyItem = wasfirstchild?parentInfoDV.Procedures[1].Get():this;
parentItemDV.Save().Dispose();
if (!wasfirstchild && firstinfo != null)
{
using (Item firstchild = firstinfo.Get())
{
firstchild.MyPrevious = this;
firstchild.Save().Dispose();
}
}
}
}
if (!wasfirstchild)
{
this.MyPrevious = null;
this.Save();
}
if (origNextItem != null) origNextItem.Dispose();
if (parentInfo != null)
parentInfo.MyContent.RefreshContentParts();
if (parentInfoDV != null)
parentInfoDV.ResetProcedures();
}
}
protected static int MakeNewItem(IVEDrillDownReadOnly parentInfoDD, ItemInfo previousInfo, string number, string title, int type, E_FromType partType)
{
int newitemid = 0;
if (parentInfoDD == null)
parentInfoDD = previousInfo.ActiveParent;
ItemInfo parentInfo = parentInfoDD as ItemInfo;
DocVersionInfo parentInfoDV = parentInfoDD as DocVersionInfo;
using (Content cont = Content.New(number, title, type, null, null))
{
using (Item fromitem = previousInfo == null ? null : previousInfo.Get())
{
ItemInfo nextInfo = null; // Check to see if the item is being inserted in the middle of some items.
if (previousInfo != null && previousInfo.NextItems != null && previousInfo.NextItems.Count > 0)
nextInfo = previousInfo.NextItems[0];
using (Item itm = Item.MakeItem(fromitem, cont))
{
newitemid = itm.ItemID;
if (nextInfo != null)
{
using (Item nextItem = nextInfo.Get())
{
nextItem.MyPrevious = itm;// Aim the next item back at the new item.
nextItem.Save().Dispose();
}
}
if (fromitem == null)
{
if (parentInfo != null) // Adding Item to Procedure, Section or Step
{
using (Item parentItem = parentInfo.Get())
{
ItemInfo firstinfo = parentInfo.FirstChild(partType);
if (firstinfo != null)
{
using (Item firstchild = firstinfo.Get())
{
parentItem.MyContent.ContentParts[(int)partType].MyItem = itm;// First update the parent to point to the new first child
parentItem.Save().Dispose();
firstchild.MyPrevious = itm;// Aim the old first child to point to the new first child.
firstchild.Save().Dispose();
}
}
else
{
parentItem.MyContent.ContentParts.Add((int)partType, itm);// update the parent to point to the new first child
parentItem.Save().Dispose();
}
}
}
if (parentInfoDV != null) // Adding Item (Procedure) to DocVersion
{
using (DocVersion parentItemDV = parentInfoDV.Get())
{
ItemInfo firstinfo = parentInfoDV.FirstChild();
parentItemDV.MyItem = itm;// First update the parent to point to the new first child
parentItemDV.Save().Dispose();
if (firstinfo != null)
{
using (Item firstchild = firstinfo.Get())
{
firstchild.MyPrevious = itm;// Aim the old first child to point to the new first child.
firstchild.Save().Dispose();
}
}
}
}
}
}
}
}
if (parentInfo != null)
parentInfo.MyContent.RefreshContentParts();
if (parentInfoDV != null)
parentInfoDV.ResetProcedures();
return newitemid;
}
}
#endregion
#region ItemInfo
public partial class ItemInfo:IVEDrillDownReadOnly
{
protected void ExtensionRefreshFields(Item tmp)
{
_ActiveParent = null;
}
#region LoadAtOnce2
public static ItemInfo GetItemAndChildren2(int? itemID)
{
try
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria2(itemID));
//_AllList.Add(tmp);
AddToCache(tmp);
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
@@ -152,7 +347,7 @@ namespace VEPROMS.CSLA.Library
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
}
_AllList.Remove(this);
RemoveFromCache(this);
}
private void SpinThroughChildren()
{
@@ -169,7 +364,7 @@ namespace VEPROMS.CSLA.Library
try
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new ItemAndChildrenCriteria(itemID,parentID));
//_AllList.Add(tmp);
AddToCache(tmp);
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
@@ -429,6 +624,27 @@ namespace VEPROMS.CSLA.Library
return temp;
}
}
public ItemInfo LastSibling
{
get
{
ItemInfo temp = this;
while (temp.NextItems[0] != null) temp = temp.NextItems[0];
return temp;
}
}
public ItemInfo LastChild(E_FromType partType)
{
ItemInfoList myitems = Lookup((int)partType);
if (myitems !=null) return myitems[myitems.Count-1];
return null;
}
public ItemInfo FirstChild(E_FromType partType)
{
ItemInfoList myitems = Lookup((int)partType);
if (myitems != null) return myitems[0];
return null;
}
public bool IsSubStep
{
get
@@ -614,16 +830,39 @@ namespace VEPROMS.CSLA.Library
}
private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList)
{
if (itemInfoList != null) return itemInfoList;
if (itemInfoList == null)
itemInfoList = Lookup(fromType);
return itemInfoList;
}
internal ItemInfoList Lookup(int fromType)
{
ItemInfoList itemInfoList = null;
if (MyContent.ContentPartCount != 0)
foreach (PartInfo partInfo in MyContent.ContentParts)
if (partInfo.FromType == fromType)
{
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID,partInfo.FromType);
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID, partInfo.FromType);
return itemInfoList;
}
return null;
}
public static void ResetParts(int itemID)
{
string key = itemID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemInfo itm in _CacheByPrimaryKey[key])
itm.ResetParts();
}
public void ResetParts()
{
_Procedures = null;
_Sections = null;
_Cautions = null;
_Notes = null;
_RNOs = null;
_Steps = null;
_Tables = null;
}
private ItemInfoList _Procedures;
public ItemInfoList Procedures
{ get { return Lookup(1,ref _Procedures); } }
@@ -740,6 +979,20 @@ namespace VEPROMS.CSLA.Library
{
get { return this.MyContent.ContentPartCount > 0; }
}
public bool HasWordContent
{
get { return this.MyContent.MyEntry != null; }
}
public bool HasStepContent
{
get
{
if (MyContent.ContentPartCount == 0) return false;
if (MyContent.ContentPartCount == 1 && MyContent.ContentParts[0].PartType == E_FromType.Section) return false;
return true;
}
}
public ItemInfo MyProcedure
{
get
@@ -757,13 +1010,14 @@ namespace VEPROMS.CSLA.Library
{
get
{
//if (_ActiveParent == this)_ActiveParent = null;
if (_ActiveParent == null)
{
if (MyPrevious != null)
_ActiveParent = _MyPrevious.ActiveParent;
else
{
if (ItemDocVersionCount > 0)
if (this.ItemDocVersions != null && this.ItemDocVersions.Count > 0)
_ActiveParent = this.ItemDocVersions[0];
else
{
@@ -778,6 +1032,7 @@ namespace VEPROMS.CSLA.Library
return _ActiveParent==this ? null : _ActiveParent;
}
internal set
//set
{
_ActiveParent = value;
}
@@ -813,7 +1068,7 @@ namespace VEPROMS.CSLA.Library
{
get
{
if(_ActiveFormat == null)
if (_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
return _ActiveFormat;
}
@@ -982,11 +1237,44 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
{
protected override void RefreshFields(Item tmp)
{
base.RefreshFields(tmp);
ExtensionRefreshFields(tmp);
}
#if ItemWithContent
public ProcedureInfo(SafeDataReader dr) : base(dr, true) { }
#else
public ProcedureInfo(SafeDataReader dr) : base(dr) { }
#endif
private ProcedureInfo() : base() { ;}
public new static ProcedureInfo Get(int itemID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
ProcedureInfo tmp = GetCachedByPrimaryKey(itemID) as ProcedureInfo;
if (tmp == null)
{
tmp = DataPortal.Fetch<ProcedureInfo>(new PKCriteria(itemID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public void MoveProcedure(IVEDrillDownReadOnly pInfo, int index)
{
using (Item ii = Item.Get(this.ItemID))
{
ii.MoveItem(pInfo, index);
}
}
public new Procedure Get()
{
return (Procedure) (_Editable = Procedure.Get(ItemID));
@@ -1013,11 +1301,14 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
Item itm = GetCachedByPrimaryKey(itemID);
Procedure tmp = itm as Procedure;
//Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
if (itm != null) Console.WriteLine("type = {0}", itm.GetType().Name);
tmp = DataPortal.Fetch<Procedure>(new PKCriteria(itemID));
_AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -1031,6 +1322,11 @@ namespace VEPROMS.CSLA.Library
{
return (Procedure)base.Save();
}
public static Procedure MakeProcedure(IVEDrillDownReadOnly parentInfo, ItemInfo previousInfo, string procNumber, string procTitle, int procType)
{
int newitemid = MakeNewItem(parentInfo, previousInfo, procNumber, procTitle, procType, E_FromType.Procedure);
return Procedure.Get(newitemid);
}
#region ProcedureConfig
[NonSerialized]
private ProcedureConfig _ProcedureConfig;
@@ -1057,15 +1353,49 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
{
protected override void RefreshFields(Item tmp)
{
base.RefreshFields(tmp);
ExtensionRefreshFields(tmp);
}
#if ItemWithContent
public SectionInfo(SafeDataReader dr) : base(dr, true) { }
#else
public SectionInfo(SafeDataReader dr) : base(dr) { }
#endif
private SectionInfo() : base() { ;}
public new static SectionInfo Get(int itemID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
SectionInfo tmp = GetCachedByPrimaryKey(itemID) as SectionInfo;
if (tmp == null)
{
tmp = DataPortal.Fetch<SectionInfo>(new PKCriteria(itemID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public void MoveSection(IVEDrillDownReadOnly pInfo, int index)
{
using (Item ii = Item.Get(this.ItemID))
{
ii.MoveItem(pInfo, index);
}
}
public new Section Get()
{
return (Section)(_Editable = Section.Get(ItemID));
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
@@ -1088,11 +1418,11 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Section tmp = (Section)GetExistingByPrimaryKey(itemID);
Section tmp = GetCachedByPrimaryKey(itemID) as Section;
if (tmp == null)
{
tmp = DataPortal.Fetch<Section>(new PKCriteria(itemID));
_AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -1102,12 +1432,15 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on Item.Get", ex);
}
}
public new Section Save()
{
return (Section)base.Save();
}
public static Section MakeSection(IVEDrillDownReadOnly parentInfo, ItemInfo previousInfo, string sectNumber, string sectTitle, int sectType)
{
int newitemid = MakeNewItem(parentInfo, previousInfo, sectNumber, sectTitle, sectType, E_FromType.Section);
return Section.Get(newitemid);
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
@@ -1134,6 +1467,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public partial class StepInfo : ItemInfo
{
protected override void RefreshFields(Item tmp)
{
base.RefreshFields(tmp);
ExtensionRefreshFields(tmp);
}
//public override string ToString()
//{
// return "Step " + base.ToString();
@@ -1143,6 +1481,34 @@ namespace VEPROMS.CSLA.Library
#else
public StepInfo(SafeDataReader dr) : base(dr) { }
#endif
private StepInfo() : base() { ;}
public new static StepInfo Get(int itemID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
StepInfo tmp = GetCachedByPrimaryKey(itemID) as StepInfo;
if (tmp == null)
{
tmp = DataPortal.Fetch<StepInfo>(new PKCriteria(itemID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public void MoveStep(IVEDrillDownReadOnly pInfo, int index)
{
using (Item ii = Item.Get(this.ItemID))
{
ii.MoveItem(pInfo, index);
}
}
public new Step Get()
{
return (Step)(_Editable = Step.Get(ItemID));
@@ -1162,11 +1528,11 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Step tmp = (Step)GetExistingByPrimaryKey(itemID);
Step tmp = (Step)GetCachedByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Step>(new PKCriteria(itemID));
_AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -1176,6 +1542,17 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on Item.Get", ex);
}
}
// TODO :MakeCaution;
// TODO :MakeNote;
// TODO :MakeRNO;
// TODO :MakeSection;
// TODO :MakeSubStep;
// TODO :MakeTable;
public static Step MakeStep(IVEDrillDownReadOnly parentInfo, ItemInfo previousInfo, string stepNumber, string stepTitle, int stepType, E_FromType fromType)
{
int newitemid = MakeNewItem(parentInfo, previousInfo, stepNumber, stepTitle, stepType, fromType);
return Step.Get(newitemid);
}
//#region StepConfig
//[NonSerialized]
//private StepConfig _StepConfig;