public void UpdateOutput(bool updateSummary = false) { ignoreTextChange = true; tbTime.Text = JiraHelpers.TimeSpanToJiraTime(WatchTimer.TimeElapsed); ignoreTextChange = false; if (WatchTimer.Running) { btnStartStop.Image = (System.Drawing.Image)(Properties.Resources.pause26); tbTime.BackColor = Color.PaleGreen; } else { btnStartStop.Image = (System.Drawing.Image)(Properties.Resources.play26); tbTime.BackColor = SystemColors.Control; } if (string.IsNullOrEmpty(Comment)) { btnPostAndReset.Image = (System.Drawing.Image)Properties.Resources.posttime26; } else { btnPostAndReset.Image = (System.Drawing.Image)Properties.Resources.posttimenote26; } btnOpen.Enabled = cbJira.Text.Trim() != ""; btnReset.Enabled = WatchTimer.Running || WatchTimer.TimeElapsed.Ticks > 0; btnPostAndReset.Enabled = WatchTimer.TimeElapsed.TotalMinutes >= 1; if (updateSummary) { UpdateSummary(); } }
public bool PostWorklog(string key, TimeSpan time, string comment) { if (string.IsNullOrEmpty(this.BaseUrl)) { return(false); } var client = GetClient(); var request = new RestRequest(String.Format("/rest/api/2/issue/{0}/worklog", key), Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(new { timeSpent = JiraHelpers.TimeSpanToJiraTime(time), comment = comment } ); IRestResponse response; response = client.Execute(request); // If login session has expired, try to login, and then re-execute the original request if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { if (!ReAuthenticate()) { return(false); } response = client.Execute(request); } if (response.StatusCode != System.Net.HttpStatusCode.Created) { return(false); } return(true); }
private void tbTime_TextChanged(object sender, EventArgs e) { // Ignore if programatically changing value (from timer) if (ignoreTextChange) { return; } TimeSpan time = JiraHelpers.JiraTimeToTimeSpan(tbTime.Text); if (time.TotalMilliseconds == 0) { return; } TimerState state = WatchTimer.GetState(); state.TotalTime = time; state.StartTime = DateTime.Now; WatchTimer.SetState(state); }