Пример #1
0
        /// <summary>
        /// Class for helping you to construct a caching pipeline engine instance with the correct context and initialization objects
        /// </summary>
        /// <param name="cacheProgress">The cache that will be run</param>
        /// <param name="ignorePermissionWindow">Set to true to ignore the CacheProgress.PermissionWindow (if any)</param>
        /// <param name="providerIfAny">The strategy for figuring out what dates to load the cache with e.g. failed cache fetches or new jobs from head of que?</param>
        /// <param name="throwIfNoPipeline"></param>
        public CachingPipelineUseCase(ICacheProgress cacheProgress, bool ignorePermissionWindow = false, ICacheFetchRequestProvider providerIfAny = null, bool throwIfNoPipeline = true)
        {
            _cacheProgress = cacheProgress;
            _providerIfAny = providerIfAny;

            //if there is no permission window or we are ignoring it
            if (ignorePermissionWindow || cacheProgress.PermissionWindow_ID == null)
            {
                _permissionWindow = new SpontaneouslyInventedPermissionWindow(_cacheProgress);
            }
            else
            {
                _permissionWindow = cacheProgress.PermissionWindow;
            }

            if (_providerIfAny == null)
            {
                _providerIfAny = new CacheFetchRequestProvider(_cacheProgress)
                {
                    PermissionWindow = _permissionWindow
                };
            }

            _pipeline = _cacheProgress.Pipeline;

            if (_pipeline == null && throwIfNoPipeline)
            {
                throw new Exception("CacheProgress " + _cacheProgress + " does not have a Pipeline configured on it");
            }

            AddInitializationObject(_cacheProgress.Repository);

            // Get the LoadDirectory for the engine initialization
            var lmd = _cacheProgress.LoadProgress.LoadMetadata;

            if (string.IsNullOrWhiteSpace(lmd.LocationOfFlatFiles))
            {
                if (throwIfNoPipeline)
                {
                    throw new Exception("LoadMetadata '" + lmd + "' does not have a Load Directory specified, cannot create ProcessingPipelineUseCase without one");
                }
            }
            else
            {
                AddInitializationObject(new LoadDirectory(lmd.LocationOfFlatFiles));
            }

            AddInitializationObject(_providerIfAny);
            AddInitializationObject(_permissionWindow);

            GenerateContext();
        }
Пример #2
0
 public void PreInitialize(ICacheFetchRequestProvider value, IDataLoadEventListener listener)
 {
     RequestProvider = value;
 }