ClassModelBuilder.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:327k
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- // string mmoo = aass30BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //30
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《30》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass30BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- //mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- // string mmoo = aass31BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //31
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《31》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass31BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass32BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //32
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《32》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass32BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass33BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //33
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《33》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass33BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- // string mmoo = aass34BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //34
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《34》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass34BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- // string mmoo = aass35BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //35
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《35》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass35BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass36BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //36
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《36》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass36BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass37BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //37
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《37》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass37BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- // string mmoo = aass38BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //38
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《38》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass38BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass39BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //39
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《39》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass39BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- //mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- // string mmoo = aass40BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //40
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《40》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass40BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass41BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //41
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《41》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass41BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- //从模板得到一个项目模板
- //string mmoo = aass42BuilderModel(mHTMs);
- string mmoo = GetComDataEND(mHTMs, tdict);
- if (mmoo.Length == 0)
- {
- //从模板得到一个项目模板
- mmoo = aass3BuilderModel(mHTMs);
- }
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- if (mmoo.Length == 0)
- {
- return "";
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- return mmoo;
- }
- }
- /// <summary>
- /// 《42》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass42BuilderModel(Hashtable mHTMs)
- {
- //得到最短的串
- string oneModel = "";
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel.Length == 0)
- {
- oneModel = de.Value.ToString();
- }
- else
- {
- if (oneModel.Length > de.Value.ToString().Length)
- {
- oneModel = de.Value.ToString();
- }
- }
- }
- foreach (System.Collections.DictionaryEntry de in mHTMs)
- {
- if (oneModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneModel;
- cXStart:
- //得到匹配临时模板的原始长度
- int onemLong = oneModel.Length;
- Hashtable tdict = new Hashtable();
- int tdictI = 0; //字典序号
- tdict.Clear();
- Hashtable oneModels = new Hashtable();
- oneModels.Clear();
- oneModels.Add(oneModel, "0"); //碎片如果相同 就不用继续寻找添加
- //存放临时碎片
- Hashtable newModels = new Hashtable();
- newModels.Clear();
- oneModel = "";
- NewStart: //开始遍历匹配串
- if (oneModel.Length > 0)
- {
- oneModels.Remove(oneModel); //移除旧的字符串 压入分解后的字符串
- }
- foreach (System.Collections.DictionaryEntry de in newModels) //加入新的碎片项
- {
- if (oneModels.Contains(de.Key) == false)
- {
- oneModels.Add(de.Key, "0");
- }
- }
- newModels.Clear();
- foreach (System.Collections.DictionaryEntry de in oneModels)
- {
- oneModel = de.Key.ToString();
- if (oneModel.Length > 2)
- {
- int h = oneModel.Length;
- while (true)
- {
- if (h < 3) //最短字符不能小于5 >=四
- { goto nextcmd2; }
- int st = 0;
- while (true)
- {
- if (st + h > oneModel.Length)
- { goto nextcmd1; }
- string a1 = oneModel.Substring(st, 1);
- string a2 = oneModel.Substring(st + h - 1, 1);
- if ((a1 != "<") | (a2 != ">")) //判断是否合法 含有 < >
- {
- goto nextcmd3;
- }
- string onestr = oneModel.Substring(st, h);
- if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
- {
- goto nextcmd3; //取开头和末尾在<>中的数据
- }
- //遍历数据 是否符合全部数据
- foreach (System.Collections.DictionaryEntry de1 in mHTMs)
- {
- if ((de1.Value.ToString().IndexOf(onestr) == -1)&(de1.Value.ToString().Length>0))
- {
- goto nextcmd3;
- }
- }
- //符合所有项都存在的条件 压入字典
- tdict.Add(tdictI, onestr);
- //数据替换
- Hashtable mtmpp = new Hashtable();
- mtmpp.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- //mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
- string tmp_str = de2.Value.ToString();
- if (tmp_str == null)
- {
- }
- else
- {
- mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
- }
- }
- mHTMs = mtmpp;
- tdictI = tdictI + 1; //字典序号
- //oneModel 截取 取出碎片 压入 newModels
- string oneModelTmp = oneModel.Replace(onestr, "*");
- string[] mykc = oneModelTmp.Split('*');
- foreach (string ddee in mykc)
- {
- if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
- {
- newModels.Add(ddee, "0");
- }
- }
- goto NewStart; //因为碎片变化 所以重新开始扫描
- nextcmd3:
- st = st + 1;
- }
- nextcmd1:
- h = h - 1;
- }
- }
- nextcmd2: ;
- goto NewStart; //本次遍历结束 去掉本字符串
- }
- //mHTMs 处理新的 网页 只留下 *0*
- Hashtable mtmppC = new Hashtable();
- mtmppC.Clear();
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- string cckc = de2.Value.ToString();
- //把cckc中的*0*提取出来
- mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
- // mtmppC.Add(de2.Key, de2.Value.ToString());
- }
- mHTMs = mtmppC;
- string mm = ""; //存储比较的值 收敛时即为模板
- bool mmT = true ; //是否收敛
- foreach (System.Collections.DictionaryEntry de2 in mHTMs)
- {
- if (mm.Length == 0)
- {
- mm = de2.Value.ToString();
- }
- else
- {
- if (mm != de2.Value.ToString())
- {
- mmT = false;
- break;
- }
- }
- }
- if (mmT == false)
- {
- return ""; //系统不收敛 无法生成模板
- }
- else
- {
- foreach (System.Collections.DictionaryEntry dec in tdict)
- {
- mm = mm.Replace("<" + dec.Key.ToString() + ">", dec.Value.ToString());
- }
- return mm;
- }
- }
- /// <summary>
- /// 总结 得到串
- /// </summary>
- /// <param name="mud"></param>
- /// <returns></returns>
- private string GetComDataEND(Hashtable mud,Hashtable kdict)
- {
- Console.Write("..");
- // <1><2><3><4><5>
- //得到最长的串
- string oneLModel = "";
- foreach (System.Collections.DictionaryEntry de in mud)
- {
- if (oneLModel.Length == 0)
- {
- oneLModel = de.Value.ToString();
- }
- else
- {
- if (oneLModel.Length < de.Value.ToString().Length)
- {
- oneLModel = de.Value.ToString();
- }
- }
- }
- //是否全部相同 若是 则返回一个模板
- foreach (System.Collections.DictionaryEntry de in mud)
- {
- if (oneLModel != de.Value.ToString()) //不相同
- {
- if (de.Value.ToString().IndexOf(oneLModel) == -1) //不包含
- {
- goto cXStart;
- }
- }
- }
- return oneLModel;
- cXStart:
- long iEndSD = getNumC(oneLModel);
- //long iiStOP = (long)Math.Pow(2, iEnd);
- //如果需要匹配的数据太长 则不匹配
- if (iEndSD > 20)
- {
- return "";
- }
- Hashtable myDB = new Hashtable();
- myDB.Clear();
- Hashtable cmyDB = new Hashtable();
- cmyDB.Clear();
- foreach (System.Collections.DictionaryEntry de in mud)
- {
- if (de.Value.ToString().Length > 0)
- {
- long iEnd = getNumC(de.Value.ToString());
- long iiStOP = (long)Math.Pow(2, iEnd);
- string[] myGdata = de.Value.ToString().Split('<');
- for (int c = 1; c < myGdata.Length; c++)
- {
- myGdata[c] = "<" + myGdata[c];
- }
- long mmPP = getNumC(de.Value.ToString()) + 1;
- string myII = "";
- for (long iv = iiStOP - 1; iv > 4; iv--)
- {
- //string myII = addOneGG(de.Value.ToString(),iv);//得到一个可能结果
- string mI = Convert.ToString(iiStOP + iv, 2);
- myII = string.Empty ;
- //按照mi 的显示 得到 新的 mdat
- for (long i = 1; i < mI.Length; i++)
- {
- if (mI.Substring((int)i, 1) == "1")
- {
- myII = myII + myGdata[i]; //得到数据
- }
- }
- if (myII.Length > 0)
- {
- if (myDB.Contains(myII) == false)//没有的话就增加
- {
- myDB.Add(myII, 1); //增加一个数据 出现次数 同一个源中出现多次 不再记录
- cmyDB.Add(myII, de.Key.ToString()); //记录此条数据来源
- }
- else
- { //当用户变化一次 记录次数才改变一次
- if (cmyDB[myII].ToString() != de.Key.ToString())
- {
- myDB[myII] = Int32.Parse(myDB[myII].ToString()) + 1; //增加一个数据 出现次数 同一个源中出现多次 不再记录
- cmyDB[myII] = de.Key.ToString(); //记录此条数据来源
- }
- }
- }
-
- }
- }
- }
- // 1 合并所有myII 相同的项目
- Hashtable as1 = new Hashtable();
- as1.Clear();
- foreach (System.Collections.DictionaryEntry de in myDB)
- {
- if (Int32.Parse(de.Value.ToString()) >= mud.Count)
- {
- as1.Add(de.Key, "0");
- }
- }
- //得到最长的串
- string as1LModel = "";
- foreach (System.Collections.DictionaryEntry de in as1)
- {
- if (as1LModel.Length == 0)
- {
- as1LModel = de.Key.ToString();
- }
- else
- {
- if (getNumC(as1LModel) < getNumC(de.Key.ToString()))
- {
- as1LModel = de.Key.ToString();
- }
- }
- }
- //得到最长的串 队列
- Hashtable myLongStr = new Hashtable();
- myLongStr.Clear();
- long Xnml = getNumC(as1LModel);
- foreach (System.Collections.DictionaryEntry de in as1)
- {
- if ( Xnml== getNumC(de.Key.ToString()))
- {
- myLongStr.Add(de.Key.ToString(), "0");
- }
- }
- //根据DICT还原
- Hashtable mDictHY = new Hashtable();
- mDictHY.Clear();
- foreach (System.Collections.DictionaryEntry de in myLongStr)
- {
- string mmoo = de.Key.ToString();
- mmoo = mmoo.Replace("<", "*");
- mmoo = mmoo.Replace(">", "*");
- foreach (System.Collections.DictionaryEntry dec in kdict)
- {
- mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
- }
- if (mDictHY.Contains(mmoo) == false)
- {
- mDictHY.Add(mmoo, de.Key.ToString());
- }
- }
- //得到最长的串 同类项中取出最长的
- string ENDBACKX = "";
- string ENDBACK2 = "";
- foreach (System.Collections.DictionaryEntry de in mDictHY)
- {
- if (ENDBACKX.Length == 0)
- {
- ENDBACKX = de.Key.ToString();
- ENDBACK2 = de.Value.ToString();
- }
- else
- {
- if (getNumC(ENDBACKX) < getNumC(de.Key.ToString()))
- {
- ENDBACKX = de.Key.ToString();
- ENDBACK2 = de.Value.ToString();
- }
- }
- }
- return ENDBACK2;
- }
- /// <summary>
- /// 得到一个可能结果
- /// </summary>
- /// <param name="data">数据</param>
- /// <param name="ii">序号 转换2进制</param>
- /// <returns></returns>
- private string addOneGG(string[] Gdata,string ii) //LENX 元素数目
- {
- Console.Write("..");
- // long LENX = getNumC(data);
- // if (ii > LENX)
- // {
- // return ""; //长度不适合此数据 则 返回
- // }
- // ii=ii + (long)Math.Pow(2,LENX); //为保持数据位 需要在前面+1
- // string mi = Convert.ToString(ii,2);
- string mi = ii;
- // data =<1><2><3><4><5><6><7>
- // string[] myGdata = data.Split('<');
- // for(int c=1;c<myGdata.Length;c++)
- // {
- // myGdata[c] = "<" + myGdata[c];
- // }
- string mdat = "";
- //按照mi 的显示 得到 新的 mdat
- for (long i = 1; i < mi.Length;i++)
- {
- if(mi.Substring((int)i,1)=="1")
- {
- mdat = mdat + Gdata[i]; //得到数据
- }
- }
- // if (mdat.Length < 6)
- // {
- // return "";
- // }
- return mdat;
- }
- /// <summary>
- /// 得到 *的大小
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- private long getNumC(string data)
- {
- return data.Length - data.Replace("<", "").Length;
-
- }
- }
- }