Program.cs 3.7 KB

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