Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// For the given StoreItem, set the current value of the specified property directly
        /// into the backing store.  If isOpen is true, the item will be assumed to already
        /// be open for edit, and won't be opened again.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void SetItemBackingValue(StoreItem item, string dsPropName, string publicPropName, object value, IsOpenedForEdit isOpen = IsOpenedForEdit.No)
        {
            DatastoreItem dsItem = item.DSItem;

            if (dsItem != null)
            {
                if (isOpen == IsOpenedForEdit.No && item.ID != 0)
                {
                    OpenForEdit(item.DSItem);
                }

                Field field = dsItem.Fields[dsPropName];
                if (!field.IsReadOnly)
                {
                    object finalValue;
                    if (!CompositeRegistry.GetCompositeFromValue(dsItem, dsPropName, publicPropName, value, out finalValue))
                    {
                        finalValue = value;
                    }

                    field.Value = finalValue;
                }
            }
        }
Ejemplo n.º 2
0
        public void SetItemSelectionPreference(ProductPreferences selection, StoreItem item)
        {
            if (selection == PlannerNameSpace.ProductPreferences.None)
            {
                return;
            }

            string productKey = Planner.Instance.CurrentProductGroupKey;

            if (!ProductPreferences.ContainsKey(productKey))
            {
                ProductPreferences.Add(productKey, new Dictionary <ProductPreferences, object>());
            }

            Dictionary <ProductPreferences, object> itemSelectionPreferences = ProductPreferences[productKey];

            if (!itemSelectionPreferences.ContainsKey(selection))
            {
                itemSelectionPreferences.Add(selection, null);
            }

            itemSelectionPreferences[selection] = item == null ? null : item.StoreKey;
            Serialize();
        }
Ejemplo n.º 3
0
 public MemoryStream GetRichTextFileAttachmentStream(StoreItem item, string propName)
 {
     return(GetFileAttachmentStream(item, propName + ".rtf"));
 }
Ejemplo n.º 4
0
 public static ExperienceItem GetDummyAllItem()
 {
     return(StoreItem.GetDummyItem <ExperienceItem>(DummyItemType.AllType));
 }
Ejemplo n.º 5
0
 public static ScrumTeamItem GetDummyAllTeam()
 {
     return(StoreItem.GetDummyItem <ScrumTeamItem>(DummyItemType.AllType));
 }
Ejemplo n.º 6
0
 public PropertyEventArgs(StoreItem item, ItemProperty property)
 {
     Item     = item;
     Property = property;
 }
Ejemplo n.º 7
0
 //------------------------------------------------------------------------------------
 /// <summary>
 ///  Commits the given item to the backing store.
 /// </summary>
 //------------------------------------------------------------------------------------
 public void CommitItem(StoreItem item)
 {
     CommitType = CommitType.ImmediateCommit;
     SetCommitItem(item);
     DoCommit(false);
 }
Ejemplo n.º 8
0
 public static PersonaItem GetDummyAllTeam()
 {
     return(StoreItem.GetDummyItem <PersonaItem>(DummyItemType.AllType));
 }
Ejemplo n.º 9
0
 public InvalidHierarchicalItemEvent(StoreItem invalidItem)
 {
     InvalidItem = invalidItem;
 }
Ejemplo n.º 10
0
 public DocumentAttachmentCollection(StoreItem item)
     : base(item)
 {
 }
Ejemplo n.º 11
0
 //------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the value of the given property as a document represented by a stream.
 /// Note: not used currently - see below.
 /// </summary>
 //------------------------------------------------------------------------------------
 public BitmapSource GetImageValue(string propName, StoreItem itemToNotify = null, [CallerMemberName] string publicPropName = null)
 {
     return(ItemImages.GetFileAttachmentImageValue(propName, itemToNotify, publicPropName));
 }
Ejemplo n.º 12
0
 public override void InitializeRequiredFieldValues(StoreItem item)
 {
     item.Severity   = "2";
     item.OpenedBy   = Planner.Instance.CurrentUserAlias;
     item.OpenedDate = DateTime.Now;
 }
Ejemplo n.º 13
0
 public ItemAttachmentCollection(StoreItem item)
 {
     Attachments = new Dictionary <string, T>();
     Item        = item;
 }
 public ImageAttachmentCollection(StoreItem item)
     : base(item)
 {
     BackgroundProcessByProperty = new HashSet <string>();
 }
