using System; using System.Collections.Generic; using CB.LotteryCatchData.Entity; using CB.LotteryCatchData.Interface; namespace CB.LotteryCatchData { public class CatchData { /// /// 彩票开奖数据抓取 /// /// public static void CatchLotteryData(LotteryConfigInfo config) { //实例化处理类 var provider = CatchProvider.GetProvider(config.CatchDataProvider); //获取临时配置 var keys = provider.GetLotteryParamKeys(config.GetParamKeyPath()); if (string.IsNullOrEmpty(keys.LocalTerm) || "0" == keys.LocalTerm) { //数据库读取最新一期开奖信息 keys.LocalTerm = "0"; var entity = provider.GetLatestOpenCode(); if (null != entity) { keys.LocalTerm = entity.Term.ToString(); keys.LastOpenTime = entity.OpenTime; } } //抓取数据 var list = provider.CatchData(config, keys); if (null != list && 0 < list.Count) { //保存数据 var n = provider.SaveData(list, ref keys); CB.Common.FileUtil.WriteLog(config.Name + "--共抓取" + list.Count + "条有效数据,存储了" + n + "条!"); //存储临时配置数据 keys.Save(config.GetParamKeyPath()); } } } }