Program.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using EVCB_OCPP.Domain;
  2. using EVCB_OCPP.WSServer.Message;
  3. using EVCB_OCPP.WSServer.Service;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.Extensions.Configuration;
  6. using Microsoft.Extensions.DependencyInjection;
  7. using Microsoft.Extensions.Hosting;
  8. using Microsoft.Extensions.Logging;
  9. using Newtonsoft.Json;
  10. using System;
  11. using NLog;
  12. using NLog.Web;
  13. using NLog.Extensions.Logging;
  14. using System.IO;
  15. using System.Data.Common;
  16. using Microsoft.Data.SqlClient;
  17. using EVCB_OCPP.WSServer.Helper;
  18. using Quartz;
  19. using EVCB_OCPP.WSServer.Jobs;
  20. using Microsoft.AspNetCore.Builder;
  21. using EVCB_OCPP.WSServer.Service.WsService;
  22. using EVCB_OCPP.Service;
  23. namespace EVCB_OCPP.WSServer
  24. {
  25. class Program
  26. {
  27. static void Main(string[] args)
  28. {
  29. AppContext.SetData("System.Net.Security.TlsCacheSize", 200);
  30. Console.WriteLine("====================================================================================================");
  31. Console.WriteLine("=================" +
  32. "===================================================================================");
  33. Console.WriteLine("== ==");
  34. Console.WriteLine("== ------------ ----------- ------------- ------------- ==");
  35. Console.WriteLine("== --- --- ---- ---------------- ---------------- ==");
  36. Console.WriteLine("== --- --- ---- ---- --- ---- --- ==");
  37. Console.WriteLine("== --- --- ---- ---- --- ---- --- ==");
  38. Console.WriteLine("== --- --- ---- ---- ------------- ---- ------------- ==");
  39. Console.WriteLine("== --- --- ---- ---- ----------- ---- ----------- ==");
  40. Console.WriteLine("== --- --- ---- ---- ---- ==");
  41. Console.WriteLine("== --- --- ---- ---- ---- ==");
  42. Console.WriteLine("== ----------- ----------- ---- ---- ==");
  43. Console.WriteLine("== ==");
  44. Console.WriteLine("====================================================================================================");
  45. Console.WriteLine("====================================================================================================");
  46. ThreadPool.GetMaxThreads(out var workerThreads, out var completionThreads);
  47. Console.WriteLine($"Max ThreadPool workerThreads:{workerThreads} completionThreads:{completionThreads}");
  48. ThreadPool.SetMinThreads((int)(10), (int)(0));
  49. var builder = WebApplication.CreateBuilder(args);
  50. //IHost host = Host.CreateDefaultBuilder(args)
  51. //.UseEnvironment("Development")
  52. //.ConfigureLogging((context, builder) => {
  53. // builder.ClearProviders();
  54. // builder.AddAzureWebAppDiagnostics();
  55. // NLog.LogManager.Configuration = new NLogLoggingConfiguration(context.Configuration.GetSection("NLog"));
  56. //})
  57. //.UseNLog()
  58. builder.Host
  59. .AddLogServcie()
  60. .ConfigureServices((hostContext, services) =>
  61. {
  62. //services.AddSingleton<MeterValueGroupSingleHandler>();
  63. //services.AddSingleton<IHostLifetime, DummyHostLifeTime>();
  64. services.AddProtalServer(hostContext.Configuration);
  65. //services.AddTransient<BlockingTreePrintService>();
  66. //services.AddTransient<GoogleGetTimePrintService>();
  67. });
  68. //.Build();
  69. var app = builder.Build();
  70. app.UseHeaderRecordService();
  71. app.UseOcppWsService();
  72. app.MapApiServce();
  73. app.InitStationConfigService();
  74. app.Run();
  75. //host.Run();
  76. }
  77. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  78. {
  79. DateTime? timevalue = null;
  80. if (reader.Value != null)
  81. {
  82. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  83. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  84. }
  85. return timevalue;
  86. }
  87. }
  88. }