Program.cs 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.Urls.Add("http://*:80");
  49. app.Run();
  50. }
  51. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  52. {
  53. DateTime? timevalue = null;
  54. if (reader.Value != null)
  55. {
  56. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  57. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  58. }
  59. return timevalue;
  60. }
  61. }
  62. }