public void UpdateOutput(bool updateSummary = false) { cbJira.Enabled = WatchTimer.TimeElapsed.TotalMilliseconds == 0 && !WatchTimer.Running; tbTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(WatchTimer.TimeElapsed); if (WatchTimer.Running) { btnStartStop.BackgroundImage = (System.Drawing.Image)(Properties.Resources.pause26); tbTime.BackColor = Color.PaleGreen; } else { btnStartStop.BackgroundImage = (System.Drawing.Image)(Properties.Resources.play26); tbTime.BackColor = SystemColors.Control; } btnOpen.Enabled = cbJira.Text.Trim() != ""; btnReset.Enabled = WatchTimer.Running || WatchTimer.TimeElapsed.Ticks > 0; btnPostAndReset.Enabled = WatchTimer.TimeElapsedNearestMinute.TotalMinutes >= 1 && cbJira.Text.Length != 0; if (updateSummary) { UpdateSummary(); } }
private void UpdateTotalTime() { TimeSpan totalTime = new TimeSpan(); foreach (var issue in this.issueControls) totalTime += issue.WatchTimer.TimeElapsed; tbTotalTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(totalTime); }
public IRestRequest CreatePostWorklogRequest(string key, DateTimeOffset started, TimeSpan time, string comment, EstimateUpdateMethods adjustmentMethod, string adjustmentValue) { var request = restRequestFactory.Create(String.Format("/rest/api/2/issue/{0}/worklog", key.Trim()), Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(new { timeSpent = JiraTimeHelpers.TimeSpanToJiraTime(time), started = JiraTimeHelpers.DateTimeToJiraDateTime(started), comment = comment } ); switch (adjustmentMethod) { case EstimateUpdateMethods.Leave: request.AddQueryParameter("adjustEstimate", "leave"); break; case EstimateUpdateMethods.SetTo: request.AddQueryParameter("adjustEstimate", "new"); request.AddQueryParameter("newEstimate", adjustmentValue); break; case EstimateUpdateMethods.ManualDecrease: request.AddQueryParameter("adjustEstimate", "manual"); request.AddQueryParameter("reduceBy", adjustmentValue); break; case EstimateUpdateMethods.Auto: request.AddQueryParameter("adjustEstimate", "auto"); break; } AddAuthHeader(request); return(request); }
public void UpdateOutput(bool updateSummary = false) { tbTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(WatchTimer.TimeElapsed); 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.TimeElapsedNearestMinute.TotalMinutes >= 1; if (updateSummary) { UpdateSummary(); } }
public EditTimeForm(TimeSpan time) { InitializeComponent(); UpdateTheme(); Time = time; tbTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(Time); }
private void UpdateSummary() { if (cbJira.Text == "") { lblSummary.Text = ""; return; } if (!jiraClient.SessionValid) { lblSummary.Text = ""; return; } Task.Factory.StartNew( () => { string key = ""; Issue issue; Worklogs worklogs; this.InvokeIfRequired( () => key = cbJira.Text ); try { issue = jiraClient.GetIssue(key); this.InvokeIfRequired( () => lblSummary.Text = settings.IncludeProjectName ? issue.Fields.Project.Name + ": " + issue.Fields.Summary : issue.Fields.Summary ); this.InvokeIfRequired( () => lStoryPoints.Text = issue.Fields.StoryPoints.ToString() + " SP" ); } catch (RequestDeniedException) { // just leave the existing summary there when fetch fails } worklogs = jiraClient.GetWorklogs(key); int totalSeconds = 0; foreach (var worklog in worklogs.Items) { if (worklog.Author.EmailAddress == settings.Username) { totalSeconds += worklog.TimeSpentSeconds; } } this.InvokeIfRequired( () => lTotalTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(TimeSpan.FromSeconds(totalSeconds)) ); } ); }
public EditTimeForm(TimeSpan time) { InitializeComponent(); tbTime.BackColor = SystemColors.Window; Time = time; tbTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(Time); }
private bool ValidateTimeInput() { TimeSpan?time = JiraTimeHelpers.JiraTimeToTimeSpan(tbTime.Text); if (time == null) { return(false); } Time = time.Value; return(true); }
public IRestRequest CreatePostWorklogRequest(string key, TimeSpan time, string comment) { var request = restRequestFactory.Create(String.Format("/rest/api/2/issue/{0}/worklog", key), Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(new { timeSpent = JiraTimeHelpers.TimeSpanToJiraTime(time), comment = comment } ); return(request); }
/// <summary> /// Checks if the time entered in the submitted textbox is valid /// Marks it as invalid if it is not /// </summary> /// <param name="tb"></param> /// <returns></returns> private bool ValidateTimeInput(TextBox tb, bool FocusIfInvalid) { bool fieldIsValid; if (tb.Enabled) { if (string.IsNullOrWhiteSpace(tb.Text)) { tb.BackColor = Color.Tomato; if (FocusIfInvalid) { tb.Select(); } fieldIsValid = false; } else { TimeSpan?time = JiraTimeHelpers.JiraTimeToTimeSpan(tb.Text); if (time == null) { tb.BackColor = Color.Tomato; if (FocusIfInvalid) { tb.Select(0, tb.Text.Length); } fieldIsValid = false; } else { tb.BackColor = SystemColors.Window; fieldIsValid = true; } } } else { fieldIsValid = true; } switch (tb.Name) { case "tbSetTo": tbSetToInvalid = !fieldIsValid; break; case "tbReduceBy": tbReduceByInvalid = !fieldIsValid; break; } return(fieldIsValid); }
private string calculatedAdjustedRemainingEstimate() { int AdjustedRemainingSeconds = RemainingEstimateSeconds - (int)Math.Floor(TimeElapsed.TotalSeconds); if (AdjustedRemainingSeconds > 0) { TimeSpan AdjustedRemaining = new TimeSpan(0, 0, AdjustedRemainingSeconds); return(JiraTimeHelpers.TimeSpanToJiraTime(AdjustedRemaining)); } else { return("0m"); } }
public WorklogForm(DateTimeOffset startTime, TimeSpan TimeElapsed, string comment, EstimateUpdateMethods estimateUpdateMethod, string estimateUpdateValue) { this.TimeElapsed = TimeElapsed; DateTimeOffset initialStartTime; if (startTime == null) { initialStartTime = DateTimeOffset.UtcNow.Subtract(TimeElapsed); } else { initialStartTime = startTime; } InitializeComponent(); if (!String.IsNullOrEmpty(comment)) { tbComment.Text = String.Format("{0}{0}{1}", Environment.NewLine, comment); tbComment.SelectionStart = 0; } loggedTimeLabel.Text = JiraTimeHelpers.TimeSpanToJiraTime(TimeElapsed); // I don't see why I need to do this, but the first time I call LocalDateTime it seems to change time zone on the actual Date4TimeOffset // So I don't get the right time. So I call just once and update both from the same object DateTime localInitialStartTime = initialStartTime.LocalDateTime; this.startDatePicker.Value = localInitialStartTime; this.startTimePicker.Value = localInitialStartTime; switch (estimateUpdateMethod) { case EstimateUpdateMethods.Auto: rdEstimateAdjustAuto.Checked = true; break; case EstimateUpdateMethods.Leave: rdEstimateAdjustLeave.Checked = true; break; case EstimateUpdateMethods.SetTo: rdEstimateAdjustSetTo.Checked = true; tbSetTo.Text = estimateUpdateValue; break; case EstimateUpdateMethods.ManualDecrease: rdEstimateAdjustManualDecrease.Checked = true; tbReduceBy.Text = estimateUpdateValue; break; } }
public void UpdateOutput(bool updateSummary = false) { tbTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(WatchTimer.TimeElapsed); if (WatchTimer.Running) { btnStartStop.BackgroundImage = Theme.imgPause; btnStartStop.Image = Theme.imgSpinner; this.BackColor = cbJira.BackColor = cbJira.ButtonColor = cbJira.BorderColor = tbTime.BackColor = btnOpen.ForeColor = btnReset.ForeColor = btnPostAndReset.ForeColor = btnRemoveIssue.ForeColor = btnStartStop.ForeColor = Theme.TimeBackgroundRunning; } else { btnStartStop.BackgroundImage = Theme.imgPlay; btnStartStop.Image = null; this.BackColor = cbJira.BackColor = cbJira.ButtonColor = cbJira.BorderColor = tbTime.BackColor = btnOpen.ForeColor = btnReset.ForeColor = btnPostAndReset.ForeColor = btnRemoveIssue.ForeColor = btnStartStop.ForeColor = this.Current ? Theme.IssueBackgroundSelected : Theme.WindowBackground; } if (string.IsNullOrEmpty(Comment)) { btnPostAndReset.Image = Theme.imgPostTime; } else { btnPostAndReset.Image = Theme.imgPostTimeNote; } btnOpen.Enabled = cbJira.Text.Trim() != ""; btnOpen.BackColor = btnOpen.Enabled ? Theme.ButtonBackground : Theme.ButtonBackgroundDisabled; btnReset.Enabled = WatchTimer.Running || WatchTimer.TimeElapsed.Ticks > 0; btnReset.BackColor = btnReset.Enabled ? Theme.ButtonBackground : Theme.ButtonBackgroundDisabled; btnPostAndReset.Enabled = WatchTimer.TimeElapsedNearestMinute.TotalMinutes >= 1; btnPostAndReset.BackColor = btnPostAndReset.Enabled ? Theme.ButtonBackground : Theme.ButtonBackgroundDisabled; if (updateSummary) { UpdateSummary(); } }
private void tbTime_TextChanged(object sender, EventArgs e) { // Ignore if programatically changing value (from timer) if (ignoreTextChange) { return; } // Validate time input TimeSpan time = JiraTimeHelpers.JiraTimeToTimeSpan(tbTime.Text); if (time.TotalMilliseconds == 0) { return; } TimerState state = WatchTimer.GetState(); state.TotalTime = time; state.StartTime = DateTime.Now; WatchTimer.SetState(state); UpdateOutput(); }
public void UpdateTotalTimeLogged(TimeSpan timeElipsed) { TotalTimeLogged += timeElipsed; tbTotalTimeRecorded.Text = JiraTimeHelpers.TimeSpanToJiraTime(TotalTimeLogged); }
void UpdateBackupTime() { tbBackupTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(backupTimer.TimeElapsedNearestMinute); }