TCP3Trend.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CB.Common;
  5. using CB.Data;
  6. using CB.Entity;
  7. using CB.Interface;
  8. using CB.Interface.Infrastructure;
  9. namespace CB.TrendChart.LotteryTrendChart
  10. {
  11. /// <summary>
  12. /// 体彩P3、P5走势图生成工具
  13. /// </summary>
  14. public class TCP3Trend
  15. {
  16. public static int Cid = 2;//Cid用于设置样式值
  17. /// <summary>
  18. /// 生成走势图,生成当前term数据及以后数据
  19. /// by JNswins 2015-06-10
  20. /// </summary>
  21. /// <param name="chartId">走势图ID</param>
  22. /// <param name="chartType">走势图类型</param>
  23. /// <param name="term">需要生成走势图期数</param>
  24. /// <param name="LotterySearchField">彩种开奖数据额外查询条件</param>
  25. /// <returns></returns>
  26. public static Tuple<bool, string> CreateTrendChart(int chartId, TrendChartType chartType, long term, LotterySearchField fields = null)
  27. {
  28. //获取走势图项及配置数据
  29. var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  30. if (null == trendChartItem || 0 >= trendChartItem.Count)
  31. return new Tuple<bool, string>(false, string.Format("未找到【ChartId={0}】走势图的项配置数据", chartId));
  32. int count = trendChartItem.Count;
  33. IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  34. IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  35. foreach (var item in trendChartItem)
  36. {
  37. //实例化项类型
  38. chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  39. //获取项CSS配置信息
  40. cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  41. }
  42. //各项初始化
  43. for (int i = 0; i < count; i++)
  44. {
  45. trendChartItem[i].Cid = Cid;
  46. chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  47. }
  48. //大于等于term开奖数据
  49. IList<TCP3Info> ListToEnd = TCP3Service.GetListToEnd(term, fields);
  50. if (null == ListToEnd || 0 >= ListToEnd.Count)
  51. return new Tuple<bool, string>(false, "未找到有效开奖数据");
  52. int j = 0;
  53. TrendChartData entity = null;
  54. var ResultEntity = new TrendChartData
  55. {
  56. ChartId = chartId,
  57. Term = term,
  58. ChartType = chartType,
  59. LocalMiss = new string[count],
  60. LastMiss = new string[count],
  61. AllMaxMiss = new string[count],
  62. AllAvgMiss = new string[count],
  63. AllTimes = new string[count]
  64. };
  65. foreach (var currentData in ListToEnd)
  66. {
  67. //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
  68. IList<TCP3Info> list = TCP3Service.ToListForTrend(currentData.Term, fields);
  69. TCP3Info info = null,lastinfo=null;
  70. info = list[0];
  71. //modified by zizi,at 2016-8-29,3d和排列三试机号10和22
  72. //TODO:下面代码可以重构到Model基类中,以后再改
  73. if (chartId == 22)
  74. {
  75. if (info.OpenCode1 == -1 || info.OpenCode2 == -1 || info.OpenCode3 == -1)
  76. {
  77. var sjh = info.ShiJiHao;
  78. if (!string.IsNullOrEmpty(sjh))
  79. {
  80. var opArr = sjh.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  81. //info.OpenCode1 = int.Parse(opArr[0]);
  82. //info.OpenCode2 = int.Parse(opArr[1]);
  83. //info.OpenCode3 = int.Parse(opArr[2]);
  84. if (opArr.Length >= 3)
  85. {
  86. info.OpenCode[0] = int.Parse(opArr[0]);
  87. info.OpenCode[1] = int.Parse(opArr[1]);
  88. info.OpenCode[2] = int.Parse(opArr[2]);
  89. info.OpenCode[3] = 0;
  90. info.OpenCode[4] = 0;
  91. }
  92. else {
  93. info.OpenCode[0] = -1;
  94. info.OpenCode[1] = -1;
  95. info.OpenCode[2] = -1;
  96. info.OpenCode[3] = 0;
  97. info.OpenCode[4] = 0;
  98. }
  99. }
  100. }
  101. }
  102. if (2 == list.Count)
  103. {
  104. //取当前期数的上一期的走势图信息及遗漏数据
  105. lastinfo = list[1];
  106. entity = ResultEntity;
  107. if (0 == j)
  108. entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
  109. }
  110. bool yes = true;
  111. var sp = new StringBuilder(20000);
  112. sp.Append("<tr>");
  113. for (int i = 0; i < count; i++)
  114. {
  115. //初始化遗漏数据(根据上期结果集计算_entity)
  116. chartItem[i].MissDataInit(entity, i);
  117. //计算项值及遗漏计算
  118. yes = yes && chartItem[i].SetItemValue(info,lastinfo);
  119. if (yes)
  120. {
  121. //结果集赋值
  122. ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
  123. ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
  124. ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
  125. ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
  126. ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
  127. //modified by zizi,at 2016-8-29,3d和排列三试机号10和22
  128. if (i == 1 && chartId == 22 && info.OpenCode1 == -1)
  129. {
  130. var singleValueItem = chartItem[i] as SingleValueItem<TCP3Info>;
  131. if (singleValueItem != null)
  132. singleValueItem._itemValue = "&nbsp;";
  133. }
  134. sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  135. }
  136. }
  137. sp.Append("</tr>");
  138. if (null != entity)
  139. ResultEntity.RecordCount = entity.RecordCount + 1;
  140. else
  141. ResultEntity.RecordCount = 1;
  142. ResultEntity.Term = currentData.Term;
  143. ResultEntity.HtmlData = sp.ToString();
  144. if (!yes)
  145. { return new Tuple<bool, string>(false, string.Format("无效开奖数据:数据生成截止期数为【term={0}】", ResultEntity.Term)); }
  146. yes = yes && DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
  147. if (!yes)
  148. { return new Tuple<bool, string>(false, string.Format("数据保存出错:数据保存截止期数为【term={0}】", ResultEntity.Term)); }
  149. j++;
  150. }
  151. return new Tuple<bool, string>(true, string.Format("正常生成完毕,截止期数为:Term={0}", ListToEnd[ListToEnd.Count - 1].Term));
  152. }
  153. /// <summary>
  154. /// 预览走势图,默认显示近30期数据 (实时计算生成)
  155. /// </summary>
  156. /// <param name="chartId"></param>
  157. /// <param name="chartType"></param>
  158. /// <param name="term"></param>
  159. /// <param name="fields"></param>
  160. /// <returns></returns>
  161. public static string PreViewTrendChart(int chartId, TrendChartType chartType, LotterySearchField fields = null)
  162. {
  163. var list = TCP3Service.GetListToEnd(0, fields);
  164. if (null == list || 0 >= list.Count)
  165. return "";
  166. //获取走势图项及配置数据
  167. var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  168. if (null == trendChartItem || 0 >= trendChartItem.Count)
  169. return "";
  170. int count = trendChartItem.Count;
  171. IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  172. IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  173. foreach (var item in trendChartItem)
  174. {
  175. //实例化项类型
  176. chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  177. //获取项CSS配置信息
  178. cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  179. }
  180. //项初始化
  181. for (int i = 0; i < count; i++)
  182. {
  183. trendChartItem[i].Cid = Cid;
  184. chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  185. }
  186. var sp = new StringBuilder(20000);
  187. int record = list.Count;
  188. int topSize = null == fields ? 30 : fields.TopSize;
  189. if (30 > topSize)
  190. topSize = 30;
  191. for (int i = 0; i < record; i++)
  192. {
  193. for (int j = count - 1; j >= 0; j--)
  194. {
  195. chartItem[j].SetItemValue(list[i]);
  196. }
  197. if (i >= record - topSize)
  198. {
  199. sp.Append("<tr>");
  200. for (int j = 0; j < count; j++)
  201. {
  202. sp.Append(chartItem[j].GetFomartString("<td {0}>{1}</td>"));
  203. }
  204. sp.Append("</tr>");
  205. }
  206. }
  207. return sp.ToString();
  208. }
  209. /// <summary>
  210. /// 预览(012路走势图4走势图),默认显示近30期数据 (实时计算生成)
  211. /// </summary>
  212. /// <param name="chartId"></param>
  213. /// <param name="chartType"></param>
  214. /// <returns></returns>
  215. public static string PreViewTCP3_012_4_TrendChart(int chartId, TrendChartType chartType,LotterySearchField fields = null)
  216. {
  217. var list = TCP3Service.GetListToEnd(0,fields);
  218. if (null == list || 0 >= list.Count)
  219. return "";
  220. //获取走势图项及配置数据
  221. var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  222. if (null == trendChartItem || 0 >= trendChartItem.Count)
  223. return "";
  224. int count = trendChartItem.Count;
  225. IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  226. IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  227. foreach (var item in trendChartItem)
  228. {
  229. //实例化项类型
  230. chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  231. //获取项CSS配置信息
  232. cssConfig.Add(ChartCssConfigService.Get(item.FuntionType, item.ChartCssId));
  233. }
  234. //项初始化
  235. for (int i = 0; i < count; i++)
  236. {
  237. trendChartItem[i].Cid = Cid;
  238. chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  239. }
  240. var sp = new StringBuilder(20000);
  241. int record = list.Count;
  242. int topSize = null == fields ? 30 : fields.TopSize;
  243. int row = 0;// 控制一行4个td
  244. sp.Append("<div class=\"zstableBox\">");
  245. for (int i = record - topSize; i < record; i++)
  246. {
  247. for (int j = count - 1; j >= 0; j--)
  248. {
  249. chartItem[j].SetItemValue(list[i]);
  250. }
  251. if (i >= record - topSize)
  252. {
  253. if ((row % 4) == 0)
  254. {
  255. sp.Append("<tr>");
  256. }
  257. for (int j = 0; j < count; j++)
  258. {
  259. sp.Append(chartItem[j].GetFomartString("<td {0}>{1}</td>"));
  260. }
  261. if ((row % 4) == 3)
  262. {
  263. sp.Append("</tr>");
  264. }
  265. row++;
  266. }
  267. }
  268. sp.Append("</div>");
  269. return sp.ToString();
  270. }
  271. /// <summary>
  272. /// 预览(012路走势图4走势图),默认显示近30期数据 (实时计算生成)
  273. /// </summary>
  274. /// <param name="chartId"></param>
  275. /// <param name="chartType"></param>
  276. /// <param name="term"></param>
  277. /// <param name="fields"></param>
  278. /// <returns></returns>
  279. public static string PreViewTCP3_012_4_TrendChart(int chartId, TrendChartType chartType,TrendChartSearchField fields)
  280. {
  281. var list = TCP3Service.GetListToEnd(0, fields);
  282. if (null == list || 0 >= list.Count)
  283. return "";
  284. if (fields != null && fields.StartTerm == 0 && fields.EndTerm == 0)
  285. {
  286. fields.EndTerm = (int)list[0].Term;
  287. fields.StartTerm = (int)list[list.Count - 1].Term;
  288. }
  289. //获取走势图项及配置数据
  290. var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  291. if (null == trendChartItem || 0 >= trendChartItem.Count)
  292. return "";
  293. int count = trendChartItem.Count;
  294. IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  295. IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  296. foreach (var item in trendChartItem)
  297. {
  298. //实例化项类型
  299. chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  300. //获取项CSS配置信息
  301. cssConfig.Add(ChartCssConfigService.Get(item.FuntionType, item.ChartCssId));
  302. }
  303. //项初始化
  304. for (int i = 0; i < count; i++)
  305. {
  306. trendChartItem[i].Cid = Cid;
  307. chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  308. }
  309. var sp = new StringBuilder(20000);
  310. int record = list.Count;
  311. //int topSize = null == fields ? 30 : fields.TopSize;
  312. //if (30 > topSize)
  313. // topSize = 30;
  314. int row = 0;// 控制一行4个td
  315. sp.Append("<div class=\"zstableBox\">");
  316. for (int i = 0; i < record; i++)
  317. {
  318. for (int j = count - 1; j >= 0; j--)
  319. {
  320. chartItem[j].SetItemValue(list[i]);
  321. }
  322. if ((row % 4) == 0)
  323. {
  324. sp.Append("<tr>");
  325. }
  326. for (int j = 0; j < count; j++)
  327. {
  328. sp.Append(chartItem[j].GetFomartString("<td {0}>{1}</td>"));
  329. }
  330. if ((row % 4) == 3)
  331. {
  332. sp.Append("</tr>");
  333. }
  334. row++;
  335. }
  336. sp.Append("</div>");
  337. return sp.ToString();
  338. }
  339. #region 生成走势图 已注释 by JNswins 2015-06-11
  340. ///// <summary>
  341. ///// 生成走势图
  342. ///// </summary>
  343. ///// <param name="chartId">走势图ID</param>
  344. ///// <param name="chartType">走势图类型</param>
  345. ///// <param name="term">需要生成走势图期数</param>
  346. ///// <param name="MultiTerm">true:生成term期数及以后期数的走势图及遗漏数据;false:仅生成当前期走势图及遗漏数据</param>
  347. ///// <param name="IsZS">true:生成组三数据;false:全部数据</param>
  348. ///// <returns></returns>
  349. //public static bool CreateTrendChart(int chartId, TrendChartType chartType, long term, int week, bool MultiTerm = false, bool IsZS = false)
  350. //{
  351. // if (MultiTerm && IsZS)
  352. // return CreateCurrentToEndZSTrendChart(chartId, chartType, term);
  353. // if (MultiTerm && !IsZS)
  354. // return CreateCurrentToEndTrendChart(chartId, chartType, term);
  355. // if (!MultiTerm && IsZS)
  356. // return CreateCurrentZSTrendChart(chartId, chartType, term);
  357. // return CreateCurrentTrendChart(chartId, chartType, term);
  358. //}
  359. ///// <summary>
  360. ///// 生成当前期走势图
  361. ///// </summary>
  362. ///// <param name="chartId"></param>
  363. ///// <param name="chartType"></param>
  364. ///// <param name="term"></param>
  365. ///// <returns></returns>
  366. //private static bool CreateCurrentTrendChart(int chartId, TrendChartType chartType, long term)
  367. //{
  368. // //获取走势图项及配置数据
  369. // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  370. // if (null == trendChartItem || 0 >= trendChartItem.Count)
  371. // return false;
  372. // int count = trendChartItem.Count;
  373. // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  374. // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  375. // foreach (var item in trendChartItem)
  376. // {
  377. // //实例化项类型
  378. // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  379. // //获取项CSS配置信息
  380. // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  381. // }
  382. // //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
  383. // var list = TCP3Service.ToListForTrend(term);
  384. // TCP3Info info = null;
  385. // TrendChartData entity = null;
  386. // if (null == list || 0 >= list.Count)
  387. // return false;
  388. // info = list[0];
  389. // if (2 == list.Count)
  390. // {
  391. // //取当前期数的上一期的走势图信息及遗漏数据
  392. // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
  393. // }
  394. // var ResultEntity = new TrendChartData
  395. // {
  396. // ChartId = chartId,
  397. // Term = term,
  398. // ChartType = chartType,
  399. // LocalMiss = new string[count],
  400. // LastMiss = new string[count],
  401. // AllMaxMiss = new string[count],
  402. // AllAvgMiss = new string[count],
  403. // AllTimes = new string[count]
  404. // };
  405. // var sp = new StringBuilder(20000);
  406. // sp.Append("<tr>");
  407. // for (int i = 0; i < count; i++)
  408. // {
  409. // //项初始化
  410. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  411. // //初始化遗漏数据(根据上期结果集计算_entity)
  412. // chartItem[i].MissDataInit(entity, i);
  413. // //计算项值及遗漏计算
  414. // chartItem[i].SetItemValue(info);
  415. // //结果集赋值
  416. // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
  417. // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
  418. // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
  419. // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
  420. // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
  421. // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  422. // }
  423. // sp.Append("</tr>");
  424. // if (entity != null)
  425. // ResultEntity.RecordCount = entity.RecordCount + 1;
  426. // else
  427. // ResultEntity.RecordCount = 1;
  428. // ResultEntity.HtmlData = sp.ToString();
  429. // return DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
  430. //}
  431. ///// <summary>
  432. ///// 生成当前期(组三)走势图
  433. ///// </summary>
  434. ///// <param name="chartId"></param>
  435. ///// <param name="chartType"></param>
  436. ///// <param name="term"></param>
  437. ///// <returns></returns>
  438. //private static bool CreateCurrentZSTrendChart(int chartId, TrendChartType chartType, long term)
  439. //{
  440. // //获取走势图项及配置数据
  441. // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  442. // if (null == trendChartItem || 0 >= trendChartItem.Count)
  443. // return false;
  444. // int count = trendChartItem.Count;
  445. // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  446. // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  447. // foreach (var item in trendChartItem)
  448. // {
  449. // //实例化项类型
  450. // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  451. // //获取项CSS配置信息
  452. // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  453. // }
  454. // //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
  455. // var list = TCP3Service.ToListForZSTrend(term);
  456. // TCP3Info info = null;
  457. // TrendChartData entity = null;
  458. // if (null == list || 0 >= list.Count)
  459. // return false;
  460. // info = list[0];
  461. // //当前期不是组三走势图
  462. // if (info.Term != term)
  463. // return false;
  464. // if (2 == list.Count)
  465. // {
  466. // //取当前期数的上一期的走势图信息及遗漏数据
  467. // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
  468. // //将上一期数据初始化(方便用期号计算机组三遗漏值)
  469. // for (int i = 0; i < count; i++)
  470. // {
  471. // //项初始化
  472. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  473. // //初始化遗漏数据(根据上期结果集计算_entity)
  474. // chartItem[i].MissDataInit(entity, i);
  475. // //计算项值及遗漏计算
  476. // chartItem[i].SetItemValue(list[1]);
  477. // }
  478. // }
  479. // var ResultEntity = new TrendChartData
  480. // {
  481. // ChartId = chartId,
  482. // Term = term,
  483. // ChartType = chartType,
  484. // LocalMiss = new string[count],
  485. // LastMiss = new string[count],
  486. // AllMaxMiss = new string[count],
  487. // AllAvgMiss = new string[count],
  488. // AllTimes = new string[count]
  489. // };
  490. // var sp = new StringBuilder(20000);
  491. // sp.Append("<tr>");
  492. // for (int i = 0; i < count; i++)
  493. // {
  494. // //项初始化
  495. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  496. // //初始化遗漏数据(根据上期结果集计算_entity)
  497. // chartItem[i].MissDataInit(entity, i);
  498. // //计算项值及遗漏计算
  499. // chartItem[i].SetItemValue(info);
  500. // //结果集赋值
  501. // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
  502. // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
  503. // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
  504. // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
  505. // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
  506. // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  507. // }
  508. // sp.Append("</tr>");
  509. // if (entity != null)
  510. // ResultEntity.RecordCount = entity.RecordCount + 1;
  511. // else
  512. // ResultEntity.RecordCount = 1;
  513. // ResultEntity.HtmlData = sp.ToString();
  514. // return DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
  515. //}
  516. ///// <summary>
  517. ///// 生成当期走势图以及后面走势图
  518. ///// </summary>
  519. ///// <param name="chartId"></param>
  520. ///// <param name="chartType"></param>
  521. ///// <param name="term"></param>
  522. ///// <returns></returns>
  523. //private static bool CreateCurrentToEndTrendChart(int chartId, TrendChartType chartType, long term)
  524. //{
  525. // //当期以及以后数据
  526. // var ListToEnd = TCP3Service.GetListToEnd(term);
  527. // if (null == ListToEnd || ListToEnd.Count <= 0)
  528. // return false;
  529. // //获取走势图项及配置数据
  530. // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  531. // if (null == trendChartItem || 0 >= trendChartItem.Count)
  532. // return false;
  533. // int count = trendChartItem.Count;
  534. // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  535. // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  536. // foreach (var item in trendChartItem)
  537. // {
  538. // //实例化项类型
  539. // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  540. // //获取项CSS配置信息
  541. // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  542. // }
  543. // //项初始化
  544. // for (int i = 0; i < count; i++)
  545. // {
  546. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  547. // }
  548. // foreach (var currentData in ListToEnd)
  549. // {
  550. // //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
  551. // var list = TCP3Service.ToListForTrend(currentData.Term);
  552. // TCP3Info info = null;
  553. // TrendChartData entity = null;
  554. // if (null == list || 0 >= list.Count)
  555. // continue;
  556. // info = list[0];
  557. // if (2 == list.Count)
  558. // {
  559. // //取当前期数的上一期的走势图信息及遗漏数据
  560. // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
  561. // }
  562. // var ResultEntity = new TrendChartData
  563. // {
  564. // ChartId = chartId,
  565. // Term = currentData.Term,
  566. // ChartType = chartType,
  567. // LocalMiss = new string[count],
  568. // LastMiss = new string[count],
  569. // AllMaxMiss = new string[count],
  570. // AllAvgMiss = new string[count],
  571. // AllTimes = new string[count]
  572. // };
  573. // var sp = new StringBuilder(20000);
  574. // sp.Append("<tr>");
  575. // for (int i = 0; i < count; i++)
  576. // {
  577. // //初始化遗漏数据(根据上期结果集计算_entity)
  578. // chartItem[i].MissDataInit(entity, i);
  579. // //计算项值及遗漏计算
  580. // chartItem[i].SetItemValue(info);
  581. // //结果集赋值
  582. // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
  583. // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
  584. // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
  585. // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
  586. // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
  587. // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  588. // }
  589. // sp.Append("</tr>");
  590. // if (entity != null)
  591. // ResultEntity.RecordCount = entity.RecordCount + 1;
  592. // else
  593. // ResultEntity.RecordCount = 1;
  594. // ResultEntity.HtmlData = sp.ToString();
  595. // DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
  596. // }
  597. // return true;
  598. //}
  599. ///// <summary>
  600. ///// 生成当期(组三)走势图以及后面走势图
  601. ///// </summary>
  602. ///// <param name="chartId"></param>
  603. ///// <param name="chartType"></param>
  604. ///// <param name="term"></param>
  605. ///// <returns></returns>
  606. //private static bool CreateCurrentToEndZSTrendChart(int chartId, TrendChartType chartType, long term)
  607. //{
  608. // //当期以及以后数据
  609. // var ListToEnd = TCP3Service.GetListToEnd(term);
  610. // if (null == ListToEnd || ListToEnd.Count <= 0)
  611. // return false;
  612. // //获取走势图项及配置数据
  613. // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  614. // if (null == trendChartItem || 0 >= trendChartItem.Count)
  615. // return false;
  616. // int count = trendChartItem.Count;
  617. // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  618. // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  619. // foreach (var item in trendChartItem)
  620. // {
  621. // //实例化项类型
  622. // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  623. // //获取项CSS配置信息
  624. // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  625. // }
  626. // //项初始化
  627. // for (int i = 0; i < count; i++)
  628. // {
  629. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  630. // }
  631. // for (int j = 0; j < ListToEnd.Count; j++)
  632. // {
  633. // //不是组三就不执行
  634. // if (!(ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode2 || ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode3 ||
  635. // ListToEnd[j].OpenCode2 == ListToEnd[j].OpenCode3 &&
  636. // (ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode2 && ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode3)))
  637. // continue;
  638. // //根据参数term期数获取近两期(组三)开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
  639. // var list = TCP3Service.ToListForZSTrend(ListToEnd[j].Term);
  640. // TCP3Info info = null;
  641. // TrendChartData entity = null;
  642. // if (null == list || 0 >= list.Count)
  643. // continue;
  644. // info = list[0];
  645. // if (2 == list.Count)
  646. // {
  647. // //取当前期数的上一期的走势图信息及遗漏数据
  648. // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
  649. // //将上一期数据初始化(方便用期号计算机组三遗漏值)--第一条记录才需要初始化上一期数据
  650. // if (j == 0)
  651. // for (int i = 0; i < count; i++)
  652. // {
  653. // //项初始化
  654. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  655. // //初始化遗漏数据(根据上期结果集计算_entity)
  656. // chartItem[i].MissDataInit(entity, i);
  657. // //计算项值及遗漏计算
  658. // chartItem[i].SetItemValue(list[1]);
  659. // }
  660. // }
  661. // var ResultEntity = new TrendChartData
  662. // {
  663. // ChartId = chartId,
  664. // Term = ListToEnd[j].Term,
  665. // ChartType = chartType,
  666. // LocalMiss = new string[count],
  667. // LastMiss = new string[count],
  668. // AllMaxMiss = new string[count],
  669. // AllAvgMiss = new string[count],
  670. // AllTimes = new string[count]
  671. // };
  672. // var sp = new StringBuilder(20000);
  673. // sp.Append("<tr>");
  674. // for (int i = 0; i < count; i++)
  675. // {
  676. // //初始化遗漏数据(根据上期结果集计算_entity)
  677. // chartItem[i].MissDataInit(entity, i);
  678. // //计算项值及遗漏计算
  679. // chartItem[i].SetItemValue(info);
  680. // //结果集赋值
  681. // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
  682. // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
  683. // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
  684. // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
  685. // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
  686. // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  687. // }
  688. // sp.Append("</tr>");
  689. // if (entity != null)
  690. // ResultEntity.RecordCount = entity.RecordCount + 1;
  691. // else
  692. // ResultEntity.RecordCount = 1;
  693. // ResultEntity.HtmlData = sp.ToString();
  694. // DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
  695. // }
  696. // return true;
  697. //}
  698. #endregion
  699. #region 生成预览走势图 已注释 by JNswins 2015-06-11
  700. ///// <summary>
  701. ///// 预览当期走势图以及后面走势图
  702. ///// </summary>
  703. ///// <param name="chartId"></param>
  704. ///// <param name="chartType"></param>
  705. ///// <param name="term"></param>
  706. ///// <returns></returns>
  707. //public static string PreViewCurrentToEndTrendChart(int chartId, TrendChartType chartType)
  708. //{
  709. // StringBuilder sp = new StringBuilder(20000);
  710. // //当期以及以后数据
  711. // var ListToEnd = TCP3Service.GetListToEnd(-1);
  712. // if (null == ListToEnd || ListToEnd.Count <= 0)
  713. // return "";
  714. // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  715. // if (null == trendChartItem || 0 >= trendChartItem.Count)
  716. // return "";
  717. // int count = trendChartItem.Count;
  718. // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  719. // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  720. // foreach (var item in trendChartItem)
  721. // {
  722. // //实例化项类型
  723. // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  724. // //获取项CSS配置信息
  725. // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  726. // }
  727. // //项初始化
  728. // for (int i = 0; i < count; i++)
  729. // {
  730. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  731. // }
  732. // for (int j = 0; j < ListToEnd.Count; j++)
  733. // {
  734. // if (j < ListToEnd.Count - 31)
  735. // {
  736. // for (int i = 0; i < count; i++)
  737. // {
  738. // //计算项值及遗漏计算
  739. // chartItem[i].SetItemValue(ListToEnd[j]);
  740. // }
  741. // }
  742. // else
  743. // {
  744. // sp.Append("<tr>");
  745. // for (int i = 0; i < count; i++)
  746. // {
  747. // //计算项值及遗漏计算
  748. // chartItem[i].SetItemValue(ListToEnd[j]);
  749. // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  750. // }
  751. // sp.Append("</tr>");
  752. // }
  753. // }
  754. // return sp.ToString();
  755. //}
  756. ///// <summary>
  757. ///// 预览当期(组三)走势图以及后面走势图
  758. ///// </summary>
  759. ///// <param name="chartId"></param>
  760. ///// <param name="chartType"></param>
  761. ///// <param name="term"></param>
  762. ///// <returns></returns>
  763. //public static string PreViewCurrentToEndZSTrendChart(int chartId, TrendChartType chartType, long term)
  764. //{
  765. // var sp = new StringBuilder(20000);
  766. // //当期以及以后数据
  767. // var ListToEnd = TCP3Service.GetListToEnd(term);
  768. // if (null == ListToEnd || ListToEnd.Count <= 0)
  769. // return "";
  770. // var List = new List<TCP3Info>();
  771. // for (int j = 0; j < ListToEnd.Count; j++)
  772. // {
  773. // //不是组三就不执行
  774. // if (!(ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode2 || ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode3 ||
  775. // ListToEnd[j].OpenCode2 == ListToEnd[j].OpenCode3 &&
  776. // (ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode2 && ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode3)))
  777. // continue;
  778. // List.Add(ListToEnd[j]);
  779. // }
  780. // ListToEnd = List;
  781. // //获取走势图项及配置数据
  782. // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  783. // if (null == trendChartItem || 0 >= trendChartItem.Count)
  784. // return "";
  785. // int count = trendChartItem.Count;
  786. // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
  787. // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
  788. // foreach (var item in trendChartItem)
  789. // {
  790. // //实例化项类型
  791. // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
  792. // //获取项CSS配置信息
  793. // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
  794. // }
  795. // //项初始化
  796. // for (int i = 0; i < count; i++)
  797. // {
  798. // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
  799. // }
  800. // for (int j = 0; j < ListToEnd.Count; j++)
  801. // {
  802. // if (j < ListToEnd.Count - 31)
  803. // {
  804. // for (int i = 0; i < count; i++)
  805. // {
  806. // //计算项值及遗漏计算
  807. // chartItem[i].SetItemValue(ListToEnd[j]);
  808. // }
  809. // }
  810. // else
  811. // {
  812. // sp.Append("<tr>");
  813. // for (int i = 0; i < count; i++)
  814. // {
  815. // //计算项值及遗漏计算
  816. // chartItem[i].SetItemValue(ListToEnd[j]);
  817. // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
  818. // }
  819. // sp.Append("</tr>");
  820. // }
  821. // }
  822. // return sp.ToString();
  823. //}
  824. #endregion
  825. }
  826. }