This commit is contained in:
2009-11-03 16:32:28 +00:00
parent afc16fb9f9
commit 391cbaea39
3 changed files with 424 additions and 5 deletions

View File

@@ -125,7 +125,7 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertSiblingBefore(string text, string number)
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new AddingPartCriteria(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Environment.UserName));
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Environment.UserName);
// this item is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update Previous
using (Item item = Get()) ItemInfo.Refresh(item);
@@ -145,14 +145,46 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new AddingPartCriteria(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName));
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName);
//tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName));
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update PreviousID field
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
RefreshNextItems();
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText();
return tmp;
}
private ItemInfo NewItemInfoFetch(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
{
ItemInfo tmp;
if (addType == EAddpingPart.Child)
{
// adding children. Type is based on 'fromType'
switch ((E_FromType)fromType)
{
case E_FromType.Procedure:
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
case E_FromType.Section:
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
default:
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
}
}
else
{
if (GetType() == typeof(ProcedureInfo))
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
else if (GetType() == typeof(SectionInfo))
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
else
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
}
return tmp;
}
public void UpdateTransitionText()
{
// Update Ordinals from here down
@@ -179,7 +211,7 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertChild(E_FromType fromType, int type, string text, string number)
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new AddingPartCriteria(ItemID, EAddpingPart.Child, number, text, type, (int?) fromType, null, null, DateTime.Now, Environment.UserName));
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Child, number, text, type, (int?) fromType, null, null, DateTime.Now, Environment.UserName);
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update PreviousID field
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
@@ -356,6 +388,7 @@ namespace VEPROMS.CSLA.Library
{
//Console.WriteLine("item = {0}, ordinal = {1}",item,item.Ordinal);
item._Ordinal = null;
item._TagsSetup = false;
if (key == null && item.NextItem != null)
key = item.NextItem.ItemID.ToString();
}
@@ -428,6 +461,7 @@ namespace VEPROMS.CSLA.Library
try
{
ItemInfo nextItem = item.NextItem;
ItemInfo prevItem = item.MyPrevious;
DataPortal.Delete(new DeleteCriteria(item.ItemID,Environment.UserName));
if (nextItem != null) // Adjust PreviousID for NextItem
{
@@ -436,6 +470,8 @@ namespace VEPROMS.CSLA.Library
nextItem.RefreshItemParts();
nextItem.UpdateTransitionText();
}
else if (prevItem != null)
prevItem.RefreshNextItems();
ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
}
catch (Exception ex)