public WorklogForm(TimeSpan TimeElapsed, string comment, EstimateUpdateMethods estimateUpdateMethod, string estimateUpdateValue) { this.TimeElapsed = TimeElapsed; InitializeComponent(); if (!String.IsNullOrEmpty(comment)) { tbComment.Text = String.Format("{0}{0}{1}", Environment.NewLine, comment); tbComment.SelectionStart = 0; } 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 WorklogForm(TimeSpan TimeElapsed, bool AllowManualEstimateAdjustments, string comment, EstimateUpdateMethods estimateUpdateMethod, string estimateUpdateValue) { this.AllowManualEstimateAdjustments = AllowManualEstimateAdjustments; this.TimeElapsed = TimeElapsed; InitializeComponent(); if (!String.IsNullOrEmpty(comment)) { tbComment.Text = String.Format("{0}{0}{1}", Environment.NewLine, comment); tbComment.SelectionStart = 0; } if (this.AllowManualEstimateAdjustments) { this.gbRemainingEstimate.Visible = true; 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; } } else { this.lblInfo.Location = new Point( this.lblInfo.Location.X, this.lblInfo.Location.Y - this.gbRemainingEstimate.Height ); this.btnSave.Location = new Point( this.btnSave.Location.X, this.btnSave.Location.Y - this.gbRemainingEstimate.Height ); this.btnOk.Location = new Point( this.btnOk.Location.X, this.btnOk.Location.Y - this.gbRemainingEstimate.Height ); this.btnCancel.Location = new Point( this.btnCancel.Location.X, this.btnCancel.Location.Y - this.gbRemainingEstimate.Height ); this.Height -= this.gbRemainingEstimate.Height; } }
public bool PostWorklog(string key, TimeSpan time, string comment, EstimateUpdateMethods estimateUpdateMethod, string estimateUpdateValue) { var started = DateTimeOffset.UtcNow.Subtract(time); var request = jiraApiRequestFactory.CreatePostWorklogRequest(key, started, time, comment, estimateUpdateMethod, estimateUpdateValue); try { jiraApiRequester.DoAuthenticatedRequest <object>(request); return(true); } catch (RequestDeniedException) { return(false); } }
private void PostAndReset(string key, TimeSpan timeElapsed, string comment, EstimateUpdateMethods estimateUpdateMethod, string estimateUpdateValue) { Task.Factory.StartNew( () => { this.InvokeIfRequired( () => { btnPostAndReset.Enabled = false; Cursor.Current = Cursors.WaitCursor; } ); bool postSuccesful = true; // First post comment in Comment-track - and clear the comment string, if it should only be posted here // Only actually post in Comment-track if text is not empty if (settings.PostWorklogComment != WorklogCommentSetting.WorklogOnly && !string.IsNullOrEmpty(comment)) { postSuccesful = jiraClient.PostComment(key, comment); if (postSuccesful && settings.PostWorklogComment == WorklogCommentSetting.CommentOnly) { comment = ""; } } // Now post the WorkLog with timeElapsed - and comment unless it was reset if (postSuccesful) { postSuccesful = jiraClient.PostWorklog(key, timeElapsed, comment, estimateUpdateMethod, estimateUpdateValue); } if (postSuccesful) { this.InvokeIfRequired( () => Reset() ); } this.InvokeIfRequired( () => { btnPostAndReset.Enabled = true; Cursor.Current = DefaultCursor; } ); } ); }
private void estimateUpdateMethod_changed(object sender, EventArgs e) { RadioButton button = sender as RadioButton; if (button != null && button.Checked) { switch (button.Name) { case "rdEstimateAdjustAuto": this._estimateUpdateMethod = EstimateUpdateMethods.Auto; this.tbSetTo.Enabled = false; this.tbSetTo.BackColor = SystemColors.Window; this.tbReduceBy.Enabled = false; this.tbReduceBy.BackColor = SystemColors.Window; break; case "rdEstimateAdjustLeave": this._estimateUpdateMethod = EstimateUpdateMethods.Leave; this.tbSetTo.Enabled = false; this.tbSetTo.BackColor = SystemColors.Window; this.tbReduceBy.Enabled = false; this.tbReduceBy.BackColor = SystemColors.Window; break; case "rdEstimateAdjustSetTo": this._estimateUpdateMethod = EstimateUpdateMethods.SetTo; this.tbSetTo.Enabled = true; this.tbReduceBy.Enabled = false; this.tbReduceBy.BackColor = SystemColors.Window; break; case "rdEstimateAdjustManualDecrease": this._estimateUpdateMethod = EstimateUpdateMethods.ManualDecrease; this.tbSetTo.Enabled = false; this.tbSetTo.BackColor = SystemColors.Window; this.tbReduceBy.Enabled = true; break; } } }
private void PostAndReset(string key, TimeSpan timeElapsed, string comment, EstimateUpdateMethods estimateUpdateMethod, string estimateUpdateValue) { Task.Factory.StartNew( () => { this.InvokeIfRequired( () => { btnPostAndReset.Enabled = false; Cursor.Current = Cursors.WaitCursor; } ); bool postSuccesful = true; // First post comment in Comment-track - and clear the comment string, if it should only be posted here // Only actually post in Comment-track if text is not empty if (settings.PostWorklogComment != WorklogCommentSetting.WorklogOnly && !string.IsNullOrEmpty(comment)) { postSuccesful = jiraClient.PostComment(key, comment); if (postSuccesful && settings.PostWorklogComment == WorklogCommentSetting.CommentOnly) comment = ""; } // Now post the WorkLog with timeElapsed - and comment unless it was reset if (postSuccesful) postSuccesful = jiraClient.PostWorklog(key, timeElapsed, comment, estimateUpdateMethod, estimateUpdateValue); if (postSuccesful) { this.InvokeIfRequired( () => Reset() ); } this.InvokeIfRequired( () => { btnPostAndReset.Enabled = true; Cursor.Current = DefaultCursor; } ); } ); }
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 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; } // 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 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; } return request; }