Ejemplo n.º 1
0
        private void addComment(JiraIssue issue)
        {
            SmartJiraServerFacade facade = SmartJiraServerFacade.Instance;
            NewIssueComment       dlg    = new NewIssueComment(issue, facade);

            dlg.ShowDialog();
            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            Thread addCommentThread =
                PlvsUtils.createThread(delegate {
                try {
                    jiraStatus.setInfo("Adding comment to issue...");
                    facade.addComment(issue, dlg.CommentBody);
                    issue = facade.getIssue(issue.Server, issue.Key);
                    jiraStatus.setInfo("Comment added");
                    UsageCollector.Instance.bumpJiraIssuesOpen();
                    container.safeInvoke(new MethodInvoker(() => JiraIssueListModelImpl.Instance.updateIssue(issue)));
                } catch (Exception ex) {
                    jiraStatus.setError("Adding comment failed", ex);
                }
            });

            addCommentThread.Start();
        }
Ejemplo n.º 2
0
        private void addIssueActionItems()
        {
            List <JiraNamedEntity> actions = null;

            try
            {
                actions = JiraServerFacade.Instance.getActionsForIssue(issue);
            }
            catch (Exception e)
            {
                status.setError("Failed to retrieve issue actions", e);
            }
            if (actions == null || actions.Count == 0)
            {
                return;
            }

            Invoke(new MethodInvoker(delegate
            {
                Items.Add(new ToolStripSeparator());
                foreach (var action in actions)
                {
                    var actionCopy         = action;
                    ToolStripMenuItem item = new ToolStripMenuItem(
                        action.Name, null, new EventHandler(delegate { runAction(actionCopy); }));
                    Items.Add(item);
                }
            }));
        }
 private void getBuildDetailsRunner()
 {
     try {
         buildWithDetails = BambooServerFacade.Instance.getBuildByKey(build.Server, build.Key);
         buildArtifacts   = BambooServerFacade.Instance.getArtifacts(build);
     } catch (Exception e) {
         status.setError("Failed to retrieve build details", e);
         unableToRetrieveDetails = true;
     }
     this.safeInvoke(new MethodInvoker(displaySummary));
     runGetTestsThread();
 }
 private void logWorkWorker(Action action, Action finished, bool closeDialogOnFinish)
 {
     try {
         status.setInfo("Logging work for issue " + issue.Key + "...");
         action();
         status.setInfo("Logged work for issue " + issue.Key);
         UsageCollector.Instance.bumpJiraIssuesOpen();
         JiraIssue updatedIssue = facade.getIssue(issue.Server, issue.Key);
         parent.safeInvoke(new MethodInvoker(() => {
             model.updateIssue(updatedIssue);
             if (activeIssueManager.isActive(issue))
             {
                 activeIssueManager.resetTimeSpent();
             }
         }));
     } catch (Exception e) {
         status.setError("Failed to log work for issue " + issue.Key, e);
     }
     parent.safeInvoke(new MethodInvoker(() => {
         if (closeDialogOnFinish)
         {
             Close();
         }
         if (finished != null)
         {
             finished();
         }
     }));
 }
Ejemplo n.º 5
0
 private void loadComponents(AbstractJiraServerFacade facade, StatusLabel status)
 {
     try {
         List <JiraNamedEntity> components = facade.getComponents(Server, project);
         parent.Invoke(new MethodInvoker(() => populateComponents(components)));
     } catch (Exception e) {
         status.setError("Unable to retrieve component list", e);
     }
 }
 private void loadProjects(StatusLabel status)
 {
     try {
         List <JiraProject> projects = Facade.getProjects(Server);
         parent.Invoke(new MethodInvoker(() => populateProjects(projects)));
     } catch (Exception e) {
         status.setError("Failed to retrieve projects", e);
     }
 }
Ejemplo n.º 7
0
 private void loadPriorities(AbstractJiraServerFacade facade, StatusLabel status)
 {
     try {
         List <JiraNamedEntity> priorities = facade.getPriorities(Server);
         parent.Invoke(new MethodInvoker(() => populatePriorities(priorities)));
     } catch (Exception e) {
         status.setError("Unable to retrieve priorities", e);
     }
 }
Ejemplo n.º 8
0
        private void runRefreshThread()
        {
            Thread worker = new Thread(new ThreadStart(delegate
            {
                try
                {
                    status.setInfo("Retrieving issue details...");
                    issue = facade.getIssue(issue.Server, issue.Key);
                    status.setInfo("Issue details retrieved");
                }
                catch (Exception e)
                {
                    status.setError("Failed to retrieve issue details", e);
                }
                rebuildAllPanels(true);
            }));

            worker.Start();
        }
