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); 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); } } }