mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Updated the jira code, in the hope to solve BUG-2122
This commit is contained in:
parent
5bdfcd5306
commit
e08985fd6f
5 changed files with 45 additions and 45 deletions
|
@ -37,7 +37,7 @@ using GreenshotPlugin.Core;
|
|||
|
||||
namespace GreenshotJiraPlugin {
|
||||
/// <summary>
|
||||
/// This encapsulates the JiraApi to make it possible to change as less old Greenshot code as needed
|
||||
/// This encapsulates the JiraClient to make it possible to change as less old Greenshot code as needed
|
||||
/// </summary>
|
||||
public class JiraConnector : IDisposable {
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraConnector));
|
||||
|
@ -48,7 +48,7 @@ namespace GreenshotJiraPlugin {
|
|||
private DateTimeOffset _loggedInTime = DateTimeOffset.MinValue;
|
||||
private bool _loggedIn;
|
||||
private readonly int _timeout;
|
||||
private JiraApi _jiraApi;
|
||||
private IJiraClient _jiraClient;
|
||||
private IssueTypeBitmapCache _issueTypeBitmapCache;
|
||||
|
||||
/// <summary>
|
||||
|
@ -60,7 +60,7 @@ namespace GreenshotJiraPlugin {
|
|||
{
|
||||
if (args.PropertyName == nameof(CoreConfig.IconSize))
|
||||
{
|
||||
JiraPlugin.Instance.JiraConnector._jiraApi?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height });
|
||||
JiraPlugin.Instance.JiraConnector._jiraClient?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// Dispose, logout the users
|
||||
/// </summary>
|
||||
public void Dispose() {
|
||||
if (_jiraApi != null)
|
||||
if (_jiraClient != null)
|
||||
{
|
||||
Task.Run(async () => await LogoutAsync()).Wait();
|
||||
}
|
||||
|
@ -103,21 +103,21 @@ namespace GreenshotJiraPlugin {
|
|||
{
|
||||
return false;
|
||||
}
|
||||
_jiraApi = new JiraApi(new Uri(JiraConfig.Url));
|
||||
_jiraApi.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height });
|
||||
_jiraClient = JiraClient.Create(new Uri(JiraConfig.Url));
|
||||
_jiraClient.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height });
|
||||
|
||||
_issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraApi);
|
||||
_issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraClient);
|
||||
LoginInfo loginInfo;
|
||||
try
|
||||
{
|
||||
loginInfo = await _jiraApi.Session.StartAsync(user, password, cancellationToken);
|
||||
loginInfo = await _jiraClient.Session.StartAsync(user, password, cancellationToken);
|
||||
Monitor = new JiraMonitor();
|
||||
await Monitor.AddJiraInstanceAsync(_jiraApi, cancellationToken);
|
||||
await Monitor.AddJiraInstanceAsync(_jiraClient, cancellationToken);
|
||||
|
||||
var favIconUri = _jiraApi.JiraBaseUri.AppendSegments("favicon.ico");
|
||||
var favIconUri = _jiraClient.JiraBaseUri.AppendSegments("favicon.ico");
|
||||
try
|
||||
{
|
||||
FavIcon = await _jiraApi.GetUriContentAsync<Bitmap>(favIconUri, cancellationToken);
|
||||
FavIcon = await _jiraClient.Server.GetUriContentAsync<Bitmap>(favIconUri, cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -177,10 +177,10 @@ namespace GreenshotJiraPlugin {
|
|||
/// End the session, if there was one
|
||||
/// </summary>
|
||||
public async Task LogoutAsync(CancellationToken cancellationToken = default(CancellationToken)) {
|
||||
if (_jiraApi != null && _loggedIn)
|
||||
if (_jiraClient != null && _loggedIn)
|
||||
{
|
||||
Monitor.Dispose();
|
||||
await _jiraApi.Session.EndAsync(cancellationToken);
|
||||
await _jiraClient.Session.EndAsync(cancellationToken);
|
||||
_loggedIn = false;
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ namespace GreenshotJiraPlugin {
|
|||
public async Task<IList<Filter>> GetFavoriteFiltersAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
return await _jiraApi.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false);
|
||||
return await _jiraClient.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -222,7 +222,7 @@ namespace GreenshotJiraPlugin {
|
|||
await CheckCredentialsAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
return await _jiraApi.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false);
|
||||
return await _jiraClient.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -244,7 +244,7 @@ namespace GreenshotJiraPlugin {
|
|||
{
|
||||
content.WriteToStream(memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
await _jiraApi.Attachment.AttachAsync(issueKey, memoryStream, content.Filename, content.ContentType, cancellationToken).ConfigureAwait(false);
|
||||
await _jiraClient.Attachment.AttachAsync(issueKey, memoryStream, content.Filename, content.ContentType, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ namespace GreenshotJiraPlugin {
|
|||
public async Task AddCommentAsync(string issueKey, string body, string visibility = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
await _jiraApi.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false);
|
||||
await _jiraClient.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -270,7 +270,7 @@ namespace GreenshotJiraPlugin {
|
|||
public async Task<IList<Issue>> SearchAsync(Filter filter, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
var searchResult = await _jiraApi.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false);
|
||||
var searchResult = await _jiraClient.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false);
|
||||
return searchResult.Issues;
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// <summary>
|
||||
/// Get the base uri
|
||||
/// </summary>
|
||||
public Uri JiraBaseUri => _jiraApi.JiraBaseUri;
|
||||
public Uri JiraBaseUri => _jiraClient.JiraBaseUri;
|
||||
|
||||
/// <summary>
|
||||
/// Is the user "logged in?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue