From 77a19b5458123219153160e50c677548cfd08d19 Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 29 Oct 2014 13:04:36 +0100 Subject: [PATCH] With JIRA 6.x using the SOAP (Webservice) API the access has gotten really slow, we improved the performance slightly by loading some information parallel. (In Greenshot 2.x we will move to another API.) --- .../additional_files/readme.txt.template | 3 ++ GreenshotJiraPlugin/Jira.cs | 44 +++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Greenshot/releases/additional_files/readme.txt.template b/Greenshot/releases/additional_files/readme.txt.template index 812cc14bd..1adc01650 100644 --- a/Greenshot/releases/additional_files/readme.txt.template +++ b/Greenshot/releases/additional_files/readme.txt.template @@ -11,6 +11,9 @@ Features: * Due to BUG-1667 we had to remove the horizontal text alignment, this afflicts the textbox and the speech bubble. * Added the possibility to select the region to capture by using the keyboard, use the cursor keys to move the cursor (ctrl-key speeds up the movement) and the enter key to mark the start and ending. +Changes: +* JIRA: With JIRA 6.x using the SOAP (Webservice) API the access has gotten really slow, we improved the performance slightly by loading some information parallel. (In Greenshot 2.x we will move to another API.) + Bugs Resolved: * BUG-1667 removed horizontal alignment of textbox in input mode, as it caused problems with textbox focus and could not be implemented consistently anyway (no vertical alignment possible) diff --git a/GreenshotJiraPlugin/Jira.cs b/GreenshotJiraPlugin/Jira.cs index ffdc99d00..7efdee7cb 100644 --- a/GreenshotJiraPlugin/Jira.cs +++ b/GreenshotJiraPlugin/Jira.cs @@ -1,3 +1,4 @@ + /* * Greenshot - a free and open source screenshot tool * Copyright (C) 2007-2014 Thomas Braun, Jens Klingen, Robin Krom @@ -18,14 +19,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Windows.Forms; + using Greenshot.IniFile; using GreenshotJiraPlugin; using GreenshotPlugin.Controls; using GreenshotPlugin.Core; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Windows.Forms; namespace Jira { #region transport classes @@ -309,6 +311,33 @@ namespace Jira { checkCredentials(); try { RemoteIssue[] issues = jira.getIssuesFromFilter(credentials, filterId); + + #region Username cache update + List users = new List(); + foreach (RemoteIssue issue in issues) { + if (issue.reporter != null && !hasUser(issue.reporter) && !users.Contains(issue.reporter)) { + users.Add(issue.reporter); + } + if (issue.assignee != null && !hasUser(issue.assignee) && !users.Contains(issue.assignee)) { + users.Add(issue.assignee); + } + } + int taskCount = users.Count; + if (taskCount > 0) { + ManualResetEvent doneEvent = new ManualResetEvent(false); + for (int i = 0; i < users.Count; i++) { + ThreadPool.QueueUserWorkItem(delegate(object name) { + LOG.InfoFormat("Retrieving {0}", name); + getUserFullName((string)name); + if (Interlocked.Decrement(ref taskCount) == 0) { + doneEvent.Set(); + } + }, users[i]); + } + doneEvent.WaitOne(); + } + #endregion + foreach (RemoteIssue issue in issues) { try { JiraIssue jiraIssue = new JiraIssue(issue.key, issue.created, getUserFullName(issue.reporter), getUserFullName(issue.assignee), issue.project, issue.summary, issue.description, "", issue.attachmentNames); @@ -354,6 +383,13 @@ namespace Jira { jira.addComment(credentials, issueKey, comment); } + private bool hasUser(string user) { + if (user != null) { + return userCache.Contains(user); + } + return false; + } + private string getUserFullName(string user) { string fullname = null; if (user != null) {