Esempio n. 1
0
 public Worker(
     IOptionsMonitor <MedioOptions> optionsMonitor,
     IExifTool exifTool,
     ILogger <Worker> logger)
 {
     _logger   = logger;
     _options  = optionsMonitor.CurrentValue;
     _exifTool = exifTool;
 }
Esempio n. 2
0
        public ExifTool(IOptionsMonitor <MedioOptions> optionsMonitor, ILogger <ExifTool> logger)
        {
            _options = optionsMonitor.CurrentValue;

            if (!Directory.Exists(_options.ExifToolFolderPath))
            {
                throw new DirectoryNotFoundException(_options.ExifToolFolderPath);
            }
            _toolsPath = _options.ExifToolFolderPath;

            var exifToolExe = Path.Combine(_options.ExifToolFolderPath, "exiftool.exe");

            if (!File.Exists(exifToolExe))
            {
                throw new FileNotFoundException(_options.ExifToolFolderPath);
            }

            var exifToolArgsFile = Path.Combine(_options.ExifToolFolderPath, "args.txt");

            // Clear args file
            File.Create(exifToolArgsFile).Dispose();


            string exifCommand = $"\"{exifToolExe}\" -stay_open true -@ args.txt";
            string arguments   = $"/c \"{exifCommand}\"";

            _process.StartInfo = new ProcessStartInfo("cmd", arguments);
            _process.StartInfo.RedirectStandardOutput = true;
            _process.StartInfo.RedirectStandardError  = true;
            _process.ErrorDataReceived        += ETErrorHandler;
            _process.StartInfo.UseShellExecute = false;
            _process.StartInfo.CreateNoWindow  = true;
            _process.Start();
            _process.BeginErrorReadLine();
            _exifToolHasBeenLoaded = true;
            _logger = logger;
        }