Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Dec 18, 2014
2 parents cc34267 + 1a33683 commit 9722727
Show file tree
Hide file tree
Showing 28 changed files with 645 additions and 65 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Gallifrey makes use of the following libraries:

* Exceptionless (http://exceptionless.com/)
* Spell Check Winforms TextBox (http://spellchecktextbox.codeplex.com/)
* Atlassian .Net SDK (https://bitbucket.org/farmas/atlassian.net-sdk/wiki/Home)

3rd Party Resources
=========
Expand Down
11 changes: 10 additions & 1 deletion src/Gallifrey.Jira/Gallifrey.Jira.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Enum\WorkLogStrategy.cs" />
<Compile Include="IJiraClient.cs" />
<Compile Include="JiraRestClient.cs" />
<Compile Include="JiraSoapClient.cs" />
<Compile Include="Model\Error.cs" />
<Compile Include="Exception\JiraClientException.cs" />
<Compile Include="Model\Fields.cs" />
<Compile Include="Model\Filter.cs" />
<Compile Include="Model\Issue.cs" />
<Compile Include="JiraClient.cs" />
<Compile Include="Model\Project.cs" />
<Compile Include="Model\TimeTracking.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -178,4 +180,11 @@
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Reference Include="Atlassian.Jira">
<HintPath>..\packages\Atlassian.SDK\lib\Atlassian.Jira.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions src/Gallifrey.Jira/IJiraClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using Gallifrey.Jira.Enum;
using Gallifrey.Jira.Model;

namespace Gallifrey.Jira
{
public interface IJiraClient
{
User GetCurrentUser();
Issue GetIssue(string issueRef);
Issue GetIssueWithWorklogs(string issueRef);
IEnumerable<Issue> GetIssuesFromFilter(string filterName);
IEnumerable<Issue> GetIssuesFromJql(string jql);
IEnumerable<Project> GetProjects();
IEnumerable<Filter> GetFilters();
Transitions GetIssueTransitions(string issueRef);
void TransitionIssue(string issueRef, string transitionName);
void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan? remainingTime = null);
void AssignIssue(string issueRef, string userName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

namespace Gallifrey.Jira
{
public class JiraClient
public class JiraRestClient : IJiraClient
{
private readonly string username;
private readonly string password;
private readonly RestClient client;
private readonly JsonDeserializer deserializer;

public JiraClient(string baseUrl, string username, string password)
public JiraRestClient(string baseUrl, string username, string password)
{
this.username = username;
this.password = password;
Expand Down Expand Up @@ -162,13 +162,6 @@ public IEnumerable<Project> GetProjects()
return deserializer.Deserialize<List<Project>>(response);
}

public IEnumerable<Status> GetAllStatuses()
{
var response = ExectuteRequest(Method.GET, HttpStatusCode.OK, "status");

return deserializer.Deserialize<List<Status>>(response);
}

public IEnumerable<Filter> GetFilters()
{
var response = ExectuteRequest(Method.GET, HttpStatusCode.OK, "filter/favourite");
Expand Down
193 changes: 193 additions & 0 deletions src/Gallifrey.Jira/JiraSoapClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Atlassian.Jira;
using Gallifrey.Jira.Enum;
using Gallifrey.Jira.Model;
using Issue = Gallifrey.Jira.Model.Issue;
using Project = Gallifrey.Jira.Model.Project;

namespace Gallifrey.Jira
{
public class JiraSoapClient : IJiraClient
{
private readonly string username;
private readonly Atlassian.Jira.Jira client;

public JiraSoapClient(string baseUrl, string username, string password)
{
this.username = username;
client = new Atlassian.Jira.Jira(baseUrl, username, password) { MaxIssuesPerRequest = 999 };
}

public User GetCurrentUser()
{
client.GetAccessToken();
return new User
{
name = username,
active = true
};
}

public Issue GetIssue(string issueRef)
{
var issue = client.GetIssue(issueRef);
return new Issue
{
key = issue.Key.Value,
fields = new Fields
{
project = new Project
{
key = issue.Project
},
status = new Status
{
name = issue.Status.Name,
id = issue.Status.Id
},
summary = issue.Summary
}
};
}

public Issue GetIssueWithWorklogs(string issueRef)
{
var issue = client.GetIssue(issueRef);
var worklogs = issue.GetWorklogs().Select(worklog => new WorkLog { author = new User { name = worklog.Author }, comment = worklog.Comment, started = worklog.StartDate.Value, timeSpent = worklog.TimeSpent, timeSpentSeconds = worklog.TimeSpentInSeconds }).ToList();
return new Issue
{
key = issue.Key.Value,
fields = new Fields
{
project = new Project
{
key = issue.Project
},
status = new Status
{
name = issue.Status.Name,
id = issue.Status.Id
},
worklog = new WorkLogs
{
maxResults = worklogs.Count(),
total = worklogs.Count(),
worklogs = worklogs
},
summary = issue.Summary,
}
};
}

public IEnumerable<Issue> GetIssuesFromFilter(string filterName)
{
var issues = client.GetIssuesFromFilter(filterName, 0, 999);
return issues.Select(issue => new Issue
{
key = issue.Key.Value,
fields = new Fields
{
project = new Project
{
key = issue.Project
},
status = new Status
{
name = issue.Status.Name,
id = issue.Status.Id
},
summary = issue.Summary
}
});
}

public IEnumerable<Issue> GetIssuesFromJql(string jql)
{
var issues = client.GetIssuesFromJql(jql, 999);
return issues.Select(issue => new Issue
{
key = issue.Key.Value,
fields = new Fields
{
project = new Project
{
key = issue.Project
},
status = new Status
{
name = issue.Status.Name,
id = issue.Status.Id
},
summary = issue.Summary
}
});
}

public IEnumerable<Project> GetProjects()
{
var projects = client.GetProjects();
return projects.Select(project => new Project { key = project.Key, name = project.Name });
}

public IEnumerable<Filter> GetFilters()
{
var returnedFilters = client.GetFilters();
return returnedFilters.Select(filter => new Filter { name = filter.Name });
}

public Transitions GetIssueTransitions(string issueRef)
{
var issue = client.GetIssue(issueRef);
var statuses = issue.GetAvailableActions().Select(action => new Status { name = action.Name, id = action.Id });
return new Transitions { transitions = statuses.ToList() };
}

public void TransitionIssue(string issueRef, string transitionName)
{
var issue = client.GetIssue(issueRef);
issue.WorkflowTransition(transitionName);
}

public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan? remainingTime = null)
{
if (logDate.Kind != DateTimeKind.Local) logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local);

var issue = client.GetIssue(issueRef);

var worklog = new Worklog(string.Format("{0}h {1}m", timeSpent.Hours, timeSpent.Minutes), logDate, comment);
string remaining = null;
if (remainingTime.HasValue)
{
remaining = string.Format("{0}h {1}m", remainingTime.Value.Hours, remainingTime.Value.Minutes);
}

WorklogStrategy strategy;
switch (workLogStrategy)
{
case WorkLogStrategy.Automatic:
strategy = WorklogStrategy.AutoAdjustRemainingEstimate;
break;
case WorkLogStrategy.LeaveRemaining:
strategy = WorklogStrategy.RetainRemainingEstimate;
break;
case WorkLogStrategy.SetValue:
strategy = WorklogStrategy.NewRemainingEstimate;
break;
default:
strategy = WorklogStrategy.RetainRemainingEstimate;
break;
}

issue.AddWorklog(worklog, strategy, remaining);
}

public void AssignIssue(string issueRef, string userName)
{
var issue = client.GetIssue(issueRef);
issue.Assignee = userName;
issue.SaveChanges();
}
}
}
4 changes: 2 additions & 2 deletions src/Gallifrey.Jira/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
3 changes: 2 additions & 1 deletion src/Gallifrey.Jira/paket.references
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
RestSharp
RestSharp
Atlassian.SDK
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PublisherName>Gallifrey</PublisherName>
<MinimumRequiredVersion>1.0.0.0</MinimumRequiredVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>2.0.0.%2a</ApplicationVersion>
<ApplicationVersion>2.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>true</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
4 changes: 2 additions & 2 deletions src/Gallifrey.UI.Classic.Beta/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
2 changes: 1 addition & 1 deletion src/Gallifrey.UI.Classic/AboutWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void btnGitHub_Click(object sender, EventArgs e)

private void btnEmail_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("mailto:GallifreyApp@gmail.com?subject=Gallifrey App Contact");
System.Diagnostics.Process.Start("mailto:contact@gallifreyapp.co.uk?subject=Gallifrey App Contact");
}

private void btnTwitter_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/Gallifrey.UI.Classic/AdjustTimerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private bool AdjustTime(bool addTime)

if (!adjustmentSuccess)
{
MessageBox.Show("You Cannot Subtract More Time Than You Have Already Exported\nHave Subtracted All Un-Exported Time", "Adjustment Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show("You Cannot Subtract More Time Than You Have Left To Export\nHave Subtracted All Un-Exported Time", "Adjustment Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

return true;
Expand Down
14 changes: 13 additions & 1 deletion src/Gallifrey.UI.Classic/ChangeLog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@
<Bug>Make Alt + Enter on export work again, bug introduced in 1.2.0.</Bug>
<Bug>Handle my companys standard method of setting in progress.</Bug>
</Bugs>
<Others />
<Others />
</Version>
<Version Number="2.1.0" Name="">
<Features>
<Feature>Add Jira SOAP client as optional with REST being default. - SOAP Client not as full featured</Feature>
</Features>
<Bugs>
<Bug>Pressing cancel on forced settings window when no connection to Jira will close the app.</Bug>
<Bug>Attempt to fix change log and only show correct versions.</Bug>
<Bug>Fix Issue with subtracting time before a timer has been stopped.</Bug>
<Bug>Added helpers to handle an update location change (ready for releases.gallifreyapp.co.uk).</Bug>
</Bugs>
<Others />
</Version>
</Versions>
18 changes: 14 additions & 4 deletions src/Gallifrey.UI.Classic/ExportTimerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,20 @@ public ExportTimerWindow(IBackend gallifrey, Guid timerGuid)
txtExportHours.Text = timerToShow.TimeToExport.Hours.ToString();
txtExportMins.Text = timerToShow.TimeToExport.Minutes.ToString();

var remainingTime = jiraIssue.fields.timetracking != null ? TimeSpan.FromSeconds(jiraIssue.fields.timetracking.remainingEstimateSeconds) : new TimeSpan();
var hours = (remainingTime.Days*24) + remainingTime.Hours;
txtRemainingHours.Text = hours.ToString();
txtRemainingMinutes.Text = remainingTime.Minutes.ToString();
if (jiraIssue.fields.timetracking == null)
{
txtRemainingHours.Text = "N/A";
txtRemainingMinutes.Text = "N/A";
}
else
{
var remainingTime = jiraIssue.fields.timetracking != null ? TimeSpan.FromSeconds(jiraIssue.fields.timetracking.remainingEstimateSeconds) : new TimeSpan();
var hours = (remainingTime.Days * 24) + remainingTime.Hours;
txtRemainingHours.Text = hours.ToString();
txtRemainingMinutes.Text = remainingTime.Minutes.ToString();
}



if (timerToShow.DateStarted.Date != DateTime.Now.Date)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Gallifrey.UI.Classic/Gallifrey.UI.Classic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PublisherName>Gallifrey</PublisherName>
<MinimumRequiredVersion>1.0.0.0</MinimumRequiredVersion>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>2.0.0.0</ApplicationVersion>
<ApplicationVersion>2.1.0.0</ApplicationVersion>
<UseApplicationTrust>true</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
Loading

0 comments on commit 9722727

Please sign in to comment.