コード例 #1
0
        private static async Task <int> Main(string[] args)
        {
            Console.WriteLine(value: "Credfeto.Gallery.OutputBuilder");

            AlterPriority();

            ServiceCollection serviceCollection = Startup.RegisterServices(args);

            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

            ILoggerFactory loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();

            loggerFactory.AddSerilog();

            ILogger logging = loggerFactory.CreateLogger(categoryName: "Credfeto.Gallery.OutputBuilder");

            ISettings      settings      = serviceProvider.GetService <ISettings>();
            IImageSettings imageSettings = serviceProvider.GetService <IImageSettings>();

            logging.LogInformation($"Source: {settings.RootFolder}");
            logging.LogInformation($"Output: {settings.DatabaseOutputFolder}");
            logging.LogInformation($"Credfeto.Gallery.Image: {settings.ImagesOutputPath}");
            logging.LogInformation($"Thumb:  {imageSettings.ThumbnailSize}");

            foreach (int resize in imageSettings.ImageMaximumDimensions)
            {
                logging.LogInformation($"Resize: {resize}");
            }

            try
            {
                IShortUrls shortUrls = serviceProvider.GetService <IShortUrls>();

                await shortUrls.LoadAsync();

                IImageLoader imageLoader = serviceProvider.GetService <IImageLoader>();

                logging.LogInformation($"Supported Extensions: {string.Join(separator: ", ", values: imageLoader.SupportedExtensions)}");

                IGalleryBuilder galleryBuilder = serviceProvider.GetService <IGalleryBuilder>();

                await galleryBuilder.ProcessGalleryAsync(imageSettings);

                return(0);
            }
            catch (Exception exception)
            {
                Console.WriteLine(format: "Error: {0}", arg0: exception.Message);
                Console.WriteLine(format: "Stack Trace: {0}", arg0: exception.StackTrace);

                return(1);
            }
            finally
            {
                IBrokenImageTracker brokenImageTracker = serviceProvider.GetService <IBrokenImageTracker>();

                await DumpBrokenImagesAsync(brokenImageTracker : brokenImageTracker, settings : settings, logging : logging);
            }
        }
コード例 #2
0
 public GalleryBuilder(IImageExtraction imageExtraction,
                       IRebuildDetection rebuildDetection,
                       IShortUrls shortUrls,
                       ILimitedUrlShortener limitedUrlShortener,
                       IBrokenImageTracker brokenImageTracker,
                       ISettings settings,
                       ILogger <GalleryBuilder> logging)
 {
     this._imageExtraction     = imageExtraction;
     this._rebuildDetection    = rebuildDetection;
     this._shortUrls           = shortUrls;
     this._limitedUrlShortener = limitedUrlShortener;
     this._brokenImageTracker  = brokenImageTracker;
     this._settings            = settings;
     this._logging             = logging;
 }