299 lines
6.6 KiB
C#
299 lines
6.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Csla;
|
|
using Csla.Data;
|
|
|
|
namespace VEPROMS.CSLA.Library
|
|
{
|
|
public partial class ContentPart
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
|
|
}
|
|
}
|
|
public partial class ItemPart
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return string.Format("{0} {1}", _MyContent.Number, MyContent.Text);
|
|
}
|
|
}
|
|
public partial class Part
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
|
|
}
|
|
}
|
|
public partial class PartInfoList
|
|
{
|
|
internal PartInfoList(SafeDataReader dr, ItemInfo itemInfo)
|
|
{
|
|
AddPartInfo(dr,itemInfo);
|
|
}
|
|
internal void AddPartInfo(SafeDataReader dr, ItemInfo itemInfo)
|
|
{
|
|
IsReadOnly = false;
|
|
this.Add(new PartInfo(dr, itemInfo));
|
|
IsReadOnly = true;
|
|
}
|
|
public PartInfo Find(E_FromType fromType)
|
|
{
|
|
foreach(PartInfo partInfo in this)
|
|
{
|
|
if ((E_FromType)partInfo.FromType == fromType)
|
|
return partInfo;
|
|
}
|
|
return null;
|
|
}
|
|
public PartInfo Find(ItemInfo itemInfo)
|
|
{
|
|
foreach (PartInfo partInfo in this)
|
|
{
|
|
if (partInfo.MyItem.ItemID == itemInfo.ItemID)
|
|
return partInfo;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
public partial class PartInfo : IVEDrillDownReadOnly
|
|
{
|
|
private string _SearchDVPath;
|
|
public string SearchDVPath
|
|
{
|
|
get
|
|
{
|
|
if (_SearchDVPath == null)
|
|
_SearchDVPath = ActiveParent.SearchDVPath;
|
|
return _SearchDVPath;
|
|
}
|
|
}
|
|
private string _SearchPath;
|
|
public string SearchPath
|
|
{
|
|
get
|
|
{
|
|
if (_SearchPath == null)
|
|
{
|
|
string partText = "";
|
|
switch ((E_FromType) FromType)
|
|
{
|
|
case E_FromType.Procedure:
|
|
break;
|
|
case E_FromType.Section:
|
|
break;
|
|
case E_FromType.Caution:
|
|
partText = ".Caution";
|
|
break;
|
|
case E_FromType.Note:
|
|
partText = ".Note";
|
|
break;
|
|
case E_FromType.RNO:
|
|
partText = ".RNO";
|
|
break;
|
|
case E_FromType.Step:
|
|
break;
|
|
case E_FromType.Table:
|
|
if (MyItem.IsRtfRaw)
|
|
partText = ".Equation";
|
|
else if (MyItem.IsFigure)
|
|
partText = ".Figure";
|
|
else
|
|
partText = ".Table";
|
|
break;
|
|
case E_FromType.SupInfo:
|
|
partText = ".SupInfo";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
_SearchPath = ActiveParent.SearchPath + partText;
|
|
}
|
|
return _SearchPath;
|
|
}
|
|
}
|
|
|
|
// B2021-076: Proms search results are not presented in order when printed to PDF
|
|
private string _SearchDefaultSort;
|
|
|
|
public string SearchDefaultSort
|
|
{
|
|
get
|
|
{
|
|
if (_SearchDefaultSort == null)
|
|
{
|
|
string partText = String.Empty;
|
|
|
|
switch ((E_FromType)FromType)
|
|
{
|
|
case E_FromType.Caution:
|
|
partText = ".Caution";
|
|
break;
|
|
|
|
case E_FromType.Note:
|
|
partText = ".Note";
|
|
break;
|
|
|
|
case E_FromType.RNO:
|
|
partText = ".RNO";
|
|
break;
|
|
|
|
case E_FromType.Table:
|
|
partText = ".Table";
|
|
break;
|
|
|
|
default:
|
|
partText = ".";
|
|
break;
|
|
}
|
|
|
|
_SearchDefaultSort = ActiveParent.SearchDefaultSort + partText;
|
|
}
|
|
|
|
return _SearchDefaultSort;
|
|
}
|
|
}
|
|
|
|
internal PartInfo(SafeDataReader dr, ItemInfo itemInfo)
|
|
{
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
|
|
try
|
|
{
|
|
ReadData(dr, itemInfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex);
|
|
throw new DbCslaException("PartInfo.Constructor", ex);
|
|
}
|
|
}
|
|
private void ReadData(SafeDataReader dr, ItemInfo itemInfo)
|
|
{
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode());
|
|
try
|
|
{
|
|
_ContentID = dr.GetInt32("pContentID");
|
|
_FromType = dr.GetInt32("FromType");
|
|
_ItemID = dr.GetInt32("ItemID");
|
|
_DTS = dr.GetDateTime("pDTS");
|
|
_UserID = dr.GetString("pUserID");
|
|
_MyItem = itemInfo;
|
|
_MyItems = new ItemInfoList(itemInfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex);
|
|
_ErrorMessage = ex.Message;
|
|
throw new DbCslaException("PartInfo.ReadData", ex);
|
|
}
|
|
}
|
|
public E_FromType PartType
|
|
{ get { return (E_FromType)_FromType; } }
|
|
public E_FromTypes PartTypes
|
|
{ get { return (E_FromTypes)_FromType; } }
|
|
public override string ToString()
|
|
{
|
|
// if the parttype is table or figure, add the correct label:
|
|
if (PartTypes == E_FromTypes.Tables)
|
|
{
|
|
if (MyItems != null && MyItems[0].IsTable) return ("Table");
|
|
if (MyItems != null && MyItems[0].IsFigure) return ("Figure");
|
|
if (MyItems != null && MyItems[0].IsRtfRaw) return ("Equation");
|
|
}
|
|
return string.Format("{0}", PartTypes);
|
|
}
|
|
//public string ToString(string str, System.IFormatProvider ifp)
|
|
//{
|
|
// return ToString();
|
|
//}
|
|
#region IVEDrillDownReadOnly
|
|
public ItemInfoList _MyItems;
|
|
public ItemInfoList MyItems
|
|
{ get { return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); } }
|
|
public System.Collections.IList GetChildren()
|
|
{
|
|
//return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
|
|
return MyItems;
|
|
}
|
|
//public bool ChildrenAreLoaded
|
|
//{
|
|
// get { return _MyItems == null; }
|
|
//}
|
|
public bool HasChildren
|
|
{
|
|
get { return this.MyContent.ContentPartCount > 0; }
|
|
}
|
|
public IVEDrillDownReadOnly ActiveParent
|
|
{
|
|
get
|
|
{
|
|
ContentInfo parentContent = MyContent;
|
|
if (parentContent == null || parentContent.ContentItemCount == 0) return null;
|
|
return parentContent.ContentItems[0];
|
|
}
|
|
}
|
|
public FormatInfo ActiveFormat
|
|
{
|
|
get { return ActiveParent.ActiveFormat; }
|
|
}
|
|
public FormatInfo LocalFormat
|
|
{
|
|
get { return null; }
|
|
}
|
|
public ConfigDynamicTypeDescriptor MyConfig
|
|
{
|
|
get { return null; }
|
|
}
|
|
public bool IsFolder
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public bool IsDocVersion
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public bool IsProcedure
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public bool IsSection
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public bool IsStep
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
//public bool HasStandardSteps()
|
|
//{ return false; }
|
|
#endregion
|
|
}
|
|
|
|
// B2017-146 added the "Part" and "Parts" types of zero so that we have a valid node name when creating an export of a procedure with this FromType value
|
|
public enum E_FromType : int
|
|
{
|
|
Part = 0, Procedure = 1, Section = 2, Caution = 3, Note = 4, RNO = 5, Step = 6, Table = 7, SupInfo = 8
|
|
}
|
|
public enum E_FromTypes : int
|
|
{
|
|
Parts = 0, Procedures = 1, Sections = 2, Cautions = 3, Notes = 4, RNOs = 5, Steps = 6, Tables = 7, SupInfos = 8
|
|
}
|
|
}
|