/// <summary>
        /// This function is here to allow setting the harvesterState to specific values to aid in setting up specific ad-hoc testing states.
        /// In the Parse database, there are some rules that automatically set the harvestState to "Updated" when the book is republished.
        /// Unfortunately, this rule also kicks in when a book is modified in the Parse dashboard or via the API Console (if no updateSource is set) :(
        ///
        /// But executing this function allows you to set it to a value other than "Updated"
        /// </summary>
        internal static void UpdateState(EnvironmentSetting parseDbEnvironment, string objectId, Parse.Model.HarvestState newState)
        {
            var updateOp = BookModel.GetNewBookUpdateOperation();

            updateOp.UpdateFieldWithString(BookModel.kHarvestStateField, newState.ToString());

            EnvironmentSetting environment = EnvironmentUtils.GetEnvOrFallback(parseDbEnvironment, EnvironmentSetting.Default);
            var parseClient = new ParseClient(environment, null);

            parseClient.UpdateObject(BookModel.GetStaticParseClassName(), objectId, updateOp.ToJson());

            Console.Out.WriteLine($"Environment={parseDbEnvironment}: Sent request to update object \"{objectId}\" with harvestState={newState}");
        }
        private ProcessedFilesInfoGenerator(GenerateProcessedFilesTSVOptions options)
            : base(new HarvesterOptions() {
            QueryWhere         = options.QueryWhere,
            ParseDBEnvironment = options.ParseDBEnvironment,
            Environment        = options.Environment,
            SuppressLogs       = true
        })
        {
            var parseDBEnvironment = EnvironmentUtils.GetEnvOrFallback(options.ParseDBEnvironment, options.Environment);

            (_downloadBucketName, _uploadBucketName) = Harvester.GetS3BucketNames(parseDBEnvironment);

            OutputPath = options.OutputPath;
        }
        public Harvester(HarvesterCommonOptions options)
        {
            // Note: If the same machine runs multiple BloomHarvester processes, then you need to add a suffix to this.
            this.Identifier = Environment.MachineName;

            if (options.SuppressLogs)
            {
                _logger = new ConsoleLogger();
            }
            else
            {
                EnvironmentSetting azureMonitorEnvironment = EnvironmentUtils.GetEnvOrFallback(options.LogEnvironment, options.Environment);
                _logger = new AzureMonitorLogger(azureMonitorEnvironment, this.Identifier);
            }

            EnvironmentSetting parseDBEnvironment = EnvironmentUtils.GetEnvOrFallback(options.ParseDBEnvironment, options.Environment);

            _parseClient        = new ParseClient(parseDBEnvironment);
            _parseClient.Logger = _logger;

            string downloadBucketName;
            string uploadBucketName;

            switch (parseDBEnvironment)
            {
            case EnvironmentSetting.Prod:
                downloadBucketName = BloomS3Client.ProductionBucketName;
                uploadBucketName   = HarvesterS3Client.HarvesterProductionBucketName;
                break;

            case EnvironmentSetting.Test:
                downloadBucketName = BloomS3Client.UnitTestBucketName;
                uploadBucketName   = HarvesterS3Client.HarvesterUnitTestBucketName;
                break;

            case EnvironmentSetting.Dev:
            case EnvironmentSetting.Local:
            default:
                downloadBucketName = BloomS3Client.SandboxBucketName;
                uploadBucketName   = HarvesterS3Client.HarvesterSandboxBucketName;
                break;
            }
            _transfer = new BookTransfer(_parseClient,
                                         bloomS3Client: new HarvesterS3Client(downloadBucketName),
                                         htmlThumbnailer: null,
                                         bookDownloadStartingEvent: new BookDownloadStartingEvent());

            _s3UploadClient = new HarvesterS3Client(uploadBucketName);
        }
Beispiel #4
0
        public Harvester(HarvesterCommonOptions options)
        {
            this.Identifier = Environment.MachineName;

            if (options.SuppressLogs)
            {
                _logger = new ConsoleLogger();
            }
            else
            {
                EnvironmentSetting azureMonitorEnvironment = EnvironmentUtils.GetEnvOrFallback(options.LogEnvironment, options.Environment);
                _logger = new AzureMonitorLogger(azureMonitorEnvironment, this.Identifier);
            }

            EnvironmentSetting parseDBEnvironment = EnvironmentUtils.GetEnvOrFallback(options.ParseDBEnvironment, options.Environment);

            _parseClient        = new ParseClient(parseDBEnvironment);
            _parseClient.Logger = _logger;
        }