public static List<EffortLogEntry> GetEffortLog(List<string> issueList, List<string> resourceList, DateTime fromDate, DateTime toDate, BackgroundWorker worker) { var effortlogList = new List<EffortLogEntry>(); JiraSoapServiceService service = null; try { service = new JiraSoapServiceService(); var count = 0; var total = issueList.Count; foreach (var sd in issueList) { if (!worker.CancellationPending) { //var errorMsg = string.Empty; try { var response = service.getWorklogs(_token, sd); var sdData = service.getIssue(_token, sd); foreach (var log in response) { var updateDate = log.startDate.Value.ToLocalTime().Date; if (resourceList.Contains(log.author) && DateTime.Compare(fromDate, updateDate) <= 0 && DateTime.Compare(toDate, updateDate) >= 0) { effortlogList.Add(new EffortLogEntry() { Date = updateDate.ToShortDateString(), ResourceName = log.updateAuthor, SDNumber = sd, EffortInSeconds = log.timeSpentInSeconds, Comment = string.IsNullOrEmpty(log.comment) ? "No Comments" : log.comment, IssueType = sdData.type.Equals("42") ? IssueType.OPEX : IssueType.CAPEX }); } } } catch (SoapException ex) { MessageBox.Show(String.Format("Unable to get the work log for following SD Number:\n\n{0}", sd), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } count++; worker.ReportProgress(count * 100 / total); } } } catch (Exception ex) { } finally { if (service != null) service.Dispose(); } return effortlogList; }
public static void GetInvalidIssues(List<string> sdList, out List<string> invalidIssueList) { invalidIssueList = new List<string>(); if (sdList != null && sdList.Count > 0) { using (JiraSoapServiceService jiraService = new JiraSoapServiceService()) { foreach (var sd in sdList.Distinct()) { try { jiraService.getIssue(_token, sd); } catch (SoapException ex) { invalidIssueList.Add(sd); } } } } }
public static IssueData GetIssueData(string issueId, List<RemoteIssueType> typeList) { string issueNumber = issueId; if (Regex.IsMatch(issueId, @"^[0-9\s]{1,6}$")) { issueNumber = "SD-" + issueId.Replace(" ", ""); } else { issueNumber = issueId; } IssueData data = new IssueData() { IssueId = issueId }; bool initializedService = false; JiraSoapServiceService service = null; try { service = new JiraSoapServiceService(); initializedService = true; RemoteIssue issue = service.getIssue(_token, issueNumber); data.IssueType = typeList.Where(m => m.id == issue.type).Select(m => m.name).FirstOrDefault(); data.SubSystem = issue.customFieldValues.Where(m => m.customfieldId.Equals("customfield_11162")).Select(m => m.values.FirstOrDefault()).FirstOrDefault(); if (data.SubSystem.Equals("Undefined")) { data.SubSystem = string.Empty; } } catch (Exception ex) { data.IsInvalid = true; } finally { if (initializedService) { service.Dispose(); } } return data; }