예제 #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 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();
        }
예제 #3
0
        private void createLiveDataCacheAndDependencies()
        {
            // The idea is that:
            // 1. Already cached MR that became closed remotely will not be removed from the cache
            // 2. Open MR that are missing in the cache, will be added to the cache
            // 3. Open MR that exist in the cache, will be updated
            // 4. Non-cached MR that are closed remotely, will not be added to the cache even if directly requested by IId
            bool updateOnlyOpened = true;

            DataCacheContext dataCacheContext = new DataCacheContext(this, _mergeRequestFilter, _keywords,
                                                                     Program.Settings.UpdateManagerExtendedLogging, "Live",
                                                                     new DataCacheCallbacks(onForbiddenProject, onNotFoundProject),
                                                                     new DataCacheUpdateRules(Program.Settings.AutoUpdatePeriodMs, Program.Settings.AutoUpdatePeriodMs,
                                                                                              updateOnlyOpened), true, true);

            _liveDataCache = new DataCache(dataCacheContext);
            getListView(EDataCacheType.Live).SetDataCache(_liveDataCache);
            getListView(EDataCacheType.Live).SetFilter(_mergeRequestFilter);

            DataCache dataCache = getDataCache(EDataCacheType.Live);

            _expressionResolver = new ExpressionResolver(dataCache);
            selectColorScheme(); // requires ExpressionResolver

            _eventFilter  = new EventFilter(Program.Settings, dataCache, _mergeRequestFilter);
            _userNotifier = new UserNotifier(dataCache, _eventFilter, _trayIcon);
        }
예제 #4
0
        private void createLiveDataCacheAndDependencies()
        {
            DataCacheContext dataCacheContext = new DataCacheContext(this, _mergeRequestFilter, _keywords);

            _liveDataCache      = new DataCache(dataCacheContext, _modificationNotifier);
            _expressionResolver = new ExpressionResolver(_liveDataCache);
            _eventFilter        = new EventFilter(Program.Settings, _liveDataCache, _mergeRequestFilter);
            _userNotifier       = new UserNotifier(_liveDataCache, _eventFilter, _trayIcon);
        }
예제 #5
0
        private void createRecentDataCache()
        {
            DataCacheContext dataCacheContext = new DataCacheContext(this, _mergeRequestFilter, _keywords,
                                                                     Program.Settings.UpdateManagerExtendedLogging, "Recent", new DataCacheCallbacks(null, null),
                                                                     getDataCacheUpdateRules(EDataCacheType.Recent), false, false);

            _recentDataCache = new DataCache(dataCacheContext);
            getListView(EDataCacheType.Recent).SetDataCache(_recentDataCache);
        }
        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;
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        internal UserCache(IUserListLoader userListLoader, DataCacheContext context, string hostname)
        {
            _userListLoader = userListLoader;
            _context        = context;
            _hostname       = hostname;

            _context.SynchronizeInvoke.BeginInvoke(new Action(
                                                       async() =>
            {
                try
                {
                    await _userListLoader.Load();
                }
                catch (BaseLoaderException ex)
                {
                    if (ex is BaseLoaderCancelledException)
                    {
                        return;
                    }
                    ExceptionHandlers.Handle("Cannot load list of users", ex);
                }
            }), null);
        }
예제 #9
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();
        }
예제 #10
0
        internal ProjectCache(InternalCacheUpdater cacheUpdater,
                              IProjectListLoader projectListLoader, DataCacheContext context)
        {
            _cacheUpdater      = cacheUpdater;
            _projectListLoader = projectListLoader;
            _context           = context;

            _context.SynchronizeInvoke.BeginInvoke(new Action(
                                                       async() =>
            {
                try
                {
                    await _projectListLoader.Load();
                }
                catch (BaseLoaderException ex)
                {
                    if (ex is BaseLoaderCancelledException)
                    {
                        return;
                    }
                    ExceptionHandlers.Handle("Cannot load list of projects", ex);
                }
            }), null);
        }
예제 #11
0
        private void createSearchDataCache()
        {
            DataCacheContext dataCacheContext = new DataCacheContext(this, _mergeRequestFilter, _keywords);

            _searchDataCache = new DataCache(dataCacheContext, _modificationNotifier);
        }