Beispiel #1
0
        /// <summary>
        /// Populate the CardSet from the url
        /// </summary>
        /// <param name="filters">Filters to apply to this request</param>
        public object Parse(Collection <string> filters)
        {
            try
            {
                var more = true;
                TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Loading the ResponseStream");
                Clear();
                var page = 0;
                filters.Add("");
                while (more)
                {
                    page++;
                    filters[filters.Count - 1] = "page=" + page.ToString();
                    var begin    = DateTime.Now.Ticks;
                    var response = Project.Mingle.Get(ProjectId, "/cards.xml", filters);
                    var end      = DateTime.Now.Ticks;
                    var span     = new TimeSpan(end - begin);
                    TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Parsing page " + page.ToString() + "took " + span.TotalMilliseconds + " milliseconds including Web server round trip for " + response.Length + " characters of data.");
                    more = FillTheCardCollection(response);
                }
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                throw;
            }

            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// Get property definitions for the project
        /// </summary>
        public MinglePropertyDefinitionCollection GetProperties()
        {
            var me    = new StackFrame().GetMethod().Name;
            var start = DateTime.Now;

            try
            {
                // Get all the property definitions
                _properties = new MinglePropertyDefinitionCollection(this);
                _properties.Parse();
            }
            catch (Exception ex)
            {
                TraceLog.Exception(me, ex);
                throw;
            }

            var stop    = DateTime.Now;
            var elapsed = stop - start;

            TraceLog.WriteLine(new StackFrame().GetMethod().Name,
                               string.Format("Elapsed time binding MingleProject.GetProperties: {0}",
                                             elapsed.TotalSeconds));
            return(_properties);
        }
Beispiel #3
0
        /// <summary>
        /// Refreshes the list of cards indicated by this Favorite
        /// </summary>
        public MingleCardCollection GetCards()
        {
            var filters = new Collection <string>
            {
                new MingleFilter
                {
                    Name  = "view",
                    Value = Name
                }.FavoriteString,
                "page=all"
            };


            var cards = new MingleCardCollection(Project);

            try
            {
                TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Loading the ResponseStream");
                var response = XElement.Parse(Project.Mingle.Get(ProjectId, "/cards.xml", filters));
                foreach (var e in response.Elements("card"))
                {
                    cards.Add(new MingleCard(e.ToString(), Project));
                }
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                throw;
            }

            return(cards);
        }
Beispiel #4
0
        /// <summary>
        /// Search for cards matching the list-indicated criteria
        /// </summary>
        private void SearchForCards()
        {
            var cards = new SortedList <int, CardListItem>();
            var types = new Collection <string>();

            foreach (
                CheckBox item in cardTypes.Children.Cast <CheckBox>().Where(item => Convert.ToBoolean(item.IsChecked, CultureInfo.CurrentCulture)))
            {
                types.Add(string.Format(CultureInfo.CurrentCulture, "{0}", item.Content.ToString()));
            }

            if (types.Count == 0)
            {
                list.ItemsSource = cards.Values;
                return;
            }

            try
            {
                Cursor = Cursors.Wait;
                _model.GetCardList(types).ToList().ForEach(c => cards.Add(c.Number, c));
                list.DataContext       = cards.Values;
                list.ItemsSource       = cards.Values;
                list.SelectedValuePath = "Number";
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                AlertUser(ex);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
        private MurmurViewWindowPane ShowMurmurWindow()
        {
            try
            {
                ToolWindowPane window = Package.FindToolWindow(typeof(MurmurViewWindowPane), 0, true);

                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException(VisualStudio.Resources.CanNotCreateWindow);
                }

                (window as MurmurViewWindowPane).Initialize(Model);

                var frame = (IVsWindowFrame)window.Frame;

                ErrorHandler.ThrowOnFailure(frame.Show());

                return(window as MurmurViewWindowPane);
            }
            catch (Exception e)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, e);
                MessageBox.Show(e.Message);
            }

            return(null);
        }
        /// <summary>
        /// Show the CardView window
        /// </summary>
        /// <param name="cardNumber">for this card number</param>
        private void ShowCardViewToolWindow(int cardNumber)
        {
            try
            {
                var window =
                    (CardViewWindowPane)Package.FindToolWindow(typeof(CardViewWindowPane), 0, true);

                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException(VisualStudio.Resources.CanNotCreateWindow);
                }

                window.Bind(Model.GetOneCard(cardNumber), RefreshMurmurs);

                var windowFrame = (IVsWindowFrame)window.Frame;
                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                MessageBox.Show(ex.Message.Contains("404")
                                    ? string.Format(CultureInfo.CurrentCulture, "{0} {1}",
                                                    VisualStudio.Resources.CardNotFound, card.Text)
                                    : ex.Message);
            }
        }
        /// <summary>
        /// Open a CardView for this card
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dataGrid.CurrentItem == null)
            {
                return;
            }

            try
            {
                var window =
                    (CardViewWindowPane)Package.FindToolWindow(typeof(CardViewWindowPane), 0, true);

                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException(VisualStudio.Resources.CanNotCreateWindow);
                }

                window.Caption = VisualStudio.Resources.CardSetWindowTitle.Replace("%%project%%",
                                                                                   _currentCardCollection.ProjectId);
                //window.Bind(dataGrid.CurrentItem as MingleCard, _currentCardCollection);

                var windowFrame = (IVsWindowFrame)window.Frame;
                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                MessageBox.Show(ex.Message);
            }
        }
        private void UserControlInitialized(object sender, EventArgs e)
        {
            if (!CheckSettings())
            {
                return;
            }

            try
            {
                Model = new ViewModel();
                Model.Initialize(MingleSettings.Host, MingleSettings.Login, MingleSettings.Password);
                Cursor = Cursors.Wait;
                BindProjectList();
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                AlertUser(ex);
                return;
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }

            comboProjects.SelectedValue = Model.ProjectId;
        }
 /// <summary>
 /// Handles double-click events for 'favorite' nodes in the TreeView
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks>
 /// This event handler is dynamically attached to the top-level favorites node
 /// </remarks>
 private void OnFavoritesTreeItemMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         Cursor = Cursors.Wait;
         string       itemValue;
         TreeViewItem item;
         GetTreeItemContainerAndValue(sender as TreeViewItem, out item, out itemValue);
         if (null == item)
         {
             return;
         }
         if (string.IsNullOrEmpty(itemValue))
         {
             return;
         }
         item.Items.Clear();
         item.MouseDoubleClick += OnFavoritesTreeCardDoubleClick;
         foreach (KeyValuePair <string, CardBasicInfo> c in Model.GetCardsForFavorite(itemValue))
         {
             item.Items.Add(c.Value.Formatted);
         }
     }
     catch (Exception ex)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         AlertUser(ex);
     }
     finally
     {
         Cursor = Cursors.Arrow;
     }
 }
