示例#1
0
        internal MergeRequestManager(
            DataCacheContext dataCacheContext,
            InternalCacheUpdater cacheUpdater,
            string hostname,
            IHostProperties hostProperties,
            DataCacheConnectionContext context,
            IModificationNotifier modificationNotifier)
        {
            _dataCacheContext     = dataCacheContext;
            _cacheUpdater         = cacheUpdater;
            _modificationNotifier = modificationNotifier;

            _modificationNotifier.MergeRequestModified += onMergeRequestModified;

            if (context.UpdateRules.UpdateMergeRequestsPeriod.HasValue)
            {
                DataCacheConnectionContext updateContext = new DataCacheConnectionContext(
                    new DataCacheCallbacks(null, null), // disable callbacks from updates
                    context.UpdateRules,
                    context.CustomData);

                _updateManager = new UpdateManager(_dataCacheContext, hostname, hostProperties,
                                                   updateContext, _cacheUpdater);
                _updateManager.MergeRequestEvent += onUpdate;
            }
        }
示例#2
0
 internal SingleMergeRequestAccessor(IHostProperties settings, MergeRequestKey mrk,
                                     IModificationListener modificationListener)
 {
     _settings             = settings;
     _mrk                  = mrk;
     _modificationListener = modificationListener;
 }
 internal MergeRequestAccessor(IHostProperties settings, ProjectKey projectKey,
                               IModificationListener modificationListener)
 {
     _settings             = settings;
     _projectKey           = projectKey;
     _modificationListener = modificationListener;
 }
示例#4
0
        async public Task Connect(GitLabInstance gitLabInstance, DataCacheConnectionContext context)
        {
            reset();

            string          hostname       = gitLabInstance.HostName;
            IHostProperties hostProperties = gitLabInstance.HostProperties;

            _operator = new DataCacheOperator(hostname, hostProperties);

            try
            {
                InternalCacheUpdater    cacheUpdater           = new InternalCacheUpdater(new InternalCache());
                IMergeRequestListLoader mergeRequestListLoader =
                    MergeRequestListLoaderFactory.CreateMergeRequestListLoader(hostname, _operator, context, cacheUpdater);

                Trace.TraceInformation(String.Format("[DataCache] Starting new dataCache at {0}", hostname));

                User currentUser = await new CurrentUserLoader(_operator).Load(hostname);
                await mergeRequestListLoader.Load();

                _internal = createCacheInternal(cacheUpdater, hostname, hostProperties, currentUser, context);

                Trace.TraceInformation(String.Format("[DataCache] Started new dataCache at {0}", hostname));
                Connected?.Invoke(hostname, currentUser);
            }
            catch (BaseLoaderException ex)
            {
                if (ex is BaseLoaderCancelledException)
                {
                    throw new DataCacheConnectionCancelledException();
                }
                throw new DataCacheException(ex.OriginalMessage, ex);
            }
        }
示例#5
0
 internal MergeRequestEditor(IHostProperties hostProperties,
                             MergeRequestKey mrk, IModificationListener modificationListener)
 {
     _mrk                  = mrk;
     _hostProperties       = hostProperties;
     _modificationListener = modificationListener;
 }
示例#6
0
        private DataCacheInternal createCacheInternal(
            InternalCacheUpdater cacheUpdater,
            string hostname,
            IHostProperties hostProperties,
            User user,
            SearchQueryCollection queryCollection,
            IModificationNotifier modificationNotifier,
            INetworkOperationStatusListener networkOperationStatusListener,
            bool isApprovalStatusSupported)
        {
            MergeRequestManager mergeRequestManager = new MergeRequestManager(
                _cacheContext, cacheUpdater, hostname, hostProperties, queryCollection, networkOperationStatusListener,
                isApprovalStatusSupported);
            DiscussionManager discussionManager = new DiscussionManager(
                _cacheContext, hostname, hostProperties, user, mergeRequestManager,
                modificationNotifier, networkOperationStatusListener);
            TimeTrackingManager timeTrackingManager = new TimeTrackingManager(
                hostname, hostProperties, user, discussionManager, modificationNotifier, networkOperationStatusListener);

            ProjectCache projectCache = null;

            if (_cacheContext.SupportProjectCache)
            {
                IProjectListLoader loader = new ProjectListLoader(hostname, _operator);
                projectCache = new ProjectCache(loader, _cacheContext, hostname);
            }
            UserCache userCache = null;

            if (_cacheContext.SupportUserCache)
            {
                IUserListLoader userListLoader = new UserListLoader(hostname, _operator);
                userCache = new UserCache(userListLoader, _cacheContext, hostname);
            }
            return(new DataCacheInternal(mergeRequestManager, discussionManager, timeTrackingManager, projectCache, userCache));
        }
