Modifications for the JIRA code needed to upgrade the package. [skip ci]

This commit is contained in:
Robin 2017-01-20 11:13:19 +01:00
commit 69deb19b1f
4 changed files with 31 additions and 31 deletions

View file

@ -34,12 +34,12 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<Reference Include="Dapplo.HttpExtensions, Version=0.6.8.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapplo.HttpExtensions, Version=0.6.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.HttpExtensions.0.6.8\lib\net45\Dapplo.HttpExtensions.dll</HintPath> <HintPath>..\packages\Dapplo.HttpExtensions.0.6.10\lib\net45\Dapplo.HttpExtensions.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Dapplo.Jira, Version=0.3.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapplo.Jira, Version=0.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.Jira.0.3.1\lib\net45\Dapplo.Jira.dll</HintPath> <HintPath>..\packages\Dapplo.Jira.0.3.4\lib\net45\Dapplo.Jira.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Dapplo.Log, Version=1.0.22.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapplo.Log, Version=1.0.22.0, Culture=neutral, processorArchitecture=MSIL">

View file

@ -97,7 +97,7 @@ namespace GreenshotJiraPlugin {
/// Internal login which catches the exceptions /// Internal login which catches the exceptions
/// </summary> /// </summary>
/// <returns>true if login was done sucessfully</returns> /// <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)) if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password))
{ {
@ -110,14 +110,14 @@ namespace GreenshotJiraPlugin {
LoginInfo loginInfo; LoginInfo loginInfo;
try try
{ {
loginInfo = await _jiraApi.StartSessionAsync(user, password); loginInfo = await _jiraApi.Session.StartAsync(user, password, cancellationToken);
Monitor = new JiraMonitor(); Monitor = new JiraMonitor();
await Monitor.AddJiraInstanceAsync(_jiraApi); await Monitor.AddJiraInstanceAsync(_jiraApi, cancellationToken);
var favIconUri = _jiraApi.JiraBaseUri.AppendSegments("favicon.ico"); var favIconUri = _jiraApi.JiraBaseUri.AppendSegments("favicon.ico");
try try
{ {
FavIcon = await _jiraApi.GetUriContentAsync<Bitmap>(favIconUri); FavIcon = await _jiraApi.GetUriContentAsync<Bitmap>(favIconUri, cancellationToken);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -137,8 +137,8 @@ namespace GreenshotJiraPlugin {
/// If there are credentials, call the real login. /// If there are credentials, call the real login.
/// </summary> /// </summary>
/// <returns>Task</returns> /// <returns>Task</returns>
public async Task LoginAsync() { public async Task LoginAsync(CancellationToken cancellationToken = default(CancellationToken)) {
await LogoutAsync(); await LogoutAsync(cancellationToken);
try { try {
// Get the system name, so the user knows where to login to // Get the system name, so the user knows where to login to
var credentialsDialog = new CredentialsDialog(JiraConfig.Url) var credentialsDialog = new CredentialsDialog(JiraConfig.Url)
@ -146,7 +146,7 @@ namespace GreenshotJiraPlugin {
Name = null Name = null
}; };
while (credentialsDialog.Show(credentialsDialog.Name) == DialogResult.OK) { 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) { if (credentialsDialog.SaveChecked) {
credentialsDialog.Confirm(true); credentialsDialog.Confirm(true);
} }
@ -176,11 +176,11 @@ namespace GreenshotJiraPlugin {
/// <summary> /// <summary>
/// End the session, if there was one /// End the session, if there was one
/// </summary> /// </summary>
public async Task LogoutAsync() { public async Task LogoutAsync(CancellationToken cancellationToken = default(CancellationToken)) {
if (_jiraApi != null && _loggedIn) if (_jiraApi != null && _loggedIn)
{ {
Monitor.Dispose(); Monitor.Dispose();
await _jiraApi.EndSessionAsync(); await _jiraApi.Session.EndAsync(cancellationToken);
_loggedIn = false; _loggedIn = false;
} }
} }
@ -190,14 +190,14 @@ namespace GreenshotJiraPlugin {
/// Do not use ConfigureAwait to call this, as it will move await from the UI thread. /// Do not use ConfigureAwait to call this, as it will move await from the UI thread.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private async Task CheckCredentialsAsync() { private async Task CheckCredentialsAsync(CancellationToken cancellationToken = default(CancellationToken)) {
if (_loggedIn) { if (_loggedIn) {
if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) { if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) {
await LogoutAsync(); await LogoutAsync(cancellationToken);
await LoginAsync(); await LoginAsync(cancellationToken);
} }
} else { } else {
await LoginAsync(); await LoginAsync(cancellationToken);
} }
} }
@ -205,23 +205,24 @@ namespace GreenshotJiraPlugin {
/// Get the favourite filters /// Get the favourite filters
/// </summary> /// </summary>
/// <returns>List with filters</returns> /// <returns>List with filters</returns>
public async Task<IList<Filter>> GetFavoriteFiltersAsync() public async Task<IList<Filter>> GetFavoriteFiltersAsync(CancellationToken cancellationToken = default(CancellationToken))
{ {
await CheckCredentialsAsync(); await CheckCredentialsAsync(cancellationToken);
return await _jiraApi.GetFavoriteFiltersAsync().ConfigureAwait(false); return await _jiraApi.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false);
} }
/// <summary> /// <summary>
/// Get the issue for a key /// Get the issue for a key
/// </summary> /// </summary>
/// <param name="issueKey">Jira issue key</param> /// <param name="issueKey">Jira issue key</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>Issue</returns> /// <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 try
{ {
return await _jiraApi.Issue.GetAsync(issueKey).ConfigureAwait(false); return await _jiraApi.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false);
} }
catch catch
{ {
@ -238,7 +239,7 @@ namespace GreenshotJiraPlugin {
/// <returns></returns> /// <returns></returns>
public async Task AttachAsync(string issueKey, IBinaryContainer content, CancellationToken cancellationToken = default(CancellationToken)) public async Task AttachAsync(string issueKey, IBinaryContainer content, CancellationToken cancellationToken = default(CancellationToken))
{ {
await CheckCredentialsAsync(); await CheckCredentialsAsync(cancellationToken);
using (var memoryStream = new MemoryStream()) using (var memoryStream = new MemoryStream())
{ {
content.WriteToStream(memoryStream); content.WriteToStream(memoryStream);
@ -256,7 +257,7 @@ namespace GreenshotJiraPlugin {
/// <param name="cancellationToken">CancellationToken</param> /// <param name="cancellationToken">CancellationToken</param>
public async Task AddCommentAsync(string issueKey, string body, string visibility = null, CancellationToken cancellationToken = default(CancellationToken)) 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); await _jiraApi.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false);
} }
@ -268,7 +269,7 @@ namespace GreenshotJiraPlugin {
/// <returns></returns> /// <returns></returns>
public async Task<IList<Issue>> SearchAsync(Filter filter, CancellationToken cancellationToken = default(CancellationToken)) 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); var searchResult = await _jiraApi.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false);
return searchResult.Issues; return searchResult.Issues;
} }

View file

@ -120,7 +120,7 @@ namespace GreenshotJiraPlugin
public async Task AddJiraInstanceAsync(JiraApi jiraInstance, CancellationToken token = default(CancellationToken)) public async Task AddJiraInstanceAsync(JiraApi jiraInstance, CancellationToken token = default(CancellationToken))
{ {
_jiraInstances.Add(jiraInstance); _jiraInstances.Add(jiraInstance);
var projects = await jiraInstance.GetProjectsAsync(token).ConfigureAwait(false); var projects = await jiraInstance.Project.GetAllAsync(cancellationToken: token).ConfigureAwait(false);
if (projects != null) if (projects != null)
{ {
foreach (var project in projects) foreach (var project in projects)
@ -208,8 +208,7 @@ namespace GreenshotJiraPlugin
if (_recentJiras.Count > _maxEntries) if (_recentJiras.Count > _maxEntries)
{ {
// Add it to the list of recent Jiras // Add it to the list of recent Jiras
IList<JiraDetails> clonedList = new List<JiraDetails>(_recentJiras.Values); _recentJiras = (from jiraDetails in _recentJiras.Values.ToList()
_recentJiras = (from jiraDetails in clonedList
orderby jiraDetails.SeenAt descending orderby jiraDetails.SeenAt descending
select jiraDetails).Take(_maxEntries).ToDictionary(jd => jd.JiraKey, jd => jd); select jiraDetails).Take(_maxEntries).ToDictionary(jd => jd.JiraKey, jd => jd);
} }

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Dapplo.HttpExtensions" version="0.6.8" targetFramework="net45" /> <package id="Dapplo.HttpExtensions" version="0.6.10" targetFramework="net45" />
<package id="Dapplo.Jira" version="0.3.1" targetFramework="net45" /> <package id="Dapplo.Jira" version="0.3.4" targetFramework="net45" />
<package id="Dapplo.Log" version="1.0.22" 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="LibZ.Tool" version="1.2.0.0" targetFramework="net45" />
<package id="Svg" version="2.3.0" targetFramework="net45" /> <package id="Svg" version="2.3.0" targetFramework="net45" />