Exemplo n.º 1
0
        public Report Load(ToggleConfigurationSection toggle, string url, string password, string login, string authorName, DateTime startDate)
        {
            var issues = (List <LoggedIssue>)Issues;

            issues.Clear();

            var toggl      = new Toggl(toggle);
            var jiraServer = new JiraNew(url, password, login, authorName);
            var firstDay   = new DateTime(startDate.Year, startDate.Month, 1);
            var endOfMonth = new DateTime(startDate.Year, startDate.Month, DateTime.DaysInMonth(startDate.Year, startDate.Month));

            var togglSummary = toggl.GetSummary(toggle.Workspace, firstDay.AddMonths(-1), endOfMonth);
            var togglItems   = togglSummary.Groups.SelectMany(g => g.Items).Select(i => new TogglLoggedItem(i)).ToList();

            var togglGroups = togglItems.GroupBy(i => i.Issue).OrderByDescending(i => i.Key).ToList();
            var jiraResult  = jiraServer.GetIssues(togglGroups.Select(x => x.Key).Where(x => !string.IsNullOrWhiteSpace(x)).ToList());

            foreach (var group in togglGroups)
            {
                if (!string.IsNullOrEmpty(group.Key))
                {
                    JiraNew.Issue issue       = jiraResult.Issues.Single(x => x.Key == group.Key);
                    var           jiraWorkLog = issue.Fields.Worklog ?? jiraServer.GetWorkLog(group.Key);
                    jiraWorkLog.Items = jiraWorkLog.Items.Where(i => i.Author.Name == jiraServer.AuthorName).ToList();
                    var loggedIssue = new LoggedIssue(group.Key, group, jiraWorkLog, issue, jiraServer);
                    issues.Add(loggedIssue);
                }
            }

            return(this);
        }
Exemplo n.º 2
0
 public LoggedIssue(string plat, IEnumerable <TogglLoggedItem> toggl, JiraNew.JiraWorkLog workLog, JiraNew.Issue issue, JiraNew jiraServer)
 {
     this.jiraServer = jiraServer;
     Issue           = issue;
     PLAT            = plat;
     Toggl           = toggl;
     WorkLog         = workLog;
     CalculateDiff();
 }