コード例 #1
0
        private string getTotalTimeText(MergeRequestKey key, User author)
        {
            ITotalTimeCache totalTimeCache = _dataCache?.TotalTimeCache;

            if (totalTimeCache == null)
            {
                return(String.Empty);
            }

            User currentUser           = _getCurrentUser(key.ProjectKey.HostName);
            bool isTimeTrackingAllowed = TimeTrackingHelpers.IsTimeTrackingAllowed(
                author, key.ProjectKey.HostName, currentUser);

            return(TimeTrackingHelpers.ConvertTotalTimeToText(totalTimeCache.GetTotalTime(key), isTimeTrackingAllowed));
        }
コード例 #2
0
        private void onTrackedTimeManagerEvent(ITotalTimeCache totalTimeCache, MergeRequestKey mrk)
        {
            MergeRequestKey?currentMergeRequestKey = getMergeRequestKey(null);

            if (currentMergeRequestKey.HasValue && currentMergeRequestKey.Value.Equals(mrk))
            {
                MergeRequest currentMergeRequest = getMergeRequest(null);
                if (currentMergeRequest != null)
                {
                    // change control enabled state
                    updateTotalTime(currentMergeRequestKey,
                                    currentMergeRequest.Author, currentMergeRequestKey.Value.ProjectKey.HostName, totalTimeCache);
                }
            }

            // Update total time column in the table
            listViewMergeRequests.Invalidate();
        }
コード例 #3
0
        private void onTrackedTimeManagerEvent(ITotalTimeCache totalTimeCache, MergeRequestKey mrk)
        {
            MergeRequestKey?currentMergeRequestKey = getMergeRequestKey(null);

            if (currentMergeRequestKey.HasValue && currentMergeRequestKey.Value.Equals(mrk))
            {
                foreach (EDataCacheType mode in Enum.GetValues(typeof(EDataCacheType)))
                {
                    if (getDataCache(mode)?.TotalTimeCache == totalTimeCache)
                    {
                        // change control enabled state
                        updateTotalTime(currentMergeRequestKey, getDataCache(mode));
                        break;
                    }
                }
            }

            // Update total time column in the table
            getListView(EDataCacheType.Live).Invalidate();
        }
コード例 #4
0
 private void onPostLoadTrackedTime(ITotalTimeCache totalTimeCache, MergeRequestKey mrk)
 {
     onTrackedTimeManagerEvent(totalTimeCache, mrk);
 }
コード例 #5
0
        private void addCustomActions()
        {
            CustomCommandLoader loader = new CustomCommandLoader(this);

            _customCommands = null;
            try
            {
                string CustomActionsFileName = "CustomActions.xml";
                _customCommands = loader.LoadCommands(CustomActionsFileName);
            }
            catch (CustomCommandLoaderException ex)
            {
                // If file doesn't exist the loader throws, leaving the app in an undesirable state.
                // Do not try to load custom actions if they don't exist.
                ExceptionHandlers.Handle("Cannot load custom actions", ex);
            }

            _keywords = _customCommands?
                        .Where(x => x is SendNoteCommand)
                        .Select(x => (x as SendNoteCommand).GetBody()) ?? null;

            if (_customCommands == null)
            {
                return;
            }

            int id = 0;

            foreach (ICommand command in _customCommands)
            {
                string name   = command.GetName();
                var    button = new System.Windows.Forms.Button
                {
                    Name     = "customAction" + id,
                    Location = new System.Drawing.Point {
                        X = 0, Y = 19
                    },
                    Size = new System.Drawing.Size {
                        Width = 72, Height = 32
                    },
                    MinimumSize = new System.Drawing.Size {
                        Width = 72, Height = 0
                    },
                    Text = name,
                    UseVisualStyleBackColor = true,
                    Enabled = false,
                    TabStop = false,
                    Tag     = command.GetDependency()
                };
                toolTip.SetToolTip(button, command.GetHint());
                button.Click += async(x, y) =>
                {
                    MergeRequestKey?mergeRequestKey = getMergeRequestKey(null);
                    if (!mergeRequestKey.HasValue)
                    {
                        return;
                    }

                    ITotalTimeCache totalTimeCache = getDataCache(!isSearchMode())?.TotalTimeCache;

                    labelWorkflowStatus.Text = "Command " + name + " is in progress";
                    try
                    {
                        await command.Run();
                    }
                    catch (Exception ex) // Whatever happened in Run()
                    {
                        string errorMessage = "Custom action failed";
                        ExceptionHandlers.Handle(errorMessage, ex);
                        MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        labelWorkflowStatus.Text = "Command " + name + " failed";
                        return;
                    }

                    string statusMessage = String.Format("Command {0} completed for merge request !{1} in project {2}",
                                                         name, mergeRequestKey.Value.IId, mergeRequestKey.Value.ProjectKey.ProjectName);
                    labelWorkflowStatus.Text = statusMessage;
                    Trace.TraceInformation(String.Format("[MainForm] {0}", statusMessage));

                    if (command.GetStopTimer())
                    {
                        await onStopTimer(true);

                        onTimerStopped(totalTimeCache);
                    }

                    bool reload = command.GetReload();
                    if (reload)
                    {
                        requestUpdates(mergeRequestKey, new int[] {
                            Program.Settings.OneShotUpdateFirstChanceDelayMs,
                            Program.Settings.OneShotUpdateSecondChanceDelayMs
                        });
                    }
                };
                groupBoxActions.Controls.Add(button);
                id++;
            }
        }