Exemple #1
0
        /// <summary>
        /// Clear the current active item
        /// </summary>
        public static void ClearActiveItem()
        {
            if (CurrentActiveItem != null)
            {
                CurrentActiveItem.IsActiveWorkItem = false;
            }

            CurrentActiveItem = null;
            WorkspaceSessionPersistanceManager.ClearActiveEntity();
        }
Exemple #2
0
        /// <summary>
        /// Set the given item as the current active item
        /// </summary>
        public static void SetActiveItem(OctaneItemViewModel octaneItem)
        {
            if (octaneItem == null)
            {
                return;
            }

            if (CurrentActiveItem != null)
            {
                CurrentActiveItem.IsActiveWorkItem = false;
            }

            CurrentActiveItem = octaneItem;

            CurrentActiveItem.IsActiveWorkItem = true;
            WorkspaceSessionPersistanceManager.SetActiveEntity(CurrentActiveItem.Entity);
        }
Exemple #3
0
        /// <summary>
        /// Retrieve all the entities related to the current user
        /// </summary>
        internal async System.Threading.Tasks.Task LoadMyItemsAsync()
        {
            if (string.IsNullOrEmpty(OctaneConfiguration.Url))
            {
                // No URL which means it's the first time use.
                Mode = MainWindowMode.FirstTime;
                return;
            }

            // If we already loading wait for the runnung load to complete.
            if (Mode == MainWindowMode.LoadingItems)
            {
                return;
            }

            Mode = MainWindowMode.LoadingItems;

            try
            {
                OctaneServices octaneService;
                try
                {
                    octaneService = OctaneServices.GetInstance();
                } catch (Exception e)
                {
                    if (e.GetBaseException().Message.Equals("Object not created"))
                    {
                        OctaneServices.Create(OctaneConfiguration.Url,
                                              OctaneConfiguration.SharedSpaceId,
                                              OctaneConfiguration.WorkSpaceId);
                    }
                    octaneService = OctaneServices.GetInstance();
                    await octaneService.Connect();
                }

                _myItems.Clear();
                _totalItems = 0;

                bool foundActiveItem           = false;
                IEnumerable <BaseEntity> items = await octaneService.GetMyItems();

                // when a user story is converted to feature it might still be in the list of my work items,
                // the plugins do not support features in my work, so we just remove those entities
                items = items.Where(entity => !WorkItem.SUBTYPE_FEATURE.Equals(entity.GetStringValue(CommonFields.SubType)));

                if (sublistsMap == null)
                {
                    sublistsMap = createMyWorkItemsSublistsMap();
                }
                else
                {
                    cleanSubListsMap(sublistsMap);
                }

                foreach (BaseEntity entity in items)
                {
                    var octaneItem = new OctaneItemViewModel(entity);
                    _totalItems++;
                    if (WorkspaceSessionPersistanceManager.IsActiveEntity(entity))
                    {
                        foundActiveItem = true;
                        OctaneItemViewModel.SetActiveItem(octaneItem);
                    }
                    MyWorkItemsSublist itemSublist;

                    string concreteEntityType = Utility.GetConcreteEntityType(entity);
                    if (sublistsMap.TryGetValue(concreteEntityType, out itemSublist))
                    {
                        itemSublist.Items.Add(octaneItem);
                    }
                }

                myWorkItemSublists = sublistsMap.Values.ToList();

                if (!foundActiveItem)
                {
                    OctaneItemViewModel.ClearActiveItem();
                    MainWindowCommand.Instance?.DisableActiveItemToolbar();
                }

                IList <BaseEntity> comments = await octaneService.GetMyCommentItems();

                foreach (BaseEntity comment in comments)
                {
                    _totalItems++;
                    MyWorkItemsSublist itemSublist;
                    if (sublistsMap.TryGetValue("comment", out itemSublist))
                    {
                        itemSublist.Items.Add(new CommentViewModel(comment));
                    }
                }

                myWorkItemSublists.ForEach(ms =>
                {
                    if (ms.IsSelected)
                    {
                        foreach (var myWorkItem in ms.Items)
                        {
                            _myItems.Add(myWorkItem);
                        }
                    }
                });

                Mode = MainWindowMode.ItemsLoaded;

                SearchFilter = "";
                MainWindowCommand.Instance?.UpdateActiveItemInToolbar();
                NotifyPropertyChanged();
            }
            catch (Exception ex)
            {
                MainWindowCommand.Instance?.DisableActiveItemToolbar();
                Mode = MainWindowMode.FailToLoad;
                if (ex is NotConnectedException)
                {
                    LastExceptionMessage = "Failed to load \"My Work\"";
                }
                else
                {
                    LastExceptionMessage = ex.Message;
                }
            }
        }