Beispiel #10
0
        /// <summary>
        /// Event handler called when the user selects the Explorer View command.
        /// </summary>
        /// <param name="caller"></param>
        /// <param name="args"></param>
        internal void ShowMingleExplorer(object caller, EventArgs args)
        {
            try
            {
                TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Creating the Explorer window pane");
                ToolWindowPane window = FindToolWindow(typeof(ExplorerViewWindowPane), 0, true);

                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException(Resources.CanNotCreateWindow);
                }

                TraceLog.WriteLine(new StackFrame().GetMethod().Name,
                                   "Handing the ViewModel to the ExplorerViewControl window");

                var frame = (IVsWindowFrame)window.Frame;

                ErrorHandler.ThrowOnFailure(frame.Show());
            }
            catch (Exception e)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, e);
                MessageBox.Show(e.Message, Resources.MingleExtensionTitle);
            }
        }
Beispiel #11
0
        private void OnButtonChooseCardClick(object sender, RoutedEventArgs e)
        {
            var    theSender    = sender as Button;
            string propertyName = ((theSender.Tag as TextBox).Tag as CardProperty).Name;

            var w = new CardListWindow(_thisCard.Model, propertyName);

            w.ShowDialog();

            if (w.Cancelled || w.SelectedCardNumber == "0")
            {
                return;
            }

            _thisCard.SetPropertyOrAttributValue(propertyName, w.SelectedCardNumber);

            try
            {
                _thisCard.Update();
                (theSender.Tag as TextBox).Text = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", w.SelectedCardNumber,
                                                                w.SelectedCardName);
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #12
0
        private void OnPropertyComboBoxSelectionChanged(object sender, RoutedEventArgs e)
        {
            if (!sender.GetType().Name.Equals("ComboBox"))
            {
                return;
            }
            string me       = new StackFrame().GetMethod().Name;
            var    cb       = sender as ComboBox;
            var    property = cb.Tag as CardProperty;

            if (property.IsCardValued)
            {
                return;
            }
            _thisCard.AddPropertyFilterToPostData((cb.DataContext as CardProperty).Name, cb.SelectedValue as string);
            try
            {
                if (!string.IsNullOrEmpty(cardName.Text))
                {
                    _thisCard.Update();
                }
                else
                {
                    MessageBox.Show(ThoughtWorksCoreLib.Resources.MingleCardNameNullOrEmpty);
                }
            }
            catch (Exception ex)
            {
                TraceLog.Exception(me, ex);
                MessageBox.Show(ex.Message);
            }

            e.Handled = true;
        }
Beispiel #13
0
        /// <summary>
        /// Get favorites
        /// </summary>
        public MingleFavoriteCollection GetFavorites()
        {
            var me    = new StackFrame().GetMethod().Name;
            var start = DateTime.Now;

            try
            {
                var response = _mingle.Get(ProjectId, "/favorites.xml");
                _favorites = new MingleFavoriteCollection(this);
                _favorites.Parse(response.ToString());
            }
            catch (Exception ex)
            {
                TraceLog.Exception(me, ex);
                throw;
            }

            var stop    = DateTime.Now;
            var elapsed = stop - start;

            TraceLog.WriteLine(new StackFrame().GetMethod().Name,
                               string.Format("Elapsed time binding MingleProject.GetFavorites: {0}",
                                             elapsed.TotalSeconds));
            return(_favorites);
        }
Beispiel #14
0
        /// <summary>
        /// Fired when the Transition button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTransitionButtonClick(object sender, RoutedEventArgs e)
        {
            var b = sender as Button;
            var t = b.DataContext as Transition;

            try
            {
                // First poll for required input


                // POST the transition
                if (t != null && !t.RequireComment)
                {
                    t.Update(_thisCard.Number);
                    Rebind();
                    return;
                }

                var collectComment =
                    new GeneralCommentView(VisualStudio.Resources.TransitionAdmonitionLabel,
                                           VisualStudio.Resources.TransitionCommentRequired,
                                           VisualStudio.Resources.TransitionWindowTitle);

                if (string.IsNullOrEmpty(collectComment.Comment))
                {
                    return;
                }

                // POST the transition
                t.Update(_thisCard.Number);

                // POST the Comment
                string cardComment = string.Format(CultureInfo.InvariantCulture, "comment[content]={0}",
                                                   collectComment.Comment);
                _thisCard.Model.Mingle.Post(MingleSettings.Project, "/cards/" + _thisCard.Number + ".xml",
                                            new Collection <string> {
                    cardComment
                });

                // Murmur the comment?
                string murmur = string.Format(CultureInfo.InvariantCulture, "murmur[body]={0}", collectComment.Comment);
                _thisCard.Model.Mingle.Post(MingleSettings.Project, "/cards/" + _thisCard.Number + ".xml",
                                            new Collection <string> {
                    murmur
                });
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                MessageBox.Show(string.Format(CultureInfo.CurrentCulture, "{0}\n\r\n\r{1} {2}\n\r\n\r{3}",
                                              VisualStudio.Resources.TransitionCannotBeApplied,
                                              VisualStudio.Resources.TransitionEquals, t.Name, ex.Message));
            }
        }
Beispiel #15
0
 /// <summary>
 /// Invoked after the window is intitialized
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnWindowIsInitialized(object sender, EventArgs e)
 {
     try
     {
         _model.CardTypesDictionary.Keys.ToList().ForEach(k => AddCheckBox(k));
     }
     catch (Exception ex)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         AlertUser(ex);
     }
 }
 /// <summary>
 /// Standard constructor for the tool window.
 /// </summary>
 public CardViewWindowPane()
     : base(null)
 {
     try
     {
         base.Content = new CardViewControl();
     }
     catch (Exception e)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, e);
         throw;
     }
 }
 /// <summary>
 /// Called after the ribbon is loaded
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnRibbonLoad(object sender, RibbonUIEventArgs e)
 {
     _mingle = new MingleOffice(this);
     try
     {
         _mingle.LoadProjects();
     }
     catch (Exception ex)
     {
         AlertUser(ex.Message);
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
     }
 }
 private void BindExplorerTrees()
 {
     try
     {
         BindFavorites();
         BindTeamMembers();
     }
     catch (Exception ex)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         throw;
     }
 }
