This commit is contained in:
Kathy Ruffing 2009-11-20 11:38:46 +00:00
parent 8f81a3a3e7
commit dbee9fde6d

View File

@ -9,6 +9,27 @@ using Csla.Data;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ItemInfoInsertEvent(object sender, ItemInfoInsertEventArgs args);
public class ItemInfoInsertEventArgs
{
private ItemInfo _ItemInserted;
public ItemInfo ItemInserted
{
get { return _ItemInserted; }
set { _ItemInserted = value; }
}
private ItemInfo.EAddpingPart _AddingPart;
public ItemInfo.EAddpingPart AddingPart
{
get { return _AddingPart; }
set { _AddingPart = value; }
}
public ItemInfoInsertEventArgs(ItemInfo itemInserted,ItemInfo.EAddpingPart addingPart)
{
_ItemInserted = itemInserted;
_AddingPart = addingPart;
}
}
public partial class ItemInfo public partial class ItemInfo
{ {
#region Old Insert #region Old Insert
@ -163,6 +184,57 @@ namespace VEPROMS.CSLA.Library
{ {
if (Deleted != null) Deleted(sender); if (Deleted != null) Deleted(sender);
} }
public event ItemInfoInsertEvent NewSiblingAfter;
internal void OnNewSiblingAfter(object sender, ItemInfoInsertEventArgs args)
{
if (NewSiblingAfter != null) NewSiblingAfter(sender,args);
}
internal void OnNewSiblingAfter(ItemInfoInsertEventArgs args)
{
string key = ItemID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key))
{
ItemInfo[] items = _CacheByPrimaryKey[key].ToArray();
foreach (ItemInfo item in items)
{
item.OnNewSiblingAfter(item,args);
}
}
}
public event ItemInfoInsertEvent NewSiblingBefore;
internal void OnNewSiblingBefore(object sender, ItemInfoInsertEventArgs args)
{
if (NewSiblingBefore != null) NewSiblingBefore(sender,args);
}
internal void OnNewSiblingBefore(ItemInfoInsertEventArgs args)
{
string key = ItemID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key))
{
ItemInfo[] items = _CacheByPrimaryKey[key].ToArray();
foreach (ItemInfo item in items)
{
item.OnNewSiblingBefore(item,args);
}
}
}
public event ItemInfoInsertEvent NewChild;
internal void OnNewChild(object sender, ItemInfoInsertEventArgs args)
{
if (NewChild != null) NewChild(sender, args);
}
internal void OnNewChild(ItemInfoInsertEventArgs args)
{
string key = ItemID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key))
{
ItemInfo[] items = _CacheByPrimaryKey[key].ToArray();
foreach (ItemInfo item in items)
{
item.OnNewChild(item, args);
}
}
}
#endregion #endregion
#region Insert Before #region Insert Before
public ItemInfo InsertSiblingBefore(string text) public ItemInfo InsertSiblingBefore(string text)
@ -177,6 +249,8 @@ namespace VEPROMS.CSLA.Library
using (Item item = Get()) ItemInfo.Refresh(item); using (Item item = Get()) ItemInfo.Refresh(item);
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item // Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText(); tmp.UpdateTransitionText();
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
((ItemInfo)ActiveParent).MyContent.RefreshContentParts();
return tmp; return tmp;
} }
#endregion #endregion
@ -199,6 +273,7 @@ namespace VEPROMS.CSLA.Library
RefreshNextItems(); RefreshNextItems();
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item // Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText(); tmp.UpdateTransitionText();
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
return tmp; 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) private ItemInfo NewItemInfoFetch(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
@ -263,6 +338,8 @@ namespace VEPROMS.CSLA.Library
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item); if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item // Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText(); tmp.UpdateTransitionText();
MyContent.RefreshContentParts();
OnNewChild(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Child));
return tmp; return tmp;
} }
#endregion #endregion
@ -432,7 +509,7 @@ namespace VEPROMS.CSLA.Library
key = null; key = null;
foreach (ItemInfo item in items) foreach (ItemInfo item in items)
{ {
//Console.WriteLine("item = {0}, ordinal = {1}",item,item.Ordinal); //Console.WriteLine("ResetOrdinal item = {0}, ordinal = {1}", item, item.Ordinal);
item._Ordinal = null; item._Ordinal = null;
item._TagsSetup = false; item._TagsSetup = false;
item.MyContent.ShowChange(); item.MyContent.ShowChange();
@ -555,8 +632,11 @@ namespace VEPROMS.CSLA.Library
if (nextItem != null) // Adjust PreviousID for NextItem if (nextItem != null) // Adjust PreviousID for NextItem
{ {
ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID); ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID);
nextItem.ResetOrdinal(); // The order of the next two methods was required to fix a null reference
// when getting myparent. This bug was found when deleting a node from the
// tree when the stepitem was not open (i.e. in the step editor window).
nextItem.RefreshItemParts(); nextItem.RefreshItemParts();
nextItem.ResetOrdinal();
nextItem.UpdateTransitionText(); nextItem.UpdateTransitionText();
} }
else if (prevItem != null) else if (prevItem != null)
@ -565,6 +645,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("ItemInsertExt: Stacktrace = {0}", ex.StackTrace);
System.Data.SqlClient.SqlException exSQL = SqlException(ex); System.Data.SqlClient.SqlException exSQL = SqlException(ex);
if (exSQL != null && exSQL.Message.Contains("###Cannot Delete Item###")) if (exSQL != null && exSQL.Message.Contains("###Cannot Delete Item###"))
//return false; //return false;