Beispiel #1
0
        public static void AddDrives(this IServiceCollection services, Action <DriveSettings> optionsBuilder, IConfigurationRoot configuration)
        {
            Ensure.NotNull(services);
            Ensure.NotNull(optionsBuilder);

            var settings = new DriveSettings();

            if (optionsBuilder != null)
            {
                optionsBuilder.Invoke(settings);
            }

            Ensure.NotNullOrEmpty(settings.FileSystemRoot);

            services.AddSingleton(settings);

            // Logging
            services.AddDbContext <DbLogContext>(options => {
                options.UseSqlServer(
                    configuration.GetConnectionString("ConnectDB"),
                    b => b.MigrationsAssembly("Angelo.Connect.Web")
                    );
            });


            var thumProcessor = new Services.ThumbnailProcessor(settings.FileSystemRoot);
            var nominalResolutionProcessor = new Services.NominalResolutionProcessor(settings.FileSystemRoot);

            services.AddTransient <IImagePostProcessor, ThumbnailProcessor>(provider => thumProcessor);
            services.AddTransient <IImagePostProcessor, NominalResolutionProcessor>(provider => nominalResolutionProcessor);


            services.AddTransient <Services.LibraryManager>();

            var ioService = new Services.LibraryIOService(settings.FileSystemRoot, settings.FileSystemCache);

            services.AddTransient <IDocumentDownloadService <FileDocument>, Services.LibraryIOService>(
                provider => ioService
                );
            services.AddTransient <IDocumentUploadService <FileDocument>, Services.LibraryIOService>(
                provider => ioService
                );
            services.AddTransient <IDocumentThumbnailService <FileDocument>, Services.LibraryIOService>(
                provider => ioService
                );

            // Folders and documents
            services.AddConnectDocuments();

            // Document IO
            // NOTE: I really didn't want to add these classes here, but I have to to run the JobZip job
            services.AddTransient <Services.LibraryZipService>();
            services.AddTransient <Jobs.JobZip>(); // The UI can see Zip jobs
            services.AddTransient <Services.LibraryIOService>(
                provider => new Services.LibraryIOService(settings.FileSystemRoot, settings.FileSystemCache)
                );
        }
Beispiel #2
0
        public LibraryManager(
            IFolderManager <FileDocument> folderManager,
            IDocumentService <FileDocument> documentService,
            IDocumentUploadService <FileDocument> uploadService,
            IDocumentThumbnailService <FileDocument> thumbnailService,
            LibraryZipService libraryZipService,
            DbLoggerProvider log,
            DbLogService logFetcher,
            IJobsManager jobsManager,
            TagManager tagManager,
            LibraryIOService libraryIOService,
            IEnumerable <IImagePostProcessor> imageProcessors,
            IHostingEnvironment env)
        {
            Ensure.NotNull(folderManager, $"{nameof(folderManager)} cannot be null.");
            Ensure.NotNull(documentService, $"{nameof(documentService)} cannot be null.");
            Ensure.NotNull(libraryIOService, $"{nameof(libraryIOService)} cannot be null.");
            Ensure.NotNull(uploadService, $"{nameof(uploadService)} cannot be null.");
            Ensure.NotNull(thumbnailService, $"{nameof(thumbnailService)} cannot be null.");
            Ensure.NotNull(libraryZipService, $"{nameof(libraryZipService)} cannot be null.");
            Ensure.NotNull(jobsManager, $"{nameof(jobsManager)} cannot be null.");
            Ensure.NotNull(log, $"{nameof(log)} cannot be null.");
            Ensure.NotNull(tagManager, $"{nameof(tagManager)} cannot be null.");

            _folderManager     = folderManager;
            _documentService   = documentService;
            _libraryIOService  = libraryIOService;
            _uploadService     = uploadService;
            _thumbnailService  = thumbnailService;
            _libraryZipService = libraryZipService;
            _jobs            = jobsManager;
            _log             = log;
            _tagManager      = tagManager;
            _imageProcessors = imageProcessors;
            _env             = env;
        }