Program.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // builder.AddAzureWebAppDiagnostics();
  47. // NLog.LogManager.Configuration = new NLogLoggingConfiguration(context.Configuration.GetSection("NLog"));
  48. //})
  49. //.UseNLog()
  50. .AddLogServcie()
  51. .ConfigureServices((hostContext, services) =>
  52. {
  53. //services.AddSingleton<MeterValueGroupSingleHandler>();
  54. services.AddProtalServer(hostContext.Configuration);
  55. })
  56. .Build();
  57. host.Run();
  58. }
  59. public static object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  60. {
  61. DateTime? timevalue = null;
  62. if (reader.Value != null)
  63. {
  64. DateTime date = ((DateTime)reader.Value).ToLocalTime();
  65. timevalue = new DateTime(date.Year, date.Month, date.Day, date.TimeOfDay.Hours, date.TimeOfDay.Minutes, date.TimeOfDay.Seconds, 000);
  66. }
  67. return timevalue;
  68. }
  69. }
  70. }