public JiraIssueDisplayModel(Issue issue)
 {
     Reference = issue.key;
     Description = issue.fields.summary;
     if (issue.fields.parent != null)
     {
         ParentReference = issue.fields.parent.key;
         ParentDescription = issue.fields.parent.fields.summary;
     }
 }
        private RecentJira BuildRecentJira(Issue jiraIssue)
        {
            string jiraParentReference = string.Empty, jiraParentName = string.Empty;
            var jiraReference = jiraIssue.key;
            var jiraProjectName = jiraIssue.fields.project.key;
            var jiraName = jiraIssue.fields.summary;

            if (jiraIssue.fields.parent != null)
            {
                jiraParentReference = jiraIssue.fields.parent.key;
                jiraParentName = jiraIssue.fields.parent.fields.summary;
            }

            return new RecentJira(jiraReference, jiraProjectName, jiraName, jiraParentReference, jiraParentName, DateTime.Now);
        }
Ejemplo n.º 3
0
 public JiraTimer(Issue jiraIssue, DateTime dateStarted, TimeSpan currentTime)
 {
     JiraReference = jiraIssue.key;
     JiraProjectName = jiraIssue.fields.project.key;
     JiraName = jiraIssue.fields.summary;
     if (jiraIssue.fields.parent != null)
     {
         JiraParentReference = jiraIssue.fields.parent.key;
         JiraParentName = jiraIssue.fields.parent.fields.summary;
     }
     DateStarted = dateStarted;
     CurrentTime = currentTime;
     ExportedTime = new TimeSpan();
     UniqueId = Guid.NewGuid();
     IsRunning = false;
     currentRunningTime = new Stopwatch();
     runningWatcher = new Timer(100);
     runningWatcher.Elapsed += runningWatcherElapsed;
 }
