using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using XYY.Service.Standard.RegionService; using Agile.Config.Client; using XYY.Service.Standard.First.JobSubscribe; using XYY.Core.Standard.Data.Infrastructure; using XYY.Service.Standard.First.DB; using XYY.Data.Standard.Tasks; using XYY.Service.Standard.Order; using XYY.Service.Standard.Finance.Charging.CustomerOrderFee; using XYY.Data.Standard.Charging; using XYY.Service.Standard.First.ESB; namespace XYY.WindowsService.MQ { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) { return Host.CreateDefaultBuilder(args) .UseWindowsService()//使用windows服务 .ConfigureServices((hostContext, services) => { services.AddSingleton(x => new UnitOfWork(ConnectionHelper.BuildDbConnection( hostContext.Configuration[DefaultConfig.SqlServiceConnectionKey]), hostContext.Configuration[DefaultConfig.SqlServiceConnectionKey])); services.AddSingleton(); services.AddSingleton(); services.AddXYYService(new ServiceOption { UseRabbit = true, NoService = true, OpenChannelApi=true, UseTrackingPUSHRedis=true, RedisConnection = "r-wz9o30bx758o8jhbrapd.redis.rds.aliyuncs.com" }, hostContext.Configuration); services.AddSingleton(x => new ESFirstDB(hostContext.Configuration[DefaultConfig.ESUrlKey])); services.AddSingleton(x => new ESFirstDB2(hostContext.Configuration[DefaultConfig.ESUrlKey])); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(x => new QYWXWebHook("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5eb4675a-773a-40a0-9bad-745501122580")); services.AddSingleton(x => new TrackingLogDB(hostContext.Configuration[DefaultConfig.ESUrlKey])); services.AddSingleton(); //services.AddTransient(); services.AddHostedService(); }).ConfigureAppConfiguration((context, config) => { //使用AddAgileConfig配置一个新的IConfigurationSource config.AddAgileConfig(); }); } } }