TimeSpanToJiraTime() public static méthode

public static TimeSpanToJiraTime ( System.TimeSpan ts ) : string
ts System.TimeSpan
Résultat string
Exemple #1
0
 private void UpdateTotalTime()
 {
     TimeSpan totalTime = new TimeSpan();
     foreach (var issue in this.issueControls)
         totalTime += issue.WatchTimer.TimeElapsed;
     tbTotalTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(totalTime);
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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 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();
            }
        }
        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);
        }
        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);
        }
        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");
            }
        }
Exemple #10
0
        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;
            }
        }
Exemple #11
0
        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();
            }
        }
        public void UpdateTotalTimeLogged(TimeSpan timeElipsed)
        {
            TotalTimeLogged += timeElipsed;

            tbTotalTimeRecorded.Text = JiraTimeHelpers.TimeSpanToJiraTime(TotalTimeLogged);
        }
Exemple #13
0
 void UpdateBackupTime()
 {
     tbBackupTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(backupTimer.TimeElapsedNearestMinute);
 }