Ejemplo n.º 9
0
        private void addIssueActionItems(int generation)
        {
            List <JiraNamedEntity> actions = null;

            if (!issue.IsSubtask && issue.Server.BuildNumber > 0)
            {
                this.safeInvoke(new MethodInvoker(delegate {
                    if (generation != menuOpenGeneration)
                    {
                        return;
                    }
                    Items.Add(new ToolStripSeparator());
                    Items.Add(new ToolStripMenuItem("Add Subtask", Resources.add_jira, new EventHandler(
                                                        delegate {
                        CreateIssue.createDialogOrBringToFront(issue.Server, issue);
                    }
                                                        )));
                }));
            }
            try {
                actions = SmartJiraServerFacade.Instance.getActionsForIssue(issue);
            } catch (Exception e) {
                status.setError("Failed to retrieve issue actions", e);
            }
            if (actions == null || actions.Count == 0)
            {
                return;
            }

            this.safeInvoke(new MethodInvoker(delegate {
                // PLVS-39 - only update current menu, skip results of previous getActionsForIssue()
                // in case the user quickly opens context menu more than once
                if (generation != menuOpenGeneration)
                {
                    return;
                }

                Items.Add(new ToolStripSeparator());
                foreach (var action in actions)
                {
                    var actionCopy         = action;
                    ToolStripMenuItem item = new ToolStripMenuItem(
                        action.Name, null,
                        new EventHandler(
                            delegate {
                        IssueActionRunner.runAction(this, actionCopy, model, issue, status, null);
                    }));
                    Items.Add(item);
                }
            }));
        }
Ejemplo n.º 10
0
        public static void runAction(Control owner, JiraNamedEntity action, JiraIssueListModel model, JiraIssue issue, StatusLabel status, Action onFinish)
        {
            Thread runner = PlvsUtils.createThread(delegate {
                try {
                    status.setInfo("Retrieving fields for action \"" + action.Name + "\"...");
                    List <JiraField> fields = SmartJiraServerFacade.Instance.getFieldsForAction(issue, action.Id);
                    runAction(owner, action, model, issue, fields, status, onFinish);
                } catch (Exception e) {
                    status.setError("Failed to run action " + action.Name + " on issue " + issue.Key, e);
                }
            });

            runner.Start();
        }
Ejemplo n.º 11
0
 private void getHistoryWorker(BambooBuild build, int myGeneration)
 {
     try {
         ICollection <BambooBuild> builds =
             BambooServerFacade.Instance.getLastNBuildsForPlan(build.Server, BambooBuildUtils.getPlanKey(build), MAX_HISTORY);
         this.safeInvoke(new MethodInvoker(delegate {
             if (myGeneration != generation)
             {
                 return;
             }
             fillHistory(builds);
         }));
     } catch (Exception e) {
         statusLabel.setError("Unable to retrieve build history", e);
     }
 }
Ejemplo n.º 12
0
        private void findBuildWorker(IEnumerable <BambooServer> servers, string buildKey)
        {
            List <BambooBuild> foundBuilds = new List <BambooBuild>();
            List <Exception>   errors      = new List <Exception>();

            foreach (BambooServer server in servers)
            {
                try {
                    status.setInfo("Searching for build " + buildKey + " on server \"" + server.Name + "\"");
                    BambooBuild build = BambooServerFacade.Instance.getBuildByKey(server, buildKey);
                    foundBuilds.Add(build);
                } catch (Exception e) {
                    errors.Add(e);
                }
            }
            this.safeInvoke(new MethodInvoker(delegate {
                if (foundBuilds.Count > 0)
                {
                    status.setInfo("");
                    foreach (BambooBuild build in foundBuilds)
                    {
                        BuildDetailsWindow.Instance.openBuild(build);
                    }
                }
                else if (errors.Count > 0)
                {
                    PlvsUtils.showErrors("Build key " + buildKey + " not found", errors);
                    status.setError("Build key " + buildKey + " not found", errors);
                }
                else if (foundBuilds.Count == 0)
                {
                    PlvsUtils.showError("Build key " + buildKey + " not found", null);
                    status.setInfo("Build key " + buildKey + " not found");
                }
                DialogResult = DialogResult.OK;
                Close();
            }));
        }
        private void showPollResults(ICollection <BambooBuild> builds, ICollection <Exception> exceptions)
        {
            if (buildTree == null)
            {
                return;
            }

            if (builds == null && exceptions == null)
            {
                BambooBuildListModelImpl.Instance.clear(true);
                buildHistoryTable.showHistoryForBuild(null);
                status.setInfo("No builds to poll found");
                return;
            }

            BambooBuildListModelImpl.Instance.clear(false);
            BambooBuildListModelImpl.Instance.addBuilds(builds);

            buildTree.restoreExpandCollapseStates();

            var buildNode = getSelectedBuildNode();

            buildHistoryTable.showHistoryForBuild(buildNode != null ? buildNode.Build : null);

            var haveExceptions = exceptions != null && exceptions.Count > 0;

            if (haveExceptions)
            {
                status.setError("Failed to poll some of the servers", exceptions);
            }
            else
            {
                lastPollTime = DateTime.Now;
                showPollTimeInfo();
            }
            bool?allpassing = null;

            if (builds != null)
            {
                allpassing = true;
                foreach (var b in builds.Where(b => allpassing.Value && b.Result != BambooBuild.BuildResult.SUCCESSFUL))
                {
                    allpassing = false;
                }
            }
            bool allOk = allpassing != null && allpassing.Value;

            if (summaryStatusOk != null && summaryStatusOk == allOk)
            {
                return;
            }

            notifyBuildStatus.Icon = allpassing != null
                                         ? (allOk && !haveExceptions ? Resources.bamboo_green_161 : Resources.bamboo_red_161)
                                         : Resources.bamboo_grey_161;
            notifyBuildStatus.BalloonTipText = allOk && !haveExceptions
                                                   ? "All builds are passing"
                                                   : (haveExceptions
                                                        ? "Failed to retrieve build information from some of the servers"
                                                        : "Some of the monitored builds failed");
            notifyBuildStatus.Text           = notifyBuildStatus.BalloonTipText;
            notifyBuildStatus.BalloonTipIcon = allOk ? ToolTipIcon.Info : ToolTipIcon.Warning;
            notifyBuildStatus.ShowBalloonTip(30000);
            summaryStatusOk = allOk;
        }
