TrendChartMain.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using TrendChartSDK.Common;
  5. using TrendChartSDK.Entity;
  6. namespace TrendChartSDK.TrendChartManager
  7. {
  8. /// <summary>
  9. /// 走势图主方法,暴露调用接口
  10. /// </summary>
  11. public sealed class TrendChartMain : BaseManager
  12. {
  13. #region 走势图彩种大厅
  14. /// <summary>
  15. /// 走势图彩种大厅
  16. /// </summary>
  17. /// <returns>Json字符串</returns>
  18. public override string GetTrendChartList()
  19. {
  20. string res = string.Empty;
  21. try
  22. {
  23. List<TrendChartListViewEnyity> trendChartList = new List<TrendChartListViewEnyity>();
  24. List<DataItem> data = GetDataList();
  25. string[] lotteryTypeCodeArr = LotteryTypeCodeStr.Split(",".ToCharArray());
  26. foreach (string code in lotteryTypeCodeArr)
  27. {
  28. string[] arr = code.Split("|".ToCharArray());
  29. List<TrendChartItems> items = new List<TrendChartItems>();
  30. //获取对应彩种
  31. List<DataItem> dataItems = data.Where(d => d.Code.Equals(arr[0])).ToList();
  32. foreach (DataItem model in dataItems)
  33. {
  34. int cid = model.LotteryType.GetLotteryCId();
  35. //string lotteryName = model.LotteryType.GetEnumDescription();
  36. TrendChartItems temp = new TrendChartItems
  37. {
  38. ChartId = 1,//TODO 根据cid获取
  39. CId = cid,
  40. TrendChartName = "",//TODO 根据cid获取
  41. EnumCode = model.LotteryType.ToString()
  42. };
  43. items.Add(temp);
  44. }
  45. trendChartList.Add(new TrendChartListViewEnyity
  46. {
  47. TypeCode = arr[0],
  48. TypeName = arr[1],
  49. LotteryItemses = items
  50. });
  51. }
  52. res = trendChartList.ToJson();
  53. }
  54. catch (Exception e)
  55. {
  56. Console.WriteLine(e.Message);
  57. }
  58. return res;
  59. }
  60. /// <summary>
  61. /// 获取数据源
  62. /// </summary>
  63. /// <returns></returns>
  64. private List<DataItem> GetDataList()
  65. {
  66. List<DataItem> lotteryTypes = new List<DataItem>();
  67. //遍历出LotteryType所有成员
  68. foreach (string name in Enum.GetNames(typeof(LotteryType)))
  69. {
  70. LotteryType type = (LotteryType)Enum.Parse(typeof(LotteryType), name, true);
  71. //如果包含LotteryCId,则取出
  72. int cid = type.GetLotteryCId();
  73. string tableName = type.GetLotteryTableName();
  74. if (cid != -1)
  75. {
  76. if (tableName.Contains("QG_"))
  77. {
  78. lotteryTypes.Add(new DataItem
  79. {
  80. Code = "QGC",
  81. LotteryType = type
  82. });
  83. }
  84. else if (tableName.Contains("DF_"))
  85. {
  86. lotteryTypes.Add(new DataItem
  87. {
  88. Code = "DFC",
  89. LotteryType = type
  90. });
  91. }
  92. //高频彩特殊处理
  93. else if (tableName.Contains("GP_"))
  94. {
  95. if (tableName.Contains("GP_11x5_"))
  96. {
  97. lotteryTypes.Add(new DataItem
  98. {
  99. Code = "GPC11X5",
  100. LotteryType = type
  101. });
  102. }
  103. else if (tableName.Contains("GP_K3_"))
  104. {
  105. lotteryTypes.Add(new DataItem
  106. {
  107. Code = "GPCK3",
  108. LotteryType = type
  109. });
  110. }
  111. else if (tableName.Contains("GP_KL10F_"))
  112. {
  113. lotteryTypes.Add(new DataItem
  114. {
  115. Code = "GPCKLSF",
  116. LotteryType = type
  117. });
  118. }
  119. else if (tableName.Contains("GP_KL12_"))
  120. {
  121. lotteryTypes.Add(new DataItem
  122. {
  123. Code = "GPCKL12",
  124. LotteryType = type
  125. });
  126. }
  127. else if (tableName.Contains("GP_SSC_"))
  128. {
  129. lotteryTypes.Add(new DataItem
  130. {
  131. Code = "GPCSSC",
  132. LotteryType = type
  133. });
  134. }
  135. else
  136. {
  137. lotteryTypes.Add(new DataItem
  138. {
  139. Code = "GPCQTC",
  140. LotteryType = type
  141. });
  142. }
  143. }
  144. }
  145. }
  146. return lotteryTypes;
  147. }
  148. private class DataItem
  149. {
  150. public string Code { get; set; }
  151. public LotteryType LotteryType { get; set; }
  152. }
  153. #endregion
  154. #region 获取走势图Html
  155. /// <summary>
  156. /// 获取走势图Html
  157. /// </summary>
  158. /// <param name="arg">查询参数</param>
  159. /// <returns></returns>
  160. public override string GetTrendChartHtml(QueryTrendChartArg arg)
  161. {
  162. string res = string.Empty;
  163. try
  164. {
  165. if (arg == null) return res;
  166. if (arg.ChatrId <= 0) return res;
  167. //获取走势图详细信息
  168. }
  169. catch (Exception e)
  170. {
  171. Console.WriteLine(e);
  172. }
  173. return res;
  174. }
  175. #endregion
  176. }
  177. }