Example #1
0
        public static void Main(string[] args)
        {
            Environment.ExitCode = 1;

            try
            {
                ConfigureLogging();

                _log.Info("Starting user synchronization ...");

                var context = new UserImporterContext(args);

                var userImport = new UserImporter(context);
                userImport.Run();

                _log.Info("Done.");

                Environment.ExitCode = 0;
            }
            catch (Exception exception)
            {
                Action <string> logAction = message => _log.Error(message);

                if (_log == null)
                {
                    logAction = message => Console.WriteLine($"FATAL ERROR (logging not configured): {message}");
                }

                if (exception is ExpectedException)
                {
                    logAction(exception.Message);
                }
                else if (exception is WebServiceException webServiceException)
                {
                    logAction($"API: ({webServiceException.StatusCode}) {string.Join(" ", webServiceException.StatusDescription, webServiceException.ErrorCode)}: {string.Join(" ", webServiceException.Message, webServiceException.ErrorMessage)}");
                }
                else
                {
                    logAction($"{exception.Message}\n{exception.StackTrace}");
                }
            }
        }
Example #2
0
 public UserImporter(UserImporterContext context)
 {
     _context = context;
 }