public override void DoProcess() { SinaCommodityPriceReader reader = new SinaCommodityPriceReader(); List <CommodityPrice> dataList = reader.GetCommodityPriceList(this.Code, DateTime.Today, DateTime.Today); CommodityPrice newData = dataList[0]; // 代码 newData.CommodityCode = this.Code.Substring(2); // 有效. newData.IsActive = true; CommodityPriceService service = new CommodityPriceService(); // 插入或更新. bool result = service.InsertOrUpdateCommodityPrice(newData); if (result) { logger.Info("Success!"); } else { logger.Info("Fail!"); logger.Info(service.ResultMessage); } }
public override void DoProcess() { CommodityPriceService service = new CommodityPriceService(); CommodityPrice newData = new CommodityPrice() { // 代码. CommodityCode = this.Code, // 日期. TradingStartDate = this.Date, TradingFinishDate = this.Date, // 开. OpenPrice = this.OpenPrice, // 收. ClosePrice = this.ClosePrice, // 高. HighestPrice = this.HighestPrice, // 地. LowestPrice = this.LowestPrice, // 量. Volume = this.Volume, // 有效. IsActive = true, }; bool result = service.InsertOrUpdateCommodityPrice(newData); if (result) { logger.Info("Success!"); } else { logger.Info("Fail!"); logger.Info(service.ResultMessage); } }
public override void DoProcess() { YahooCommodityPriceReader reader = new YahooCommodityPriceReader(); List <CommodityPrice> dataList = reader.GetCommodityPriceList(this.Code, this.DateStart, this.DateFinish); CommodityPriceService service = new CommodityPriceService(); foreach (CommodityPrice newData in dataList.OrderBy(p => p.TradingStartDate)) { // 代码 newData.CommodityCode = this.Code.Substring(0, 6); // 有效. newData.IsActive = true; // 插入或更新. bool result = service.InsertOrUpdateCommodityPrice(newData); if (result) { logger.Info("Success!"); } else { logger.Info("Fail!"); logger.Info(service.ResultMessage); } } Console.WriteLine("Done!"); }