39 lines
983 B
C#
39 lines
983 B
C#
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Controls.Primitives;
|
|
using JD.Jira.Service;
|
|
|
|
namespace JD.Jira.WPF.View
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for JiraStatusControl.xaml
|
|
/// </summary>
|
|
public partial class JiraStatusControl : StatusBarItem
|
|
{
|
|
public JiraStatusControl(JiraService jiraService)
|
|
{
|
|
InitializeComponent();
|
|
|
|
CheckStatus(jiraService);
|
|
}
|
|
|
|
public async void CheckStatus(JiraService jiraService)
|
|
{
|
|
bool ok = false;
|
|
try
|
|
{
|
|
var projects = await jiraService.Jira.Projects.GetProjectsAsync();
|
|
ok = projects.Any();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// swallow exceptions
|
|
}
|
|
|
|
StatusControl.IsConnected = ok;
|
|
StatusControl.ToolTip = ok ? "Connected to Jira" : "Not connected to Jira";
|
|
}
|
|
}
|
|
}
|