// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { // Setup basic logging ILog log = new LogToConsole(); try { var builder = new ContainerBuilder(); builder.RegisterWebExtensions <AppSettings, IAppSettings>(services, Configuration, "SettingsUrl", log); builder.Register(ctx => { var settings = ctx.Resolve <IReloadingManager <IAppSettings> >(); return(AzureTableStorage <PartnerTemplateSettings> .Create( settings.ConnectionString(x => x.TemplateFormatterSettings.Partners.ConnectionString), settings.CurrentValue.TemplateFormatterSettings.Partners.TableName, ctx.Resolve <ILog>())); }) .As <INoSQLTableStorage <PartnerTemplateSettings> >() .SingleInstance(); // Add framework services. services.AddMvc().AddWebExtensions(); // Add swagger generator services.AddSwaggerGen(x => { x.SwaggerDoc("v1", new Info { Title = Title, Version = Version }); }); builder.Populate(services); ApplicationContainer = builder.Build(); // Create the IServiceProvider based on the container. return(new AutofacServiceProvider(ApplicationContainer)); } catch (Exception ex) { log.WriteFatalErrorAsync(nameof(Startup), nameof(TemplateFormatter), nameof(ConfigureServices), ex, DateTime.UtcNow); throw; } }
static async Task Main() { Console.WriteLine("Start"); try { var config = await GetConfigurationRoot(); var programDemo = new Program(config.DemoHistoryDbConnectionString, "DEMO"); var programLive = new Program(config.LiveHistoryDbConnectionString, "LIVE"); Console.WriteLine("Converting.."); await Task.WhenAll(programDemo.RunConvert(), programLive.RunConvert()); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.DarkYellow; await LogToConsole.WriteFatalErrorAsync(null, nameof(MirgateAccountHistory), "TOP LEVEL FAIL", e); } while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine("End. Press 'q' to exit."); } }
public async Task WriteFatalErrorAsync(string component, string process, string context, Exception exeption, DateTime?dateTime = null) { await _consoleLog.WriteFatalErrorAsync(component, process, context, exeption); await _tableLog.WriteFatalErrorAsync(component, process, context, exeption); }