Beispiel #19
0
 private void OnClickButtonMurmur(object sender, RoutedEventArgs e)
 {
     try
     {
         Model.SendMurmur(murmurText.Text);
         murmursList.ItemsSource = Model.Murmurs;
     }
     catch (Exception ex)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #20
0
 /// <summary>
 /// Updates the persisted instance of this Card with properties associated with this object
 /// </summary>
 public void Update()
 {
     try
     {
         RawData = XElement.Parse(_project.Mingle.Put(ProjectId, Url, PostData).Body);
         PostData.Clear();
     }
     catch (Exception ex)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         throw;
     }
 }
 /// <summary>
 /// Standard constructor for the tool window.
 /// </summary>
 public MurmurViewWindowPane()
     : base(null)
 {
     try
     {
         Control      = new MurmurViewControl();
         base.Content = Control;
     }
     catch (Exception e)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, e);
         throw;
     }
 }
 /// <summary>
 /// Store Mingle login credentials and host name in User Settings
 /// </summary>
 /// <param name="loginDetails"></param>
 public void SetMingleLoginDetails(LoginWindow.LoginDetails loginDetails)
 {
     try
     {
         TraceLog.WriteLine(new StackFrame().GetMethod().Name, string.Format(CultureInfo.InstalledUICulture, "host={0}, user={1}", loginDetails.Host, loginDetails.Username));
         _mingleProject.SetLoginDetails(loginDetails.Host, loginDetails.Username, loginDetails.Password);
     }
     catch (Exception ex)
     {
         _ribbon.AlertUser(ex.Message);
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         return;
     }
     _ribbonModel.EnableFetchButton();
 }
        /// <summary>
        /// Refreshes the list of Favorites
        /// </summary>
        public object Parse()
        {
            try
            {
                XElement.Parse(Project.Mingle.Get(ProjectId, "/favorites.xml")).
                Elements("favorite").ToList().ForEach(f => Add(f.Element("name").
                                                               Value, new MingleFavorite(f.ToString(), Project)));
            }
            catch (XmlException ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                throw;
            }

            return(this);
        }
 /// <summary>
 /// Standard constructor for the tool window.
 /// </summary>
 public ExplorerViewWindowPane()
     : base(null)
 {
     try
     {
         BitmapResourceID = 101;
         BitmapIndex      = 0;
         _control         = new ExplorerViewControl();
         base.Content     = _control;
     }
     catch (Exception e)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, e);
         throw;
     }
 }