Ejemplo n.º 15
0
 //------------------------------------------------------------------------------------
 /// <summary>
 /// Transfers the contents of the in-memory cache for this item to the store cache,
 /// in preparation for persisting the contents to the store.
 /// </summary>
 //------------------------------------------------------------------------------------
 private void WriteItemToDS(StoreItem item)
 {
     item.WriteToBackingStoreBeforeSave(IsOpenedForEdit.Yes);
 }
Ejemplo n.º 16
0
        public override int Compare(object x, object y)
        {
            object compareX = x;
            object compareY = y;

            if (x is FilterValue && y is FilterValue)
            {
                FilterValue filterValueX = (FilterValue)x;
                FilterValue filterValueY = (FilterValue)y;
                compareX = filterValueX.Value;
                compareY = filterValueY.Value;
            }

            StoreItem itemX      = (StoreItem)compareX;
            StoreItem itemY      = (StoreItem)compareY;
            bool      isXEarlier = false;

            if (itemX == itemY)
            {
                return(0);
            }
            else if (itemX.IsDummyItem && itemY.IsDummyItem)
            {
                isXEarlier = itemX.IsAllItem;
            }
            else if (itemX.IsDummyItem)
            {
                isXEarlier = true;
            }
            else if (itemY.IsDummyItem)
            {
                isXEarlier = false;
            }
            else
            {
                object xValue = SortProp.GetValue(itemX);
                object yValue = SortProp.GetValue(itemY);
                if (xValue is int && yValue is int)
                {
                    int intX = (int)xValue;
                    int intY = (int)yValue;
                    if (intX == intY)
                    {
                        return(0);
                    }

                    isXEarlier = intX < intY;
                }
                else
                {
                    string strX = (string)xValue;
                    string strY = (string)yValue;

                    int compare = strX.CompareTo(strY);
                    if (compare == 0)
                    {
                        return(0);
                    }

                    isXEarlier = compare < 0;
                }
            }

            if (m_direction == ListSortDirection.Ascending)
            {
                return(isXEarlier ? -1 : 1);
            }
            else
            {
                return(isXEarlier ? 1 : -1);
            }
        }
Ejemplo n.º 17
0
 private void FinalizePropertyAfterSave(StoreItem item, ItemProperty itemProperty)
 {
     item.FinalizePropertyAfterSave(itemProperty);
 }
Ejemplo n.º 18
0
 void IStoreItemList.Add(StoreItem item)
 {
     Add((T)item);
 }
Ejemplo n.º 19
0
 public BitmapSource GetUserPicture(StoreItem itemToNotify, [CallerMemberName] string publicPropName = null)
 {
     return(GetActiveDirectoryImageValue(Alias, itemToNotify, publicPropName));
 }
Ejemplo n.º 20
0
 bool IStoreItemList.Remove(StoreItem item)
 {
     return(Remove((T)item));
 }
Ejemplo n.º 21
0
        BackgroundTaskResult CommitItemWorker(StoreItem item, List <StoreItem> newCommittedItems)
        {
            //try
            {
                Datastore store = item.Store;
                switch (item.ChangeAction)
                {
                case StoreChangeAction.Default:
                    if (item.IsNew)
                    {
                        item.DSItem = store.CreateDSItem();

                        ItemTypeKey typeKey = store.GetItemTypeKey(item.StoreItemType);
                        item.DSItem.Fields[store.PropNameType].Value = typeKey.TypeName;

                        if (store.PropSubTypeName != null && typeKey.SubTypeName != Constants.c_Any)
                        {
                            item.DSItem.Fields[store.PropSubTypeName].Value = typeKey.SubTypeName;
                        }

                        store.SaveItemWorker(item);
                        store.FinalizeAfterSave(item);
                        item.PersistState = PersistStates.PersistedToStore;
                        newCommittedItems.Add(item);
                    }
                    else
                    {
                        store.SaveItemWorker(item);
                        store.FinalizeAfterSave(item);
                    }
                    break;

                case StoreChangeAction.ResolveItem:
                    item.Status = StatusValues.Active;
                    store.ResolveStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;

                case StoreChangeAction.ResolveAndCloseItem:
                    store.ResolveStoreItemWorker(item);
                    store.CloseStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;

                case StoreChangeAction.CloseItem:
                    store.CloseStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;

                case StoreChangeAction.ActivateItem:
                    store.ActivateStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;
                }

                return(new BackgroundTaskResult {
                    ResultType = ResultType.Completed
                });
            }

            //catch (Exception exception)
            //{
            //    Planner.ApplicationManager.HandleException(exception);
            //    return new BackgroundTaskResult { ResultType = ResultType.Failed, ResultMessage = exception.Message };
            //}
        }
