private void ChildAdded(StoreItem childItem) { IStoreItemList childItems = GetChildItems(); if (childItems == null) { return; } // If this child item isn't the type that this parent expects, // don't add it to the list of children. if (!childItems.ItemMatchesListType(childItem)) { Planner.OnInvalidHierarchicalItemEvent(this, childItem); return; } if (!childItems.Contains(childItem)) { childItems.Add(childItem); if (Planner.Instance.IsStartupComplete) { NotifyItemUpdatedWorker(new NotificationArgs(childItem, ChangeType.Added, HierarchicalChangeSource.ChildItem, null)); } if (StoreItem.IsRealItem(ParentItem)) { ParentItem.ChildAdded(this); } } }
//------------------------------------------------------------------------------------ /// <summary> /// Will be called when the given property for this item has been updated. /// </summary> //------------------------------------------------------------------------------------ public void OnUpdate(ItemProperty itemProperty) { // Maintain hierarchy if (itemProperty.PublicPropName == ParentKeyProperty) { StoreItem previousParent = Planner.Instance.ItemRepository.GetItem((string)itemProperty.PreviousValue); StoreItem newParent = Planner.Instance.ItemRepository.GetItem((string)itemProperty.CurrentValue); if (StoreItem.IsRealItem(previousParent)) { previousParent.ChildRemoved(this); } if (StoreItem.IsRealItem(newParent)) { newParent.ChildAdded(this); } } // Maintain ownership else if (itemProperty.PublicPropName == OwnerKeyProperty) { StoreItem previousOwner = Planner.Instance.ItemRepository.GetItem((string)itemProperty.PreviousValue); StoreItem newOwner = Planner.Instance.ItemRepository.GetItem((string)itemProperty.CurrentValue); if (StoreItem.IsRealItem(previousOwner)) { previousOwner.RemoveOwnedItem(this); } if (StoreItem.IsRealItem(newOwner)) { newOwner.AddOwnedItem(this); } } else if (itemProperty.PublicPropName == OwnerAssignedProperty) { StoreItem previousOwner = Planner.Instance.ItemRepository.GetMemberByAlias((string)itemProperty.PreviousValue); StoreItem newOwner = Planner.Instance.ItemRepository.GetMemberByAlias((string)itemProperty.CurrentValue); if (StoreItem.IsRealItem(previousOwner)) { previousOwner.RemoveOwnedItem(this); } if (StoreItem.IsRealItem(newOwner)) { newOwner.AddOwnedItem(this); } } else { NotifyItemUpdated(itemProperty); } MaintainFilters(ChangeType.Updated); }
//------------------------------------------------------------------------------------ /// <summary> /// Will be called when this item is being deleted, and removed from the global /// cache. /// </summary> //------------------------------------------------------------------------------------ public void OnRemove() { // Maintain item cache RemoveFromItemCache(); if (StoreItem.IsRealItem(ParentItem)) { ParentItem.ChildRemoved(this); } // Maintain owners if (StoreItem.IsRealItem(OwnerItem)) { OwnerItem.RemoveOwnedItem(this); } }
public override int Compare(object x, object y) { StoreItem storeItemX = (StoreItem)x; StoreItem storeItemY = (StoreItem)y; bool isXLater = false; // Any item assigned to a train ranks higher than an item 'on the backlog' if (StoreItem.IsRealItem(storeItemX.ParentTrainItem) && !StoreItem.IsRealItem(storeItemY.ParentTrainItem)) { isXLater = false; } else if (!StoreItem.IsRealItem(storeItemX.ParentTrainItem) && StoreItem.IsRealItem(storeItemY.ParentTrainItem)) { isXLater = true; } // The item assigned to the earlier train ranks earlier else if (StoreItem.IsRealItem(storeItemX.ParentTrainItem) && StoreItem.IsRealItem(storeItemY.ParentTrainItem) && storeItemX.ParentTrainItem.EndDate > storeItemY.ParentTrainItem.EndDate) { isXLater = true; } else if (StoreItem.IsRealItem(storeItemX.ParentTrainItem) && StoreItem.IsRealItem(storeItemY.ParentTrainItem) && storeItemX.ParentTrainItem.EndDate < storeItemY.ParentTrainItem.EndDate) { isXLater = false; } else { // If both items are assigned to the same train, then rank according to BusinessRank if (storeItemX.BusinessRank == storeItemY.BusinessRank) { return(0); } isXLater = storeItemX.BusinessRank > storeItemY.BusinessRank; } if (m_direction == ListSortDirection.Ascending) { return(isXLater ? 1 : -1); } else { return(isXLater ? -1 : 1); } }
//------------------------------------------------------------------------------------ /// <summary> /// Will be called when this item comes into existence and has been added to the /// global cache. /// </summary> //------------------------------------------------------------------------------------ public void OnAdd() { // Maintain item cache AddToItemCache(); // Maintain hierarchy if (StoreItem.IsRealItem(ParentItem)) { ParentItem.ChildAdded(this); } // Maintain owners if (StoreItem.IsRealItem(OwnerItem)) { OwnerItem.AddOwnedItem(this); } FinalizeItem(); }
public override int Compare(object x, object y) { BacklogItem backlogItemX = (BacklogItem)x; BacklogItem backlogItemY = (BacklogItem)y; Nullable <DateTime> landingDateX = null; // TypeUtils.GetNullableDateTimeValue(backlogItemX.LandingDateText); Nullable <DateTime> landingDateY = null; // TypeUtils.GetNullableDateTimeValue(backlogItemY.LandingDateText); bool isXLater = false; if (backlogItemX.IsActive && !backlogItemY.IsActive) { isXLater = true; } else if (!backlogItemX.IsActive && backlogItemY.IsActive) { isXLater = false; } // Always treat non-date text as greater than a date value, so they'll sort to the end of the list else if (landingDateX == null && landingDateY == null) { // Any item assigned to a train ranks higher than an item 'on the backlog' if (StoreItem.IsRealItem(backlogItemX.ParentTrainItem) && !StoreItem.IsRealItem(backlogItemY.ParentTrainItem)) { isXLater = false; } else if (!StoreItem.IsRealItem(backlogItemX.ParentTrainItem) && StoreItem.IsRealItem(backlogItemY.ParentTrainItem)) { isXLater = true; } // The item assigned to the earlier train ranks earlier else if (backlogItemX.ParentTrainItem.EndDate > backlogItemY.ParentTrainItem.EndDate) { isXLater = true; } else if (backlogItemX.ParentTrainItem.EndDate < backlogItemY.ParentTrainItem.EndDate) { isXLater = false; } else { // If both items are assigned to the same train, then rank according to BusinessRank if (backlogItemX.BusinessRank == backlogItemY.BusinessRank) { return(0); } isXLater = backlogItemX.BusinessRank > backlogItemY.BusinessRank; } } else if (landingDateX != null && landingDateY == null) { isXLater = false; } else if (landingDateX == null && landingDateY != null) { isXLater = true; } if (landingDateX != null && landingDateY != null) { if (landingDateX == landingDateY) { return(0); } else { isXLater = landingDateX.Value > landingDateY; } } if (m_direction == ListSortDirection.Ascending) { return(isXLater ? 1 : -1); } else { return(isXLater ? -1 : 1); } }