示例#7
0
        internal UpdateManager(
            DataCacheContext dataCacheContext,
            string hostname,
            IHostProperties hostProperties,
            SearchQueryCollection queryCollection,
            InternalCacheUpdater cacheUpdater,
            INetworkOperationStatusListener networkOperationStatusListener,
            bool isApprovalStatusSupported)
        {
            _updateOperator         = new DataCacheOperator(hostname, hostProperties, networkOperationStatusListener);
            _mergeRequestListLoader = new MergeRequestListLoader(
                hostname, _updateOperator, cacheUpdater, null, queryCollection,
                isApprovalStatusSupported);
            _mergeRequestLoader = new MergeRequestLoader(_updateOperator, cacheUpdater,
                                                         dataCacheContext.UpdateRules.UpdateOnlyOpenedMergeRequests, isApprovalStatusSupported);
            _extLogging    = dataCacheContext.UpdateManagerExtendedLogging;
            _tagForLogging = dataCacheContext.TagForLogging;

            _cache = cacheUpdater.Cache;

            _timer = new System.Timers.Timer
            {
                Interval = dataCacheContext.UpdateRules.UpdateMergeRequestsPeriod.Value
            };
            _timer.Elapsed            += onTimer;
            _timer.SynchronizingObject = dataCacheContext.SynchronizeInvoke;
            _timer.Start();
        }
