private async void btnListWorkLogList_Click(object sender, EventArgs e)
        {
            this.btnListWorkLogList.Enabled = false;

            DateTime from = this.dtpFrom.Value;
            DateTime to   = this.dtpTo.Value;

            from = DateTime.Today.AddDays(-1);
            to   = DateTime.Today.AddDays(1);

            var GetUpdatedIssueListByAssignee = JiraProxy.GetUpdatedIssueListByTimeslot(from, to);
            var issueList = await GetUpdatedIssueListByAssignee;

            if (issueList == null || issueList.Count == 0)
            {
                return;
            }

            Dictionary <string, JiraTask> workLogsStore = new Dictionary <string, JiraTask>();

            foreach (var issue in issueList)
            {
                if (issue == null)
                {
                    continue;
                }

                string taskKey        = issue.fields.parent.key;
                string taskSummary    = issue.fields.parent.fields.summary;
                string taskType       = issue.fields.parent.fields.issuetype.name;
                string subTaskkey     = issue.key;
                string subTaskSummary = issue.fields.summary;

                var workLogs = await JiraProxy.GetWorklogs(issue);

                if (workLogs != null && workLogs.Count > 0)
                {
                    foreach (var worklog in workLogs)
                    {
                        if (worklog.created.Year == DateTime.Today.Year &&
                            worklog.created.Month == DateTime.Today.Month &&
                            worklog.created.Day == DateTime.Today.Day)
                        {
                            if (!workLogsStore.ContainsKey(taskKey))
                            {
                                JiraTask jiraTask = new JiraTask();
                                jiraTask.Key      = taskKey;
                                jiraTask.summary  = taskSummary;
                                jiraTask.Type     = taskType;
                                jiraTask.subTasks = new Dictionary <string, SubTask>();
                                workLogsStore.Add(taskKey, jiraTask);
                            }

                            JiraTask jiraTask1 = workLogsStore[taskKey];
                            if (!jiraTask1.subTasks.ContainsKey(subTaskkey))
                            {
                                SubTask subTask = new SubTask();
                                subTask.Key     = subTaskkey;
                                subTask.summary = subTaskSummary;
                                jiraTask1.subTasks.Add(subTaskkey, subTask);
                            }

                            SubTask subTask1 = jiraTask1.subTasks[subTaskkey];
                            if (subTask1.worklogs == null)
                            {
                                subTask1.worklogs = new List <Worklog>();
                            }

                            Worklog workLog = new Worklog();
                            workLog.displayName = worklog.author.displayName;
                            workLog.timeSpent   = worklog.timeSpent;
                            workLog.comment     = worklog.comment.Replace("\r\n", ";");
                            subTask1.worklogs.Add(workLog);

                            jiraTask1.subTasks[subTaskkey] = subTask1;
                            workLogsStore[taskKey]         = jiraTask1;
                        }
                    }
                }
            }

            /*
             * string dailyWorkLogSummaryReport = "";
             * int index1 = 1;
             * foreach (string taskKey in workLogsStore.Keys)
             * {
             *  JiraTask jiraTask = workLogsStore[taskKey];
             *
             *  dailyWorkLogSummaryReport += index1 + " " + jiraTask.Type + " - " + taskKey + " " + jiraTask.summary + "<br/>";
             *
             *  int index2 = 1;
             *  foreach (string subTaskkey in jiraTask.subTasks.Keys)
             *  {
             *      SubTask subTask = jiraTask.subTasks[subTaskkey];
             *
             *      dailyWorkLogSummaryReport += index1 + "." + index2 + " Sub Task: " + subTaskkey + " " + subTask.summary + "<br/>";
             *
             *      int index3 = 1;
             *      foreach (var workLog in subTask.worklogs)
             *      {
             *          dailyWorkLogSummaryReport += index1 + "." + index2 + "." + index3 + " " + workLog.displayName + "[" + workLog.timeSpent + "]" + workLog.comment + "<br/>";
             *
             *          index3++;
             *      }
             *
             *      index2++;
             *  }
             *
             *  dailyWorkLogSummaryReport += "<br/><br/>";
             *  index1++;
             * }
             */

            string dailyWorkLogSummaryReport = "";
            Dictionary <string, List <IndividualWorkLog> > IndividualWorkLogs = new Dictionary <string, List <IndividualWorkLog> >();

            foreach (string taskKey in workLogsStore.Keys)
            {
                JiraTask jiraTask = workLogsStore[taskKey];
                foreach (string subTaskkey in jiraTask.subTasks.Keys)
                {
                    SubTask subTask = jiraTask.subTasks[subTaskkey];
                    foreach (var workLog in subTask.worklogs)
                    {
                        IndividualWorkLog individualWorkLog = new IndividualWorkLog();
                        individualWorkLog.jiraKey        = taskKey;
                        individualWorkLog.summary        = jiraTask.summary;
                        individualWorkLog.subTaskSummary = subTask.summary;
                        individualWorkLog.timeSpent      = workLog.timeSpent;
                        individualWorkLog.comment        = workLog.comment;

                        if (!IndividualWorkLogs.ContainsKey(workLog.displayName))
                        {
                            IndividualWorkLogs.Add(workLog.displayName, new List <IndividualWorkLog>());
                        }
                        List <IndividualWorkLog> workLogs = IndividualWorkLogs[workLog.displayName];
                        workLogs.Add(individualWorkLog);
                        IndividualWorkLogs[workLog.displayName] = workLogs;
                    }
                }
            }

            dailyWorkLogSummaryReport = @"<table cellspacing='1' cellpadding='1' border='0' bgcolor='111111' style='border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;'>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>No</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Name</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Work Logs</td>                                               
                                            </tr>";

            int i = 1;

            foreach (string name in IndividualWorkLogs.Keys)
            {
                dailyWorkLogSummaryReport += "  <tr>";
                dailyWorkLogSummaryReport += "      <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>" + i + "</td>";
                dailyWorkLogSummaryReport += "      <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>" + name + "</td>";
                dailyWorkLogSummaryReport += "      <td align='left' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>";

                int j = 1;
                List <IndividualWorkLog> workLogs = IndividualWorkLogs[name];
                foreach (var worklog in workLogs)
                {
                    dailyWorkLogSummaryReport += "" + j + ") " + worklog.jiraKey + " - " + worklog.summary + "<br/>";
                    dailyWorkLogSummaryReport += "[" + worklog.subTaskSummary + "] " + worklog.timeSpent + " - " + worklog.comment + "<br/>";
                    j++;
                }
                dailyWorkLogSummaryReport += "      </td>";
                dailyWorkLogSummaryReport += "  </tr>";

                i++;
            }

            dailyWorkLogSummaryReport += "</table>";

            string content          = @"Hi, All guys<br/><br/>Below is the work log summary report.<br/><br/>" + dailyWorkLogSummaryReport + "Thanks<br/>Accela Support Team";
            string fromEmailAddress = "*****@*****.**";
            string toEmailAddress   = "[email protected];[email protected]";
            string ccEmailAddress   = "*****@*****.**";
            string subject          = "Daily Work Log Summary - " + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + DateTime.Now.Year;

            try
            {
                EmailUtil.SendEmail(fromEmailAddress, toEmailAddress, ccEmailAddress, subject, content);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failed to send email");
            }

            System.Console.WriteLine(dailyWorkLogSummaryReport);

            this.btnListWorkLogList.Enabled = true;
        }
