This commit is contained in:
Kathy Ruffing 2009-03-05 16:02:43 +00:00
parent e98f6c1e92
commit abf2a8919c
2 changed files with 160 additions and 17 deletions

View File

@ -516,6 +516,11 @@ namespace VEPROMS.CSLA.Library
int stepType = ((int)MyContent.Type) % 10000;
StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList;
StepData sd = sdlist[stepType];
while (sd.Index != 0)
{
if (sd.Type == type) return true;
sd = sdlist[sd.ParentType];
}
// TODO: RHM20071115 while (sd.Index != 0)
// TODO: RHM20071115 {
// TODO: RHM20071115 if (sd.Type == type) return true;
@ -527,84 +532,84 @@ namespace VEPROMS.CSLA.Library
{
get
{
return IsType("CAUTION");
return IsType("Caution");
}
}
public bool IsNote
{
get
{
return IsType("NOTE");
return IsType("Note");
}
}
public bool IsTable
{
get
{
return IsType("TABLE");
return IsType("Table");
}
}
public bool IsFigure
{
get
{
return IsType("FIGURE");
return IsType("Figure");
}
}
public bool IsOr
{
get
{
return IsType("OR");
return IsType("Or");
}
}
public bool IsAnd
{
get
{
return IsType("AND");
return IsType("And");
}
}
public bool IsEquipmentList
{
get
{
return IsType("EQUIPMENTLIST");
return IsType("EquipmentList");
}
}
public bool IsTitle
{
get
{
return IsType("TITLE");
return IsType("Title");
}
}
public bool IsAccPages
{
get
{
return IsType("ACCPAGES");
return IsType("AccPages");
}
}
public bool IsParagraph
{
get
{
return IsType("PARAGRAPH");
return IsType("Paragraph");
}
}
public bool IsDefault
{
get
{
return IsType("DEFAULT");
return IsType("Default");
}
}
public bool IsContAcSequential
{
get
{
return IsType("CONTACSEQUENTIAL");
return IsType("ContAcSequential");
}
}
public bool IsHigh
@ -669,15 +674,28 @@ namespace VEPROMS.CSLA.Library
}
/// <summary>
/// FormatStepType - Maps to step type in format file. All types map directly from step type in content
/// to step type in format except rno. The '39' is the RNO index in the format file. Note that we
/// could loop through the format's stepdata to find rnotype if we want this to be more flexible?
/// to step type in format
/// </summary>
public int FormatStepType
{
get
{
if (IsRNO) return 40;
else return (((int)MyContent.Type) % 10000);
return (((int)MyContent.Type) % 10000);
}
}
/// <summary>
/// returns the format's stepdata for the given content type.
/// </summary>
public StepData FormatStepData
{
get
{
int typ = (int)MyContent.Type - 20000;
foreach (StepData sd in ActiveFormat.PlantFormat.FormatData.StepDataList)
{
if (sd.Index == typ) return sd;
}
return null;
}
}
public ItemInfo FirstSibling
@ -1090,7 +1108,7 @@ namespace VEPROMS.CSLA.Library
if (MyContent.MyEntry == null)
return MyContent.Number;
if (MyContent.Number != "")
return MyContent.Number;
return (MyContent.MyEntry.MyDocument.LibTitle == null ? "" : "\xA3 ") + MyContent.Number;
if (MyContent.Text.Length <= 10)
return MyContent.Text;
return MyContent.Text.Split(" ,.;:-_".ToCharArray())[0] + "...";
@ -1282,6 +1300,113 @@ namespace VEPROMS.CSLA.Library
{
_MyContent = new ContentInfo(dr, true);
}
#region Insert New Items
public ItemInfo InsertSiblingBefore(string text)
{
return InsertSiblingBefore(text, null);
}
public ItemInfo InsertSiblingBefore(string text, string number)
{
ItemInfo prevItemInfo = MyPrevious;
ItemInfo newItemInfo = null;
PartInfoList partInfoList = MyParent != null && MyParent.MyContent != null ? MyParent.MyContent.ContentParts : null;
using (Item prevItem = prevItemInfo == null ? null : prevItemInfo.Get()) // Get the previous Item
{
using (Item newItem = Item.MakeItem(prevItem, Content.MakeContent(number, "", MyContent.Type, null, null))) // Create the new Item
{
using (Item thisItem = Get()) // Get the next item in the list
{
thisItem.MyPrevious = newItem; // Point to the new item
thisItem.Save(); // Save Changes
if (prevItem == null)
{
PartInfo partInfo = partInfoList.Find(this);
using (Part part = partInfo.Get())
{
part.MyItem = newItem;
part.Save();
}
}
}
newItemInfo = ItemInfo.Get(newItem.ItemID);
}
}
return newItemInfo;
}
public ItemInfo InsertSiblingAfter(string text)
{
return InsertSiblingAfter(text, null);
}
public ItemInfo InsertSiblingAfter(string text, string number)
{
return InsertSiblingAfter(text, number, MyContent.Type);
}
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
{
ItemInfo nextItemInfo = (NextItemCount > 0) ? NextItems[0] : null;
ItemInfo newItemInfo = null;
using (Item thisItem = Get()) // Get the Current Item
{
using (Item newItem = Item.MakeItem(thisItem, Content.MakeContent(number, text, type, null, null))) // Create the new Item
{
if (nextItemInfo != null) // Simple case, adding to end of list:
using (Item nextItem = nextItemInfo.Get()) // Get the next item in the list
{
nextItem.MyPrevious = newItem; // Point to the new item
nextItem.Save(); // Save Changes
}
newItemInfo = ItemInfo.Get(newItem.ItemID);
}
}
return newItemInfo;
}
public ItemInfo InsertChild(E_FromType fromType,int type,string text)
{
return InsertChild(fromType,type,text, null);
}
public ItemInfo InsertChild(E_FromType fromType,int type, string text, string number)
{
ItemInfo newItemInfo = null;
using (Item thisItem = Get()) // Get the Current Item
{
using (Item newItem = Item.MakeItem(null, Content.MakeContent(number, text, type, null, null))) // Create the new Item
{
PartInfo partInfo = MyContent.ContentParts == null ? null : MyContent.ContentParts.Find(fromType);
if (partInfo != null)
{
//this could be equivalent to adding a sibling with a specific type
using (Part part = partInfo.Get())
{
part.MyItem.MyPrevious = newItem;
part.MyItem.Save();
part.MyItem = newItem;
part.Save();
}
}
else
{
// This means that a part needs to be added to point to the new item
//using (Part part = Part.MakePart(thisItem.MyContent, ))
//{ ;}
thisItem.MyContent.ContentParts.Add((int)fromType, newItem);
thisItem.Save();
}
newItemInfo = ItemInfo.Get(newItem.ItemID);
}
}
ResetParts();
return newItemInfo;
}
public ItemInfo NextItem
{
get
{
if (NextItemCount > 0 && NextItems.Count > 0)
return NextItems[0];
return null;
}
}
#endregion
}
#endregion ItemInfo
#region ItemInfoList

View File

@ -39,6 +39,24 @@ namespace VEPROMS.CSLA.Library
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
{