public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan? remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); var postData = new Dictionary<string, object> { { "started", $"{logDate.ToString("yyyy-MM-ddTHH:mm:ss.fff")}{logDate.ToString("zzz").Replace(":", "")}"}, { "comment", comment }, { "timeSpent", $"{timeSpent.Hours}h {timeSpent.Minutes}m"}, }; var adjustmentMethod = string.Empty; var newEstimate = string.Empty; if (remainingTime.HasValue) { newEstimate = $"{remainingTime.Value.Hours}h {remainingTime.Value.Minutes}m"; } switch (workLogStrategy) { case WorkLogStrategy.Automatic: adjustmentMethod = "auto"; break; case WorkLogStrategy.LeaveRemaining: adjustmentMethod = "leave"; break; case WorkLogStrategy.SetValue: adjustmentMethod = "new"; break; } restClient.Post(HttpStatusCode.Created, $"issue/{issueRef}/worklog?adjustEstimate={adjustmentMethod}&newEstimate={newEstimate}&reduceBy=", postData); }
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan? remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); var issue = client.GetIssue(issueRef); var worklog = new Worklog(string.Format("{0}h {1}m", timeSpent.Hours, timeSpent.Minutes), logDate, comment); string remaining = null; if (remainingTime.HasValue) { remaining = string.Format("{0}h {1}m", remainingTime.Value.Hours, remainingTime.Value.Minutes); } WorklogStrategy strategy; switch (workLogStrategy) { case WorkLogStrategy.Automatic: strategy = WorklogStrategy.AutoAdjustRemainingEstimate; break; case WorkLogStrategy.LeaveRemaining: strategy = WorklogStrategy.RetainRemainingEstimate; break; case WorkLogStrategy.SetValue: strategy = WorklogStrategy.NewRemainingEstimate; break; default: strategy = WorklogStrategy.RetainRemainingEstimate; break; } issue.AddWorklog(worklog, strategy, remaining); }
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan? remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); var postData = new Dictionary<string, object> { { "started", string.Format("{0}{1}", logDate.ToString("yyyy-MM-ddTHH:mm:ss.fff"), logDate.ToString("zzz").Replace(":","")) }, { "comment", comment }, { "timeSpent", string.Format("{0}h {1}m", timeSpent.Hours, timeSpent.Minutes) }, }; var adjustmentMethod = string.Empty; var newEstimate = string.Empty; if (remainingTime.HasValue) { newEstimate = string.Format("{0}h {1}m", remainingTime.Value.Hours, remainingTime.Value.Minutes); } switch (workLogStrategy) { case WorkLogStrategy.Automatic: adjustmentMethod = "auto"; break; case WorkLogStrategy.LeaveRemaining: adjustmentMethod = "leave"; break; case WorkLogStrategy.SetValue: adjustmentMethod = "new"; break; } ExectuteRequest(Method.POST, HttpStatusCode.Created, string.Format("issue/{0}/worklog?adjustEstimate={1}&newEstimate={2}&reduceBy=", issueRef, adjustmentMethod, newEstimate), postData); }
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan?remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) { logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); } timeSpent = new TimeSpan(timeSpent.Hours, timeSpent.Minutes, 0); if (tempoClient != null) { if (string.IsNullOrWhiteSpace(comment)) { comment = "N/A"; } var remaining = 0d; switch (workLogStrategy) { case WorkLogStrategy.Automatic: remaining = GetIssue(issueRef).fields.timetracking.remainingEstimateSeconds - timeSpent.TotalSeconds; if (remaining < 0) { remaining = 0; } break; case WorkLogStrategy.LeaveRemaining: remaining = GetIssue(issueRef).fields.timetracking.remainingEstimateSeconds; break; case WorkLogStrategy.SetValue: remaining = remainingTime?.TotalSeconds ?? 0; break; } var tempoWorkLog = new TempoWorkLogUpload { issueKey = issueRef, timeSpentSeconds = timeSpent.TotalSeconds, startDate = $"{logDate:yyyy-MM-dd}", startTime = $"{logDate:hh:mm:ss}", description = comment, authorAccountId = myUser.accountId, remainingEstimateSeconds = remaining }; tempoClient.Post(HttpStatusCode.OK, "worklogs", tempoWorkLog); } else { var postData = new Dictionary <string, object> { { "started", $"{logDate:yyyy-MM-ddTHH:mm:ss.fff}{logDate.ToString("zzz").Replace(":", "")}" },
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan?remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) { logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); } var issue = client.GetIssue(issueRef); var worklog = new Worklog($"{timeSpent.Hours}h {timeSpent.Minutes}m", logDate, comment); string remaining = null; if (remainingTime.HasValue) { remaining = $"{remainingTime.Value.Hours}h {remainingTime.Value.Minutes}m"; } WorklogStrategy strategy; switch (workLogStrategy) { case WorkLogStrategy.Automatic: strategy = WorklogStrategy.AutoAdjustRemainingEstimate; break; case WorkLogStrategy.LeaveRemaining: strategy = WorklogStrategy.RetainRemainingEstimate; break; case WorkLogStrategy.SetValue: strategy = WorklogStrategy.NewRemainingEstimate; break; default: strategy = WorklogStrategy.RetainRemainingEstimate; break; } issue.AddWorklog(worklog, strategy, remaining); }
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan?remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) { logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); } var postData = new Dictionary <string, object> { { "started", $"{logDate.ToString("yyyy-MM-ddTHH:mm:ss.fff")}{logDate.ToString("zzz").Replace(":", "")}" }, { "comment", comment }, { "timeSpent", $"{timeSpent.Hours}h {timeSpent.Minutes}m" }, }; var adjustmentMethod = string.Empty; var newEstimate = string.Empty; if (remainingTime.HasValue) { newEstimate = $"{remainingTime.Value.Hours}h {remainingTime.Value.Minutes}m"; } switch (workLogStrategy) { case WorkLogStrategy.Automatic: adjustmentMethod = "auto"; break; case WorkLogStrategy.LeaveRemaining: adjustmentMethod = "leave"; break; case WorkLogStrategy.SetValue: adjustmentMethod = "new"; break; } ExecuteRequest(Method.POST, HttpStatusCode.Created, $"issue/{issueRef}/worklog?adjustEstimate={adjustmentMethod}&newEstimate={newEstimate}&reduceBy=", postData); }
public ExportModel(JiraTimer timer, TimeSpan?exportTime, IExportSettings exportSettings) { UpdateTimer(timer, exportTime); ExportDate = timer.DateStarted.Date != DateTime.Now.Date ? timer.DateStarted.Date.AddHours(12) : DateTime.Now; switch (exportSettings.DefaultRemainingValue) { case DefaultRemaining.Auto: WorkLogStrategy = WorkLogStrategy.Automatic; break; case DefaultRemaining.Leave: WorkLogStrategy = WorkLogStrategy.LeaveRemaining; break; case DefaultRemaining.Set: WorkLogStrategy = WorkLogStrategy.SetValue; break; } DefaultComment = exportSettings.EmptyExportComment; }
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan?remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) { logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); } timeSpent = new TimeSpan(timeSpent.Hours, timeSpent.Minutes, 0); if (HasTempo) { if (string.IsNullOrWhiteSpace(comment)) { comment = "N/A"; } var issue = new TempoWorkLog.TempoWorkLogIssue(); switch (workLogStrategy) { case WorkLogStrategy.Automatic: var remaining = GetIssue(issueRef).fields.timetracking.remainingEstimateSeconds - timeSpent.TotalSeconds; issue = new TempoWorkLog.TempoWorkLogIssue { key = issueRef, remainingEstimateSeconds = remaining }; break; case WorkLogStrategy.LeaveRemaining: issue = new TempoWorkLog.TempoWorkLogIssue { key = issueRef }; break; case WorkLogStrategy.SetValue: issue = new TempoWorkLog.TempoWorkLogIssue { key = issueRef, remainingEstimateSeconds = remainingTime?.TotalSeconds ?? 0 }; break; } var tempoWorkLog = new TempoWorkLog { issue = issue, timeSpentSeconds = timeSpent.TotalSeconds, dateStarted = $"{logDate:s}.000", comment = comment, author = new TempoWorkLog.TempoWorkLogUser { key = myUser.key, name = myUser.name } }; restClient.Post(HttpStatusCode.OK, "tempo-timesheets/3/worklogs", tempoWorkLog); } else { var postData = new Dictionary <string, object> { { "started", $"{logDate.ToString("yyyy-MM-ddTHH:mm:ss.fff")}{logDate.ToString("zzz").Replace(":", "")}" }, { "comment", comment }, { "timeSpent", $"{timeSpent.Hours}h {timeSpent.Minutes}m" }, }; var adjustmentMethod = string.Empty; var newEstimate = string.Empty; if (remainingTime.HasValue) { newEstimate = $"{remainingTime.Value.Hours}h {remainingTime.Value.Minutes}m"; } switch (workLogStrategy) { case WorkLogStrategy.Automatic: adjustmentMethod = "auto"; break; case WorkLogStrategy.LeaveRemaining: adjustmentMethod = "leave"; break; case WorkLogStrategy.SetValue: adjustmentMethod = "new"; break; } restClient.Post(HttpStatusCode.Created, $"api/2/issue/{issueRef}/worklog?adjustEstimate={adjustmentMethod}&newEstimate={newEstimate}&reduceBy=", postData); } }
private static WorklogStrategy GetJiraWorkLogStrategy(WorkLogStrategy strategy) => strategy switch {
public void LogTime(string jiraRef, DateTime exportTimeStamp, TimeSpan exportTime, WorkLogStrategy strategy, bool addStandardComment, string comment = "", TimeSpan? remainingTime = null) { trackUsage.TrackAppUsage(TrackingType.ExportOccured); if (string.IsNullOrWhiteSpace(comment)) comment = exportSettings.EmptyExportComment; if (!string.IsNullOrWhiteSpace(exportSettings.ExportCommentPrefix)) { comment = $"{exportSettings.ExportCommentPrefix}: {comment}"; } try { jira.AddWorkLog(jiraRef, strategy, comment, exportTime, DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), remainingTime); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (addStandardComment) { try { jira.AddComment(jiraRef, comment); } catch (Exception ex) { throw new CommentException("Comment was not added", ex); } } }
public void LogTime(string jiraRef, DateTime exportTimeStamp, TimeSpan exportTime, WorkLogStrategy strategy, bool addStandardComment, string comment = "", TimeSpan?remainingTime = null) { trackUsage.TrackAppUsage(TrackingType.ExportOccured); if (string.IsNullOrWhiteSpace(comment)) { comment = exportSettings.EmptyExportComment; } if (!string.IsNullOrWhiteSpace(exportSettings.ExportCommentPrefix)) { comment = $"{exportSettings.ExportCommentPrefix}: {comment}"; } try { jira.AddWorkLog(jiraRef, strategy, comment, exportTime, DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), remainingTime); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (addStandardComment) { try { jira.AddComment(jiraRef, comment); } catch (Exception ex) { throw new CommentException("Comment was not added", ex); } } }
public void LogTime(string jiraRef, DateTime exportTimeStamp, TimeSpan exportTime, WorkLogStrategy strategy, string comment = "", TimeSpan?remainingTime = null) { trackUsage.TrackAppUsage(TrackingType.ExportOccured); var jiraIssue = jira.GetIssue(jiraRef); var wasClosed = TryReopenJira(jiraIssue); if (string.IsNullOrWhiteSpace(comment)) { comment = exportSettings.EmptyExportComment; } if (!string.IsNullOrWhiteSpace(exportSettings.ExportCommentPrefix)) { comment = string.Format("{0}: {1}", exportSettings.ExportCommentPrefix, comment); } try { jira.AddWorkLog(jiraRef, strategy, comment, exportTime, DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), remainingTime); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (wasClosed) { try { ReCloseJira(jiraRef); } catch (Exception ex) { throw new StateChangedException("Time Logged, but state is now open", ex); } } }
public void LogTime(string jiraRef, DateTime exportTimeStamp, TimeSpan exportTime, WorkLogStrategy strategy, bool addStandardComment, string comment = "", TimeSpan?remainingTime = null) { trackUsage.TrackAppUsage(TrackingType.ExportOccured); var jiraIssue = jira.GetIssue(jiraRef); if (string.IsNullOrWhiteSpace(comment)) { comment = exportSettings.EmptyExportComment; } if (!string.IsNullOrWhiteSpace(exportSettings.ExportCommentPrefix)) { comment = $"{exportSettings.ExportCommentPrefix}: {comment}"; } var erroredOnWorkLogAttempt1 = false; try { jira.AddWorkLog(jiraRef, strategy, comment, exportTime, DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), remainingTime); } catch (Exception) { erroredOnWorkLogAttempt1 = true; } if (erroredOnWorkLogAttempt1) { var wasClosed = TryReopenJira(jiraIssue); try { jira.AddWorkLog(jiraRef, strategy, comment, exportTime, DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), remainingTime); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (wasClosed) { try { ReCloseJira(jiraRef); } catch (Exception ex) { throw new StateChangedException("Time Logged, but state is now open", ex); } } } if (addStandardComment) { try { jira.AddComment(jiraRef, comment); } catch (Exception ex) { throw new CommentException("Comment was not added", ex); } } }
public void LogTime(string jiraRef, DateTime exportTimeStamp, TimeSpan exportTime, WorkLogStrategy strategy, string comment = "", TimeSpan? remainingTime = null) { trackUsage.TrackAppUsage(TrackingType.ExportOccured); var jiraIssue = jira.GetIssue(jiraRef); var wasClosed = TryReopenJira(jiraIssue); if (string.IsNullOrWhiteSpace(comment)) comment = exportSettings.EmptyExportComment; if (!string.IsNullOrWhiteSpace(exportSettings.ExportCommentPrefix)) { comment = string.Format("{0}: {1}", exportSettings.ExportCommentPrefix, comment); } try { jira.AddWorkLog(jiraRef, strategy, comment, exportTime, DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), remainingTime); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (wasClosed) { try { ReCloseJira(jiraRef); } catch (Exception ex) { throw new StateChangedException("Time Logged, but state is now open", ex); } } }