Example #1
0
        protected override void ConfigureTuhuServices(ITuhuBuilder builder)
        {
            builder.AddMessageQueue().AddSentryLogging()
            .AddDbHelper().AddConnectionStrings(SqlClientFactory.Instance, builder.Configuration.GetSection("connectionString"))
            .Services.Configure <AppSettingOptions>(builder.Configuration.GetSection("AppSettings"))
            ;
            ;

            builder.AddWcfServer();                                         //.AddServerPolicy().AddDefaultPolicy();
            builder.AddNosql();
            builder.Services.AddLogging(p => this.DisableAspNetCoreLog(p)); //过滤不需要的日志

            builder.Services.AddTuhuMemoryCacheNoJson();

            //注入底层类
            builder.AddDataAccess();
            builder.AddServiceProxy();
            builder.AddManager();

            //需要开启Profiling时取消注释下面一段代码,需要哪个就请开启哪个
            //builder.AddProfiling()
            //    .AddWcfServer()//Tuhu.Service.Server --wcf客户端一定不要
            //    .AddElasticsearch()//Tuhu.Elasticsearch
            //    .AddRedis()//Tuhu.Nosql.Redis
            //    .AddAdo()//Tuhu.Profiling.Data
            //    .AddEntityFramework()/*Tuhu.Profiling.EntityFramework*/);
        }
        /// <summary>
        /// 注入manager
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static ITuhuBuilder AddManager(this ITuhuBuilder builder)
        {
            builder.Services.AddScoped <ICouponManager, CouponManager> ();
            //builder.Services.AddHttpClient<ICouponGetRuleManager, CouponGetRuleManager>(options => options.BaseAddress = new System.Uri( builder.Configuration.GetSection("HttpClient:xxx:Address").Value));
            builder.Services.AddScoped <ICouponGetRuleManager, CouponGetRuleManager>();
            builder.Services.AddScoped <ICouponGetRuleAuditManager, CouponGetRuleAuditManager>();
            builder.Services.AddScoped <ICouponTaskManager, CouponTaskManager>();
            builder.Services.AddScoped <ICommonManager, CommonManager>();
            builder.Services.AddScoped <IRegionManager, RegionManager>();
            builder.Services.AddScoped <IActivityManager, ActivityManager>();
            builder.Services.AddScoped <IUserActivityApplyManager, UserActivityApplyManager>();
            builder.Services.AddScoped <IUserManager, UserManager>();

            return(builder);
        }
        /// <summary>
        /// 注入 ServiceProxy
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static ITuhuBuilder AddServiceProxy(this ITuhuBuilder builder)
        {
            //基础配置
            builder.Services.AddScoped <IConfigBaseClient, ConfigBaseClient>();
            builder.Services.AddScoped <IConfigBaseService, ConfigBaseService>();

            //日志
            builder.Services.AddScoped <IConfigLogClient, ConfigLogClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IConfigLogService, ConfigLogService>();
            //创建优惠券
            builder.Services.AddScoped <ICreatePromotionClient, CreatePromotionClient>();
            builder.Services.AddScoped <Server.ServiceProxy.ICreatePromotionService, CreatePromotionService>();

            //订单
            builder.Services.AddScoped <IOrderApiForCClient, OrderApiForCClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.IOrderService, OrderService>();

            //门店
            builder.Services.AddScoped <IShopClient, ShopClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.IShopService, ShopService>();


            //门店
            builder.Services.AddScoped <IProductInfoQueryClient, ProductInfoQueryClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.IProductService, ProductService>();


            //用户
            builder.Services.AddScoped <IUserAccountClient, UserAccountClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.IUserAccountService, UserAccountService>();

            //短信
            builder.Services.AddScoped <ISmsClient, SmsClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.ISmsService, SmsService>();

            //推送
            builder.Services.AddScoped <ITemplatePushClient, TemplatePushClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.IPushService, PushService>();

            //监控 - metric
            builder.Services.AddScoped <IMonitorClient, MonitorClient>();
            builder.Services.AddScoped <Server.ServiceProxy.IServiceProxy.IMonitorService, MonitorService>();

            return(builder);
        }
        /// <summary>
        /// 注入 DataAccess
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static ITuhuBuilder AddDataAccess(this ITuhuBuilder builder)
        {
            builder.Services.AddScoped <IPromotionCodeRepository, PromotionCodeRepository>();
            builder.Services.AddScoped <ICouponGetRuleRepository, CouponGetRuleRepository>();
            builder.Services.AddScoped <ICouponUseRuleRepository, CouponUseRuleRepository>();
            builder.Services.AddScoped <ICouponGetRuleAuditRepository, CouponGetRuleAuditRepository>();
            builder.Services.AddScoped <IPromotionTaskRepository, PromotionTaskRepository>();
            builder.Services.AddScoped <IPromotionTaskPromotionListRepository, PromotionTaskPromotionListRepository>();
            builder.Services.AddScoped <IPromotionSingleTaskUsersRepository, PromotionSingleTaskUsersRepository>();
            builder.Services.AddScoped <IPromotionSingleTaskUsersHistoryRepository, PromotionSingleTaskUsersHistoryRepository>();
            builder.Services.AddScoped <IChannelDictionariesRepository, ChannelDictionariesRepository>();
            builder.Services.AddScoped <IPromotionTaskProductCategoryRepository, PromotionTaskProductCategoryRepository>();
            builder.Services.AddScoped <IPromotionOprLogRepository, PromotionOprLogRepository>();
            builder.Services.AddScoped <IPromotionTaskBudgetRepository, PromotionTaskBudgetRepository>();
            builder.Services.AddScoped <IRegionRepository, RegionRepository>();
            builder.Services.AddScoped <IActivityRepository, ActivityRepository>();
            builder.Services.AddScoped <IUserActivityApplyRepository, UserActivityApplyRepository>();
            builder.Services.AddScoped <IUserRepository, UserRepository>();

            return(builder);
        }
Example #5
0
 protected override void ConfigureTuhuServices(ITuhuBuilder builder)
 {
     builder.AddWcfClient().AddPromotion().AddClientPolicy().AddDefaultPolicy();
 }