public async Task <OperationResult> AddWorkLogAsync(WorkLogEntry entry)
    {
        try
        {
            await _jira.Issues.AddWorklogAsync(entry.IssueKey, entry.JiraWorkLog);

            return(OperationResult.Success(entry));
        }
        catch (Exception ex)
        {
            return(OperationResult.Error(ex.Message, entry));
        }
    }
Ejemplo n.º 2
0
        public void CanRound()
        {
            var workLogEntry = new WorkLogEntry
            {
                Description = "My Entry",
                Start       = new DateTime(2014, 03, 25, 12, 34, 53),
                Stop        = new DateTime(2014, 03, 25, 13, 21, 27),
            };

            workLogEntry.Round(7);

            Assert.AreEqual("3/25/2014 - 00:49:00 - My Entry",
                            workLogEntry.ToString());
        }
    public async Task <OperationResult> UpdateWorkLogAsync(WorkLogEntry entry)
    {
        try
        {
            // https://bitbucket.org/farmas/atlassian.net-sdk/issues/304/update-of-a-worklog
            // https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-id-put
            await _jira.RestClient.ExecuteRequestAsync(Method.PUT, $"rest/api/3/issue/{entry.IssueKey}/worklog/{entry.JiraWorkLog.Id}", entry.JiraWorkLog);

            return(OperationResult.Success(entry));
        }
        catch (Exception ex)
        {
            return(OperationResult.Error(ex.Message, entry));
        }
    }
    private async Task <List <WorkLogEntry> > GetWorkLogEntriesAsync(DateTime startDate, DateTime endDate, Issue issue)
    {
        var workLogs = await issue.GetWorklogsAsync();

        return(workLogs
               .Where(workLog => workLog.StartDate >= startDate &&
                      workLog.StartDate.Value.AddSeconds(workLog.TimeSpentInSeconds) <= endDate &&
                      (workLog.Author == _options.Value.Username || workLog.AuthorUser.Email == _options.Value.Username))
               .Select(wl =>
        {
            var sourceId = WorkLogEntry.GetSourceId(wl.Comment);
            return sourceId == null ? null : new WorkLogEntry(issue.Key.Value, sourceId, wl);
        })
               .WhereNotNull()
               .ToList());
    }
 public bool DifferentFrom(WorkLogEntry other)
 {
     if (other.TimeSpent != TimeSpent)
     {
         return(true);
     }
     if (other.JiraWorkLog.StartDate != JiraWorkLog.StartDate)
     {
         return(true);
     }
     if (other.JiraWorkLog.Comment != JiraWorkLog.Comment)
     {
         return(true);
     }
     return(false);
 }
 public void Synchronize(WorkLogEntry other)
 {
     JiraWorkLog.StartDate = other.JiraWorkLog.StartDate;
     JiraWorkLog.TimeSpent = other.JiraWorkLog.TimeSpent;
     JiraWorkLog.Comment   = other.JiraWorkLog.Comment;
 }
 public static WorkLogEntry SetSourceId(this WorkLogEntry workLogEntry, int sourceId)
 {
     workLogEntry.Description = $"[toggl-id:{sourceId}] " + workLogEntry.Description;
     return(workLogEntry);
 }
 public string GetSourceId(string input)
 {
     return(WorkLogEntry.GetSourceId(input));
 }