示例#1
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();
        }
示例#2
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);
            }
        }
示例#3
0
 public ProjectBasedProjectListLoader(DataCacheOperator op,
                                      InternalCacheUpdater cacheUpdater, DataCacheConnectionContext dataCacheConnectionContext)
     : base(op)
 {
     _cacheUpdater = cacheUpdater;
     _dataCacheConnectionContext = dataCacheConnectionContext;
     Debug.Assert(_dataCacheConnectionContext.CustomData is ProjectBasedContext);
 }
 internal SearchBasedProjectListLoader(string hostname, DataCacheOperator op,
                                       InternalCacheUpdater cacheUpdater, DataCacheConnectionContext dataCacheConnectionContext)
     : base(op)
 {
     _hostname     = hostname;
     _cacheUpdater = cacheUpdater;
     _dataCacheConnectionContext = dataCacheConnectionContext;
     Debug.Assert(_dataCacheConnectionContext.CustomData is SearchBasedContext);
 }
示例#5
0
 internal MergeRequestLoader(DataCacheOperator op, InternalCacheUpdater cacheUpdater, bool updateOnlyOpened,
                             bool isApprovalStatusSupported)
     : base(op)
 {
     _cacheUpdater     = cacheUpdater;
     _versionLoader    = new VersionLoader(op, cacheUpdater);
     _approvalLoader   = isApprovalStatusSupported ? new ApprovalLoader(op, cacheUpdater) : null;
     _updateOnlyOpened = updateOnlyOpened;
 }
示例#6
0
 internal MergeRequestListLoader(string hostname, DataCacheOperator op,
                                 InternalCacheUpdater cacheUpdater, DataCacheCallbacks callbacks,
                                 SearchQueryCollection queryCollection, bool isApprovalStatusSupported)
     : base(op)
 {
     _hostname        = hostname;
     _cacheUpdater    = cacheUpdater;
     _versionLoader   = new VersionLoader(_operator, cacheUpdater);
     _approvalLoader  = isApprovalStatusSupported ? new ApprovalLoader(_operator, cacheUpdater) : null;
     _callbacks       = callbacks;
     _queryCollection = queryCollection;
 }
示例#7
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;
            }
        }
        internal static IProjectListLoader CreateProjectListLoader(string hostname,
                                                                   DataCacheOperator op, DataCacheConnectionContext context, InternalCacheUpdater cache)
        {
            IProjectListLoader listLoader = null;

            if (context.CustomData is ProjectBasedContext)
            {
                listLoader = new ProjectBasedProjectListLoader(op, cache, context);
            }
            else if (context.CustomData is SearchBasedContext)
            {
                listLoader = new SearchBasedProjectListLoader(hostname, op, cache, context);
            }
            return(listLoader);
        }
示例#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();
        }
 internal ProjectListLoader(string hostname, DataCacheOperator op)
     : base(op)
 {
     _hostname = hostname;
 }
示例#11
0
 internal ApprovalLoader(DataCacheOperator op, InternalCacheUpdater cacheUpdater)
     : base(op)
 {
     _cacheUpdater = cacheUpdater;
 }
示例#12
0
 public UserListLoader(string hostname, DataCacheOperator op)
     : base(op)
 {
     _hostname = hostname;
 }
示例#13
0
 internal BaseDataCacheLoader(DataCacheOperator op)
 {
     _operator = op;
 }
示例#14
0
 internal VersionLoader(DataCacheOperator op, InternalCacheUpdater cacheUpdater)
     : base(op)
 {
     _cacheUpdater = cacheUpdater;
 }
示例#15
0
 internal CurrentUserLoader(DataCacheOperator op)
     : base(op)
 {
 }
示例#16
0
 internal MergeRequestLoader(DataCacheOperator op, InternalCacheUpdater cacheUpdater)
     : base(op)
 {
     _cacheUpdater  = cacheUpdater;
     _versionLoader = new VersionLoader(op, cacheUpdater);
 }