示例#8
0
 internal UserAccessor(string hostname, IHostProperties hostProperties,
                       INetworkOperationStatusListener networkOperationStatusListener)
 {
     _hostname       = hostname;
     _hostProperties = hostProperties;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#9
0
 internal MergeRequestCreator(ProjectKey projectKey, IHostProperties hostProperties,
                              INetworkOperationStatusListener networkOperationStatusListener)
 {
     _projectKey     = projectKey;
     _hostProperties = hostProperties;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#10
0
 internal RepositoryAccessor(IHostProperties settings, ProjectKey projectKey,
                             INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings   = settings;
     _projectKey = projectKey;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#11
0
 internal ProjectAccessor(IHostProperties settings, string hostname,
                          IModificationListener modificationListener)
 {
     _settings             = settings;
     _hostname             = hostname;
     _modificationListener = modificationListener;
 }
 internal SingleProjectAccessor(ProjectKey projectKey, IHostProperties settings,
                                IModificationListener modificationListener)
 {
     _projectKey           = projectKey;
     _settings             = settings;
     _modificationListener = modificationListener;
 }
示例#13
0
 internal BaseOperator(string hostname, IHostProperties hostProperties,
                       INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings = hostProperties;
     Hostname  = hostname;
     _client   = new GitLabTaskRunner(hostname, _settings.GetAccessToken(hostname));
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#14
0
 internal TimeTracker(MergeRequestKey mrk, IHostProperties hostProperties,
                      IModificationListener modificationListener)
 {
     _mergeRequestKey      = mrk;
     _hostProperties       = hostProperties;
     _modificationListener = modificationListener;
     _stopwatch            = new Stopwatch();
 }
示例#15
0
 internal MergeRequestAccessor(IHostProperties settings, ProjectKey projectKey,
                               IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings                       = settings;
     _projectKey                     = projectKey;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#16
0
 internal SingleDiscussionAccessor(IHostProperties settings, MergeRequestKey mrk, string discussionId,
                                   IModificationListener modificationListener)
 {
     _settings             = settings;
     _mrk                  = mrk;
     _discussionId         = discussionId;
     _modificationListener = modificationListener;
 }
示例#17
0
 internal ProjectAccessor(IHostProperties settings, string hostname,
                          IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings                       = settings;
     _hostname                       = hostname;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#18
0
 internal DiscussionAccessor(IHostProperties settings, MergeRequestKey mrk,
                             IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings                       = settings;
     _mrk                            = mrk;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
 internal SingleProjectAccessor(ProjectKey projectKey, IHostProperties settings,
                                IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener)
 {
     _projectKey                     = projectKey;
     _settings                       = settings;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#20
0
 internal DiscussionEditor(MergeRequestKey mrk, string discussionId, IHostProperties hostProperties,
                           IModificationListener modificationListener)
 {
     _hostProperties       = hostProperties;
     _mergeRequestKey      = mrk;
     _discussionId         = discussionId;
     _modificationListener = modificationListener;
 }
示例#21
0
 internal MergeRequestEditor(IHostProperties hostProperties,
                             MergeRequestKey mrk, IModificationListener modificationListener,
                             INetworkOperationStatusListener networkOperationStatusListener)
 {
     _mrk                            = mrk;
     _hostProperties                 = hostProperties;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
示例#22
0
 internal DiscussionCreator(MergeRequestKey mrk, IHostProperties hostProperties,
                            User currentUser, IModificationListener modificationListener,
                            INetworkOperationStatusListener networkOperationStatusListener)
 {
     _discussionOperator = new DiscussionOperator(
         mrk.ProjectKey.HostName, hostProperties, networkOperationStatusListener);
     _mergeRequestKey      = mrk;
     _currentUser          = currentUser;
     _modificationListener = modificationListener;
 }
示例#23
0
        public GitLabInstance(string hostname, IHostProperties hostProperties, ISynchronizeInvoke synchronizeInvoke)
        {
            HostProperties = hostProperties;
            HostName       = hostname;

            ModificationNotifier modificationNotifier = new ModificationNotifier();

            ModificationListener = modificationNotifier;
            ModificationNotifier = modificationNotifier;

            _synchronizeInvoke = synchronizeInvoke;
        }
示例#24
0
        async public Task Connect(GitLabInstance gitLabInstance, DataCacheConnectionContext connectionContext)
        {
            assertNotConnected();

            string          hostname       = gitLabInstance.HostName;
            IHostProperties hostProperties = gitLabInstance.HostProperties;

            _operator = new DataCacheOperator(hostname, hostProperties, gitLabInstance.NetworkOperationStatusListener);
            DataCacheOperator myOperator = _operator;

            _isConnecting = true;
            try
            {
                Connecting?.Invoke(hostname);

                InternalCacheUpdater cacheUpdater = new InternalCacheUpdater(new InternalCache());
                bool isApprovalStatusSupported    = await gitLabInstance.IsApprovalStatusSupported();

                IMergeRequestListLoader mergeRequestListLoader = new MergeRequestListLoader(
                    hostname, _operator, cacheUpdater,
                    _cacheContext.Callbacks, connectionContext.QueryCollection,
                    isApprovalStatusSupported);

                traceInformation(String.Format("Connecting data cache to {0}...", hostname));
                string accessToken = hostProperties.GetAccessToken(hostname);
                await new CurrentUserLoader(_operator).Load(hostname, accessToken);
                User currentUser = GlobalCache.GetAuthenticatedUser(hostname, accessToken);

                await mergeRequestListLoader.Load();

                _internal = createCacheInternal(cacheUpdater, hostname, hostProperties, currentUser,
                                                connectionContext.QueryCollection, gitLabInstance.ModificationNotifier,
                                                gitLabInstance.NetworkOperationStatusListener, isApprovalStatusSupported);

                ConnectionContext = connectionContext;
                traceInformation(String.Format("Data cache connected to {0}", hostname));
                Connected?.Invoke(hostname, currentUser);
            }
            catch (BaseLoaderException ex)
            {
                reset();

                if (ex is BaseLoaderCancelledException)
                {
                    throw new DataCacheConnectionCancelledException();
                }
                throw new DataCacheException(ex.OriginalMessage, ex);
            }
            finally
            {
                _isConnecting = false;
            }
        }
示例#25
0
        public TimeTrackingManager(
            string hostname,
            IHostProperties hostProperties,
            User user,
            IDiscussionLoader discussionLoader,
            IModificationNotifier modificationNotifier)
        {
            _operator             = new TimeTrackingOperator(hostname, hostProperties);
            _currentUser          = user;
            _modificationNotifier = modificationNotifier;

            _modificationNotifier.TrackedTimeModified += onTrackedTimeModified;

            _discussionLoader = discussionLoader;
            _discussionLoader.DiscussionsLoading += preProcessDiscussions;
            _discussionLoader.DiscussionsLoaded  += processDiscussions;
        }
示例#26
0
        private DataCacheInternal createCacheInternal(
            InternalCacheUpdater cacheUpdater,
            string hostname,
            IHostProperties hostProperties,
            User user,
            DataCacheConnectionContext context)
        {
            MergeRequestManager mergeRequestManager = new MergeRequestManager(
                _dataCacheContext, cacheUpdater, hostname, hostProperties, context, _modificationNotifier);
            DiscussionManager discussionManager = new DiscussionManager(
                _dataCacheContext, hostname, hostProperties, user, mergeRequestManager, context, _modificationNotifier);
            TimeTrackingManager timeTrackingManager = new TimeTrackingManager(
                hostname, hostProperties, user, discussionManager, _modificationNotifier);

            IProjectListLoader loader = ProjectListLoaderFactory.CreateProjectListLoader(
                hostname, _operator, context, cacheUpdater);
            ProjectCache projectCache = new ProjectCache(cacheUpdater, loader, _dataCacheContext);

            return(new DataCacheInternal(mergeRequestManager, discussionManager, timeTrackingManager, projectCache));
        }
        internal MergeRequestManager(
            DataCacheContext dataCacheContext,
            InternalCacheUpdater cacheUpdater,
            string hostname,
            IHostProperties hostProperties,
            SearchQueryCollection queryCollection,
            INetworkOperationStatusListener networkOperationStatusListener,
            bool isApprovalStatusSupported)
        {
            _cacheUpdater         = cacheUpdater;
            _listRefreshTimestamp = DateTime.Now;

            if (dataCacheContext.UpdateRules.UpdateMergeRequestsPeriod.HasValue)
            {
                _updateManager = new UpdateManager(dataCacheContext, hostname, hostProperties,
                                                   queryCollection, _cacheUpdater, networkOperationStatusListener,
                                                   isApprovalStatusSupported);
                _updateManager.MergeRequestEvent         += onUpdate;
                _updateManager.MergeRequestListRefreshed += onListRefreshed;
                _updateManager.MergeRequestRefreshed     += onMergeRequestRefreshed;
            }
        }
        internal DiscussionManager(
            DataCacheContext dataCacheContext,
            string hostname,
            IHostProperties hostProperties,
            User user,
            IMergeRequestCache mergeRequestCache,
            IModificationNotifier modificationNotifier,
            INetworkOperationStatusListener networkOperationStatusListener)
        {
            _operator = new DiscussionOperator(hostname, hostProperties, networkOperationStatusListener);

            _parser = new DiscussionParser(this, dataCacheContext.DiscussionKeywords, user);
            _parser.DiscussionEvent += onDiscussionParserEvent;

            _mergeRequestFilterChecker = dataCacheContext.MergeRequestFilterChecker;
            _tagForLogging             = dataCacheContext.TagForLogging;

            _mergeRequestCache = mergeRequestCache;
            _mergeRequestCache.MergeRequestEvent += OnMergeRequestEvent;
            _modificationNotifier = modificationNotifier;

            _modificationNotifier.DiscussionResolved += onDiscussionResolved;
            _modificationNotifier.DiscussionModified += onDiscussionModified;

            if (dataCacheContext.UpdateRules.UpdateDiscussionsPeriod.HasValue)
            {
                _timer = new System.Timers.Timer
                {
                    Interval = dataCacheContext.UpdateRules.UpdateDiscussionsPeriod.Value
                };
                _timer.Elapsed            += onTimer;
                _timer.SynchronizingObject = dataCacheContext.SynchronizeInvoke;
                _timer.Start();

                scheduleUpdate(null /* update all merge requests cached at the moment of update processing */,
                               DiscussionUpdateType.InitialSnapshot);
            }
        }
示例#29
0
        internal UpdateManager(
            DataCacheContext dataCacheContext,
            string hostname,
            IHostProperties hostProperties,
            DataCacheConnectionContext context,
            InternalCacheUpdater cacheUpdater)
        {
            DataCacheOperator updateOperator = new DataCacheOperator(hostname, hostProperties);

            _mergeRequestListLoader = MergeRequestListLoaderFactory.CreateMergeRequestListLoader(
                hostname, updateOperator, context, cacheUpdater);
            _mergeRequestLoader = new MergeRequestLoader(updateOperator, cacheUpdater);

            _cache = cacheUpdater.Cache;

            _timer = new System.Timers.Timer
            {
                Interval = context.UpdateRules.UpdateMergeRequestsPeriod.Value
            };
            _timer.Elapsed            += onTimer;
            _timer.SynchronizingObject = dataCacheContext.SynchronizeInvoke;
            _timer.Start();
        }
 internal RepositoryOperator(ProjectKey projectKey, IHostProperties settings,
                             INetworkOperationStatusListener networkOperationStatusListener)
     : base(projectKey.HostName, settings, networkOperationStatusListener)
 {
     _projectname = projectKey.ProjectName;
 }