123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using CB.Entity;
- using CB.Common;
- using System.Collections;
- using CB.Data;
- using System.IO;
- namespace CB.TrendTool
- {
- public class TrendToolRule
- {
- public static bool NumberIsNeed(string OneNumber, bool IsInclude, List<string> FilterData, TrendToolInfo content, FilterType filterType)
- {
- bool isRemove = false;
- List<string> results = new List<string>();
- List<string> numSplits = new List<string>(OneNumber.Split(','));
- //如果填写了范围按范围取值
- if (content.IndexStart != -1 && content.IndexEnd != -1 && content.IndexEnd >= content.IndexStart)
- {
- int skipIndex = content.IndexStart;
- int takeCount = content.IndexEnd - content.IndexStart + 1;
- numSplits = numSplits.Skip(skipIndex).Take(takeCount).ToList();
- }
- switch (filterType)
- {
- case FilterType.Filter_ShaHao:
- results = Filter_ShaHaoRule(OneNumber, IsInclude, FilterData, content);
- break;
- //case FilterType.Filter_DanMa:
- // results = Filter_DanMaRule(OneNumber, IsInclude, FilterData, content);
- // break;
- case FilterType.Filter_ShunZi:
- isRemove = Filter_ShunZhiRule(OneNumber, IsInclude, FilterData);
- return isRemove;
- case FilterType.Filter_ErMaHe:
- results = Filter_ErMaHeRule(OneNumber);
- break;
- case FilterType.Filter_ErMaCha:
- results = Filter_ErMaChaRule(OneNumber);
- break;
- case FilterType.Filter_ErMa:
- results = Filter_ErMaRule(OneNumber);
- break;
- case FilterType.Filter_Filter012:
- results = Filter_Filter012Rule(OneNumber);
- break;
- case FilterType.Filter_HeZhi:
- results = Filter_HeZhiRule(OneNumber);
- break;
- case FilterType.Filter_HeWei:
- results = Filter_HeWeiRule(OneNumber);
- break;
- case FilterType.Filter_KuaDu:
- results = Filter_KuaDuRule(OneNumber);
- break;
- case FilterType.Filter_DaZhongXiao:
- results = Filter_DaZhongXiaoRule(OneNumber);
- break;
- case FilterType.Filter_DaXiao:
- results = Filter_DaXiaoRule(OneNumber);
- break;
- case FilterType.Filter_JiOu:
- results = Filter_JiOuRule(OneNumber);
- break;
- case FilterType.Filter_ZhiHe:
- results = Filter_ZhiHeRule(OneNumber);
- break;
- case FilterType.Filter_ProportionOfJiOu:
- results = Filter_ProportionOfJiOuRule(numSplits);
- break;
- case FilterType.Filter_ZuXuan_ZhiHe:
- results = Filter_ZuXuan_ZhiHeRule(OneNumber);
- break;
- case FilterType.Filter_ZuXuan_JiOu:
- results = Filter_ZuXuan_JiOuRule(OneNumber);
- break;
- case FilterType.Filter_ZuXuan_DaXiao:
- results = Filter_ZuXuan_DaXiaoRule(OneNumber);
- break;
- case FilterType.Filter_ZuXuan_Filter012:
- results = Filter_ZuXuan_Filter012Rule(OneNumber);
- break;
- case FilterType.Filter_HeZhi012:
- results = Filter_HeZhi012Rule(OneNumber);
- break;
- case FilterType.Filte_P5ZhuHe0:
- results = Filte_P5ZhuHe0Rule(OneNumber);
- break;
- case FilterType.Filte_P5ZhuHe1:
- results = Filte_P5ZhuHe1Rule(OneNumber);
- break;
- case FilterType.Filte_P5ZhuHe2:
- results = Filte_P5ZhuHe2Rule(OneNumber);
- break;
- case FilterType.Filter_Ac:
- results = Filter_ErAcRule(numSplits);
- break;
- case FilterType.Filter_FirstJiOu:
- results = Filter_FirstJiOuFilter(numSplits);
- break;
- case FilterType.Filter_LastJiOu:
- results = Filter_LastJiOuFilter(numSplits);
- break;
- case FilterType.Filter_ProportionOfZhiHe:
- results = Filter_ProportionOfZhiHeRule(numSplits);
- break;
- case FilterType.Filter_hzSpan:
- results = Filter_hzSpanFilter(numSplits, FilterData);
- break;
- case FilterType.Filter_LianHaoCount:
- results = Filter_LianHaoCountRule(numSplits, content);
- break;
- case FilterType.Filter_TzCount:
- results = Filter_TzCountRule(numSplits);
- break;
- case FilterType.Filter_ProportionOfDaXiao:
- results = Filter_ProportionOfDxRule(numSplits, content);
- break;
- }
- isRemove = IncludeFilter(IsInclude, results, FilterData);
- return isRemove;
- }
- #region 组选过滤
- [ToolFunctionAttr("质合过滤-组选-(3D)", FilterType.Filter_ZuXuan_ZhiHe)]
- public static List<string> Filter_ZuXuan_ZhiHeRule(string number)
- {
- List<string> zhi = new List<string>() { "1", "2", "3", "5", "7" };
- string[] nums = number.Split(',');
- string zhihe = "";
- int zhiCount = 0;
- foreach (string num in nums)
- { if (zhi.Contains(num)) zhiCount++; }
- switch (zhiCount)
- {
- case 0:
- zhihe = "全合";
- break;
- case 1:
- zhihe = "两合一质";
- break;
- case 2:
- zhihe = "两质一合";
- break;
- case 3:
- zhihe = "全质";
- break;
- }
- List<string> reData = new List<string>();
- reData.Add(zhihe);
- return reData;
- }
- [ToolFunctionAttr("奇偶过滤-组选-(3D)", FilterType.Filter_ZuXuan_JiOu)]
- public static List<string> Filter_ZuXuan_JiOuRule(string number)
- {
- List<string> ji = new List<string>() { "1", "3", "5", "7", "9" };
- //List<string> ou = new List<string>() { "0", "2", "4", "6", "8", };
- string[] nums = number.Split(',');
- string jiou = "";
- int jiCount = 0;
- foreach (string num in nums)
- { if (ji.Contains(num)) jiCount++; }
- switch (jiCount)
- {
- case 0:
- jiou = "全偶";
- break;
- case 1:
- jiou = "两偶一奇";
- break;
- case 2:
- jiou = "两奇一偶";
- break;
- case 3:
- jiou = "全奇";
- break;
- }
- List<string> reData = new List<string>();
- reData.Add(jiou);
- return reData;
- }
- /// <summary>
- /// 大小过滤
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("大小过滤-组选-(3D)", FilterType.Filter_ZuXuan_DaXiao)]
- public static List<string> Filter_ZuXuan_DaXiaoRule(string number)
- {
- List<string> reData = new List<string>();
- List<string> da = new List<string>() { "5", "6", "7", "8", "9" };
- string daxiao = "";
- //List<string> xiao = new List<string>() { "0", "1", "2", "3", "4", };
- string[] nums = number.Split(',');
- int daCount = 0;
- foreach (string num in nums)
- {
- if (da.Contains(num)) daCount++;
- }
- switch (daCount)
- {
- case 0:
- daxiao = "全小";
- break;
- case 1:
- daxiao = "两小一大";
- break;
- case 2:
- daxiao = "两大一小";
- break;
- case 3:
- daxiao = "全大";
- break;
- }
- reData.Add(daxiao);
- return reData;
- }
- [ToolFunctionAttr("012路过滤-组选-(3D)", FilterType.Filter_ZuXuan_Filter012)]
- public static List<string> Filter_ZuXuan_Filter012Rule(string Number)
- {
- string[] nums = Number.Split(',');
- string lu = "";
- //3个0 3个1 3个2 2个0 2个1 2个2 各1个
- int Count0 = 0;
- int Count1 = 0;
- int Count2 = 0;
- foreach (string num in nums)
- {
- int data = int.Parse(num);
- if ((data % 3) == 0) Count0++;
- if ((data % 3) == 1) Count1++;
- if ((data % 3) == 2) Count2++;
- }
- if (Count0 == 3) lu = "3个0";
- else if (Count0 == 2) lu = "2个0";
- else if (Count1 == 3) lu = "3个1";
- else if (Count1 == 2) lu = "2个1";
- else if (Count2 == 3) lu = "3个2";
- else if (Count2 == 2) lu = "2个2";
- else lu = "各1个";
- List<string> reData = new List<string>();
- reData.Add(lu);
- return reData;
- }
- #endregion
- #region 一般过滤
- [ToolFunctionAttr("大中小过滤-(3D,P3)", FilterType.Filter_DaZhongXiao)]
- public static List<string> Filter_DaZhongXiaoRule(string number)
- {
- List<string> da = new List<string>() { "7", "8", "9" };
- List<string> zhong = new List<string>() { "3", "4", "5", "6" };
- //List<string> xiao = new List<string>() { "0", "1", "2" };
- string[] nums = number.Split(',');
- string dazhongxiao = "";
- foreach (string num in nums)
- {
- if (da.Contains(num))
- dazhongxiao += "大";
- else if (zhong.Contains(num))
- dazhongxiao += "中";
- else
- dazhongxiao += "小";
- }
- List<string> reData = new List<string>();
- reData.Add(dazhongxiao);
- return reData;
- }
- /// <summary>
- /// 大小过滤
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("大小过滤-(3D,P3)", FilterType.Filter_DaXiao)]
- public static List<string> Filter_DaXiaoRule(string number)
- {
- List<string> da = new List<string>() { "5", "6", "7", "8", "9" };
- //List<string> xiao = new List<string>() { "0", "1", "2", "3", "4", };
- string[] nums = number.Split(',');
- string daxiao = "";
- List<string> reData = new List<string>();
- foreach (string num in nums)
- {
- if (da.Contains(num))
- daxiao += "大";
- else
- daxiao += "小";
- }
- reData.Add(daxiao);
- return reData;
- }
- /// <summary>
- /// 大小比过滤
- /// </summary>
- /// <param name="number">单个组合的号码</param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("大小比(数字类型比例,例:1:2)", FilterType.Filter_ProportionOfDaXiao)]
- public static List<string> Filter_ProportionOfDxRule(List<string> numSplits, TrendToolInfo content)
- {
- int indexnumber = 0;
- switch (content.Id)
- {
- case 150:
- indexnumber = 6;
- break;
- default:
- indexnumber = 18;
- break;
- }
- int d = 0;
- int x = 0;
- foreach (var item in numSplits)
- {
- if (TypeConverter.StrToInt(item) > indexnumber)
- { d++; }
- else
- { x++; }
- }
- List<string> reData = new List<string>();
- reData.Add(d.ToString() + ":" + x.ToString());
- return reData;
- }
- /// <summary>
- /// 连号组数
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("连号组数", FilterType.Filter_LianHaoCount)]
- public static List<string> Filter_LianHaoCountRule(List<string> numSplits, TrendToolInfo content)
- {
- int lh = 0;
- for (int i = 0; i < numSplits.Count; i++)
- {
- if (i > 0 && Convert.ToInt32(numSplits[i]) - Convert.ToInt32(numSplits[i - 1]) == 1)
- lh++;
- }
- List<string> reData = new List<string>();
- if (lh == 0)
- {
- reData.Add("无连号");
- }
- else
- {
- reData.Add(lh + "连号");
- }
- return reData;
- }
- /// <summary>
- /// 尾数相同组数
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("每注中尾数不相同的投注号码", FilterType.Filter_TzCount)]
- public static List<string> Filter_TzCountRule(List<string> numSplits)
- {
- List<int> count = new List<int>();
- for (int i = 0; i < numSplits.Count; i++)
- {
- if (!count.Contains(TypeConverter.StrToInt(numSplits[i]) % 10))
- {
- count.Add(TypeConverter.StrToInt(numSplits[i]) % 10);
- }
- }
- List<string> reData = new List<string>();
- reData.Add((count.Count).ToString());
- return reData;
- }
- [ToolFunctionAttr("杀号过滤和不定位杀过滤-(3D,P3,P5)", FilterType.Filter_ShaHao)]
- public static List<string> Filter_ShaHaoRule(string OneNumber, bool IsInclude, List<string> FilterData, TrendToolInfo content)
- {
- List<string> reData = new List<string>(OneNumber.Split(','));
- //如果填写了范围按范围取值
- if (content.IndexStart != -1 && content.IndexEnd != -1 && content.IndexEnd >= content.IndexStart)
- {
- int skipIndex = content.IndexStart;
- int takeCount = content.IndexEnd - content.IndexStart + 1;
- reData = reData.Skip(skipIndex).Take(takeCount).ToList();
- }
- return reData;
- }
- /// <summary>
- /// 胆码过滤和不定位胆码过滤
- /// </summary>
- /// <param name="oneNumber"></param>
- /// <param name="IsInclude"></param>
- /// <param name="FilterData"></param>
- /// <param name="content"></param>
- /// <returns></returns>
- //public static List<string> Filter_DanMaRule(string oneNumber, bool IsInclude, List<string> FilterData, TrendToolInfo content)
- //{
- // List<string> reData = new List<string>(oneNumber.Split(','));
- // //如果填写了范围按范围取值
- // if (content.IndexStart != -1 && content.IndexEnd != -1 && content.IndexEnd >= content.IndexStart)
- // {
- // int skipIndex = content.IndexStart;
- // int takeCount = content.IndexEnd - content.IndexStart + 1;
- // reData = reData.Skip(skipIndex).Take(takeCount).ToList();
- // }
- // return reData;
- //}
- /// <summary>
- /// 和值过滤(区间段)
- /// </summary>
- [ToolFunctionAttr("和值过滤(区间段)", FilterType.Filter_hzSpan)]
- public static List<string> Filter_hzSpanFilter(List<string> numSplits, List<string> FilteData)
- {
- List<int> sums = new List<int>();
- foreach (var item in FilteData)
- {
- sums.Add(TypeConverter.StrToInt(item));
- }
- int sum = 0;
- foreach (var item in numSplits)
- {
- sum += TypeConverter.StrToInt(item);
- }
- List<string> result = new List<string>();
- if (sum >= sums.Min() && sum <= sums.Max())
- {
- result.Add(sums.Min().ToString());
- }
- else
- {
- result.Add("");
- }
- return result;
- }
- /// <summary>
- /// 二码差过滤
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <param name="erma"></param>
- /// <returns></returns>
- [ToolFunctionAttr("二码差过滤-(3D,P3)", FilterType.Filter_ErMaCha)]
- public static List<string> Filter_ErMaChaRule(string number)
- {
- List<string> nums = new List<string>(number.Split(','));
- List<string> ErMaValue = new List<string>();
- for (int n1 = 0; n1 < nums.Count; n1++)
- {
- for (int n2 = n1 + 1; n2 < nums.Count; n2++)
- {
- string data = string.Empty;
- data = Math.Abs(int.Parse(nums[n1]) - int.Parse(nums[n2])).ToString();
- if (!ErMaValue.Contains(data))
- ErMaValue.Add(data);
- }
- }
- return ErMaValue;
- }
- /// <summary>
- /// 二码和过滤
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <param name="erma"></param>
- /// <returns></returns>
- [ToolFunctionAttr("二码和过滤-(3D,P3)", FilterType.Filter_ErMaHe)]
- public static List<string> Filter_ErMaHeRule(string number)
- {
- List<string> nums = new List<string>(number.Split(','));
- List<string> ErMaValue = new List<string>();
- for (int n1 = 0; n1 < nums.Count; n1++)
- {
- for (int n2 = n1 + 1; n2 < nums.Count; n2++)
- {
- string data = string.Empty;
- data = (int.Parse(nums[n1]) + int.Parse(nums[n2])).ToString();
- if (!ErMaValue.Contains(data))
- ErMaValue.Add(data);
- }
- }
- return ErMaValue;
- }
- /// <summary>
- /// 首位奇偶过滤
- /// </summary>
- /// <param name="Numbers"></param>
- /// <param name="filter"></param>
- /// <param name="list"></param>
- /// <param name="filterType"></param>
- /// <param name="p"></param>
- [ToolFunctionAttr("首位奇偶过滤", FilterType.Filter_FirstJiOu)]
- public static List<string> Filter_FirstJiOuFilter(List<string> numSplits)
- {
- string Lastnumber = numSplits[0];
- string result = "";
- if (TypeConverter.StrToInt(Lastnumber) % 2 == 0)
- {
- result = "2";
- }
- else
- {
- result = "1";
- }
- List<string> reData = new List<string>();
- reData.Add(result);
- return reData;
- }
- /// <summary>
- /// 末位奇偶过滤
- /// </summary>
- [ToolFunctionAttr("末位奇偶过滤", FilterType.Filter_LastJiOu)]
- public static List<string> Filter_LastJiOuFilter(List<string> numSplits)
- {
- string num = numSplits[numSplits.Count - 1];
- string result = "";
- if (TypeConverter.StrToInt(num) % 2 == 0)
- {
- result = "2";
- }
- else
- {
- result = "1";
- }
- List<string> reData = new List<string>();
- reData.Add(result);
- return reData;
- }
- [ToolFunctionAttr("二码过滤-(3D,P3)", FilterType.Filter_ErMa)]
- public static List<string> Filter_ErMaRule(string number)
- {
- List<string> nums = new List<string>(number.Split(','));
- List<string> ErMaValue = new List<string>();
- for (int n1 = 0; n1 < nums.Count; n1++)
- {
- for (int n2 = n1 + 1; n2 < nums.Count; n2++)
- {
- string data = string.Empty;
- var erma = new List<string>() { nums[n1], nums[n2] };
- erma.Sort();
- data = erma[0] + erma[1];
- if (!ErMaValue.Contains(data))
- ErMaValue.Add(data);
- }
- }
- return ErMaValue;
- }
- [ToolFunctionAttr("012路过滤-(3D,P3))", FilterType.Filter_Filter012)]
- public static List<string> Filter_Filter012Rule(string number)
- {
- string[] nums = number.Split(',');
- string lu = "";
- foreach (string num in nums)
- {
- int data = int.Parse(num);
- lu += (data % 3).ToString();
- }
- List<string> reData = new List<string>();
- reData.Add(lu);
- return reData;
- }
- /// <summary>
- /// 和值过滤
- /// </summary>
- /// <param name="OneNumber"></param>
- /// <param name="IsInclude"></param>
- /// <param name="FilterData"></param>
- /// <returns></returns>
- [ToolFunctionAttr("和值过滤-(3D,P3)", FilterType.Filter_HeZhi)]
- public static List<string> Filter_HeZhiRule(string OneNumber)
- {
- string[] nums = OneNumber.Split(',');
- int data = 0;
- foreach (string num in nums)
- {
- data += Convert.ToInt32(num);
- }
- List<string> reData = new List<string>();
- string sdata = data.ToString("00");
- reData.Add(sdata);
- return reData;
- }
- [ToolFunctionAttr("和尾过滤-(3D,P3,P5)", FilterType.Filter_HeWei)]
- public static List<string> Filter_HeWeiRule(string number)
- {
- string[] nums = number.Split(',');
- int idata = 0;
- foreach (string num in nums)
- {
- idata += Convert.ToInt32(num);
- }
- string hewei = idata.ToString();
- List<string> reData = new List<string>();
- //取最后一位
- string sdata = hewei.Substring(hewei.Length - 1, 1);
- reData.Add(sdata);
- return reData;
- }
- [ToolFunctionAttr("顺子过滤-(3D,P3)", FilterType.Filter_ShunZi)]
- public static bool Filter_ShunZhiRule(string OneNumber, bool IsInclude, List<string> FilterData)
- {
- string ShunZhi = FilterData.First();
- if (ShunZhi == "0")
- { return false; }
- //对数组排序
- List<string> nums = new List<string>(OneNumber.Split(',')).OrderBy(x => int.Parse(x)).ToList();
- int idata1 = Math.Abs(Convert.ToInt32(nums[0]) - Convert.ToInt32(nums[1]));
- int idata2 = Math.Abs(Convert.ToInt32(nums[1]) - Convert.ToInt32(nums[2]));
- if (ShunZhi == "1")//过滤顺子
- {
- if (idata1 == idata2 && idata1 == 1)
- { return true; }
- }
- else if (ShunZhi == "3")
- {
- if (idata1 == 1 || idata2 == 1)
- { return true; }
- }
- return false;
- }
- [ToolFunctionAttr("跨度过滤-(3D,P3)", FilterType.Filter_KuaDu)]
- public static List<string> Filter_KuaDuRule(string number)
- {
- List<string> numorder = new List<string>(number.Split(',')).OrderBy(x => int.Parse(x)).ToList();
- //最大值
- int maxnum = int.Parse(numorder[numorder.Count - 1]);
- //最小值
- int min = int.Parse(numorder[0]);
- List<string> reData = new List<string>();
- string sdata = (maxnum - min).ToString();
- reData.Add(sdata);
- return reData;
- }
- [ToolFunctionAttr("质合过滤-(3D,P3)", FilterType.Filter_ZhiHe)]
- public static List<string> Filter_ZhiHeRule(string number)
- {
- List<string> zhi = new List<string>() { "1", "2", "3", "5", "7" };
- string[] nums = number.Split(',');
- string zhihe = "";
- foreach (string num in nums)
- {
- if (zhi.Contains(num))
- { zhihe += "质"; }
- else
- { zhihe += "合"; }
- }
- List<string> reData = new List<string>();
- reData.Add(zhihe);
- return reData;
- }
- /// <summary>
- /// 奇偶过滤
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("奇偶过滤-(3D,P3)", FilterType.Filter_JiOu)]
- public static List<string> Filter_JiOuRule(string number)
- {
- List<string> ji = new List<string>() { "1", "3", "5", "7", "9" };
- //List<string> ou = new List<string>() { "0", "2", "4", "6", "8", };
- string[] nums = number.Split(',');
- string jiou = "";
- foreach (string num in nums)
- {
- if (ji.Contains(num))
- jiou += "奇";
- else
- jiou += "偶";
- }
- List<string> reData = new List<string>();
- reData.Add(jiou);
- return reData;
- }
- /// <summary>
- /// 奇偶比过滤
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("奇偶比过滤(数字类型比例,例:1:2)", FilterType.Filter_ProportionOfJiOu)]
- public static List<string> Filter_ProportionOfJiOuRule(List<string> numSplits)
- {
- int ji = 0;
- int ou = 0;
- foreach (string item in numSplits)
- {
- if (TypeConverter.StrToInt(item) % 2 == 0)
- { ou++; }
- else
- { ji++; }
- }
- List<string> reData = new List<string>();
- reData.Add(ji.ToString() + ":" + ou.ToString());
- return reData;
- }
- /// <summary>
- /// AC-过滤
- /// </summary>
- /// <param name="numSplits"></param>
- /// <returns></returns>
- [ToolFunctionAttr("AC值过滤", FilterType.Filter_Ac)]
- public static List<string> Filter_ErAcRule(List<string> numSplits)
- {
- List<string> result = GetCombination(numSplits, 2);
- ArrayList acarray = new ArrayList();
- int tpac = 0;
- for (int i = 0; i < result.Count; i++)
- {
- string[] tp = result[i].Split(',');
- int tmp = Math.Abs(Convert.ToInt32(tp[0]) - Convert.ToInt32(tp[1]));
- if (!acarray.Contains(tmp))
- {
- tpac++;
- acarray.Add(tmp);
- }
- }
- List<string> reData = new List<string>();
- reData.Add((tpac - (numSplits.Count - 1)).ToString());
- return reData;
- }
- /// <summary>
- /// 组合算法
- /// </summary>
- /// <param name="data">组合源数据</param>
- /// <param name="count">所选组合个数</param>
- /// <returns></returns>
- private static List<string> GetCombination(List<string> data, int count)
- {
- Dictionary<string, int> dic = new Dictionary<string, int>();
- List<string> output = new List<string>();
- for (int i = 0; i < data.Count; i++)
- {
- dic.Add(data[i], i);
- }
- SelectN(dic, data, count, 1, ref output);
- return output;
- }
- /// <summary>
- /// 字典组合算法
- /// </summary>
- /// <param name="dd"></param>
- /// <param name="data"></param>
- /// <param name="count"></param>
- /// <param name="times"></param>
- /// <param name="output"></param>
- private static void SelectN(Dictionary<string, int> dd, List<string> data, int count, int times, ref List<string> output)
- {
- Dictionary<string, int> dic = new Dictionary<string, int>();
- foreach (KeyValuePair<string, int> kv in dd)
- {
- for (int i = kv.Value + 1; i < data.Count; i++)
- {
- if (times < count - 1)
- {
- dic.Add(kv.Key + "," + data[i], i);
- }
- else
- {
- output.Add(kv.Key + "," + data[i]);
- }
- }
- }
- times++;
- if (dic.Count > 0)
- {
- SelectN(dic, data, count, times, ref output);
- }
- }
- /// <summary>
- /// 质合比过滤(通用)
- /// </summary>
- /// <param name="number"></param>
- /// <param name="filter"></param>
- /// <returns></returns>
- [ToolFunctionAttr("质合比(数字类型比例,例:1:2)", FilterType.Filter_ProportionOfZhiHe)]
- public static List<string> Filter_ProportionOfZhiHeRule(List<string> numSplits)
- {
- int[] znumbers = { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
- int z = 0;
- int h = 0;
- foreach (var item in numSplits)
- {
- if (znumbers.Contains(TypeConverter.StrToInt(item)))
- { z++; }
- else
- { h++; }
- }
- List<string> reData = new List<string>();
- reData.Add(z.ToString() + ":" + h.ToString());
- return reData;
- }
- [ToolFunctionAttr("和值012路过滤-(P5)", FilterType.Filter_HeZhi012)]
- public static List<string> Filter_HeZhi012Rule(string number)
- {
- string[] nums = number.Split(',');
- int data = 0;
- foreach (string num in nums)
- {
- data += Convert.ToInt32(num);
- }
- List<string> reData = new List<string>();
- string sdata = (data % 3).ToString();
- reData.Add(sdata);
- return reData;
- }
- [ToolFunctionAttr("0路组合式形态过滤-(P5)", FilterType.Filte_P5ZhuHe0)]
- public static List<string> Filte_P5ZhuHe0Rule(string number)
- {
- string xt = string.Empty;
- List<string> nums = new List<string>(number.Split(','));
- int data = 0;
- foreach (string num in nums)
- { data += Convert.ToInt32(num); }
- xt = P5ZhuHe012Rule(data, 0, nums);
- List<string> result = new List<string>() { xt };
- return result;
- }
- [ToolFunctionAttr("1路组合式形态过滤-(P5)", FilterType.Filte_P5ZhuHe1)]
- public static List<string> Filte_P5ZhuHe1Rule(string number)
- {
- string xt = string.Empty;
- List<string> nums = new List<string>(number.Split(','));
- int data = 0;
- foreach (string num in nums)
- { data += Convert.ToInt32(num); }
- xt = P5ZhuHe012Rule(data, 1, nums);
- List<string> result = new List<string>() { xt };
- return result;
- }
- [ToolFunctionAttr("2路组合式形态过滤-(P5)", FilterType.Filte_P5ZhuHe2)]
- public static List<string> Filte_P5ZhuHe2Rule(string number)
- {
- string xt = string.Empty;
- List<string> nums = new List<string>(number.Split(','));
- int data = 0;
- foreach (string num in nums)
- { data += Convert.ToInt32(num); }
- xt = P5ZhuHe012Rule(data, 2, nums);
- List<string> result = new List<string>() { xt };
- return result;
- }
- #endregion
- #region 特殊过滤
- [ToolFunctionAttr("组合选项-特殊方法-(3D,P3)", FilterType.Filter_ZuHe)]
- public static void SpecialFilter_ZuHeFilter(ref List<string> Numbers, FilterType ft, bool IsSave)
- {
- string zuhe = "";
- string[] filters = new string[] { "zuhe3", "zuhe6", "baozi" };
- //组三,组六,豹子
- foreach (string filter in filters)
- {
- string f = WRequest.GetString(filter);
- if (f == "组三") f = "1";
- else if (f == "组六") f = "0";
- else if (f == "豹子") f = "3";
- zuhe += string.IsNullOrEmpty(f) ? "" : f + ",";
- }
- if (!string.IsNullOrEmpty(zuhe))
- {
- for (int i = 0; i < Numbers.Count; i++)
- {
- List<string> No = new List<string>(Numbers[i].Split(','));
- //组六sameCount为0,都不等,
- //组三sameCount为1,有两个数相等
- //豹子sameCount为3,有三个数相等
- int sameCount = 0;
- if (No[0] == No[1]) sameCount++;
- if (No[1] == No[2]) sameCount++;
- if (No[0] == No[2]) sameCount++;
- List<int> filterDataList = new List<int>(zuhe.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList());
- if (!filterDataList.Contains(sameCount))
- { Numbers.RemoveAt(i); i--; }
- }
- }
- //直选还是组选过滤
- string zhizuxuan = WRequest.GetString("zuhe");
- if ("组选" == zhizuxuan) zhizuxuan = "1";
- if (zhizuxuan == "1")
- {
- //组选 即123,321算一个号码,直选即123,321算2个号码,
- List<string> NewNumber = new List<string>();
- for (int i = 0; i < Numbers.Count; i++)
- {
- List<string> No = new List<string>(Numbers[i].Split(','));
- No.Sort();
- string Num = string.Join(",", No.ToArray());
- if (!NewNumber.Contains(Num))
- { NewNumber.Add(Num); }
- else
- { Numbers.RemoveAt(i); i--; }
- }
- }
- }
- [ToolFunctionAttr("双色球中六保五", FilterType.Filter_ZlBw)]
- public static void SpecialFilter_ZlBwFilter(int Id, ref List<string> Numbers, FilterType filterType, bool IsSave)
- {
- List<TrendToolInfo> Childs = new List<TrendToolInfo>();
- //Childs = TrendToolService.ChildToList(new TrendToolInfo() { Id = Id }).ToList();
- Childs = Caches.GetTrendToolChildList(new TrendToolInfo() { Id = Id }).ToList();
- TrendToolInfo include = Childs.Find(x => x.FilterCodeType == FilterCodeType.Include);
- //内容项目
- List<TrendToolInfo> contents = Childs.FindAll(x => x.FilterCodeType == FilterCodeType.Content);
- string ContentData = GetContentsData(contents[0], filterType);
- List<string> FilterData = new List<string>(ContentData.Split(','));
- if (string.IsNullOrEmpty(ContentData)) return;
- StringBuilder str = new StringBuilder();
- string result = string.Empty;
- str = GetSsqHm("ssqhm.txt");
- str = str.Replace("\n", " ");
- string[] str1 = str.ToString().Split(',');
- int numberCount = FilterData.Count;
- string[] str2 = str1[numberCount - 8].Replace(" ", "+").Split('+');
- int mod6 = 0;
- int count = 6;
- for (int i = 0; i < str2.Length; i++)
- {
- string[] str3 = str2[i].Replace(" ", "+").Split('+');
- for (int j = 0; j < str3.Length; j++)
- {
- if (str3[j].Trim().Length > 0)
- {
- mod6 = mod6 + 1;
- result += FilterData[Convert.ToInt32(str3[j]) - 1];
- if (mod6 % count == 0)
- {
- result = result.Substring(0, result.Length);
- result += "+";
- }
- else
- {
- result += ",";
- }
- }
- }
- }
- result = result.Substring(0, result.Length - 1);
- string[] listtxt = result.Split('+');
- // int zhushu = listtxt.Length;
- foreach (string t in listtxt)
- { Numbers.Add(t.Substring(0, t.Length)); }
- }
- private static string GetContentsData(TrendToolInfo content, FilterType filterType)
- {
- string requestName = ToolUtility.FilterNamePrefix + content.Id.ToString();
- string ContentData = WRequest.GetString(requestName).Trim().Replace(" ", "");
- switch (filterType)
- {
- case FilterType.Filter_HeZhi012:
- if (ContentData == "0路和值")
- { ContentData = "0"; }
- else if (ContentData == "1路和值")
- { ContentData = "1"; }
- else if (ContentData == "2路和值")
- { ContentData = "2"; }
- break;
- case FilterType.Filter_ShunZi:
- if ("过滤顺子" == ContentData)
- { ContentData = "1"; }
- else if ("过滤半顺子" == ContentData)
- { ContentData = "3"; }
- else ContentData = "0";
- break;
- }
- return ContentData;
- }
- /// <summary>
- /// 获取基础数据
- /// </summary>
- /// <param name="txtName">基础数据名称</param>
- /// <returns></returns>
- private static StringBuilder GetSsqHm(string txtName)
- {
- StringBuilder str = new StringBuilder();
- FileStream fs = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "//tool//inc//" + txtName, FileMode.Open, FileAccess.Read);
- StreamReader reader = new StreamReader(fs); ;
- reader.BaseStream.Seek(0, SeekOrigin.Begin);
- string strLine = reader.ReadLine();
- while (strLine != null)
- {
- str.Append(strLine + "\n");
- strLine = reader.ReadLine();
- }
- if (reader != null)
- reader.Close();
- if (fs != null)
- fs.Close();
- return str;
- }
- [ToolFunctionAttr("七乐彩中七保六", FilterType.Filter_ZqBl)]
- public static void SpecialFilter_ZqBlFilter(int id, ref List<string> Numbers, FilterType filterType, bool IsSave)
- {
- List<TrendToolInfo> Childs = new List<TrendToolInfo>();
- //Childs = TrendToolService.ChildToList(new TrendToolInfo() { Id = id }).ToList();
- Childs = Caches.GetTrendToolChildList(new TrendToolInfo() { Id = id }).ToList();
- TrendToolInfo include = Childs.Find(x => x.FilterCodeType == FilterCodeType.Include);
- //内容项目
- List<TrendToolInfo> contents = Childs.FindAll(x => x.FilterCodeType == FilterCodeType.Content);
- string ContentData = GetContentsData(contents[0], filterType);
- List<string> FilterData = new List<string>(ContentData.Split(','));
- string contentData = GetContentsData(contents[0], filterType);
- string[] listnum = contentData.Split(',');
- if (listnum.Length == 0)
- {
- Numbers.Add("没有选择红球基本号码,请重新选择...");
- return;
- }
- if (listnum.Length < 8 || listnum.Length > 20)
- {
- Numbers.Add("红球基本号只能是8至20个,请返回重新选号...");
- return;
- }
- StringBuilder str = new StringBuilder();
- string result = string.Empty;
- str = GetSsqHm("qlchm.txt");
- str = str.Replace("\n", " ");
- string[] str1 = str.ToString().Split(',');
- int numberCount = FilterData.Count;
- string[] str2 = str1[numberCount - 8].Replace(" ", "+").Split('+');
- int mod6 = 0;
- int count = 7;
- for (int i = 0; i < str2.Length; i++)
- {
- string[] str3 = str2[i].Replace(" ", "+").Split('+');
- for (int j = 0; j < str3.Length; j++)
- {
- if (str3[j].Trim().Length > 0)
- {
- mod6 = mod6 + 1;
- result += FilterData[Convert.ToInt32(str3[j]) - 1];
- if (mod6 % count == 0)
- {
- result = result.Substring(0, result.Length);
- result += "+";
- }
- else
- {
- result += ",";
- }
- }
- }
- }
- result = result.Substring(0, result.Length - 1);
- string[] listtxt = result.Split('+');
- ///int zhushu = listtxt.Length;
- Numbers.AddRange(listtxt.Select(t => t.Substring(0, t.Length)));
- }
- [ToolFunctionAttr("大乐透5保4旋转矩阵", FilterType.Filter_Dlt5b4)]
- public static void SpecialFilter_Dlt5b4Filter(int Id, ref List<string> Numbers, FilterType filterType, bool IsSave)
- {
- string result = string.Empty;
- List<TrendToolInfo> Childs = new List<TrendToolInfo>();
- //Childs = TrendToolService.ChildToList(new TrendToolInfo() { Id = Id }).ToList();
- Childs = Caches.GetTrendToolChildList(new TrendToolInfo() { Id = Id }).ToList();
- //内容项目
- List<TrendToolInfo> contents = Childs.FindAll(x => x.FilterCodeType == FilterCodeType.Content);
- string contentData = GetContentsData(contents[0], filterType);
- string[] listnum = contentData.Split(',');
- if (listnum.Length == 0)
- {
- Numbers.Add("没有选择红球基本号码,请重新选择...");
- return;
- }
- if (listnum.Length < 7 || listnum.Length > 18)
- {
- Numbers.Add("红球基本号只能是7至18个,请返回重新选号...");
- return;
- }
- StringBuilder str = new StringBuilder();
- str = GetSsqHm("dlthm.txt");
- str = str.Replace("\n", " ");
- string[] str1 = str.ToString().Split(',');
- int numberCount = listnum.Length;
- string[] str2 = str1[listnum.Length - 7].Replace("/n", "+").Split('+');
- int mod6 = 0;
- for (int i = 0; i < str2.Length; i++)
- {
- string[] str3 = str2[i].Replace(" ", "+").Split('+');
- for (int j = 0; j < str3.Length; j++)
- {
- if (str3[j].Trim().Length > 0)
- {
- mod6 = mod6 + 1;
- result += listnum[Convert.ToInt32(str3[j]) - 1];
- if (mod6 % 5 == 0)
- {
- result = result.Substring(0, result.Length);
- result += "+";
- }
- else
- {
- result += ",";
- }
- }
- }
- }
- Numbers = result.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- }
- /// <summary>
- /// 定位/不定位胆码运算
- /// </summary>
- /// <param name="id"></param>
- /// <param name="numbers"></param>
- /// <param name="filterType"></param>
- /// <param name="isSave"></param>
- /// <param name="isDingWei">是否定位</param>
- [ToolFunctionAttr("胆码过滤和不定位胆码过滤-(3D,P3)", FilterType.Filter_DanMa)]
- public static void SpecialFilter_DanMa(int id, ref List<string> numbers, FilterType filterType, bool isSave)
- {
- if (numbers.Count < 1)
- { return; }
- var childs = Caches.GetTrendToolChildList(new TrendToolInfo() { Id = id }).ToList();
- //包含排除项
- TrendToolInfo include = childs.Find(x => x.FilterCodeType == FilterCodeType.Include);
- //内容项目
- List<TrendToolInfo> contents = childs.FindAll(x => x.FilterCodeType == FilterCodeType.Content && x.ParentID != -1);
- //bool isInclude = ToolCommFilter.GetIncludeData(include);
- //定位胆码
- if (contents.Count == 3)
- {
- string data0 = GetContentsData(contents[0], filterType);
- string data1 = GetContentsData(contents[1], filterType);
- string data2 = GetContentsData(contents[2], filterType);
- if ((data0 + data1 + data2).Length < 1) { return; }
- for (int num = 0; num < numbers.Count; num++)
- {
- string oneNumber = numbers[num].ToString();
- string[] oneNumberArr = oneNumber.Split(',');
- if ((!string.IsNullOrEmpty(data0) && data0.IndexOf(oneNumberArr[0]) != -1)
- || (!string.IsNullOrEmpty(data1) && data1.IndexOf(oneNumberArr[1]) != -1)
- || (!string.IsNullOrEmpty(data2) && data2.IndexOf(oneNumberArr[2]) != -1))
- { }
- else { numbers.RemoveAt(num); num--; }
- }
- }
- else if (contents.Count == 1)//不定位胆码
- {
- string data0 = GetContentsData(contents[0], filterType);
- if (string.IsNullOrWhiteSpace(data0)) { return; }
- List<string> data = new List<string>(data0.Split(','));
- for (int num = 0; num < numbers.Count; num++)
- {
- List<string> lnum = new List<string>(numbers[num].Split(','));
- if (!data.Intersect(lnum).Any()) { numbers.RemoveAt(num); num--; }
- }
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 包含不包含过滤
- /// </summary>
- /// <param name="IsInclude"></param>
- /// <param name="results"></param>
- /// <param name="filterList"></param>
- /// <returns></returns>
- private static bool IncludeFilter(bool IsInclude, List<string> results, List<string> filterList)
- {
- bool isRemove = false;
- //包含所需要的值
- if (IsInclude == true)
- {
- if (!(filterList.Intersect(results).Count() > 0))
- { isRemove = true; }
- else
- { isRemove = false; }
- }//排除选中的值
- else if (IsInclude == false)
- {
- if (filterList.Intersect(results).Count() > 0)
- { isRemove = true; }
- }
- return isRemove;
- }
- private static string P5ZhuHe012Rule(int data, int lu, List<string> nums)
- {
- string xt = string.Empty;
- if (data % 3 == lu)
- {
- //号码的012路形态
- int mod;
- List<int> arr = new List<int>();
- for (int i = 0; i < nums.Count; i++)
- {
- mod = Convert.ToInt32(nums[i]) % 3;
- arr.Add(mod);
- }
- arr.Sort();
- try
- { xt = arr[0].ToString() + arr[1].ToString() + arr[2].ToString() + arr[3].ToString() + arr[4].ToString(); }
- catch
- { }
- }
- return xt;
- }
- #endregion
- }
- }
|