Esempio n. 1
0
        public static void Main(string[] args)
        {
            try {
                SetupConsole();
                LogCurrentSettings(ConfigurationManager.AppSettings);

                var fileService  = new Services.FileService();
                var stateService = new Services.StateService();
                var zipService   = new Services.ZipService();

                _logger.Info("##### 1. Transfer data");
                fileService.DirectoryCopy(_source, _targetInstance, true);

                _logger.Info("##### 2. Cleanup obsolete data");
                fileService.CleanDirectory(_target, _versions);

                _logger.Info("##### 3. Zip target");
                ZipTarget(zipService);

                _logger.Info("##### 4. Set machine state");
                SetState(stateService);

                _logger.Info($"All task's completed, {_source} has succesfully been backed up to {_target}");
                if (Debugger.IsAttached)
                {
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                _logger.Info("To see more verbose logging, enable 'Debug' or 'Trace' logging in the NLog.config.");
                _logger.Fatal(ex, "Application crashed:");
                throw;
            }
        }
Esempio n. 2
0
 private static void ZipTarget(Services.ZipService zipService)
 {
     if (_zipData)
     {
         zipService.ZipFolder(_targetInstance, true);
     }
     else
     {
         _logger.Trace("Skipping task, due to configuration...");
     }
 }