25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
1.8 KiB

  1. using Microsoft.Extensions.DependencyInjection;
  2. using Microsoft.Extensions.Logging;
  3. using System;
  4. using JT808.Protocol;
  5. using JT808.Protocol.MessageBody;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Threading;
  9. using Microsoft.Extensions.Hosting;
  10. using JT808.Gateway.Client;
  11. using JT808.Gateway.SimpleClient.Services;
  12. using JT808.Gateway.SimpleClient.Jobs;
  13. using JT808.Gateway.WebApiClientTool;
  14. using JT808.Gateway.SimpleClient.Customs;
  15. namespace JT808.Gateway.SimpleClient
  16. {
  17. class Program
  18. {
  19. static async Task Main(string[] args)
  20. {
  21. var serverHostBuilder = new HostBuilder()
  22. .ConfigureLogging((context, logging) =>
  23. {
  24. logging.AddConsole();
  25. logging.SetMinimumLevel(LogLevel.Trace);
  26. })
  27. .ConfigureServices((hostContext, services) =>
  28. {
  29. services.AddSingleton<ILoggerFactory, LoggerFactory>();
  30. services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
  31. services.AddJT808Configure()
  32. .AddClient()
  33. .Builder()
  34. //可以注册一个或者可以自定义扩展
  35. .AddWebApiClientTool(new Uri("http://127.0.0.1:828/"), "123456")
  36. .AddWebApiClientTool<JT808HttpClientExt>(new Uri("http://127.0.0.1:828/"), "123456");
  37. services.AddHostedService<Up2011Service>();
  38. services.AddHostedService<Up2013Service>();
  39. services.AddHostedService<Up2019Service>();
  40. services.AddHostedService<CallHttpClientJob>();
  41. services.AddHostedService<CallHttpClientJobExt>();
  42. });
  43. await serverHostBuilder.RunConsoleAsync();
  44. }
  45. }
  46. }