GP11x5_ChongQing.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Xml;
  4. using CB.Common;
  5. using CB.Entity;
  6. using CB.Entity.Frequency;
  7. using CB.Interface.Infrastructure.Frequency;
  8. using CB.LotteryCatchData.Entity;
  9. using CB.LotteryCatchData.Interface;
  10. namespace CB.LotteryCatchData.Opencai
  11. {
  12. /// <summary>
  13. /// 重庆 高频11选5
  14. /// </summary>
  15. public class GP11x5_ChongQing : CatchRepository, ICatchDataProvider
  16. {
  17. public override LotteryParamKeys GetLotteryParamKeys(string fileName)
  18. {
  19. return GetLotteryParamKeysDefault(fileName);
  20. }
  21. public override LotteryOpenCode GetLatestOpenCode()
  22. {
  23. return CB.Data.Frequency.GP11x5ChongQingService.GetLatestOpenCodeForCatch();
  24. }
  25. public override IList<LotteryOpenCode> CatchData(LotteryConfigInfo config, LotteryParamKeys keys)
  26. {
  27. if (!this.IsCatchData(config, keys))
  28. return null;
  29. XmlDocument doc = new XmlDocument();
  30. try
  31. {
  32. doc.Load(config.DataUrl);
  33. var nodeList = doc.SelectNodes("xml/row");
  34. if (null == nodeList || 0 >= nodeList.Count)
  35. return null;
  36. IList<LotteryOpenCode> list = new List<LotteryOpenCode>();
  37. LotteryOpenCode entity = null;
  38. string qi = "";
  39. string[] data;
  40. foreach (XmlNode node in nodeList)
  41. {
  42. qi = node.Attributes["expect"].Value.Trim();
  43. if (0 <= keys.LocalTerm.CompareTo(qi))
  44. continue;
  45. data = node.Attributes["opencode"].Value.Trim().Split(',');
  46. entity = new LotteryOpenCode()
  47. {
  48. Term = long.Parse(qi)
  49. };
  50. entity.OpenCode = new List<int>();
  51. entity.OpenCode.Add(TypeConverter.StrToInt(data[0]));
  52. entity.OpenCode.Add(TypeConverter.StrToInt(data[1]));
  53. entity.OpenCode.Add(TypeConverter.StrToInt(data[2]));
  54. entity.OpenCode.Add(TypeConverter.StrToInt(data[3]));
  55. entity.OpenCode.Add(TypeConverter.StrToInt(data[4]));
  56. entity.Addtime = DateTime.Now;
  57. entity.OpenTime = GetRealOpenTime(config.StartTime, config.OpenPeriod, qi, TypeConverter.StrToDateTime(node.Attributes["opentime"].Value.Trim(), entity.Addtime), 8, 2);
  58. list.Add(entity);
  59. }
  60. return list;
  61. }
  62. catch (Exception ex)
  63. {
  64. throw ex;
  65. }
  66. }
  67. public override int SaveData(IList<LotteryOpenCode> list, ref LotteryParamKeys keys)
  68. {
  69. if (null == list || 0 >= list.Count)
  70. return -1;
  71. int n = 0;
  72. long term = Convert.ToInt64(keys.LocalTerm);
  73. DateTime t = keys.LastOpenTime;
  74. GP11x5Info_ChongQing entity = null;
  75. foreach (var item in list)
  76. {
  77. entity = new GP11x5Info_ChongQing()
  78. {
  79. Term = item.Term,
  80. OpenCode1 = item.OpenCode[0],
  81. OpenCode2 = item.OpenCode[1],
  82. OpenCode3 = item.OpenCode[2],
  83. OpenCode4 = item.OpenCode[3],
  84. OpenCode5 = item.OpenCode[4],
  85. OpenTime = item.OpenTime,
  86. Addtime = item.Addtime
  87. };
  88. if (CB.Data.Frequency.GP11x5ChongQingService.Save(entity))
  89. {
  90. n++;
  91. if (term < item.Term)
  92. term = item.Term;
  93. if (t < item.OpenTime)
  94. t = item.OpenTime;
  95. }
  96. }
  97. if (0 < n)
  98. {
  99. keys.IsCatch = 1;
  100. keys.LocalTerm = term.ToString();
  101. keys.LastOpenTime = t;
  102. }
  103. return n;
  104. }
  105. }
  106. }