/// <summary> /// Deletes the worklog with the given id and updates the remaining estimate field on the isssue /// </summary> public void DeleteWorklog(Worklog worklog, WorklogStrategy worklogStrategy = WorklogStrategy.AutoAdjustRemainingEstimate, string newEstimate = null) { if (String.IsNullOrEmpty(_originalIssue.key)) { throw new InvalidOperationException("Unable to delete worklog from issue, issue has not been saved to server."); } Jira.WithToken((token, client) => { switch (worklogStrategy) { case WorklogStrategy.AutoAdjustRemainingEstimate: client.DeleteWorklogAndAutoAdjustRemainingEstimate(token, this._originalIssue.key, worklog.Id); break; case WorklogStrategy.RetainRemainingEstimate: client.DeleteWorklogAndRetainRemainingEstimate(token, this._originalIssue.key, worklog.Id); break; case WorklogStrategy.NewRemainingEstimate: client.DeleteWorklogWithNewRemainingEstimate(token, this._originalIssue.key, worklog.Id, newEstimate); break; } }); }
/// <summary> /// Adds a worklog to this issue. /// </summary> /// <param name="worklog">The worklog instance to add</param> /// <param name="worklogStrategy">How to handle the remaining estimate, defaults to AutoAdjustRemainingEstimate</param> /// <param name="newEstimate">New estimate (only used if worklogStrategy set to NewRemainingEstimate)</param> /// <returns>Worklog as constructed by server</returns> public Worklog AddWorklog(Worklog worklog, WorklogStrategy worklogStrategy = WorklogStrategy.AutoAdjustRemainingEstimate, string newEstimate = null) { if (String.IsNullOrEmpty(_originalIssue.key)) { throw new InvalidOperationException("Unable to add worklog to issue, issue has not been saved to server."); } RemoteWorklog remoteWorklog = worklog.ToRemote(); _jira.WithToken(token => { switch (worklogStrategy) { case WorklogStrategy.RetainRemainingEstimate: remoteWorklog = _jira.RemoteService.AddWorklogAndRetainRemainingEstimate(token, _originalIssue.key, remoteWorklog); break; case WorklogStrategy.NewRemainingEstimate: remoteWorklog = _jira.RemoteService.AddWorklogWithNewRemainingEstimate(token, _originalIssue.key, remoteWorklog, newEstimate); break; default: remoteWorklog = _jira.RemoteService.AddWorklogAndAutoAdjustRemainingEstimate(token, _originalIssue.key, remoteWorklog); break; } }); return(new Worklog(remoteWorklog)); }
/// <summary> /// Deletes the given worklog from the issue and updates the remaining estimate field. /// </summary> /// <param name="worklog">The worklog to remove.</param> /// <param name="worklogStrategy">How to handle the remaining estimate, defaults to AutoAdjustRemainingEstimate.</param> /// <param name="newEstimate">New estimate (only used if worklogStrategy set to NewRemainingEstimate)</param> /// <param name="token">Cancellation token for this operation.</param> public Task DeleteWorklogAsync(Worklog worklog, WorklogStrategy worklogStrategy = WorklogStrategy.AutoAdjustRemainingEstimate, string newEstimate = null, CancellationToken token = default(CancellationToken)) { if (String.IsNullOrEmpty(_originalIssue.key)) { throw new InvalidOperationException("Unable to delete worklog from issue, issue has not been saved to server."); } return(_jira.Issues.DeleteWorklogAsync(_originalIssue.key, worklog.Id, worklogStrategy, newEstimate, token)); }
/// <summary> /// Converts a Jira Worklog into a JTR JiraWorkLog /// </summary> /// <param name="worklog">An <see cref="Atlassian.Jira.Worklog"/> to convert into <see cref="JiraWorkLog"/></param> /// <returns>A converted <see cref="JiraWorkLog"/></returns> public static JiraWorkLog Convert(this Atlassian.Jira.Worklog worklog) { { var jtrJiraWorklog = new JiraWorkLog { WorkLogId = System.Convert.ToInt32(worklog.Id), Author = worklog.Author, Comment = worklog.Comment, CreateDate = worklog.CreateDate, StartDate = worklog.StartDate, UpdateDate = worklog.UpdateDate, TimeSpent = worklog.TimeSpent, TimeSpentInSeconds = worklog.TimeSpentInSeconds, }; return(jtrJiraWorklog); } }