Ejemplo n.º 1
0
        async public Task Stop()
        {
            _stopwatch.Stop();
            TimeSpan span = _stopwatch.Elapsed;

            MergeRequestEditor editor = new MergeRequestEditor(_hostProperties, _mergeRequestKey, _modificationListener);

            try
            {
                await editor.AddTrackedTime(span, true);
            }
            catch (TimeTrackingException ex)
            {
                throw new TimeTrackerException("Cannot stop timer", ex);
            }

            Trace.TraceInformation(String.Format(
                                       "[TimeTracker] Time tracking stopped. Sending {0} for MR IId {1} (project {2})",
                                       span.ToString(@"hh\:mm\:ss"), _mergeRequestKey.IId, _mergeRequestKey.ProjectKey.ProjectName));
        }
Ejemplo n.º 2
0
        async public Task <TimeSpan> Stop()
        {
            _stopwatch.Stop();
            TimeSpan span = Elapsed;

            MergeRequestEditor editor = new MergeRequestEditor(
                _hostProperties, _mergeRequestKey, _modificationListener, _networkOperationStatusListener);

            try
            {
                await editor.AddTrackedTime(span, true);
            }
            catch (TimeTrackingException ex)
            {
                if (ex.InnerException is OperatorException opex)
                {
                    if (opex.InnerException is GitLabSharp.Accessors.GitLabRequestException glex)
                    {
                        if (glex.InnerException is System.Net.WebException wex)
                        {
                            if (wex.Response is System.Net.HttpWebResponse response &&
                                response.StatusCode == System.Net.HttpStatusCode.Forbidden)
                            {
                                throw new ForbiddenTimeTrackerException(ex, span);
                            }
                        }
                    }
                }
                throw new TimeTrackerException("Cannot stop timer", ex, span);
            }

            Trace.TraceInformation(String.Format(
                                       "[TimeTracker] Time tracking stopped. Sending {0} for MR IId {1} (project {2})",
                                       span.ToString(@"hh\:mm\:ss"), _mergeRequestKey.IId, _mergeRequestKey.ProjectKey.ProjectName));
            return(span);
        }