Program.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using EVCB_OCPP.WSServer.Service;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using Microsoft.Extensions.Hosting;
  4. using Newtonsoft.Json;
  5. using EVCB_OCPP.WSServer.Helper;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.AspNetCore.Hosting;
  8. using EVCB_OCPP.WSServer.Service.WsService;
  9. namespace EVCB_OCPP.WSServer
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. AppContext.SetData("System.Net.Security.TlsCacheSize", 200);
  16. Console.WriteLine("====================================================================================================");
  17. Console.WriteLine("=================" +
  18. "===================================================================================");
  19. Console.WriteLine("== ==");
  20. Console.WriteLine("== ------------ ----------- ------------- ------------- ==");
  21. Console.WriteLine("== --- --- ---- ---------------- ---------------- ==");
  22. Console.WriteLine("== --- --- ---- ---- --- ---- --- ==");
  23. Console.WriteLine("== --- --- ---- ---- --- ---- --- ==");
  24. Console.WriteLine("== --- --- ---- ---- ------------- ---- ------------- ==");
  25. Console.WriteLine("== --- --- ---- ---- ----------- ---- ----------- ==");
  26. Console.WriteLine("== --- --- ---- ---- ---- ==");
  27. Console.WriteLine("== --- --- ---- ---- ---- ==");
  28. Console.WriteLine("== ----------- ----------- ---- ---- ==");
  29. Console.WriteLine("== ==");
  30. Console.WriteLine("====================================================================================================");
  31. Console.WriteLine("====================================================================================================");
  32. ThreadPool.GetMaxThreads(out var workerThreads, out var completionThreads);
  33. Console.WriteLine($"Max ThreadPool workerThreads:{workerThreads} completionThreads:{completionThreads}");
  34. ThreadPool.SetMinThreads((int)(10), (int)(0));
  35. var builder = WebApplication.CreateBuilder(args);
  36. builder.Host
  37. .AddLogServcie()
  38. .ConfigureServices((hostContext, services) =>
  39. {
  40. //services.AddSingleton<MeterValueGroupSingleHandler>();
  41. //services.AddSingleton<IHostLifetime, DummyHostLifeTime>();
  42. services.AddProtalServer(hostContext.Configuration);
  43. //services.AddTransient<BlockingTreePrintService>();
  44. //services.AddTransient<GoogleGetTimePrintService>();
  45. });
  46. var app = builder.Build();
  47. app.MapWsService();
  48. app.MapApiServce();
  49. app.Urls.Add("http://*:80");
  50. app.Run();
  51. }
  52. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  53. {
  54. DateTime? timevalue = null;
  55. if (reader.Value != null)
  56. {
  57. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  58. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  59. }
  60. return timevalue;
  61. }
  62. }
  63. }