ClassModelBuilder.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:327k
- {
- 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 = aass15BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //15
- ////////////////////////////////////////////////////////////////////////////////
- //15
- /// <summary>
- /// 《15》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass15BuilderModel(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 = aass16BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //16
- ////////////////////////////////////////////////////////////////////////////////
- //16
- /// <summary>
- /// 《16》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass16BuilderModel(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 = aass17BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //17
- ////////////////////////////////////////////////////////////////////////////////
- //17
- /// <summary>
- /// 《17》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass17BuilderModel(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 = aass18BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //18
- ////////////////////////////////////////////////////////////////////////////////
- //18
- /// <summary>
- /// 《18》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass18BuilderModel(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 = aass19BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //19
- ////////////////////////////////////////////////////////////////////////////////
- //19
- /// <summary>
- /// 《19》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass19BuilderModel(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 = aass20BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //20
- ////////////////////////////////////////////////////////////////////////////////
- //20
- /// <summary>
- /// 《20》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass20BuilderModel(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 = aass21BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //21
- ////////////////////////////////////////////////////////////////////////////////
- //21
- /// <summary>
- /// 《21》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass21BuilderModel(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 = aass22BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //22
- ////////////////////////////////////////////////////////////////////////////////
- //22
- /// <summary>
- /// 《22》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass22BuilderModel(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 = aass23BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //23
- ////////////////////////////////////////////////////////////////////////////////
- //23
- /// <summary>
- /// 《23》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass23BuilderModel(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 = aass24BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //24
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《24》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass24BuilderModel(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 = aass25BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //25
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《25》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass25BuilderModel(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 = aass26BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //26
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《26》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass26BuilderModel(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 = aass27BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //27
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《27》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass27BuilderModel(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 = aass28BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //28
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《28》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass28BuilderModel(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 = aass29BuilderModel(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;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- //29
- ////////////////////////////////////////////////////////////////////////////////
- /// <summary>
- /// 《29》根据子模板建立一个超级模板
- /// </summary>
- /// <param name="mHTMs"></param>
- /// <returns></returns>
- private string aass29BuilderModel(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; }