Program.cs 4.5 KB

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