private async void btnPull_Click(object sender, EventArgs e) { this.btnPull.Enabled = false; DateTime from = this.dtpFrom.Value; DateTime to = this.dtpTo.Value; var issues = await JiraProxy.GetUpdatedIssueList(from, to); if (issues == null || issues.Count == 0) { this.btnPull.Enabled = true; return; } jiraIssueList.Clear(); JiraIssue jiraIssue = null; foreach (var issue in issues) { jiraIssue = new JiraIssue(); jiraIssue.key = issue.key; jiraIssue.issueType = issue.fields.issueType.name; jiraIssue.name = issue.fields.summary; jiraIssue.assignee = issue.fields.assignee.name; jiraIssue.assigneeEmailAddress = issue.fields.assignee.emailAddress; jiraIssue.assigneeDisplayName = issue.fields.assignee.displayName; jiraIssue.status = issue.fields.status.name; jiraIssue.subtasks = new Dictionary <string, SubTask>(); if (issue.fields.subtasks == null || issue.fields.subtasks.Count == 0) { jiraIssueList.Add(jiraIssue); continue; } double timeSpentSeconds = 0; foreach (var subtask in issue.fields.subtasks) { string subTaskKey = subtask.key; string subTaskName = subtask.fields.summary; bool isSubTask = subtask.fields.issuetype.subtask; if (isSubTask && !jiraIssue.subtasks.ContainsKey(subTaskName)) { IssueRef issueRef = new IssueRef(); issueRef.id = subTaskKey; issueRef.key = subTaskKey; var subTaskInfo = await JiraProxy.LoadIssue(issueRef); if (subTaskInfo == null) { continue; } SubTask subTaskItem = new SubTask(); subTaskItem.key = subTaskInfo.key; subTaskItem.name = subTaskInfo.fields.summary; subTaskItem.assignee = subTaskInfo.fields.assignee.displayName; subTaskItem.status = subTaskInfo.fields.status.name; subTaskItem.MEO = subTaskInfo.fields.customfield_14101 == null ? "" : subTaskInfo.fields.customfield_14101.value; var worklogs = await JiraProxy.GetWorklogs(issueRef); if (worklogs == null && worklogs.Count == 0) { jiraIssue.subtasks.Add(subTaskItem.name, subTaskItem); continue; } subTaskItem.worklogs = new List <WorkLog>(); foreach (var worklog in worklogs) { WorkLog individualWorkLog = new WorkLog(); individualWorkLog.assignee = worklog.author.displayName; individualWorkLog.assigneeEmailAddress = worklog.author.emailAddress; individualWorkLog.timeSpent = worklog.timeSpent; individualWorkLog.comment = worklog.comment.Replace("\r\n", ";"); subTaskItem.worklogs.Add(individualWorkLog); timeSpentSeconds += worklog.timeSpentSeconds; } subTaskItem.timespent = Math.Round((double)subTaskInfo.fields.timespent / 3600, 2); jiraIssue.subtasks.Add(subTaskItem.name, subTaskItem); } } jiraIssue.timespent = Math.Round((double)timeSpentSeconds / 3600, 2); jiraIssueList.Add(jiraIssue); } DataTable table = new DataTable("Daily Work Log Report"); table.Columns.Add("No", typeof(int)); table.Columns.Add("IssueType", typeof(string)); table.Columns.Add("JiraKey", typeof(string)); table.Columns.Add("Summary", typeof(string)); table.Columns.Add("Status", typeof(string)); table.Columns.Add("Assignee", typeof(string)); table.Columns.Add("AssigneeQA", typeof(string)); table.Columns.Add("TimeSpent", typeof(string)); table.Columns.Add("ReviewAndRecreateQA", typeof(string)); table.Columns.Add("Assignee1", typeof(string)); table.Columns.Add("Status1", typeof(string)); table.Columns.Add("MEO1", typeof(string)); table.Columns.Add("TimeSpent1", typeof(string)); table.Columns.Add("ReviewAndRecreateDev", typeof(string)); table.Columns.Add("Assignee2", typeof(string)); table.Columns.Add("Status2", typeof(string)); table.Columns.Add("MEO2", typeof(string)); table.Columns.Add("TimeSpent2", typeof(string)); table.Columns.Add("ResearchRootCauseDev", typeof(string)); table.Columns.Add("Assignee3", typeof(string)); table.Columns.Add("Status3", typeof(string)); table.Columns.Add("MEO3", typeof(string)); table.Columns.Add("TimeSpent3", typeof(string)); table.Columns.Add("CodeFixDev", typeof(string)); table.Columns.Add("Assignee4", typeof(string)); table.Columns.Add("Status4", typeof(string)); table.Columns.Add("MEO4", typeof(string)); table.Columns.Add("TimeSpent4", typeof(string)); table.Columns.Add("WriteTestCaseQA", typeof(string)); table.Columns.Add("Assignee5", typeof(string)); table.Columns.Add("Status5", typeof(string)); table.Columns.Add("MEO5", typeof(string)); table.Columns.Add("TimeSpent5", typeof(string)); table.Columns.Add("ExecuteTestCaseQA", typeof(string)); table.Columns.Add("Assignee6", typeof(string)); table.Columns.Add("Status6", typeof(string)); table.Columns.Add("MEO6", typeof(string)); table.Columns.Add("TimeSpent6", typeof(string)); table.Columns.Add("WriteReleaseNotesDev", typeof(string)); table.Columns.Add("Assignee7", typeof(string)); table.Columns.Add("Status7", typeof(string)); table.Columns.Add("MEO7", typeof(string)); table.Columns.Add("TimeSpent7", typeof(string)); table.Columns.Add("ReviewReleaseNotesQA", typeof(string)); table.Columns.Add("Assignee8", typeof(string)); table.Columns.Add("Status8", typeof(string)); table.Columns.Add("MEO8", typeof(string)); table.Columns.Add("TimeSpent8", typeof(string)); int index = 1; foreach (var jiraIssueItem in jiraIssueList) { DataRow row = table.NewRow(); row["No"] = index; row["IssueType"] = jiraIssueItem.issueType; row["JiraKey"] = jiraIssueItem.key; row["Summary"] = jiraIssueItem.name; row["Status"] = jiraIssueItem.status; row["Assignee"] = jiraIssueItem.assignee; row["AssigneeQA"] = jiraIssueItem.assignee; row["TimeSpent"] = jiraIssueItem.timespent; SubTask subTaskReviewAndRecreateQA = jiraIssueItem.subtasks.ContainsKey("Review and Recreate(QA)") ? jiraIssueItem.subtasks["Review and Recreate(QA)"] : null; if (subTaskReviewAndRecreateQA != null) { row["ReviewAndRecreateQA"] = subTaskReviewAndRecreateQA.key; row["Assignee1"] = subTaskReviewAndRecreateQA.assignee; row["Status1"] = subTaskReviewAndRecreateQA.status; row["MEO1"] = subTaskReviewAndRecreateQA.MEO; row["TimeSpent1"] = subTaskReviewAndRecreateQA.timespent; } SubTask subTaskReviewAndRecreateDev = jiraIssueItem.subtasks.ContainsKey("Review and Recreate(Dev)") ? jiraIssueItem.subtasks["Review and Recreate(Dev)"] : null; if (subTaskReviewAndRecreateDev != null) { row["ReviewAndRecreateDev"] = subTaskReviewAndRecreateDev.key; row["Assignee2"] = subTaskReviewAndRecreateDev.assignee; row["Status2"] = subTaskReviewAndRecreateDev.status; row["MEO2"] = subTaskReviewAndRecreateDev.MEO; row["TimeSpent2"] = subTaskReviewAndRecreateDev.timespent; } SubTask subTaskResearchRootCause = jiraIssueItem.subtasks.ContainsKey("Research Root Cause") ? jiraIssueItem.subtasks["Research Root Cause"] : null; if (subTaskResearchRootCause != null) { row["ResearchRootCauseDev"] = subTaskResearchRootCause.key; row["Assignee3"] = subTaskResearchRootCause.assignee; row["Status3"] = subTaskResearchRootCause.status; row["MEO3"] = subTaskResearchRootCause.MEO; row["TimeSpent3"] = subTaskResearchRootCause.timespent; } SubTask subTaskCodeFixDev = jiraIssueItem.subtasks.ContainsKey("Code Fix(Dev)") ? jiraIssueItem.subtasks["Code Fix(Dev)"] : null; if (subTaskCodeFixDev != null) { row["CodeFixDev"] = subTaskCodeFixDev.key; row["Assignee4"] = subTaskCodeFixDev.assignee; row["Status4"] = subTaskCodeFixDev.status; row["MEO4"] = subTaskCodeFixDev.MEO; row["TimeSpent4"] = subTaskCodeFixDev.timespent; } SubTask subTaskWriteTestCaseQA = jiraIssueItem.subtasks.ContainsKey("Write Test Case(QA)") ? jiraIssueItem.subtasks["Write Test Case(QA)"] : null; if (subTaskWriteTestCaseQA != null) { row["WriteTestCaseQA"] = subTaskWriteTestCaseQA.key; row["Assignee5"] = subTaskWriteTestCaseQA.assignee; row["Status5"] = subTaskWriteTestCaseQA.status; row["MEO5"] = subTaskWriteTestCaseQA.MEO; row["TimeSpent5"] = subTaskWriteTestCaseQA.timespent; } SubTask subTaskExecuteTestCaseQA = jiraIssueItem.subtasks.ContainsKey("Execute Test Case(QA)") ? jiraIssueItem.subtasks["Execute Test Case(QA)"] : null; if (subTaskExecuteTestCaseQA != null) { row["ExecuteTestCaseQA"] = subTaskExecuteTestCaseQA.key; row["Assignee6"] = subTaskExecuteTestCaseQA.assignee; row["Status6"] = subTaskExecuteTestCaseQA.status; row["MEO6"] = subTaskExecuteTestCaseQA.MEO; row["TimeSpent6"] = subTaskExecuteTestCaseQA.timespent; } SubTask subTaskWriteReleaseNotesDev = jiraIssueItem.subtasks.ContainsKey("Write Release Notes(Dev)") ? jiraIssueItem.subtasks["Write Release Notes(Dev)"] : null; if (subTaskWriteReleaseNotesDev != null) { row["WriteReleaseNotesDev"] = subTaskWriteReleaseNotesDev.key; row["Assignee7"] = subTaskWriteReleaseNotesDev.assignee; row["Status7"] = subTaskWriteReleaseNotesDev.status; row["MEO7"] = subTaskWriteReleaseNotesDev.MEO; row["TimeSpent7"] = subTaskWriteReleaseNotesDev.timespent; } SubTask subTaskReviewReleaseNotesQA = jiraIssueItem.subtasks.ContainsKey("Review Release Notes(QA)") ? jiraIssueItem.subtasks["Review Release Notes(QA)"] : null; if (subTaskReviewReleaseNotesQA != null) { row["ReviewReleaseNotesQA"] = subTaskReviewReleaseNotesQA.key; row["Assignee8"] = subTaskReviewReleaseNotesQA.assignee; row["Status8"] = subTaskReviewReleaseNotesQA.status; row["MEO8"] = subTaskReviewReleaseNotesQA.MEO; row["TimeSpent8"] = subTaskReviewReleaseNotesQA.timespent; } table.Rows.Add(row); index++; } this.dgvSubTaskTable.AutoGenerateColumns = false; this.dgvSubTaskTable.DataSource = table; this.btnPull.Enabled = true; return; }