public UploadPolicyResponse UploadFullPolicy(UpLoadPolicyRequest request) { OnWoking(this, new EventMsg { Status = RunStatus.Normal, PurchaserType = PolicyService.Enums.PurchaserType.Qunar, Msg = "------------------------------Start------------------------------------" }); ShowMsg(this, new EventMsg() { Status = RunStatus.Normal, PurchaserType = PurchaserType.Qunar, Msg = DateTime.Now + ":开始上传政策" }); IHandlerBuilder builder = new HandlerBuilder(); builder.Use <QunarLoadFullPolicyMiddleware>() //载入全量政策中间件 .Use <QunarFilterSplitMiddleware>() //过滤并拆分中间件 .Use <QunarFullDispatcherMiddleware>() //全量分发政策中间件 .Use <QunarFormatMiddleware>() //先格式化成去哪儿格式并保存xml文件 .Use <PackageZipFileMiddleware>() //压缩成zip文件 .Use <QunarUploadMiddleware>(); //上传到去哪儿服务器 IHandlerContext context = new HandlerContext(request); IHandler handler = new DefaultHandler(builder, ShowMsg); handler.Execute(context); OnWoking(this, new EventMsg { Status = RunStatus.Normal, PurchaserType = PolicyService.Enums.PurchaserType.Qunar, Msg = "-------------------------------End---------------------------------------" }); return(context.UploadResponse); }
/// <summary> /// 初始化一个新的处理上下文。 /// </summary> /// <param name="request">一个请求。</param> /// <exception cref="ArgumentNullException"><paramref name="request"/> 为null。</exception> public HandlerContext(UpLoadPolicyRequest request) { Request = request; Environment = new ConcurrentDictionary <string, object>(StringComparer.OrdinalIgnoreCase); UploadResponse = new UploadPolicyResponse(); //设置默认的依赖解析器。 //this.SetDependencyResolver(DefaultDependencyResolver.Instance); }
public HandlerContext(UpLoadPolicyRequest request, ConcurrentDictionary <string, object> environment) { Request = request; Environment = environment; UploadResponse = new UploadPolicyResponse(); //设置默认的依赖解析器。 //this.SetDependencyResolver(DefaultDependencyResolver.Instance); }
public UploadPolicyResponse UpLoadIncrementPolicy(UpLoadPolicyRequest request, bool isTaskPolicy = true) { OnWoking(this, new EventMsg { Status = RunStatus.Normal, PurchaserType = PolicyService.Enums.PurchaserType.Qunar, Msg = "------------------------------Start------------------------------------" }); QunarUploadPolicyRequest qunarIncrementRequest = CoreHelper.ChangeToChild <UpLoadPolicyRequest, QunarUploadPolicyRequest>(request); IHandlerBuilder builder = new HandlerBuilder(); if (isTaskPolicy == true) { builder.Use <QunarLoadIncrementalPolicyMiddleware>() //载入增量政策 .Use <QunarFilterSplitMiddleware>() //过滤并拆分中间件 .Use <QunarIncrementalDispatcherMiddleware>() //增量分发政策中间件 .Use <QunarFormatMiddleware>() //先格式化成去哪儿格式并保存xml文件 .Use <PackageZipFileMiddleware>() //压缩成zip文件 .Use <QunarUploadMiddleware>(); //上传到去哪儿服务器 } else//有现成的数据 { builder.Use <QunarFilterRepeatUploadMiddleware>() //过滤不在上传列表的政策中间件 .Use <QunarFilterSplitMiddleware>() //过滤并拆分中间件 .Use <QunarIncrementalDispatcherMiddleware>() //增量分发政策中间件 .Use <QunarFormatMiddleware>() //先格式化成去哪儿格式并保存xml文件 .Use <PackageZipFileMiddleware>() //压缩成zip文件 .Use <QunarUploadMiddleware>(); //上传到去哪儿服务器 } IHandlerContext context = new HandlerContext(request); IHandler handler = new DefaultHandler(builder, ShowMsg); handler.Execute(context); OnWoking(this, new EventMsg { Status = RunStatus.Normal, PurchaserType = PolicyService.Enums.PurchaserType.Qunar, Msg = "-------------------------------End---------------------------------------" }); return(context.UploadResponse); }
public static void SetRequest(this IHandlerContext context, UpLoadPolicyRequest request) { context.Request = request; }