Ejemplo n.º 1
0
    protected async override void OnStartup(StartupEventArgs e)
    {
        Log.Logger = new LoggerConfiguration()
#if DEBUG
                     .MinimumLevel.Debug()
#else
                     .MinimumLevel.Information()
#endif
                     .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                     .Enrich.FromLogContext()
                     .WriteTo.Async(c => c.File("Logs/logs.txt"))
                     .CreateLogger();

        try
        {
            Log.Information("Starting WPF host.");

            _abpApplication = await AbpApplicationFactory.CreateAsync <MyProjectNameModule>(options =>
            {
                options.UseAutofac();
                options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true));
            });

            await _abpApplication.InitializeAsync();

            _abpApplication.Services.GetRequiredService <MainWindow>()?.Show();
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, "Host terminated unexpectedly!");
        }
    }
Ejemplo n.º 2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _abpApplication = await AbpApplicationFactory.CreateAsync <EasyStoreConsoleAppAppModule>(options =>
            {
                options.Services.ReplaceConfiguration(_configuration);
                options.Services.AddSingleton(_hostEnvironment);

                options.UseAutofac();
                options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog());
            });

            await _abpApplication.InitializeAsync();

            var helloWorldService = _abpApplication.ServiceProvider.GetRequiredService <HelloWorldService>();

            await helloWorldService.SayHelloAsync();
        }