public void Dispose()
 {
     _mongod?.Dispose();
     _mongod = null;
     process?.Dispose();
     process = null;
 }
        public MongoExport(Mongod mongod, IOptions <Settings> settings, ILogger <MongoExport> logger)
        {
            _mongod   = mongod;
            _settings = settings.Value;
            _logger   = logger;

            process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    CreateNoWindow         = false,
                    UseShellExecute        = false,
                    FileName               = $@"{_settings.MongoPath}mongoexport.exe",
                    WindowStyle            = ProcessWindowStyle.Maximized,
                    Arguments              = $@"--db {_settings.Database} --collection {_settings.Collection} --out ../recipesBackup.json",
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true
                }
            };

            process.ErrorDataReceived  += Process_ErrorDataReceived;
            process.OutputDataReceived += Process_OutputDataReceived;
            process.Start();
            process.BeginErrorReadLine();
            process.BeginOutputReadLine();
        }