Program.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Database.Database;
  2. using Kitty_Fall.Woker.Services;
  3. using log4net;
  4. using Microsoft.AspNetCore.Builder;
  5. using Microsoft.EntityFrameworkCore;
  6. using Microsoft.Extensions.DependencyInjection;
  7. using Microsoft.Extensions.Hosting;
  8. using System.Reflection;
  9. using System.Xml;
  10. Environment.SetEnvironmentVariable("ORA_SDTZ", "UTC");
  11. XmlDocument log4netConfig = new XmlDocument();
  12. log4netConfig.Load(File.OpenRead("log4net.config"));
  13. var repo = log4net.LogManager.CreateRepository(
  14. Assembly.GetEntryAssembly(),
  15. typeof(log4net.Repository.Hierarchy.Hierarchy)
  16. );
  17. log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);
  18. var builder = WebApplication.CreateBuilder(args);
  19. var oracleSessionTimeZone = builder.Configuration["OracleSessionTimeZone"];
  20. if (!string.IsNullOrWhiteSpace(oracleSessionTimeZone))
  21. {
  22. Environment.SetEnvironmentVariable("ORA_SDTZ", oracleSessionTimeZone);
  23. }
  24. // Add services to the container.
  25. builder.Services.AddDbContext<ModelContext>(options =>
  26. options.UseOracle(builder.Configuration["Connection"]));
  27. builder.Services.AddHostedService<GameRewardPayoutWorker>();
  28. builder.Services.AddHostedService<GameMonthlyWinnerWorker>();
  29. var app = builder.Build();
  30. app.Run();