Program.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Microsoft.Extensions.DependencyInjection;
  2. using Microsoft.Extensions.Hosting;
  3. using XYY.Service.Standard.RegionService;
  4. using Agile.Config.Client;
  5. using XYY.Service.Standard.First.JobSubscribe;
  6. using XYY.Core.Standard.Data.Infrastructure;
  7. using XYY.Service.Standard.First.DB;
  8. using XYY.Data.Standard.Tasks;
  9. using XYY.Service.Standard.Order;
  10. using XYY.Service.Standard.Finance.Charging.CustomerOrderFee;
  11. using XYY.Data.Standard.Charging;
  12. using XYY.Service.Standard.First.ESB;
  13. namespace XYY.WindowsService.MQ
  14. {
  15. public class Program
  16. {
  17. public static void Main(string[] args)
  18. {
  19. CreateHostBuilder(args).Build().Run();
  20. }
  21. public static IHostBuilder CreateHostBuilder(string[] args)
  22. {
  23. return Host.CreateDefaultBuilder(args)
  24. .UseWindowsService()//使用windows服务
  25. .ConfigureServices((hostContext, services) =>
  26. {
  27. services.AddSingleton<IUnitOfWork>(x => new UnitOfWork(ConnectionHelper.BuildDbConnection(
  28. hostContext.Configuration[DefaultConfig.SqlServiceConnectionKey]), hostContext.Configuration[DefaultConfig.SqlServiceConnectionKey]));
  29. services.AddSingleton<ITaskTrackDataRepository, TaskTrackDataRepository>();
  30. services.AddSingleton<IFinance_Charge_LogRepository, Finance_Charge_LogRepository>();
  31. services.AddXYYService(new ServiceOption
  32. {
  33. UseRabbit = true,
  34. NoService = true,
  35. OpenChannelApi=true,
  36. UseTrackingPUSHRedis=true,
  37. RedisConnection = "r-wz9o30bx758o8jhbrapd.redis.rds.aliyuncs.com"
  38. }, hostContext.Configuration);
  39. services.AddSingleton<IFirstDB>(x => new ESFirstDB(hostContext.Configuration[DefaultConfig.ESUrlKey]));
  40. services.AddSingleton<IFirstDB2>(x => new ESFirstDB2(hostContext.Configuration[DefaultConfig.ESUrlKey]));
  41. services.AddSingleton<IJobSubscribe, JobSubscribe>();
  42. services.AddSingleton<ITrackSupplement, TrackSupplement>();
  43. services.AddSingleton<IAddHNJobSubscribe, AddHNJobSubscribe>();
  44. services.AddSingleton<ISendFirstSubscribe, SendFirstSubscribe>();
  45. services.AddSingleton<ISendFirstNoteSubscribe, SendFirstNoteSubscribe>();
  46. services.AddSingleton<IFinanceQuotationJobSub, FinanceQuotationJobSub>();
  47. services.AddSingleton<IFeeBaseFileJobSub, FeeBaseFileJobSub>();
  48. services.AddSingleton<ICancelOrderJobSubscribe, CancelOrderJobSubscribe>();
  49. services.AddSingleton<IFinanceChargeConsumer, FinanceChargeConsumer>();
  50. services.AddSingleton<IESBService
  51. , ESBTrackingService>();
  52. services.AddSingleton<IWebHook>(x => new QYWXWebHook("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5eb4675a-773a-40a0-9bad-745501122580"));
  53. services.AddSingleton<ITrackingLogDB>(x => new TrackingLogDB(hostContext.Configuration[DefaultConfig.ESUrlKey]));
  54. services.AddSingleton<XiKeTrackingSendJobSubscribe>();
  55. //services.AddTransient<IChargeLogService, ChargeLogService>();
  56. services.AddHostedService<Worker>();
  57. }).ConfigureAppConfiguration((context, config) =>
  58. {
  59. //使用AddAgileConfig配置一个新的IConfigurationSource
  60. config.AddAgileConfig();
  61. });
  62. }
  63. }
  64. }