Пример #1
0
        private void TeamsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox    teamsComboBox           = sender as ComboBox;
            Deliverable selectedDeliverableItem = this.AllDeliverableList.CurrentItem as Deliverable;
            string      prevTeam = selectedDeliverableItem.Team;
            string      newTeam  = teamsComboBox.SelectedItem as string;

            // In case previous team = new team - no op - return.
            if (string.Equals(prevTeam, newTeam, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // In case <unmapped> was selected - don't allow it - return.
            if (string.Equals(newTeam, "<unmapped>", StringComparison.OrdinalIgnoreCase))
            {
                teamsComboBox.SelectedItem = prevTeam;
                return;
            }

            // We found a new team (previous could be either <unmapped> or a different team)
            // For building full area path - We assume that all teams are sub node of root node
            myApp().UpdateStatus($"Team Area path changed, was: {prevTeam}, now: {newTeam}");

            selectedDeliverableItem.Team             = newTeam;
            selectedDeliverableItem.AreaPath         = $@"{myConfig().TeamsRootNode}\{newTeam}";
            selectedDeliverableItem.AreaPathModified = true;
            selectedDeliverableItem.Mod = true;
        }
Пример #2
0
        public async Task <int> Refresh()
        {
            // CNOTETODO - prompt if there are dirty records
            myApp().UpdateProgress(true);
            myApp().UpdateStatus("Refreshing...");
            int tickStart = Environment.TickCount;

            AllItems.Clear();

            var refreshTask = Task <List <Dictionary <string, object> > > .Factory.StartNew(() => RefreshTask());

            await refreshTask;

            var allItemsData = refreshTask.Result;

            foreach (var item in allItemsData)
            {
                try
                {
                    //private int _id;
                    //private string _title;
                    //private int _rank;
                    //private string _team;
                    //private float _originalEstimate;
                    //private float _remainingDevDays;
                    //private string _customString1;
                    //private string _pmOwner;
                    //private string _area6 (subTeam)
                    //private string _customString2;
                    //private string _customString3;
                    // End known field IDs

                    Deliverable d = new Deliverable(
                        item[_ado.KnownFields[0]], myConfig(), this);

                    if (item.ContainsKey(_ado.KnownFields[1]))
                    {
                        d.Title = item[_ado.KnownFields[1]].ToString();
                    }

                    if (item.ContainsKey(_ado.KnownFields[2]))
                    {
                        d.Rank = int.Parse(item[_ado.KnownFields[2]].ToString());
                    }

                    /*  OLD TEAM HANDLINE
                     * if (item.ContainsKey(_ado.KnownFields[3]))
                     * {
                     *  bool addTeamNormal = true;
                     *
                     *  // See if we are matching against level 5 or 6, depending on root path
                     *  string[] queryPathParts = myConfig().RootNode.Split('\\');
                     *
                     *  if (queryPathParts.Length == 4)
                     *  {
                     *      // Regular mode, "per-DM"
                     *
                     *      // See if we have a subteam as well, which is mapped
                     *      if (item.ContainsKey(_ado.KnownFields[8]))
                     *      {
                     *          string possibleFullTeam = item[_ado.KnownFields[3]].ToString() + "\\" + item[_ado.KnownFields[8]].ToString();
                     *
                     *          // See if this possible name is in the list of teams
                     *          foreach (TeamConfig t in myConfig().Teams)
                     *          {
                     *              if (string.Compare(t.GroupName, possibleFullTeam, true) == 0)
                     *              {
                     *                  d.Team = possibleFullTeam;
                     *                  addTeamNormal = false;
                     *                  break;
                     *              }
                     *          }
                     *      }
                     *  }
                     *  else if (queryPathParts.Length == 5)
                     *  {
                     *      // "per-lead" - check area 6 and use that or "<root>"
                     *      if (item.ContainsKey(_ado.KnownFields[8]))
                     *      {
                     *          d.Team = item[_ado.KnownFields[8]].ToString();
                     *      }
                     *      else
                     *      {
                     *          d.Team = "<root>";
                     *      }
                     *
                     *      addTeamNormal = false;
                     *  }
                     *
                     *  if(addTeamNormal)
                     *  {
                     *      d.Team = item[_ado.KnownFields[3]].ToString();
                     *  }
                     * }
                     * else
                     * {
                     *  d.Team = "<root>";
                     * }
                     */



                    if (item.ContainsKey(_ado.KnownFields[4]))
                    {
                        d.OriginalEstimate = float.Parse(item[_ado.KnownFields[4]].ToString());
                    }

                    if (item.ContainsKey(_ado.KnownFields[5]))
                    {
                        d.RemainingDevDays = float.Parse(item[_ado.KnownFields[5]].ToString());
                    }

                    if (item.ContainsKey("AdoUrl"))
                    {
                        d.AdoUrl = item["AdoUrl"].ToString();
                    }

                    if (item.ContainsKey(_ado.KnownFields[6]))
                    {
                        d.CustomString1 = item[_ado.KnownFields[6]].ToString();
                    }

                    if (item.ContainsKey(_ado.KnownFields[7]))
                    {
                        d.PMOwner = item[_ado.KnownFields[7]].ToString();
                    }

                    if (item.ContainsKey(_ado.KnownFields[9]))
                    {
                        d.CustomString2 = item[_ado.KnownFields[9]].ToString();
                    }

                    if (item.ContainsKey(_ado.KnownFields[10]))
                    {
                        d.CustomString3 = item[_ado.KnownFields[10]].ToString();
                    }

                    // Map the team to anything that matches the substring
                    if (item.ContainsKey(_ado.KnownFields[11]))
                    {
                        d.AreaPath = item[_ado.KnownFields[11]].ToString();

                        // Find which team
                        d.Team = "<unmapped>";

                        foreach (TeamConfig t in myConfig().Teams)
                        {
                            if (d.AreaPath.Contains(t.GroupName))
                            {
                                d.Team = t.GroupName;
                                break;
                            }
                        }
                    }


                    AllItems.Add(d);
                }
                catch (Exception)
                {
                    Debug.WriteLine("Failed to create deliverable");
                }
            }

            Resort();

            RedoGroups();

            int totalCount = AllItems.Count;
            int totalTime  = Environment.TickCount - tickStart;

            myApp().UpdateStatus($"Loaded {totalCount} items in {totalTime} ms.");
            myApp().UpdateProgress(false);

            return(totalCount);
        }