Beispiel #25
0
        /// <summary>
        /// Load a MingleObjectMember collection from Mingle
        /// </summary>
        public object Parse()
        {
            try
            {
                XElement.Parse(Project.Mingle.Get(ProjectId, "/users.xml")).
                Elements("projects_member").ToList().ForEach(e => Add(e.Element("user").
                                                                      Element("login").Value, new MingleProjectMember(e.ToString())));
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                return(new MingleProjectMemberCollection(Project));
            }

            return(this);
        }
 /// <summary>
 /// Standard constructor for the tool window.
 /// </summary>
 public PipelinePropertiesViewWindowPane()
     : base(null)
 {
     try
     {
         BitmapResourceID = 101;
         BitmapIndex      = 0;
         _control         = new PipelinePropertiesSearchViewControl();
         base.Content     = _control;
     }
     catch (Exception e)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, e);
         throw;
     }
 }
        /// <summary>
        /// Gets the transitions for the url
        /// </summary>
        /// <param name="url">A Mingle url segment of the form /api/v2/projects/...</param>
        private object Parse(string url)
        {
            try
            {
                var response = XElement.Parse(Project.Mingle.Get(ProjectId, url));
                response.Elements("transition").
                ToList().ForEach(t => Add(t.Element("name").Value, new MingleTransition(t.ToString(), Project)));
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                throw;
            }

            return(this);
        }
