public void Execute(IJobExecutionContext context) { LoggingExtensions.Logging.Log.InitializeWith <LoggingExtensions.log4net.Log4NetLog>(); //init(); IObjectSync sync = new OjbectSync_Tencent(); //获取所有大盘指标的名称和值, var objList = sync.GetAllObjects(); //存储到数据库 foreach (var obj in objList) { this.Log().Info("添加大盘指标:" + obj.name); if (objService.Find(obj.code) == null) { objService.Add(obj); } } //遍历大盘指标,获取每个指标的日周月数据,存储到数据库。 foreach (var obj in objList) { this.Log().Info("初始化大盘指标" + obj.name + "的日线数据:"); var dayList = sync.GetPriceByDay(obj); Complete(dayList); objService.AddPriceByDay <data.data_object_day_latest>(dayList, false); //Send(obj.code, data.TechCycle.Day); this.Log().Info("初始化大盘指标" + obj.name + "的周线数据:"); var weekList = sync.GetPriceByWeek(obj); Complete(weekList); objService.AddPriceByWeek <data.data_object_week_latest>(weekList, false); //Send(obj.code, data.TechCycle.Week); this.Log().Info("初始化大盘指标" + obj.name + "的月线数据:"); var monthList = sync.GetPriceByMonth(obj); Complete(monthList); objService.AddPriceByMonth <data.data_object_month_latest>(monthList, false); //Send(obj.code, data.TechCycle.Month); } this.Log().Info("完成初始化大盘指标线数据!"); }
private void UpdateObject() { var objList = objService.FindAll(); var sync = new OjbectSync_Tencent(); var objInfoList = sync.GetPrice(objList); IList <data.PriceInfo> priceList = objInfoList.Select(p => new data.PriceInfo { code = p.object_code, date = p.date, high = p.high, low = p.low, open = p.open, percent = p.percent, price = p.price, updown = p.updown, volume = p.volume, yestclose = p.yestclose, turnover = p.turnover }).ToList(); foreach (var info in priceList) { this.Log().Info("更新大盘:" + string.Format("{0}_{1}", (int)ObjectType.Object, info.code) + ":" + info.code); UpdateRealTimePrice(ObjectType.Object, info); UpdateDayPrice(ObjectType.Object, info); //UpdatePrice(ObjectType.Object, TechCycle.Week,info); //UpdatePrice(ObjectType.Object, TechCycle.Month,info); } //objService.UpdateObjectInfo(objInfoList); //objService.AddPriceByDay<data.data_object_day_latest>(priceList); //objService.AddPriceByWeek<data.data_object_week_latest>(priceList); //objService.AddPriceByMonth<data.data_object_month_latest>(priceList); }