You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.1 KiB
74 lines
2.1 KiB
1 year ago
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Microsoft.Extensions.Hosting;
|
||
|
using Serilog;
|
||
|
using Serilog.Events;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
using Volo.Abp;
|
||
|
|
||
|
namespace WinFormsApp
|
||
|
{
|
||
|
public class Program
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// The main entry point for the application.
|
||
|
/// </summary>
|
||
|
// [STAThread]
|
||
|
static async Task Main()
|
||
|
{
|
||
|
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 web host.");
|
||
|
|
||
|
using (var host =Host
|
||
|
.CreateDefaultBuilder(null)
|
||
|
.UseAutofac()
|
||
|
.UseSerilog()
|
||
|
.ConfigureServices((hostContext, services) =>
|
||
|
{
|
||
|
services.AddApplication<WinFormModule>();
|
||
|
}).Build())
|
||
|
{
|
||
|
|
||
|
await host.StartAsync();
|
||
|
|
||
|
|
||
|
}
|
||
|
using (var application = AbpApplicationFactory.Create<WinFormModule>())
|
||
|
{
|
||
|
application.Initialize();
|
||
|
|
||
|
// Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||
|
Application.EnableVisualStyles();
|
||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||
|
var mainForm = application.ServiceProvider.GetService<Form1>();
|
||
|
Application.Run(mainForm);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex )
|
||
|
{
|
||
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
||
|
return;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
Log.CloseAndFlush();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|