Exemple #1
0
        static void Main(string[] args)
        {
            System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;

            var interaction = new ConsoleUserInteraction();

            interaction.ReportStatus("Placeless console app starting.");

            // add the framework services
            var services = new ServiceCollection()
                           .AddLogging();

            if (!System.IO.File.Exists(Path.Combine(AppContext.BaseDirectory, "appsettings.json")))
            {
                interaction.ReportError("Missing config file: appsettings.json");
                return; // exit app
            }

            string settingsFile = "appsettings.json";

#if DEBUG
            settingsFile = "appsettings.Development.json";
#endif

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Path.Combine(AppContext.BaseDirectory))
                          .AddJsonFile(settingsFile, optional: false);

            var configuration = builder.Build();


            var config    = new AspDotNetConfiguration(configuration);
            var blobStore = new FileSystemBlobStore(config);
            var store     = new SqlMetadataStore(config, interaction, blobStore);
            var source    = new FlickrSource(store, config, interaction);

            ////var generator = new Generator.Generator(store);
            ////generator.Generate(new CreatedYearAttributeGenerator());
            ////generator.Generate(new MediumThumbnailGenerator());

            var collector = new Collector <FlickrSource>(store, source, interaction);

            var discoveryTask = collector.Discover();

            var rootPercent = collector.DiscoveredRoots == 0 ? 0 : 100 * collector.ProcessedRoots / collector.DiscoveredRoots;
            var filePercent = collector.DiscoveredFiles == 0 ? 0 : 100 * collector.ProcessedFiles / collector.DiscoveredFiles;

            while (!discoveryTask.Wait(1000))
            {
                rootPercent = collector.DiscoveredRoots == 0 ? 0 : 100 * collector.ProcessedRoots / collector.DiscoveredRoots;
                filePercent = collector.DiscoveredFiles == 0 ? 0 : 100 * collector.ProcessedFiles / collector.DiscoveredFiles;

                System.Console.WriteLine($"Roots: {collector.ProcessedRoots}/{collector.DiscoveredRoots} ({rootPercent}%); Files: {collector.ProcessedFiles}/{collector.DiscoveredFiles} ({filePercent}%)");
            }
            rootPercent = collector.DiscoveredRoots == 0 ? 0 : 100 * collector.ProcessedRoots / collector.DiscoveredRoots;
            filePercent = collector.DiscoveredFiles == 0 ? 0 : 100 * collector.ProcessedFiles / collector.DiscoveredFiles;
            System.Console.WriteLine($"Roots: {collector.ProcessedRoots}/{collector.DiscoveredRoots} ({rootPercent}%); Files: {collector.ProcessedFiles}/{collector.DiscoveredFiles} ({filePercent}%)");
        }
        public void SetUp()
        {
            _tempLocalDirectory = Path.GetTempPath() + Guid.NewGuid().ToString();
            Directory.CreateDirectory(_tempLocalDirectory);
            _directoryManager = new DirectoryManager(_tempLocalDirectory);

            _sut = new FileSystemBlobStore(MongoDbTestConnectionProvider.OriginalsDb,
                                           "originals",
                                           _tempLocalDirectory,
                                           new CounterService(MongoDbTestConnectionProvider.SystemDb))
            {
                Logger = new ConsoleLogger()
            };
        }
Exemple #3
0
        public void SetUp()
        {
            _tempLocalDirectory = Path.GetTempPath() + Guid.NewGuid().ToString();
            Directory.CreateDirectory(_tempLocalDirectory);

            if (_blobStoreToTest == "filesystem")
            {
                var fsStore = new FileSystemBlobStore(
                    MongoDbTestConnectionProvider.OriginalsDb,
                    FileSystemBlobStore.OriginalDescriptorStorageCollectionName,
                    _tempLocalDirectory,
                    new CounterService(MongoDbTestConnectionProvider.SystemDb),
                    "",
                    "")
                {
                    Logger = new ConsoleLogger()
                };
                _sut         = fsStore;
                _sutAdvanced = fsStore as IBlobStoreAdvanced;
            }
            else if (_blobStoreToTest == "gridfs")
            {
                MongoDbTestConnectionProvider.DropTestsTenant();

                var gridfsStore = new GridFsBlobStore
                                  (
                    MongoDbTestConnectionProvider.OriginalsDbLegacy,
                    new CounterService(MongoDbTestConnectionProvider.SystemDb)
                                  )
                {
                    Logger = new ConsoleLogger()
                };
                _sut         = gridfsStore;
                _sutAdvanced = gridfsStore as IBlobStoreAdvanced;
            }
        }