Ejemplo n.º 14
0
        private void reloadKnownJiraServers()
        {
            filtersTree.Nodes.Clear();
            model.clear(true);

            getMoreIssues.Visible = false;

            // copy to local list so that we can reuse in our threads
            List <JiraServer> servers = new List <JiraServer>(JiraServerModel.Instance.getAllServers());

            if (servers.Count == 0)
            {
                status.setInfo("No JIRA servers defined");
                return;
            }

            foreach (JiraServer server in servers)
            {
                filtersTree.Nodes.Add(new JiraServerTreeNode(server, 0));
            }

            Thread metadataThread = new Thread(new ThreadStart(delegate
            {
                try
                {
                    foreach (JiraServer server in servers)
                    {
                        status.setInfo("[" + server.Name + "] Loading project definitions...");
                        List <JiraProject> projects = facade.getProjects(server);
                        JiraServerCache.Instance.clearProjects();
                        foreach (JiraProject proj in projects)
                        {
                            JiraServerCache.Instance.addProject(server, proj);
                        }
                        status.setInfo("[" + server.Name + "] Loading issue types...");
                        List <JiraNamedEntity> issueTypes = facade.getIssueTypes(server);
                        JiraServerCache.Instance.clearIssueTypes();
                        foreach (JiraNamedEntity type in issueTypes)
                        {
                            JiraServerCache.Instance.addIssueType(server, type);
                            ImageCache.Instance.getImage(type.IconUrl);
                        }
                        status.setInfo("[" + server.Name + "] Loading issue priorities...");
                        List <JiraNamedEntity> priorities = facade.getPriorities(server);
                        JiraServerCache.Instance.clearPriorities();
                        foreach (JiraNamedEntity prio in priorities)
                        {
                            JiraServerCache.Instance.addPriority(server, prio);
                            ImageCache.Instance.getImage(prio.IconUrl);
                        }
                        status.setInfo("[" + server.Name + "] Loading issue statuses...");
                        List <JiraNamedEntity> statuses = facade.getStatuses(server);
                        JiraServerCache.Instance.clearStatuses();
                        foreach (JiraNamedEntity s in statuses)
                        {
                            JiraServerCache.Instance.addStatus(server, s);
                            ImageCache.Instance.getImage(s.IconUrl);
                        }

                        status.setInfo("[" + server.Name + "] Loading saved filters...");
                        List <JiraSavedFilter> filters = facade.getSavedFilters(server);
                        JiraServer jiraServer          = server;
                        Invoke(new MethodInvoker(delegate
                        {
                            fillSavedFiltersForServer(jiraServer, filters);
                            status.setInfo("Loaded saved filters for server " +
                                           jiraServer.Name);
                            addCustomFilterNodes(jiraServer);
                        }));
                    }
                    Invoke(new MethodInvoker(delegate
                    {
                        filtersTree.Nodes.Add(new RecentlyOpenIssuesTreeNode(3));
                        filtersTree.ExpandAll();
                    }));
                }
                catch (Exception e)
                {
                    status.setError("Failed to load server metadata", e);
                }
            }));

            metadataThread.Start();
        }