Program.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. using EVCB_OCPP.Service;
  10. using Microsoft.Extensions.Logging;
  11. namespace EVCB_OCPP.WSServer
  12. {
  13. class Program
  14. {
  15. static void Main(string[] args)
  16. {
  17. AppContext.SetData("System.Net.Security.TlsCacheSize", 200);
  18. Console.WriteLine("====================================================================================================");
  19. Console.WriteLine("=================" +
  20. "===================================================================================");
  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. Console.WriteLine("====================================================================================================");
  33. Console.WriteLine("====================================================================================================");
  34. ThreadPool.GetMaxThreads(out var workerThreads, out var completionThreads);
  35. Console.WriteLine($"Max ThreadPool workerThreads:{workerThreads} completionThreads:{completionThreads}");
  36. ThreadPool.SetMinThreads((int)(10), (int)(0));
  37. var builder = WebApplication.CreateBuilder(args);
  38. builder.Host
  39. .AddLogServcie()
  40. .ConfigureServices((hostContext, services) =>
  41. {
  42. //services.AddSingleton<MeterValueGroupSingleHandler>();
  43. //services.AddSingleton<IHostLifetime, DummyHostLifeTime>();
  44. services.AddProtalServer(hostContext.Configuration);
  45. //services.AddTransient<BlockingTreePrintService>();
  46. //services.AddTransient<GoogleGetTimePrintService>();
  47. });
  48. var app = builder.Build();
  49. app.UseHeaderRecordService();
  50. app.UseOcppWsService();
  51. app.MapApiServce();
  52. app.Urls.Add("http://*:80");
  53. app.Run();
  54. }
  55. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  56. {
  57. DateTime? timevalue = null;
  58. if (reader.Value != null)
  59. {
  60. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  61. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  62. }
  63. return timevalue;
  64. }
  65. }
  66. }