Esempio n. 1
0
        /// <summary>
        /// Create menu for projects if they more 1
        /// </summary>
        /// <param name="pActiveItemMenu"></param>
        /// <param name="pWorkItems"></param>
        private void UpdateWorkitemMenuList(MenuItem pActiveItemMenu, ActiveWIList pWorkItems)
        {
            if (pWorkItems == null)
            {
                return;
            }

            if (pActiveItemMenu.HasItems)
            {
                pActiveItemMenu.Items.Clear();
            }

            IEnumerable <String> _projects = (from _workitems in pWorkItems.value select _workitems.TeamProject).Distinct();

            if (_projects.Count() > 1)
            {
                foreach (string _projectname in _projects)
                {
                    MenuItem _projectmenu = new MenuItem();
                    _projectmenu.Header = _projectname;
                    pActiveItemMenu.Items.Add(_projectmenu);
                    UpdateProjectMenu(_projectmenu, pWorkItems, _projectname);
                }
            }
            else if (_projects.Count() > 0)
            {
                UpdateProjectMenu(pActiveItemMenu, pWorkItems, _projects.ElementAt(0));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Craete menu item for workitems and assign event
        /// </summary>
        /// <param name="pParentMenu"></param>
        /// <param name="pWorkItems"></param>
        /// <param name="pProjectName"></param>
        /// <param name="pWiType"></param>
        private void UpdateWITypeMenu(MenuItem pParentMenu, ActiveWIList pWorkItems, string pProjectName, string pWiType)
        {
            IEnumerable <ActiveWIList.ActiveWiListValues> _wis =
                (from _workitems in pWorkItems.value
                 where _workitems.TeamProject == pProjectName && _workitems.WorkItemType == pWiType
                 select _workitems).Distinct();

            foreach (ActiveWIList.ActiveWiListValues _wi in _wis)
            {
                MenuItem _wimenu     = new MenuItem();
                string   _menuheader = _wi.Id + ": " + _wi.Title;
                _wimenu.Header = _menuheader.Length > 30 ? (_menuheader.Substring(0, 27) + "...") : _menuheader;
                pParentMenu.Items.Add(_wimenu);
                _wimenu.Tag     = _wi.Id;
                _wimenu.ToolTip = _wi.Title;
                _wimenu.Click  += _wimenu_Click;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create menu for work item types if they more 1
        /// </summary>
        /// <param name="pParentMenu"></param>
        /// <param name="pWorkItems"></param>
        /// <param name="pProjectName"></param>
        private void UpdateProjectMenu(MenuItem pParentMenu, ActiveWIList pWorkItems, string pProjectName)
        {
            IEnumerable <String> _witypes =
                (from _workitems in pWorkItems.value where _workitems.TeamProject == pProjectName
                 select _workitems.WorkItemType).Distinct();

            if (_witypes.Count() > 1)
            {
                foreach (string _witype in _witypes)
                {
                    MenuItem _witypemenu = new MenuItem();
                    _witypemenu.Header = _witype;
                    pParentMenu.Items.Add(_witypemenu);
                    UpdateWITypeMenu(_witypemenu, pWorkItems, pProjectName, _witype);
                }
            }
            else
            {
                UpdateWITypeMenu(pParentMenu, pWorkItems, pProjectName, _witypes.ElementAt(0));
            }
        }
        public static ActiveWIList GetActiveWorkItems()
        {
            ActiveWIList activeWIList = new ActiveWIList();

            if (ConnectToServce())
            {
                var wiql = new Wiql();
                wiql.Query = String.Format(Properties.Settings.Default.QueryActiveWI, Properties.Settings.Default.ActiveState);
                var queryres = WitClient.QueryByWiqlAsync(wiql).Result;

                if (queryres.WorkItems != null)
                {
                    var ids = from wi in queryres.WorkItems select wi.Id;

                    if (ids.Count() > 0)
                    {
                        var wiList = WitClient.GetWorkItemsAsync(ids).Result;

                        foreach (var workItem in wiList)
                        {
                            activeWIList.value.Add(new ActiveWIList.ActiveWiListValues
                            {
                                Id           = workItem.Id.Value,
                                Rev          = workItem.Rev.Value,
                                Title        = workItem.Fields[WIConsts.Title].ToString(),
                                WorkItemType = workItem.Fields[WIConsts.WorkItemType].ToString(),
                                TeamProject  = workItem.Fields[WIConsts.TeamProject].ToString(),
                                Url          = workItem.Url
                            });
                        }
                    }
                }
            }

            return(activeWIList);
        }
Esempio n. 5
0
        private void ActiveWorkItems_Click(object sender, RoutedEventArgs e)
        {
            ActiveWorkItems = RestApiHelper.GetActiveWorkItems();

            UpdateWorkitemMenuList((MenuItem)sender, ActiveWorkItems);
        }