Example #1
0
 protected ScheduledDataLoadProcess(IRDMPPlatformRepositoryServiceLocator repositoryLocator, ILoadMetadata loadMetadata, ICheckable preExecutionChecker, IDataLoadExecution loadExecution, JobDateGenerationStrategyFactory jobDateGenerationStrategyFactory, ILoadProgressSelectionStrategy loadProgressSelectionStrategy, int?overrideNumberOfDaysToLoad, ILogManager logManager, IDataLoadEventListener dataLoadEventListener, HICDatabaseConfiguration configuration)
     : base(repositoryLocator, loadMetadata, preExecutionChecker, logManager, dataLoadEventListener, loadExecution, configuration)
 {
     JobDateGenerationStrategyFactory = jobDateGenerationStrategyFactory;
     LoadProgressSelectionStrategy    = loadProgressSelectionStrategy;
     OverrideNumberOfDaysToLoad       = overrideNumberOfDaysToLoad;
 }
        /// <summary>
        /// Always respects the LoadProgress dates and crashes if there arent any load progresses associated with the given load metadata
        /// Uses SingleScheduleCacheDateTrackingStrategy if there is a cache associated with any of the load progresses otherwise uses SingleScheduleConsecutiveDateStrategy (meaning for example each day for the next 5 days)
        /// </summary>
        /// <param name="strategy"></param>
        public JobDateGenerationStrategyFactory(ILoadProgressSelectionStrategy strategy)

        {
            _typeToCreate =
                strategy.GetAllLoadProgresses().Any(p => p.CacheProgress != null) //if any of the strategies you plan to use (without locking btw) have a cache progress
                ? typeof(SingleScheduleCacheDateTrackingStrategy)                 //then we should use a cache progress based strategy
                : typeof(SingleScheduleConsecutiveDateStrategy);                  //otherwise we should probably use consecutive days strategy;
        }
Example #3
0
        public int Run(IRDMPPlatformRepositoryServiceLocator locator, IDataLoadEventListener listener, ICheckNotifier checkNotifier, GracefulCancellationToken token)
        {
            ILoadProgress loadProgress = locator.CatalogueRepository.GetObjectByID <LoadProgress>(_options.LoadProgress);
            ILoadMetadata loadMetadata = locator.CatalogueRepository.GetObjectByID <LoadMetadata>(_options.LoadMetadata);

            if (loadMetadata == null && loadProgress != null)
            {
                loadMetadata = loadProgress.LoadMetadata;
            }

            if (loadMetadata == null)
            {
                throw new ArgumentException("No Load Metadata specified");
            }

            if (loadProgress != null && loadProgress.LoadMetadata_ID != loadMetadata.ID)
            {
                throw new ArgumentException("The supplied LoadProgress does not belong to the supplied LoadMetadata load");
            }

            var databaseConfiguration = new HICDatabaseConfiguration(loadMetadata);
            var flags = new HICLoadConfigurationFlags();

            flags.ArchiveData                = !_options.DoNotArchiveData;
            flags.DoLoadToStaging            = !_options.StopAfterRAW;
            flags.DoMigrateFromStagingToLive = !_options.StopAfterSTAGING;

            var checkable = new CheckEntireDataLoadProcess(loadMetadata, databaseConfiguration, flags, locator.CatalogueRepository.MEF);

            switch (_options.Command)
            {
            case CommandLineActivity.run:

                var loggingServer = loadMetadata.GetDistinctLoggingDatabase();
                var logManager    = new LogManager(loggingServer);

                // Create the pipeline to pass into the DataLoadProcess object
                var dataLoadFactory = new HICDataLoadFactory(loadMetadata, databaseConfiguration, flags, locator.CatalogueRepository, logManager);

                IDataLoadExecution execution = dataLoadFactory.Create(listener);
                IDataLoadProcess   dataLoadProcess;

                if (loadMetadata.LoadProgresses.Any())
                {
                    //Then the load is designed to run X days of source data at a time
                    //Load Progress
                    ILoadProgressSelectionStrategy whichLoadProgress = loadProgress != null ? (ILoadProgressSelectionStrategy) new SingleLoadProgressSelectionStrategy(loadProgress) : new AnyAvailableLoadProgressSelectionStrategy(loadMetadata);

                    var jobDateFactory = new JobDateGenerationStrategyFactory(whichLoadProgress);

                    dataLoadProcess = _options.Iterative
                            ? (IDataLoadProcess) new IterativeScheduledDataLoadProcess(locator, loadMetadata, checkable, execution, jobDateFactory, whichLoadProgress, _options.DaysToLoad, logManager, listener, databaseConfiguration) :
                                      new SingleJobScheduledDataLoadProcess(locator, loadMetadata, checkable, execution, jobDateFactory, whichLoadProgress, _options.DaysToLoad, logManager, listener, databaseConfiguration);
                }
                else
                {
                    //OnDemand
                    dataLoadProcess = new DataLoadProcess(locator, loadMetadata, checkable, logManager, listener, execution, databaseConfiguration);
                }

                var exitCode = dataLoadProcess.Run(token);

                //return 0 for success or load not required otherwise return the exit code (which will be non zero so error)
                return(exitCode == ExitCodeType.Success || exitCode == ExitCodeType.OperationNotRequired? 0: (int)exitCode);

            case CommandLineActivity.check:

                checkable.Check(checkNotifier);

                return(0);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }