Program.cs 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. namespace EVCB_OCPP.WSServer
  21. {
  22. class Program
  23. {
  24. static void Main(string[] args)
  25. {
  26. AppContext.SetData("System.Net.Security.TlsCacheSize", 200);
  27. Console.WriteLine("====================================================================================================");
  28. Console.WriteLine("=================" +
  29. "===================================================================================");
  30. Console.WriteLine("== ==");
  31. Console.WriteLine("== ------------ ----------- ------------- ------------- ==");
  32. Console.WriteLine("== --- --- ---- ---------------- ---------------- ==");
  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. ThreadPool.GetMaxThreads(out var workerThreads, out var completionThreads);
  44. Console.WriteLine($"Max ThreadPool workerThreads:{workerThreads} completionThreads:{completionThreads}");
  45. ThreadPool.SetMinThreads((int)(10), (int)(0));
  46. IHost host = Host.CreateDefaultBuilder(args)
  47. //.UseEnvironment("Development")
  48. //.ConfigureLogging((context, builder) => {
  49. // builder.ClearProviders();
  50. // builder.AddAzureWebAppDiagnostics();
  51. // NLog.LogManager.Configuration = new NLogLoggingConfiguration(context.Configuration.GetSection("NLog"));
  52. //})
  53. //.UseNLog()
  54. .AddLogServcie()
  55. .ConfigureServices((hostContext, services) =>
  56. {
  57. //services.AddSingleton<MeterValueGroupSingleHandler>();
  58. services.AddSingleton<IHostLifetime, DummyHostLifeTime>();
  59. services.AddProtalServer(hostContext.Configuration);
  60. services.AddTransient<BlockingTreePrintService>();
  61. services.AddTransient<GoogleGetTimePrintService>();
  62. })
  63. .Build();
  64. host.Run();
  65. }
  66. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  67. {
  68. DateTime? timevalue = null;
  69. if (reader.Value != null)
  70. {
  71. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  72. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  73. }
  74. return timevalue;
  75. }
  76. }
  77. }