Program.cs 3.9 KB

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