/// <summary> /// </summary> /// <param name="jira"></param> /// <param name="issue"></param> /// <param name="data"></param> /// <returns></returns> // ReSharper disable once TooManyDeclarations private async Task <IssueCard> GetIssueCardAsync(Jira jira, Issue issue, SettingsModel data) { var timeTrack = await issue.GetTimeTrackingDataAsync().ConfigureAwait(true); var assignee = issue.Assignee != null ? await jira.Users.GetUserAsync(issue.Assignee).ConfigureAwait(true) : null; var reporter = issue.Reporter != null ? await jira.Users.GetUserAsync(issue.Reporter).ConfigureAwait(true) : null; var version = issue.FixVersions.OrderBy(i => i.Id).FirstOrDefault(); // ReSharper disable once ComplexConditionExpression var item = new IssueCard { Key = issue.Key.Value, Url = $"{issue.Jira.Url}browse/{issue.Key.Value}", Summary = issue.Summary, Description = issue.Description, IssueType = issue.Type.Name, Estimate = timeTrack.OriginalEstimate, EstimateSeconds = timeTrack.OriginalEstimateInSeconds, Spent = timeTrack.TimeSpent, SpentSeconds = timeTrack.TimeSpentInSeconds, Remaining = timeTrack.RemainingEstimate, RemainingSeconds = timeTrack.RemainingEstimateInSeconds, Assignee = assignee?.DisplayName ?? string.Empty, Reporter = reporter?.DisplayName ?? string.Empty, Created = issue.Created.GetValueOrDefault(), Updated = issue.Updated.GetValueOrDefault(), DueDate = issue.DueDate.GetValueOrDefault(), Status = issue.Status != null ? issue.Status.Name : string.Empty, StatusImage = issue.Status != null?LoadImage(issue.Status.IconUrl) : null, StatusImageUrl = issue.Status != null ? issue.Status.IconUrl : string.Empty, Priority = issue.Priority != null ? issue.Priority.Name : string.Empty, TypeIconUrl = issue.Type != null ? issue.Type.IconUrl : null, TypeIconImage = issue.Type != null?LoadImage(issue.Type.IconUrl) : null, PriorityIconUrl = issue.Priority != null ? issue.Priority.IconUrl : null, PriorityIconImage = issue.Priority != null?LoadImage(issue.Priority.IconUrl) : null, AffectedVersion = issue.AffectsVersions.OrderBy(i => i.Name).FirstOrDefault()?.Name ?? string.Empty, FixedVersion = version?.Name ?? string.Empty, FixedVersionId = version?.Id ?? string.Empty, ReleaseDate = version?.ReleasedDate.GetValueOrDefault() ?? DateTime.MaxValue, CustomField1 = GetCustomField(issue.CustomFields, data.CustomField1), CustomField2 = GetCustomField(issue.CustomFields, data.CustomField2), CustomField3 = GetCustomField(issue.CustomFields, data.CustomField3), CustomField4 = GetCustomField(issue.CustomFields, data.CustomField4) }; return(item); }
public async void LoadSubscribedIssuesAsync() { await Task.Factory.StartNew(() => { Dispatcher.BeginInvoke(new Action(() => { if (Directory.Exists(Constants.GetIssueFilesDirectory())) { string[] SubscribedIssues = Directory.GetFiles(Constants.GetIssueFilesDirectory()); SubscribedIssuesContainer.Children.Clear(); int FixedIssues = 0; int TotalIssuesSubscribed = 0; foreach (string s in SubscribedIssues) { TotalIssuesSubscribed++; SubscribeIssue subscribeIssue = Constants.GetSubscribedIssue(s); IssueCard issueCard = new IssueCard(subscribeIssue.SubscribedIssueTitle, subscribeIssue.SubscribedIssueDescription, subscribeIssue.SubscribedIssueLink, this, null, true); if (issueCard.HasIssueResolutionChanged(s, out Constants.IssueResolution OutChangedResolution) == false) { if (OutChangedResolution != Constants.IssueResolution.Fixed) { SubscribedIssuesContainer.Children.Add(issueCard); } else { FixedIssues++; } } } if (FixedIssues > 0) { NumberOfIssuesFixed.Text = string.Format("{0}/{1} ISSUE(S) HAS BEEN FIXED!", FixedIssues, TotalIssuesSubscribed); NumberOfIssuesFixedDialogHost.IsOpen = true; } } })); }); }