Ejemplo n.º 22
0
 bool IStoreItemList.ItemMatchesListType(StoreItem item)
 {
     return(ItemMatchesListType(item));
 }
Ejemplo n.º 23
0
 private void SetCommitItem(StoreItem item)
 {
     System.Diagnostics.Debug.Assert(ChangeList == null);
     ChangeList = new List <StoreItem>();
     ChangeList.Add(item);
 }
Ejemplo n.º 24
0
        bool ItemMatchesListType(StoreItem item)
        {
            T actualItem = item as T;

            return(actualItem == null ? false : true);
        }
Ejemplo n.º 25
0
 public static bool IsRealItem(StoreItem item)
 {
     return(item != null && !item.IsDummyItem);
 }
Ejemplo n.º 26
0
 //------------------------------------------------------------------------------------
 /// <summary>
 /// Add information about the given item to the event log, along with the given
 /// message.
 /// </summary>
 //------------------------------------------------------------------------------------
 public void AddStoreItemLogEntry(StoreItem item, string message)
 {
     WriteToEventLog(" ID=" + item.ID.ToString() + "; Title=" + item.Title + "; " + message);
 }
Ejemplo n.º 27
0
 public ItemDiscoveredEventArgs(StoreItem discoveredItem, DiscoveryAction action)
 {
     DiscoveredItem = discoveredItem;
     Action         = action;
 }
Ejemplo n.º 28
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Performs a save to the backing store for the given store item.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void SaveItemWorker(StoreItem item)
        {
            try
            {
                Debug.WriteLine("Saving item - " + item.ID.ToString() + ": " + item.Title);

                if (item.ID != 0)
                {
                    OpenForEdit(item.DSItem);
                }

                WriteItemToDS(item);

                // Save all attached document files
                item.ItemDocuments.SaveAll();

                // Save all attached image files
                item.ItemImages.SaveAll();

                // List of standard files to attach
                if (item.AttachedFileNamesToCommit != null)
                {
                    DatastoreItem dsItem = item.DSItem;
                    foreach (string filename in item.AttachedFileNamesToCommit)
                    {
                        // If a previous file with this filename exists in the store, remove it.
                        RemoveAttachedFile(dsItem, filename);

                        // Add the new file
                        dsItem.Files.AddEx(filename);
                    }
                }

                // An attached file to be removed
                if (item.AttachedFileNameToRemove != null)
                {
                    QueueAttachedFileForRemoval(item, item.AttachedFileNameToRemove);
                }

                item.DSItem.Save();
                ResetItem(item);

                Debug.WriteLine("Save complete:" + item.ID.ToString());

                item.LastSavedTime = DateTime.Now;
            }

            catch (Exception exception)
            {
                Debug.WriteLine("SaveItemWorker exception: " + exception.Message);

                // Has someone else saved changes to this item since we opened it?
                if (exception.Message.Contains(Constants.PSErrIssueUpdated))
                {
                    if (item.CommitErrorState != CommitErrorStates.MergingChanges)
                    {
                        //  Yes, so re-open the item, merge their changes with ours, then then re-save it.
                        DatastoreItem dsItem = m_storeItemList.Datastore.GetDatastoreItem(PsDatastoreItemTypeEnum.psDatastoreItemTypeBugs, item.ID);
                        OpenForEdit(dsItem);
                        item.CommitErrorState = CommitErrorStates.MergingChanges;
                        item.MergeChanges(dsItem);
                        SaveItemWorker(item);
                    }
                    else
                    {
                        // Should never happen, but we got the same IssueUpdated error again after trying to
                        // re-open and merge changes.
                    }
                }
                else if (exception.Message.Contains(Constants.PSErrAttachmentShare))
                {
                    item.CommitErrorState = CommitErrorStates.ErrorAccessingAttachmentShare;
                    Planner.Instance.HandleStoreItemException(item, exception);
                }
                else
                {
                    throw exception;
                }
            }
        }
Ejemplo n.º 29
0
        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);
            }
        }
Ejemplo n.º 30
0
 public abstract void InitializeRequiredFieldValues(StoreItem item);