Пример #2
0
        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;
        }
Пример #3
0
        private async void btnSync_Click(object sender, EventArgs e)
        {
            this.btnSync.Enabled = false;

            DateTime from      = this.dtpFrom.Value;
            DateTime to        = this.dtpTo.Value;
            var      issueList = await JiraProxy.GetUpdatedIssueListByAssigneeList(from, to, GetSupportTeamMembers());

            if (issueList == null || issueList.Count == 0)
            {
                this.btnSync.Enabled = true;
                return;
            }

            Dictionary <string, List <IndividualWorkLog> > IndividualWorkLogs = new Dictionary <string, List <IndividualWorkLog> >();

            foreach (var issue in issueList)
            {
                if (issue == null)
                {
                    continue;
                }

                /*
                 * string taskKey = issue.fields.parent.key;
                 * string taskSummary = issue.fields.parent.fields.summary;
                 * string taskType = issue.fields.parent.fields.issuetype.name;
                 * string subTaskkey = issue.key;
                 * string subTaskSummary = issue.fields.summary;
                 */

                string            issueType         = issue.fields.issueType.name;
                IndividualWorkLog individualWorkLog = new IndividualWorkLog();

                if ("Sub-task".Equals(issueType, StringComparison.InvariantCultureIgnoreCase))
                {
                    /*
                     * issue.fields.assignee.name = "*****@*****.**"
                     * issue.fields.assignee.emailAddress = "*****@*****.**"
                     * issue.fields.assignee.displayName = "Gordon Chen"
                     * issue.fields.issueType.name = "Sub-task"
                     * issue.fields.issueType.subtask = true
                     * issue.fields.parent.key = "ENGSUPP-14215"
                     * issue.fields.parent.fields.summary = "Unable to delete logs in Batch Engine"
                     * issue.fields.parent.fields.status.name = "In Progress"
                     */
                    var workLogs = await JiraProxy.GetWorklogs(issue);

                    if (workLogs != null && workLogs.Count > 0)
                    {
                        foreach (var worklog in workLogs)
                        {
                            if (DateTime.Compare(worklog.created, from) >= 0 && DateTime.Compare(worklog.created, to) <= 0)
                            {
                                individualWorkLog                  = new IndividualWorkLog();
                                individualWorkLog.subTaskKey       = issue.key;
                                individualWorkLog.subTaskSummary   = issue.fields.summary;
                                individualWorkLog.subTaskAssignee  = issue.fields.assignee.displayName;
                                individualWorkLog.jiraIssueKey     = issue.fields.parent.key;
                                individualWorkLog.jiraIssueSummary = issue.fields.parent.fields.summary;

                                individualWorkLog.assignee             = worklog.author.displayName;
                                individualWorkLog.assigneeEmailAddress = worklog.author.emailAddress;
                                individualWorkLog.timeSpent            = worklog.timeSpent;
                                individualWorkLog.comment = worklog.comment.Replace("\r\n", ";");

                                if (!IndividualWorkLogs.ContainsKey(individualWorkLog.jiraIssueKey))
                                {
                                    IndividualWorkLogs.Add(individualWorkLog.jiraIssueKey, new List <IndividualWorkLog>());
                                }
                                List <IndividualWorkLog> individualWorkLogList = IndividualWorkLogs[individualWorkLog.jiraIssueKey];
                                individualWorkLogList.Add(individualWorkLog);
                                IndividualWorkLogs[individualWorkLog.jiraIssueKey] = individualWorkLogList;
                            }
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("No work log on " + issue.key);
                    }
                }
                else
                {
                    var workLogs = await JiraProxy.GetWorklogs(issue);

                    if (workLogs != null && workLogs.Count > 0)
                    {
                        foreach (var worklog in workLogs)
                        {
                            System.Console.WriteLine("Work Log are created on " + worklog.created);

                            if (DateTime.Compare(worklog.created, from) >= 0 && DateTime.Compare(worklog.created, to) <= 0)
                            {
                                individualWorkLog = new IndividualWorkLog();
                                //individualWorkLog.subTaskKey = issue.fields.parent.key;
                                //individualWorkLog.subTaskSummary = issue.fields.summary;
                                //individualWorkLog.subTaskAssignee = issue.fields.assignee.displayName;
                                individualWorkLog.jiraIssueKey     = issue.key;
                                individualWorkLog.jiraIssueSummary = issue.fields.summary;

                                individualWorkLog.assignee             = worklog.author.displayName;
                                individualWorkLog.assigneeEmailAddress = worklog.author.emailAddress;
                                individualWorkLog.timeSpent            = worklog.timeSpent;
                                individualWorkLog.comment = worklog.comment.Replace("\r\n", ";");

                                if (!IndividualWorkLogs.ContainsKey(individualWorkLog.jiraIssueKey))
                                {
                                    IndividualWorkLogs.Add(individualWorkLog.jiraIssueKey, new List <IndividualWorkLog>());
                                }
                                List <IndividualWorkLog> individualWorkLogList = IndividualWorkLogs[individualWorkLog.jiraIssueKey];
                                individualWorkLogList.Add(individualWorkLog);
                                IndividualWorkLogs[individualWorkLog.jiraIssueKey] = individualWorkLogList;
                            }
                            else
                            {
                                System.Console.WriteLine("Work Log cannot be added.");
                            }
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("No work log on " + issue.key);
                    }
                }
            }

            if (IndividualWorkLogs.Count == 0)
            {
                this.btnSync.Enabled = true;
                return;
            }

            DataTable table = new DataTable("Daily Work Log Report");

            table.Columns.Add("No", typeof(int));
            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("EmailAddress", typeof(string));
            table.Columns.Add("Effort", typeof(string));
            table.Columns.Add("SubTaskID", typeof(string));
            table.Columns.Add("SubTaskSummary", typeof(string));
            table.Columns.Add("SubTaskAssignee", typeof(string));
            table.Columns.Add("SubTaskComment", typeof(string));
            table.Columns.Add("JiraKey", typeof(string));
            table.Columns.Add("JiraSummary", typeof(string));

            int index = 1;

            foreach (string key in IndividualWorkLogs.Keys)
            {
                List <IndividualWorkLog> individualWorkLogList = IndividualWorkLogs[key];
                foreach (var workLog in individualWorkLogList)
                {
                    DataRow row = table.NewRow();
                    row["No"]              = index;
                    row["Name"]            = workLog.assignee;
                    row["EmailAddress"]    = workLog.assigneeEmailAddress;
                    row["Effort"]          = workLog.timeSpent;
                    row["SubTaskID"]       = workLog.subTaskKey;
                    row["SubTaskSummary"]  = workLog.subTaskSummary;
                    row["SubTaskAssignee"] = workLog.subTaskAssignee;
                    row["SubTaskComment"]  = workLog.comment;
                    row["JiraKey"]         = workLog.jiraIssueKey;
                    row["JiraSummary"]     = workLog.jiraIssueSummary;

                    table.Rows.Add(row);
                    index++;
                }
            }

            dgvWorkLogReport.AutoGenerateColumns = false;
            dgvWorkLogReport.DataSource          = table;
            this.btnSync.Enabled = true;
        }