Example #1
0
        public void ReportBug(BugException ex)
        {
            if (!this.active)
            {
                return;
            }

            try
            {
                var fulltext = new ApplicationEditorSearchConstraint("query", ex.Title);
                var statuses = ManiphestSearchConstraintFactory.Statuses(new List <string> {
                    "open", "stalled"
                });

                var maniphestTasks = this.maniphest.Search(constraints: new[] { fulltext, statuses });

                var fod = maniphestTasks.FirstOrDefault(x => x.Title == ex.Title);
                if (fod == null)
                {
                    fod = new ManiphestTask
                    {
                        Title       = ex.Title,
                        Description = ex.Description,
                        Priority    = "normal",
                        Points      = 1
                    };
                    fod.AddProjects(this.projectPhid);
                }
                else
                {
                    fod.AddComment(ex.Description);
                    fod.Points = fod.Points.GetValueOrDefault(0) + 1;
                }

                this.maniphest.Edit(fod);
            }
            catch (Exception ex2)
            {
                this.logger.Warn("Exception while logging bug", ex2);
                this.logger.Error("Exception encountered while logging bug; including here for reference", ex);
            }
        }
Example #2
0
        public XmlElement PopulateFromExternalSource(ExternalNode node)
        {
            if (!this.active)
            {
                throw new InvalidOperationException(
                          "Cannot retrieve external resources from Phabricator as this is not configured.");
            }

            string location = node.Location;

            if (node.Location.StartsWith("P"))
            {
                location = node.Location.Substring(1);
            }

            var document = new XmlDocument();

            try
            {
                var pasteId = new ApplicationEditorSearchConstraint("ids", new List <int> {
                    int.Parse(location)
                });
                var pasteItems = this.paste.Search(constraints: new[] { pasteId }, attachments: new[] { "content" });

                var pasteItem = pasteItems.First();

                document.LoadXml(pasteItem.Text);
                node.Comment = pasteItem.Title;

                return(document.DocumentElement);
            }
            catch (WebException ex)
            {
                this.logger.ErrorFormat(ex, "Exception encountered while trying to retrieve remote stalk configuration");

                document.LoadXml("<false />");
                node.Comment = "Error loading fragment from remote source.";

                return(document.DocumentElement);
            }
        }
Example #3
0
        public XmlElement GetFragmentFromSource(string location)
        {
            if (!this.active)
            {
                throw new InvalidOperationException(
                          "Cannot retrieve external resources from Phabricator as this is not configured.");
            }

            if (location.StartsWith("P"))
            {
                location = location.Substring(1);
            }

            var pasteId = new ApplicationEditorSearchConstraint("ids", new List <int> {
                int.Parse(location)
            });
            var pasteItems = this.paste.Search(constraints: new[] { pasteId }, attachments: new[] { "content" });

            var document = new XmlDocument();

            document.LoadXml(pasteItems.First().Text);
            return(document.DocumentElement);
        }