Exemple #4
0
        public TenantConfiguration(
            String tenantId,
            ILogger logger)
        {
            TenantId = tenantId;

            //Eventstore connection string and username and password for file system.
            var eventStoreConnectionString = ConfigurationManager.AppSettings[$"eventStoreconnection-{tenantId}"];
            var descriptorConnectionString = ConfigurationManager.AppSettings[$"fileSystemStoreDescriptors-{tenantId}"];
            var fileSystemRootUserName     = ConfigurationManager.AppSettings["fileSystemStoreUserName"];
            var fileSystemRootPassword     = ConfigurationManager.AppSettings["fileSystemStorePassword"];

            EventStoreDb = GetDb(eventStoreConnectionString);

            //We need to have original blob store and destination blob store for original blob
            var originalConnectionString = ConfigurationManager.AppSettings[$"OriginalBlobConnection-{tenantId}"];

            if (String.IsNullOrEmpty(originalConnectionString))
            {
                throw new ConfigurationErrorsException($"App settings OriginalBlobConnection-{tenantId} with connection string of original blob store not found");
            }

            OriginalGridFsBlobStore = new GridFsBlobStore(GetLegacyDb(originalConnectionString), null)
            {
                Logger = logger
            };
            var originalFileSystemRoot = ConfigurationManager.AppSettings[$"fileSystemStoreOriginal-{tenantId}"];

            if (!String.IsNullOrEmpty(fileSystemRootUserName))
            {
                PinvokeWindowsNetworking.ConnectToRemote(originalFileSystemRoot, fileSystemRootUserName, fileSystemRootPassword);
            }

            if (String.IsNullOrEmpty(originalFileSystemRoot))
            {
                throw new ConfigurationErrorsException($"File system settings for tenant {tenantId} (settings fileSystemStoreOriginal-{tenantId}) not found in configuration");
            }

            OriginalFileSystemBlobStore = new FileSystemBlobStore(
                GetDb(descriptorConnectionString),
                FileSystemBlobStore.OriginalDescriptorStorageCollectionName,
                originalFileSystemRoot,
                null, //Counter service is not needed for the migrator
                fileSystemRootUserName,
                fileSystemRootPassword
                )
            {
                Logger = logger
            };

            //we need to have artifacts blob store for source and destination
            //We need to have original blob store and destination blob store for original blob
            var artifactConnectionString = ConfigurationManager.AppSettings[$"ArtifactBlobConnection-{tenantId}"];

            if (String.IsNullOrEmpty(artifactConnectionString))
            {
                throw new ConfigurationErrorsException($"App settings ArtifactBlobConnection-{tenantId} with connection string of original blob store not found");
            }

            ArtifactsGridFsBlobStore = new GridFsBlobStore(GetLegacyDb(artifactConnectionString), null)
            {
                Logger = logger
            };
            var artifactFileSystemRoot = ConfigurationManager.AppSettings[$"fileSystemStoreArtifacts-{tenantId}"];

            if (String.IsNullOrEmpty(artifactFileSystemRoot))
            {
                throw new ConfigurationErrorsException($"File system settings for tenant {tenantId} (settings fileSystemStoreArtifacts-{tenantId}) not found in configuration");
            }

            ArtifactsFileSystemBlobStore = new FileSystemBlobStore(
                GetDb(descriptorConnectionString),
                FileSystemBlobStore.ArtifactsDescriptorStorageCollectionName,
                artifactFileSystemRoot,
                null,
                FileSystemUserName,
                FileSystemPassword)
            {
                Logger = logger
            };

            //Null counter service is used to ensure that no new blob could be created.
            ArtifactsGridFsBlobStore = new GridFsBlobStore(GetLegacyDb(artifactConnectionString), null)
            {
                Logger = logger
            };
        }