123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CB.Common;
- using CB.Data;
- using CB.Entity;
- using CB.Interface;
- using CB.Interface.Infrastructure;
- namespace CB.TrendChart.LotteryTrendChart
- {
- /// <summary>
- /// 体彩P3、P5走势图生成工具
- /// </summary>
- public class TCP3Trend
- {
- public static int Cid = 2;//Cid用于设置样式值
- /// <summary>
- /// 生成走势图,生成当前term数据及以后数据
- /// by JNswins 2015-06-10
- /// </summary>
- /// <param name="chartId">走势图ID</param>
- /// <param name="chartType">走势图类型</param>
- /// <param name="term">需要生成走势图期数</param>
- /// <param name="LotterySearchField">彩种开奖数据额外查询条件</param>
- /// <returns></returns>
- public static Tuple<bool, string> CreateTrendChart(int chartId, TrendChartType chartType, long term, LotterySearchField fields = null)
- {
- //获取走势图项及配置数据
- var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- if (null == trendChartItem || 0 >= trendChartItem.Count)
- return new Tuple<bool, string>(false, string.Format("未找到【ChartId={0}】走势图的项配置数据", chartId));
- int count = trendChartItem.Count;
- IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- foreach (var item in trendChartItem)
- {
- //实例化项类型
- chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- //获取项CSS配置信息
- cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- }
- //各项初始化
- for (int i = 0; i < count; i++)
- {
- trendChartItem[i].Cid = Cid;
- chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- }
- //大于等于term开奖数据
- IList<TCP3Info> ListToEnd = TCP3Service.GetListToEnd(term, fields);
- if (null == ListToEnd || 0 >= ListToEnd.Count)
- return new Tuple<bool, string>(false, "未找到有效开奖数据");
- int j = 0;
- TrendChartData entity = null;
- var ResultEntity = new TrendChartData
- {
- ChartId = chartId,
- Term = term,
- ChartType = chartType,
- LocalMiss = new string[count],
- LastMiss = new string[count],
- AllMaxMiss = new string[count],
- AllAvgMiss = new string[count],
- AllTimes = new string[count]
- };
- foreach (var currentData in ListToEnd)
- {
- //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
- IList<TCP3Info> list = TCP3Service.ToListForTrend(currentData.Term, fields);
- TCP3Info info = null,lastinfo=null;
- info = list[0];
- //modified by zizi,at 2016-8-29,3d和排列三试机号10和22
- //TODO:下面代码可以重构到Model基类中,以后再改
- if (chartId == 22)
- {
- if (info.OpenCode1 == -1 || info.OpenCode2 == -1 || info.OpenCode3 == -1)
- {
- var sjh = info.ShiJiHao;
- if (!string.IsNullOrEmpty(sjh))
- {
- var opArr = sjh.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- //info.OpenCode1 = int.Parse(opArr[0]);
- //info.OpenCode2 = int.Parse(opArr[1]);
- //info.OpenCode3 = int.Parse(opArr[2]);
- if (opArr.Length >= 3)
- {
- info.OpenCode[0] = int.Parse(opArr[0]);
- info.OpenCode[1] = int.Parse(opArr[1]);
- info.OpenCode[2] = int.Parse(opArr[2]);
- info.OpenCode[3] = 0;
- info.OpenCode[4] = 0;
- }
- else {
- info.OpenCode[0] = -1;
- info.OpenCode[1] = -1;
- info.OpenCode[2] = -1;
- info.OpenCode[3] = 0;
- info.OpenCode[4] = 0;
- }
-
- }
- }
- }
- if (2 == list.Count)
- {
- //取当前期数的上一期的走势图信息及遗漏数据
- lastinfo = list[1];
- entity = ResultEntity;
- if (0 == j)
- entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
- }
- bool yes = true;
- var sp = new StringBuilder(20000);
- sp.Append("<tr>");
- for (int i = 0; i < count; i++)
- {
- //初始化遗漏数据(根据上期结果集计算_entity)
- chartItem[i].MissDataInit(entity, i);
- //计算项值及遗漏计算
- yes = yes && chartItem[i].SetItemValue(info,lastinfo);
- if (yes)
- {
- //结果集赋值
- ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
- ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
- ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
- ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
- ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
- //modified by zizi,at 2016-8-29,3d和排列三试机号10和22
- if (i == 1 && chartId == 22 && info.OpenCode1 == -1)
- {
- var singleValueItem = chartItem[i] as SingleValueItem<TCP3Info>;
- if (singleValueItem != null)
- singleValueItem._itemValue = " ";
- }
- sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- }
- }
- sp.Append("</tr>");
- if (null != entity)
- ResultEntity.RecordCount = entity.RecordCount + 1;
- else
- ResultEntity.RecordCount = 1;
- ResultEntity.Term = currentData.Term;
- ResultEntity.HtmlData = sp.ToString();
- if (!yes)
- { return new Tuple<bool, string>(false, string.Format("无效开奖数据:数据生成截止期数为【term={0}】", ResultEntity.Term)); }
- yes = yes && DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
- if (!yes)
- { return new Tuple<bool, string>(false, string.Format("数据保存出错:数据保存截止期数为【term={0}】", ResultEntity.Term)); }
- j++;
- }
- return new Tuple<bool, string>(true, string.Format("正常生成完毕,截止期数为:Term={0}", ListToEnd[ListToEnd.Count - 1].Term));
- }
- /// <summary>
- /// 预览走势图,默认显示近30期数据 (实时计算生成)
- /// </summary>
- /// <param name="chartId"></param>
- /// <param name="chartType"></param>
- /// <param name="term"></param>
- /// <param name="fields"></param>
- /// <returns></returns>
- public static string PreViewTrendChart(int chartId, TrendChartType chartType, LotterySearchField fields = null)
- {
- var list = TCP3Service.GetListToEnd(0, fields);
- if (null == list || 0 >= list.Count)
- return "";
- //获取走势图项及配置数据
- var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- if (null == trendChartItem || 0 >= trendChartItem.Count)
- return "";
- int count = trendChartItem.Count;
- IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- foreach (var item in trendChartItem)
- {
- //实例化项类型
- chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- //获取项CSS配置信息
- cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- }
- //项初始化
- for (int i = 0; i < count; i++)
- {
- trendChartItem[i].Cid = Cid;
- chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- }
- var sp = new StringBuilder(20000);
- int record = list.Count;
- int topSize = null == fields ? 30 : fields.TopSize;
- if (30 > topSize)
- topSize = 30;
- for (int i = 0; i < record; i++)
- {
- for (int j = count - 1; j >= 0; j--)
- {
- chartItem[j].SetItemValue(list[i]);
- }
- if (i >= record - topSize)
- {
- sp.Append("<tr>");
- for (int j = 0; j < count; j++)
- {
- sp.Append(chartItem[j].GetFomartString("<td {0}>{1}</td>"));
- }
- sp.Append("</tr>");
- }
- }
- return sp.ToString();
- }
- /// <summary>
- /// 预览(012路走势图4走势图),默认显示近30期数据 (实时计算生成)
- /// </summary>
- /// <param name="chartId"></param>
- /// <param name="chartType"></param>
- /// <returns></returns>
- public static string PreViewTCP3_012_4_TrendChart(int chartId, TrendChartType chartType,LotterySearchField fields = null)
- {
- var list = TCP3Service.GetListToEnd(0,fields);
- if (null == list || 0 >= list.Count)
- return "";
- //获取走势图项及配置数据
- var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- if (null == trendChartItem || 0 >= trendChartItem.Count)
- return "";
- int count = trendChartItem.Count;
- IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- foreach (var item in trendChartItem)
- {
- //实例化项类型
- chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- //获取项CSS配置信息
- cssConfig.Add(ChartCssConfigService.Get(item.FuntionType, item.ChartCssId));
- }
- //项初始化
- for (int i = 0; i < count; i++)
- {
- trendChartItem[i].Cid = Cid;
- chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- }
- var sp = new StringBuilder(20000);
- int record = list.Count;
- int topSize = null == fields ? 30 : fields.TopSize;
-
- int row = 0;// 控制一行4个td
- sp.Append("<div class=\"zstableBox\">");
- for (int i = record - topSize; i < record; i++)
- {
- for (int j = count - 1; j >= 0; j--)
- {
- chartItem[j].SetItemValue(list[i]);
- }
- if (i >= record - topSize)
- {
- if ((row % 4) == 0)
- {
- sp.Append("<tr>");
- }
- for (int j = 0; j < count; j++)
- {
- sp.Append(chartItem[j].GetFomartString("<td {0}>{1}</td>"));
- }
- if ((row % 4) == 3)
- {
- sp.Append("</tr>");
- }
- row++;
- }
- }
- sp.Append("</div>");
- return sp.ToString();
- }
- /// <summary>
- /// 预览(012路走势图4走势图),默认显示近30期数据 (实时计算生成)
- /// </summary>
- /// <param name="chartId"></param>
- /// <param name="chartType"></param>
- /// <param name="term"></param>
- /// <param name="fields"></param>
- /// <returns></returns>
- public static string PreViewTCP3_012_4_TrendChart(int chartId, TrendChartType chartType,TrendChartSearchField fields)
- {
- var list = TCP3Service.GetListToEnd(0, fields);
- if (null == list || 0 >= list.Count)
- return "";
- if (fields != null && fields.StartTerm == 0 && fields.EndTerm == 0)
- {
- fields.EndTerm = (int)list[0].Term;
- fields.StartTerm = (int)list[list.Count - 1].Term;
- }
- //获取走势图项及配置数据
- var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- if (null == trendChartItem || 0 >= trendChartItem.Count)
- return "";
- int count = trendChartItem.Count;
- IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- foreach (var item in trendChartItem)
- {
- //实例化项类型
- chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- //获取项CSS配置信息
- cssConfig.Add(ChartCssConfigService.Get(item.FuntionType, item.ChartCssId));
- }
- //项初始化
- for (int i = 0; i < count; i++)
- {
- trendChartItem[i].Cid = Cid;
- chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- }
- var sp = new StringBuilder(20000);
- int record = list.Count;
- //int topSize = null == fields ? 30 : fields.TopSize;
- //if (30 > topSize)
- // topSize = 30;
- int row = 0;// 控制一行4个td
- sp.Append("<div class=\"zstableBox\">");
- for (int i = 0; i < record; i++)
- {
- for (int j = count - 1; j >= 0; j--)
- {
- chartItem[j].SetItemValue(list[i]);
- }
- if ((row % 4) == 0)
- {
- sp.Append("<tr>");
- }
- for (int j = 0; j < count; j++)
- {
- sp.Append(chartItem[j].GetFomartString("<td {0}>{1}</td>"));
- }
- if ((row % 4) == 3)
- {
- sp.Append("</tr>");
- }
- row++;
- }
- sp.Append("</div>");
- return sp.ToString();
- }
- #region 生成走势图 已注释 by JNswins 2015-06-11
- ///// <summary>
- ///// 生成走势图
- ///// </summary>
- ///// <param name="chartId">走势图ID</param>
- ///// <param name="chartType">走势图类型</param>
- ///// <param name="term">需要生成走势图期数</param>
- ///// <param name="MultiTerm">true:生成term期数及以后期数的走势图及遗漏数据;false:仅生成当前期走势图及遗漏数据</param>
- ///// <param name="IsZS">true:生成组三数据;false:全部数据</param>
- ///// <returns></returns>
- //public static bool CreateTrendChart(int chartId, TrendChartType chartType, long term, int week, bool MultiTerm = false, bool IsZS = false)
- //{
- // if (MultiTerm && IsZS)
- // return CreateCurrentToEndZSTrendChart(chartId, chartType, term);
- // if (MultiTerm && !IsZS)
- // return CreateCurrentToEndTrendChart(chartId, chartType, term);
- // if (!MultiTerm && IsZS)
- // return CreateCurrentZSTrendChart(chartId, chartType, term);
- // return CreateCurrentTrendChart(chartId, chartType, term);
- //}
- ///// <summary>
- ///// 生成当前期走势图
- ///// </summary>
- ///// <param name="chartId"></param>
- ///// <param name="chartType"></param>
- ///// <param name="term"></param>
- ///// <returns></returns>
- //private static bool CreateCurrentTrendChart(int chartId, TrendChartType chartType, long term)
- //{
- // //获取走势图项及配置数据
- // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- // if (null == trendChartItem || 0 >= trendChartItem.Count)
- // return false;
- // int count = trendChartItem.Count;
- // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- // foreach (var item in trendChartItem)
- // {
- // //实例化项类型
- // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- // //获取项CSS配置信息
- // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- // }
- // //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
- // var list = TCP3Service.ToListForTrend(term);
- // TCP3Info info = null;
- // TrendChartData entity = null;
- // if (null == list || 0 >= list.Count)
- // return false;
- // info = list[0];
- // if (2 == list.Count)
- // {
- // //取当前期数的上一期的走势图信息及遗漏数据
- // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
- // }
- // var ResultEntity = new TrendChartData
- // {
- // ChartId = chartId,
- // Term = term,
- // ChartType = chartType,
- // LocalMiss = new string[count],
- // LastMiss = new string[count],
- // AllMaxMiss = new string[count],
- // AllAvgMiss = new string[count],
- // AllTimes = new string[count]
- // };
- // var sp = new StringBuilder(20000);
- // sp.Append("<tr>");
- // for (int i = 0; i < count; i++)
- // {
- // //项初始化
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // //初始化遗漏数据(根据上期结果集计算_entity)
- // chartItem[i].MissDataInit(entity, i);
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(info);
- // //结果集赋值
- // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
- // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
- // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
- // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
- // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
- // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- // }
- // sp.Append("</tr>");
- // if (entity != null)
- // ResultEntity.RecordCount = entity.RecordCount + 1;
- // else
- // ResultEntity.RecordCount = 1;
- // ResultEntity.HtmlData = sp.ToString();
- // return DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
- //}
- ///// <summary>
- ///// 生成当前期(组三)走势图
- ///// </summary>
- ///// <param name="chartId"></param>
- ///// <param name="chartType"></param>
- ///// <param name="term"></param>
- ///// <returns></returns>
- //private static bool CreateCurrentZSTrendChart(int chartId, TrendChartType chartType, long term)
- //{
- // //获取走势图项及配置数据
- // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- // if (null == trendChartItem || 0 >= trendChartItem.Count)
- // return false;
- // int count = trendChartItem.Count;
- // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- // foreach (var item in trendChartItem)
- // {
- // //实例化项类型
- // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- // //获取项CSS配置信息
- // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- // }
- // //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
- // var list = TCP3Service.ToListForZSTrend(term);
- // TCP3Info info = null;
- // TrendChartData entity = null;
- // if (null == list || 0 >= list.Count)
- // return false;
- // info = list[0];
- // //当前期不是组三走势图
- // if (info.Term != term)
- // return false;
- // if (2 == list.Count)
- // {
- // //取当前期数的上一期的走势图信息及遗漏数据
- // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
- // //将上一期数据初始化(方便用期号计算机组三遗漏值)
- // for (int i = 0; i < count; i++)
- // {
- // //项初始化
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // //初始化遗漏数据(根据上期结果集计算_entity)
- // chartItem[i].MissDataInit(entity, i);
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(list[1]);
- // }
- // }
- // var ResultEntity = new TrendChartData
- // {
- // ChartId = chartId,
- // Term = term,
- // ChartType = chartType,
- // LocalMiss = new string[count],
- // LastMiss = new string[count],
- // AllMaxMiss = new string[count],
- // AllAvgMiss = new string[count],
- // AllTimes = new string[count]
- // };
- // var sp = new StringBuilder(20000);
- // sp.Append("<tr>");
- // for (int i = 0; i < count; i++)
- // {
- // //项初始化
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // //初始化遗漏数据(根据上期结果集计算_entity)
- // chartItem[i].MissDataInit(entity, i);
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(info);
- // //结果集赋值
- // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
- // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
- // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
- // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
- // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
- // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- // }
- // sp.Append("</tr>");
- // if (entity != null)
- // ResultEntity.RecordCount = entity.RecordCount + 1;
- // else
- // ResultEntity.RecordCount = 1;
- // ResultEntity.HtmlData = sp.ToString();
- // return DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
- //}
- ///// <summary>
- ///// 生成当期走势图以及后面走势图
- ///// </summary>
- ///// <param name="chartId"></param>
- ///// <param name="chartType"></param>
- ///// <param name="term"></param>
- ///// <returns></returns>
- //private static bool CreateCurrentToEndTrendChart(int chartId, TrendChartType chartType, long term)
- //{
- // //当期以及以后数据
- // var ListToEnd = TCP3Service.GetListToEnd(term);
- // if (null == ListToEnd || ListToEnd.Count <= 0)
- // return false;
- // //获取走势图项及配置数据
- // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- // if (null == trendChartItem || 0 >= trendChartItem.Count)
- // return false;
- // int count = trendChartItem.Count;
- // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- // foreach (var item in trendChartItem)
- // {
- // //实例化项类型
- // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- // //获取项CSS配置信息
- // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- // }
- // //项初始化
- // for (int i = 0; i < count; i++)
- // {
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // }
- // foreach (var currentData in ListToEnd)
- // {
- // //根据参数term期数获取近两期开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
- // var list = TCP3Service.ToListForTrend(currentData.Term);
- // TCP3Info info = null;
- // TrendChartData entity = null;
- // if (null == list || 0 >= list.Count)
- // continue;
- // info = list[0];
- // if (2 == list.Count)
- // {
- // //取当前期数的上一期的走势图信息及遗漏数据
- // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
- // }
- // var ResultEntity = new TrendChartData
- // {
- // ChartId = chartId,
- // Term = currentData.Term,
- // ChartType = chartType,
- // LocalMiss = new string[count],
- // LastMiss = new string[count],
- // AllMaxMiss = new string[count],
- // AllAvgMiss = new string[count],
- // AllTimes = new string[count]
- // };
- // var sp = new StringBuilder(20000);
- // sp.Append("<tr>");
- // for (int i = 0; i < count; i++)
- // {
- // //初始化遗漏数据(根据上期结果集计算_entity)
- // chartItem[i].MissDataInit(entity, i);
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(info);
- // //结果集赋值
- // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
- // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
- // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
- // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
- // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
- // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- // }
- // sp.Append("</tr>");
- // if (entity != null)
- // ResultEntity.RecordCount = entity.RecordCount + 1;
- // else
- // ResultEntity.RecordCount = 1;
- // ResultEntity.HtmlData = sp.ToString();
- // DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
- // }
- // return true;
- //}
- ///// <summary>
- ///// 生成当期(组三)走势图以及后面走势图
- ///// </summary>
- ///// <param name="chartId"></param>
- ///// <param name="chartType"></param>
- ///// <param name="term"></param>
- ///// <returns></returns>
- //private static bool CreateCurrentToEndZSTrendChart(int chartId, TrendChartType chartType, long term)
- //{
- // //当期以及以后数据
- // var ListToEnd = TCP3Service.GetListToEnd(term);
- // if (null == ListToEnd || ListToEnd.Count <= 0)
- // return false;
- // //获取走势图项及配置数据
- // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- // if (null == trendChartItem || 0 >= trendChartItem.Count)
- // return false;
- // int count = trendChartItem.Count;
- // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- // foreach (var item in trendChartItem)
- // {
- // //实例化项类型
- // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- // //获取项CSS配置信息
- // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- // }
- // //项初始化
- // for (int i = 0; i < count; i++)
- // {
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // }
- // for (int j = 0; j < ListToEnd.Count; j++)
- // {
- // //不是组三就不执行
- // if (!(ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode2 || ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode3 ||
- // ListToEnd[j].OpenCode2 == ListToEnd[j].OpenCode3 &&
- // (ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode2 && ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode3)))
- // continue;
- // //根据参数term期数获取近两期(组三)开奖信息TOP 2 [Term]<=term ORDER BY [Term] DESC
- // var list = TCP3Service.ToListForZSTrend(ListToEnd[j].Term);
- // TCP3Info info = null;
- // TrendChartData entity = null;
- // if (null == list || 0 >= list.Count)
- // continue;
- // info = list[0];
- // if (2 == list.Count)
- // {
- // //取当前期数的上一期的走势图信息及遗漏数据
- // entity = TCP3TrendChartDataService.GetTrendChartDataByTerm(chartId, chartType, list[1].Term);
- // //将上一期数据初始化(方便用期号计算机组三遗漏值)--第一条记录才需要初始化上一期数据
- // if (j == 0)
- // for (int i = 0; i < count; i++)
- // {
- // //项初始化
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // //初始化遗漏数据(根据上期结果集计算_entity)
- // chartItem[i].MissDataInit(entity, i);
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(list[1]);
- // }
- // }
- // var ResultEntity = new TrendChartData
- // {
- // ChartId = chartId,
- // Term = ListToEnd[j].Term,
- // ChartType = chartType,
- // LocalMiss = new string[count],
- // LastMiss = new string[count],
- // AllMaxMiss = new string[count],
- // AllAvgMiss = new string[count],
- // AllTimes = new string[count]
- // };
- // var sp = new StringBuilder(20000);
- // sp.Append("<tr>");
- // for (int i = 0; i < count; i++)
- // {
- // //初始化遗漏数据(根据上期结果集计算_entity)
- // chartItem[i].MissDataInit(entity, i);
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(info);
- // //结果集赋值
- // ResultEntity.LocalMiss[i] = chartItem[i].GetMissData(MissDataType.LocalMiss);
- // ResultEntity.LastMiss[i] = chartItem[i].GetMissData(MissDataType.LastMiss);
- // ResultEntity.AllMaxMiss[i] = chartItem[i].GetMissData(MissDataType.AllMaxMiss);
- // ResultEntity.AllAvgMiss[i] = chartItem[i].GetMissData(MissDataType.AllAvgMiss);
- // ResultEntity.AllTimes[i] = chartItem[i].GetMissData(MissDataType.AllTimes);
- // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- // }
- // sp.Append("</tr>");
- // if (entity != null)
- // ResultEntity.RecordCount = entity.RecordCount + 1;
- // else
- // ResultEntity.RecordCount = 1;
- // ResultEntity.HtmlData = sp.ToString();
- // DatabaseProvider.GetDbProvider<ITCP3TrendChartDataService>().Save(ResultEntity);
- // }
- // return true;
- //}
- #endregion
- #region 生成预览走势图 已注释 by JNswins 2015-06-11
- ///// <summary>
- ///// 预览当期走势图以及后面走势图
- ///// </summary>
- ///// <param name="chartId"></param>
- ///// <param name="chartType"></param>
- ///// <param name="term"></param>
- ///// <returns></returns>
- //public static string PreViewCurrentToEndTrendChart(int chartId, TrendChartType chartType)
- //{
- // StringBuilder sp = new StringBuilder(20000);
- // //当期以及以后数据
- // var ListToEnd = TCP3Service.GetListToEnd(-1);
- // if (null == ListToEnd || ListToEnd.Count <= 0)
- // return "";
- // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- // if (null == trendChartItem || 0 >= trendChartItem.Count)
- // return "";
- // int count = trendChartItem.Count;
- // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- // foreach (var item in trendChartItem)
- // {
- // //实例化项类型
- // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- // //获取项CSS配置信息
- // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- // }
- // //项初始化
- // for (int i = 0; i < count; i++)
- // {
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // }
- // for (int j = 0; j < ListToEnd.Count; j++)
- // {
- // if (j < ListToEnd.Count - 31)
- // {
- // for (int i = 0; i < count; i++)
- // {
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(ListToEnd[j]);
- // }
- // }
- // else
- // {
- // sp.Append("<tr>");
- // for (int i = 0; i < count; i++)
- // {
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(ListToEnd[j]);
- // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- // }
- // sp.Append("</tr>");
- // }
- // }
- // return sp.ToString();
- //}
- ///// <summary>
- ///// 预览当期(组三)走势图以及后面走势图
- ///// </summary>
- ///// <param name="chartId"></param>
- ///// <param name="chartType"></param>
- ///// <param name="term"></param>
- ///// <returns></returns>
- //public static string PreViewCurrentToEndZSTrendChart(int chartId, TrendChartType chartType, long term)
- //{
- // var sp = new StringBuilder(20000);
- // //当期以及以后数据
- // var ListToEnd = TCP3Service.GetListToEnd(term);
- // if (null == ListToEnd || ListToEnd.Count <= 0)
- // return "";
- // var List = new List<TCP3Info>();
- // for (int j = 0; j < ListToEnd.Count; j++)
- // {
- // //不是组三就不执行
- // if (!(ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode2 || ListToEnd[j].OpenCode1 == ListToEnd[j].OpenCode3 ||
- // ListToEnd[j].OpenCode2 == ListToEnd[j].OpenCode3 &&
- // (ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode2 && ListToEnd[j].OpenCode1 != ListToEnd[j].OpenCode3)))
- // continue;
- // List.Add(ListToEnd[j]);
- // }
- // ListToEnd = List;
- // //获取走势图项及配置数据
- // var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
- // if (null == trendChartItem || 0 >= trendChartItem.Count)
- // return "";
- // int count = trendChartItem.Count;
- // IList<IChartItem<TCP3Info>> chartItem = new List<IChartItem<TCP3Info>>(count);
- // IList<ChartCssConfigInfo> cssConfig = new List<ChartCssConfigInfo>(count);
- // foreach (var item in trendChartItem)
- // {
- // //实例化项类型
- // chartItem.Add(TrendChartUtils.GetTrendChartInterface<TCP3Info>(item.ClassName));
- // //获取项CSS配置信息
- // cssConfig.Add(ChartCssConfigService.Get(item.ChartCssId));
- // }
- // //项初始化
- // for (int i = 0; i < count; i++)
- // {
- // chartItem[i].Init(cssConfig[i], trendChartItem[i]);
- // }
- // for (int j = 0; j < ListToEnd.Count; j++)
- // {
- // if (j < ListToEnd.Count - 31)
- // {
- // for (int i = 0; i < count; i++)
- // {
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(ListToEnd[j]);
- // }
- // }
- // else
- // {
- // sp.Append("<tr>");
- // for (int i = 0; i < count; i++)
- // {
- // //计算项值及遗漏计算
- // chartItem[i].SetItemValue(ListToEnd[j]);
- // sp.Append(chartItem[i].GetFomartString("<td {0}>{1}</td>"));
- // }
- // sp.Append("</tr>");
- // }
- // }
- // return sp.ToString();
- //}
- #endregion
- }
- }
|