Program.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. namespace EVCB_OCPP.WSServer
  19. {
  20. class Program
  21. {
  22. static void Main(string[] args)
  23. {
  24. Console.WriteLine("====================================================================================================");
  25. Console.WriteLine("=================" +
  26. "===================================================================================");
  27. Console.WriteLine("== ==");
  28. Console.WriteLine("== ------------ ----------- ------------- ------------- ==");
  29. Console.WriteLine("== --- --- ---- ---------------- ---------------- ==");
  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. //ThreadPool.GetMaxThreads(out var workerThreads, out var completionThreads);
  41. //ThreadPool.SetMinThreads((int)(workerThreads * 0.8), (int)(completionThreads * 0.8));
  42. IHost host = Host.CreateDefaultBuilder(args)
  43. //.UseEnvironment("Development")
  44. .ConfigureLogging((context, builder) => {
  45. builder.ClearProviders();
  46. NLog.LogManager.Configuration = new NLogLoggingConfiguration(context.Configuration.GetSection("NLog"));
  47. })
  48. .UseNLog()
  49. .ConfigureServices((hostContext, services) =>
  50. {
  51. services.AddSingleton<MeterValueGroupSingleHandler>();
  52. services.AddProtalServer(hostContext.Configuration);
  53. })
  54. .Build();
  55. host.Run();
  56. }
  57. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  58. {
  59. DateTime? timevalue = null;
  60. if (reader.Value != null)
  61. {
  62. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  63. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  64. }
  65. return timevalue;
  66. }
  67. }
  68. }