Beispiel #28
0
        /// <summary>
        /// Calls MingleCard.Update() to update the card with contents of the text box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPropertyTextBoxLostFocus(object sender, RoutedEventArgs e)
        {
            e.Source = _thisCard;
            string me = new StackFrame().GetMethod().Name;

            var tb = sender as TextBox;

            if (tb.Text == tb.Tag as string)
            {
                e.Handled = true;
                return;
            }
            switch (tb.DataContext.GetType().Name)
            {
            case "Card":
                // The name of the field is "cardXXXXXX", so we strip the "card" prefix from the
                // name of the TextBox.
                _thisCard.AddCardAttributeFilterToPostData(
                    tb.Name.Replace("card", string.Empty).ToLowerInvariant(), tb.Text);
                break;

            case "CardProperty":
                // The DataContext of the TextBox is a MinglePropertyDefinition object. So, we
                // take its name and pass it over to AddPropertyPostData.
                _thisCard.AddPropertyFilterToPostData((tb.DataContext as CardProperty).Name, tb.Text);
                break;
            }
            try
            {
                if (!string.IsNullOrEmpty(cardName.Text))
                {
                    _thisCard.Update();
                    descriptionBrowser.Refresh();
                }
                else
                {
                    MessageBox.Show(ThoughtWorksCoreLib.Resources.MingleCardNameNullOrEmpty);
                }
            }
            catch (Exception ex)
            {
                TraceLog.Exception(me, ex);
                MessageBox.Show(ex.Message);
            }

            e.Handled = true;
        }
Beispiel #29
0
        /// <summary>
        /// Fetch a single card
        /// </summary>
        /// <param name="cardNumber">Card Number (not the Card Id)</param>
        public object Parse(int cardNumber)
        {
            try
            {
                TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Loading the ResponseStream");
                var response = Project.Mingle.Get(ProjectId, string.Format(CultureInfo.InvariantCulture, "/cards/{0}.xml", cardNumber));

                Add(new MingleCard(response, Project));

                return(this);
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                throw;
            }
        }
 /// <summary>
 /// Authenticate to Mingle
 /// </summary>
 public void Login()
 {
     try
     {
         _ribbon.AskUserForLoginDetails(LoginDetails,
                                        details =>
         {
             SetMingleLoginDetails(details);
             LoadProjects();
         });
     }
     catch (Exception ex)
     {
         TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
         _ribbon.AlertUser(ex.Message);
     }
 }