mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Modifications for the JIRA code needed to upgrade the package. [skip ci]
This commit is contained in:
parent
e7e1d768b9
commit
69deb19b1f
4 changed files with 31 additions and 31 deletions
|
@ -34,12 +34,12 @@
|
|||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
<ItemGroup>
|
||||
<Reference Include="Dapplo.HttpExtensions, Version=0.6.8.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapplo.HttpExtensions.0.6.8\lib\net45\Dapplo.HttpExtensions.dll</HintPath>
|
||||
<Reference Include="Dapplo.HttpExtensions, Version=0.6.10.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapplo.HttpExtensions.0.6.10\lib\net45\Dapplo.HttpExtensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Dapplo.Jira, Version=0.3.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapplo.Jira.0.3.1\lib\net45\Dapplo.Jira.dll</HintPath>
|
||||
<Reference Include="Dapplo.Jira, Version=0.3.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapplo.Jira.0.3.4\lib\net45\Dapplo.Jira.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Dapplo.Log, Version=1.0.22.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// Internal login which catches the exceptions
|
||||
/// </summary>
|
||||
/// <returns>true if login was done sucessfully</returns>
|
||||
private async Task<bool> DoLoginAsync(string user, string password)
|
||||
private async Task<bool> DoLoginAsync(string user, string password, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
|
@ -110,14 +110,14 @@ namespace GreenshotJiraPlugin {
|
|||
LoginInfo loginInfo;
|
||||
try
|
||||
{
|
||||
loginInfo = await _jiraApi.StartSessionAsync(user, password);
|
||||
loginInfo = await _jiraApi.Session.StartAsync(user, password, cancellationToken);
|
||||
Monitor = new JiraMonitor();
|
||||
await Monitor.AddJiraInstanceAsync(_jiraApi);
|
||||
await Monitor.AddJiraInstanceAsync(_jiraApi, cancellationToken);
|
||||
|
||||
var favIconUri = _jiraApi.JiraBaseUri.AppendSegments("favicon.ico");
|
||||
try
|
||||
{
|
||||
FavIcon = await _jiraApi.GetUriContentAsync<Bitmap>(favIconUri);
|
||||
FavIcon = await _jiraApi.GetUriContentAsync<Bitmap>(favIconUri, cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -137,8 +137,8 @@ namespace GreenshotJiraPlugin {
|
|||
/// If there are credentials, call the real login.
|
||||
/// </summary>
|
||||
/// <returns>Task</returns>
|
||||
public async Task LoginAsync() {
|
||||
await LogoutAsync();
|
||||
public async Task LoginAsync(CancellationToken cancellationToken = default(CancellationToken)) {
|
||||
await LogoutAsync(cancellationToken);
|
||||
try {
|
||||
// Get the system name, so the user knows where to login to
|
||||
var credentialsDialog = new CredentialsDialog(JiraConfig.Url)
|
||||
|
@ -146,7 +146,7 @@ namespace GreenshotJiraPlugin {
|
|||
Name = null
|
||||
};
|
||||
while (credentialsDialog.Show(credentialsDialog.Name) == DialogResult.OK) {
|
||||
if (await DoLoginAsync(credentialsDialog.Name, credentialsDialog.Password)) {
|
||||
if (await DoLoginAsync(credentialsDialog.Name, credentialsDialog.Password, cancellationToken)) {
|
||||
if (credentialsDialog.SaveChecked) {
|
||||
credentialsDialog.Confirm(true);
|
||||
}
|
||||
|
@ -176,11 +176,11 @@ namespace GreenshotJiraPlugin {
|
|||
/// <summary>
|
||||
/// End the session, if there was one
|
||||
/// </summary>
|
||||
public async Task LogoutAsync() {
|
||||
public async Task LogoutAsync(CancellationToken cancellationToken = default(CancellationToken)) {
|
||||
if (_jiraApi != null && _loggedIn)
|
||||
{
|
||||
Monitor.Dispose();
|
||||
await _jiraApi.EndSessionAsync();
|
||||
await _jiraApi.Session.EndAsync(cancellationToken);
|
||||
_loggedIn = false;
|
||||
}
|
||||
}
|
||||
|
@ -190,14 +190,14 @@ namespace GreenshotJiraPlugin {
|
|||
/// Do not use ConfigureAwait to call this, as it will move await from the UI thread.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task CheckCredentialsAsync() {
|
||||
private async Task CheckCredentialsAsync(CancellationToken cancellationToken = default(CancellationToken)) {
|
||||
if (_loggedIn) {
|
||||
if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
await LogoutAsync();
|
||||
await LoginAsync();
|
||||
await LogoutAsync(cancellationToken);
|
||||
await LoginAsync(cancellationToken);
|
||||
}
|
||||
} else {
|
||||
await LoginAsync();
|
||||
await LoginAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,23 +205,24 @@ namespace GreenshotJiraPlugin {
|
|||
/// Get the favourite filters
|
||||
/// </summary>
|
||||
/// <returns>List with filters</returns>
|
||||
public async Task<IList<Filter>> GetFavoriteFiltersAsync()
|
||||
public async Task<IList<Filter>> GetFavoriteFiltersAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync();
|
||||
return await _jiraApi.GetFavoriteFiltersAsync().ConfigureAwait(false);
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
return await _jiraApi.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the issue for a key
|
||||
/// </summary>
|
||||
/// <param name="issueKey">Jira issue key</param>
|
||||
/// <param name="cancellationToken">CancellationToken</param>
|
||||
/// <returns>Issue</returns>
|
||||
public async Task<Issue> GetIssueAsync(string issueKey)
|
||||
public async Task<Issue> GetIssueAsync(string issueKey, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync();
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
return await _jiraApi.Issue.GetAsync(issueKey).ConfigureAwait(false);
|
||||
return await _jiraApi.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -238,7 +239,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// <returns></returns>
|
||||
public async Task AttachAsync(string issueKey, IBinaryContainer content, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync();
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
content.WriteToStream(memoryStream);
|
||||
|
@ -256,7 +257,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// <param name="cancellationToken">CancellationToken</param>
|
||||
public async Task AddCommentAsync(string issueKey, string body, string visibility = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync();
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
await _jiraApi.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
@ -268,7 +269,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// <returns></returns>
|
||||
public async Task<IList<Issue>> SearchAsync(Filter filter, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
await CheckCredentialsAsync();
|
||||
await CheckCredentialsAsync(cancellationToken);
|
||||
var searchResult = await _jiraApi.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false);
|
||||
return searchResult.Issues;
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace GreenshotJiraPlugin
|
|||
public async Task AddJiraInstanceAsync(JiraApi jiraInstance, CancellationToken token = default(CancellationToken))
|
||||
{
|
||||
_jiraInstances.Add(jiraInstance);
|
||||
var projects = await jiraInstance.GetProjectsAsync(token).ConfigureAwait(false);
|
||||
var projects = await jiraInstance.Project.GetAllAsync(cancellationToken: token).ConfigureAwait(false);
|
||||
if (projects != null)
|
||||
{
|
||||
foreach (var project in projects)
|
||||
|
@ -208,8 +208,7 @@ namespace GreenshotJiraPlugin
|
|||
if (_recentJiras.Count > _maxEntries)
|
||||
{
|
||||
// Add it to the list of recent Jiras
|
||||
IList<JiraDetails> clonedList = new List<JiraDetails>(_recentJiras.Values);
|
||||
_recentJiras = (from jiraDetails in clonedList
|
||||
_recentJiras = (from jiraDetails in _recentJiras.Values.ToList()
|
||||
orderby jiraDetails.SeenAt descending
|
||||
select jiraDetails).Take(_maxEntries).ToDictionary(jd => jd.JiraKey, jd => jd);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Dapplo.HttpExtensions" version="0.6.8" targetFramework="net45" />
|
||||
<package id="Dapplo.Jira" version="0.3.1" targetFramework="net45" />
|
||||
<package id="Dapplo.HttpExtensions" version="0.6.10" targetFramework="net45" />
|
||||
<package id="Dapplo.Jira" version="0.3.4" targetFramework="net45" />
|
||||
<package id="Dapplo.Log" version="1.0.22" targetFramework="net45" />
|
||||
<package id="LibZ.Tool" version="1.2.0.0" targetFramework="net45" />
|
||||
<package id="Svg" version="2.3.0" targetFramework="net45" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue