Beispiel #1
0
        static void Main(string[] args)
        {
            var services = new ServiceCollection();

            ConfigureServices(services);

            var serviceProvider = services.BuildServiceProvider();

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

            loggerFactory.AddNLog(new NLogProviderOptions {
                CaptureMessageTemplates = true, CaptureMessageProperties = true
            });
            loggerFactory.ConfigureNLog("nlog.config");

            _logger = loggerFactory.CreateLogger <Program>();
            var watcher = new Stopwatch();

            watcher.Start();
            _logger.LogInformation("********Debut de la synchro********");

            try
            {
                ILotManager lotManager    = serviceProvider.GetService <ILotManager>();
                string      dateMinString = configuration.GetValue <string>("dateMin");
                _logger.LogInformation($"Date min : {dateMinString}");
                DateTime dateMin     = DateTime.ParseExact(dateMinString, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                string[] monthsNames = configuration.GetSection("monthsNames").GetChildren().Select(p => p.Value).ToArray();

                var result = lotManager.SyncLotFromRef(dateMin, monthsNames);

                if (!result.processOk)
                {
                    StringBuilder builder = new StringBuilder();
                    foreach (var error in result.errors)
                    {
                        builder.AppendLine(error);
                    }
                    _logger.LogError($"Erreur lors de l'execution de la synchro : {builder.ToString()}");
                }
                watcher.Stop();
                _logger.LogInformation($"Fin de la synchro : temps écoulé {watcher.Elapsed.TotalMinutes} min");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Erreur lors de l'execution de la synchro");
            }
            _logger.LogInformation("********Fin de la synchro********");
            Console.ReadLine();
        }
Beispiel #2
0
 public LotController(ILotManager lotManager)
 {
     _lotManager = lotManager;
 }