Ejemplo n.º 4
0
        public void RefreshFromJira(Issue jiraIssue, User currentUser)
        {
            if (jiraIssue == null) return;

            SetJiraExportedTime(jiraIssue.GetCurrentLoggedTimeForDate(DateStarted, currentUser));
            JiraReference = jiraIssue.key;
            JiraProjectName = jiraIssue.fields.project.key;
            JiraName = jiraIssue.fields.summary;
            if (jiraIssue.fields.parent != null)
            {
                JiraParentReference = jiraIssue.fields.parent.key;
                JiraParentName = jiraIssue.fields.parent.fields.summary;
            }
            else
            {
                JiraParentReference = string.Empty;
                JiraParentName = string.Empty;
            }

            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("ExactCurrentTime"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("TimeToExport"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("JiraReference"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("JiraProjectName"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("JiraName"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("JiraParentReference"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("JiraParentName"));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("HasParent"));
        }
Ejemplo n.º 5
0
        public void UpdateTimer(JiraTimer timer, Issue jiraIssue)
        {
            UpdateTimer(timer, ToExportMaxTime);

            OriginalRemaining = jiraIssue.fields.timetracking != null ? TimeSpan.FromSeconds(jiraIssue.fields.timetracking.remainingEstimateSeconds) : new TimeSpan();

            SetRemaining();
        }
Ejemplo n.º 6
0
        public Guid RenameTimer(Guid timerGuid, Issue newIssue)
        {
            var currentTimer = GetTimer(timerGuid);
            if (currentTimer.IsRunning) currentTimer.StopTimer();
            var newTimer = new JiraTimer(newIssue, currentTimer.DateStarted, currentTimer.ExactCurrentTime);

            var timerSearch = timerList.FirstOrDefault(timer => timer.JiraReference == newTimer.JiraReference && timer.DateStarted.Date == newTimer.DateStarted.Date);

            if (timerSearch != null)
            {
                throw new DuplicateTimerException("Already have a timer for this task on this day!", timerSearch.UniqueId);
            }

            RemoveTimerInternal(timerGuid);
            AddTimer(newTimer);
            SaveTimers();
            return newTimer.UniqueId;
        }
Ejemplo n.º 7
0
 public void RefreshFromJira(Guid uniqueId, Issue jiraIssue, User currentUser)
 {
     var timer = GetTimer(uniqueId);
     if (timer != null)
     {
         timer.RefreshFromJira(jiraIssue);
         timer.UpdateExportTimeFromJira(jiraIssue, currentUser);
         SaveTimers();
     }
 }
Ejemplo n.º 8
0
 public Guid AddTimer(Issue jiraIssue, DateTime startDate, TimeSpan seedTime, bool startNow)
 {
     var newTimer = new JiraTimer(jiraIssue, startDate, seedTime);
     AddTimer(newTimer);
     if (startNow)
     {
         StartTimer(newTimer.UniqueId);
     }
     else
     {
         if (exportSettings.ExportPrompt != null && exportSettings.ExportPrompt.OnCreatePreloaded && !newTimer.FullyExported && !newTimer.LocalTimer)
         {
             exportPrompt?.Invoke(this, new ExportPromptDetail(newTimer.UniqueId, seedTime));
         }
     }
     return newTimer.UniqueId;
 }
Ejemplo n.º 9
0
        public void UpdateExportTimeFromJira(Issue jiraIssue, User currentUser)
        {
            if (jiraIssue == null) return;

            LocalTimer = false;

            SetJiraExportedTime(jiraIssue.GetCurrentLoggedTimeForDate(DateStarted, currentUser));

            LastJiraTimeCheck = DateTime.UtcNow;

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ExactCurrentTime"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TimeToExport"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LastJiraTimeCheck"));
        }
Ejemplo n.º 10
0
 internal JiraSearchResult(Issue issue)
 {
     JiraRef = issue.key;
     JiraDesc = issue.fields.summary;
     if (issue.fields.parent != null)
     {
         ParentJiraRef = issue.fields.parent.key;
         ParentJiraDesc = issue.fields.parent.fields.summary;
     }
 }
Ejemplo n.º 11
0
 public void AddRecentJira(Issue jiraIssue)
 {
     AddRecentJiras(new [] {jiraIssue});
 }
Ejemplo n.º 12
0
 public void RefreshFromJira(Guid uniqueId, Issue jiraIssue, User currentUser)
 {
     var timer = GetTimer(uniqueId);
     timer.RefreshFromJira(jiraIssue, currentUser);
     SaveTimers();
 }
Ejemplo n.º 13
0
        private bool TryReopenJira(Issue jiraIssue)
        {
            var wasClosed = false;
            if (jiraIssue.fields.status.name == "Closed")
            {
                try
                {
                    var inProgressStatuses = new List<string>
                    {
                        "Reopen Issue",
                        "Open"
                    };

                    TransitionIssue(jiraIssue.key, inProgressStatuses);
                    wasClosed = true;
                }
                catch (Exception)
                {
                    wasClosed = false;
                }
            }
            return wasClosed;
        }
Ejemplo n.º 14
0
        public ExportTimerWindow(IBackend gallifrey, Guid timerGuid)
        {
            DisplayForm = true;
            this.gallifrey = gallifrey;
            timerToShow = gallifrey.JiraTimerCollection.GetTimer(timerGuid);
            InitializeComponent();

            try
            {
                jiraIssue = gallifrey.JiraConnection.GetJiraIssue(timerToShow.JiraReference, true);
            }
            catch (NoResultsFoundException)
            {
                MessageBox.Show(string.Format("Unable To Locate Jira {0}!\nCannot Export Time\nPlease Verify/Correct Jira Reference", timerToShow.JiraReference), "Unable To Locate Jira", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DisplayForm = false;
            }

            gallifrey.JiraTimerCollection.RefreshFromJira(timerGuid, jiraIssue, gallifrey.JiraConnection.CurrentUser);

            timerToShow = gallifrey.JiraTimerCollection.GetTimer(timerGuid);

            if (timerToShow.FullyExported)
            {
                MessageBox.Show("There Is No Time To Export", "Nothing To Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DisplayForm = false;
            }

            txtJiraRef.Text = timerToShow.JiraReference;
            txtDescription.Text = timerToShow.JiraName;
            if (timerToShow.HasParent)
            {
                txtParentRef.Text = timerToShow.JiraParentReference;
                txtParentDesc.Text = timerToShow.JiraParentName;
            }
            else
            {
                txtParentRef.Visible = false;
                txtParentDesc.Visible = false;
                lblParentRef.Visible = false;
                lblParentDesc.Visible = false;
            }

            txtTotalHours.Text = timerToShow.ExactCurrentTime.Hours.ToString();
            txtTotalMinutes.Text = timerToShow.ExactCurrentTime.Minutes.ToString();
            txtExportedHours.Text = timerToShow.ExportedTime.Hours.ToString();
            txtExportedMins.Text = timerToShow.ExportedTime.Minutes.ToString();
            txtExportHours.Text = timerToShow.TimeToExport.Hours.ToString();
            txtExportMins.Text = timerToShow.TimeToExport.Minutes.ToString();

            if (jiraIssue.fields.timetracking == null)
            {
                txtRemainingHours.Text = "N/A";
                txtRemainingMinutes.Text = "N/A";
            }
            else
            {
                var remainingTime = jiraIssue.fields.timetracking != null ? TimeSpan.FromSeconds(jiraIssue.fields.timetracking.remainingEstimateSeconds) : new TimeSpan();
                var hours = (remainingTime.Days * 24) + remainingTime.Hours;
                txtRemainingHours.Text = hours.ToString();
                txtRemainingMinutes.Text = remainingTime.Minutes.ToString();
            }

            if (timerToShow.DateStarted.Date != DateTime.Now.Date)
            {
                calExportDate.Value = timerToShow.DateStarted.Date.AddHours(12);
            }
            else
            {
                calExportDate.Value = DateTime.Now;
            }

            radAutoAdjust.Checked = gallifrey.Settings.ExportSettings.DefaultRemainingValue == DefaultRemaining.Auto;
            radLeaveRemaining.Checked = gallifrey.Settings.ExportSettings.DefaultRemainingValue == DefaultRemaining.Leave;
            radSetValue.Checked = gallifrey.Settings.ExportSettings.DefaultRemainingValue == DefaultRemaining.Set;
            radSetValue_CheckedChanged(this, null);

            TopMost = gallifrey.Settings.UiSettings.AlwaysOnTop;

            txtComment.AltEnterEvent += btnOK_Click;
        }
Ejemplo n.º 15
0
 public JiraTimer(Issue jiraIssue, DateTime dateStarted, TimeSpan currentTime)
     : this(jiraIssue.key, jiraIssue.fields.project.key, jiraIssue.fields.summary, dateStarted, currentTime, new TimeSpan(), Guid.NewGuid(), jiraIssue.fields.parent == null ? string.Empty : jiraIssue.fields.parent.key, jiraIssue.fields.parent == null ? string.Empty : jiraIssue.fields.parent.fields.summary, null, false)
 {
 }
Ejemplo n.º 16
0
        private async Task<bool> AddPeriodTimer(Issue jiraIssue, TimeSpan seedTime)
        {
            var workingDate = DataModel.StartDate.Value;


            while (workingDate <= DataModel.EndDate.Value)
            {
                var addTimer = true;
                if (!modelHelpers.Gallifrey.Settings.AppSettings.ExportDays.Contains(workingDate.DayOfWeek))
                {
                    var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Add For Non-Working Day?", $"The Date {workingDate.ToString("ddd, dd MMM")} Is Not A Working Day.\nWould You Still Like To Add A Timer For This Date?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative });

                    if (result == MessageDialogResult.Negative)
                    {
                        addTimer = false;
                    }
                }

                if (addTimer)
                {
                    var added = await AddSingleTimer(jiraIssue, seedTime, workingDate);
                    if (!added && workingDate < DataModel.EndDate.Value)
                    {
                        var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Continue Adding?", $"The Timer For {workingDate.ToString("ddd, dd MMM")} Was Not Added.\nWould You Like To Carry On Adding For The Remaining Dates?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative });

                        if (result == MessageDialogResult.Negative)
                        {
                            return false;
                        }
                    }
                }

                workingDate = workingDate.AddDays(1);
            }

            return true;
        }
Ejemplo n.º 17
0
        private async Task<bool> AddSingleTimer(Issue jiraIssue, TimeSpan seedTime, DateTime startDate)
        {
            try
            {
                if (DataModel.LocalTimer)
                {
                    NewTimerId = modelHelpers.Gallifrey.JiraTimerCollection.AddLocalTimer(DataModel.LocalTimerDescription, startDate, seedTime, DataModel.StartNow);
                }
                else
                {
                    NewTimerId = modelHelpers.Gallifrey.JiraTimerCollection.AddTimer(jiraIssue, startDate, seedTime, DataModel.StartNow);
                }
                AddedTimer = true;
                if (!DataModel.TimeEditable)
                {
                    modelHelpers.Gallifrey.JiraTimerCollection.AddIdleTimer(NewTimerId, DataModel.IdleTimers);
                }
            }
            catch (DuplicateTimerException ex)
            {
                var doneSomething = false;
                if (seedTime.TotalMinutes > 0 || !DataModel.TimeEditable)
                {
                    var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Duplicate Timer", $"The Timer Already Exists On {DataModel.StartDate.Value.ToString("ddd, dd MMM")}, Would You Like To Add The Time?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative });

                    if (result == MessageDialogResult.Affirmative)
                    {
                        if (DataModel.TimeEditable)
                        {
                            modelHelpers.Gallifrey.JiraTimerCollection.AdjustTime(ex.TimerId, seedTime.Hours, seedTime.Minutes, true);
                        }
                        else
                        {
                            modelHelpers.Gallifrey.JiraTimerCollection.AddIdleTimer(ex.TimerId, DataModel.IdleTimers);
                        }

                        doneSomething = true;
                    }
                    else
                    {
                        return false;
                    }
                }

                if (DataModel.StartNow)
                {
                    modelHelpers.Gallifrey.JiraTimerCollection.StartTimer(ex.TimerId);
                    doneSomething = true;
                }

                if (!doneSomething)
                {
                    await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Duplicate Timer", "This Timer Already Exists!");
                    return false;
                }

                NewTimerId = ex.TimerId;
            }

            return true;
        }
Ejemplo n.º 18
0
        public void RefreshFromJira(Issue jiraIssue)
        {
            if (jiraIssue == null) return;

            LocalTimer = false;

            JiraReference = jiraIssue.key;
            JiraProjectName = jiraIssue.fields.project.key;
            JiraName = jiraIssue.fields.summary;
            if (jiraIssue.fields.parent != null)
            {
                JiraParentReference = jiraIssue.fields.parent.key;
                JiraParentName = jiraIssue.fields.parent.fields.summary;
            }
            else
            {
                JiraParentReference = string.Empty;
                JiraParentName = string.Empty;
            }

            LastJiraTimeCheck = DateTime.UtcNow;

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("JiraReference"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("JiraProjectName"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("JiraName"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("JiraParentReference"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("JiraParentName"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("HasParent"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LastJiraTimeCheck"));
        }