ClassModelBuilder.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:327k
源码类别:

搜索引擎

开发平台:

C#

  1.                                 {
  2.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  3.                                 }
  4.                             }
  5.                             mHTMs = mtmpp;
  6.                             tdictI = tdictI + 1;  //字典序号
  7.                             //oneModel  截取   取出碎片 压入 newModels
  8.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  9.                             string[] mykc = oneModelTmp.Split('*');
  10.                             foreach (string ddee in mykc)
  11.                             {
  12.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  13.                                 {
  14.                                     newModels.Add(ddee, "0");
  15.                                 }
  16.                             }
  17.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  18.                         nextcmd3:
  19.                             st = st + 1;
  20.                         }
  21.                     nextcmd1:
  22.                         h = h - 1;
  23.                     }
  24.                 }
  25.             nextcmd2: ;
  26.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  27.             }
  28.             //mHTMs  处理新的 网页  只留下 *0*
  29.             Hashtable mtmppC = new Hashtable();
  30.             mtmppC.Clear();
  31.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  32.             {
  33.                 string cckc = de2.Value.ToString();
  34.                 //把cckc中的*0*提取出来
  35.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  36.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  37.             }
  38.             mHTMs = mtmppC;
  39.             //从模板得到一个项目模板
  40.             //string mmoo = aass15BuilderModel(mHTMs);
  41.             string mmoo = GetComDataEND(mHTMs, tdict);
  42.             if (mmoo.Length == 0)
  43.             {
  44.                 //从模板得到一个项目模板
  45.                 mmoo = aass3BuilderModel(mHTMs);
  46.             }
  47.             mmoo = mmoo.Replace("<", "*");
  48.             mmoo = mmoo.Replace(">", "*");
  49.             if (mmoo.Length == 0)
  50.             {
  51.                 return "";
  52.             }
  53.             else
  54.             {
  55.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  56.                 {
  57.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  58.                 }
  59.                 return mmoo;
  60.             }
  61.         }
  62.         ////////////////////////////////////////////////////////////////////////////////
  63.         //15
  64.         ////////////////////////////////////////////////////////////////////////////////
  65.         //15
  66.         /// <summary>
  67.         /// 《15》根据子模板建立一个超级模板
  68.         /// </summary>
  69.         /// <param name="mHTMs"></param>
  70.         /// <returns></returns>
  71.         private string aass15BuilderModel(Hashtable mHTMs)
  72.         {
  73.             //得到最短的串
  74.             string oneModel = "";
  75.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  76.             {
  77.                 if (oneModel.Length == 0)
  78.                 {
  79.                     oneModel = de.Value.ToString();
  80.                 }
  81.                 else
  82.                 {
  83.                     if (oneModel.Length > de.Value.ToString().Length)
  84.                     {
  85.                         oneModel = de.Value.ToString();
  86.                     }
  87.                 }
  88.             }
  89.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  90.             {
  91.                 if (oneModel != de.Value.ToString())                    //不相同
  92.                 {
  93.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  94.                     {
  95.                         goto cXStart;
  96.                     }
  97.                 }
  98.             }
  99.             return oneModel;
  100.         cXStart:
  101.             //得到匹配临时模板的原始长度
  102.             int onemLong = oneModel.Length;
  103.             Hashtable tdict = new Hashtable();
  104.             int tdictI = 0; //字典序号
  105.             tdict.Clear();
  106.             Hashtable oneModels = new Hashtable();
  107.             oneModels.Clear();
  108.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  109.             //存放临时碎片
  110.             Hashtable newModels = new Hashtable();
  111.             newModels.Clear();
  112.             oneModel = "";
  113.         NewStart: //开始遍历匹配串
  114.             if (oneModel.Length > 0)
  115.             {
  116.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  117.             }
  118.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  119.             {
  120.                 if (oneModels.Contains(de.Key) == false)
  121.                 {
  122.                     oneModels.Add(de.Key, "0");
  123.                 }
  124.             }
  125.             newModels.Clear();
  126.             foreach (System.Collections.DictionaryEntry de in oneModels)
  127.             {
  128.                 oneModel = de.Key.ToString();
  129.                 if (oneModel.Length > 2)
  130.                 {
  131.                     int h = oneModel.Length;
  132.                     while (true)
  133.                     {
  134.                         if (h < 3)         //最短字符不能小于5  >=四
  135.                         { goto nextcmd2; }
  136.                         int st = 0;
  137.                         while (true)
  138.                         {
  139.                             if (st + h > oneModel.Length)
  140.                             { goto nextcmd1; }
  141.                             string a1 = oneModel.Substring(st, 1);
  142.                             string a2 = oneModel.Substring(st + h - 1, 1);
  143.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  144.                             {
  145.                                 goto nextcmd3;
  146.                             }
  147.                             string onestr = oneModel.Substring(st, h);
  148.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  149.                             {
  150.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  151.                             }
  152.                             //遍历数据  是否符合全部数据
  153.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  154.                             {
  155.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  156.                                 {
  157.                                     goto nextcmd3;
  158.                                 }
  159.                             }
  160.                             //符合所有项都存在的条件 压入字典  
  161.                             tdict.Add(tdictI, onestr);
  162.                             //数据替换
  163.                             Hashtable mtmpp = new Hashtable();
  164.                             mtmpp.Clear();
  165.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  166.                             {
  167.                               //  mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  168.                                 string tmp_str = de2.Value.ToString();
  169.                                 if (tmp_str == null)
  170.                                 {
  171.                                 }
  172.                                 else
  173.                                 {
  174.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  175.                                 }
  176.                             }
  177.                             mHTMs = mtmpp;
  178.                             tdictI = tdictI + 1;  //字典序号
  179.                             //oneModel  截取   取出碎片 压入 newModels
  180.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  181.                             string[] mykc = oneModelTmp.Split('*');
  182.                             foreach (string ddee in mykc)
  183.                             {
  184.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  185.                                 {
  186.                                     newModels.Add(ddee, "0");
  187.                                 }
  188.                             }
  189.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  190.                         nextcmd3:
  191.                             st = st + 1;
  192.                         }
  193.                     nextcmd1:
  194.                         h = h - 1;
  195.                     }
  196.                 }
  197.             nextcmd2: ;
  198.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  199.             }
  200.             //mHTMs  处理新的 网页  只留下 *0*
  201.             Hashtable mtmppC = new Hashtable();
  202.             mtmppC.Clear();
  203.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  204.             {
  205.                 string cckc = de2.Value.ToString();
  206.                 //把cckc中的*0*提取出来
  207.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  208.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  209.             }
  210.             mHTMs = mtmppC;
  211.             //从模板得到一个项目模板
  212.            // string mmoo = aass16BuilderModel(mHTMs);
  213.             string mmoo = GetComDataEND(mHTMs, tdict);
  214.             if (mmoo.Length == 0)
  215.             {
  216.                 //从模板得到一个项目模板
  217.                 mmoo = aass3BuilderModel(mHTMs);
  218.             }
  219.             mmoo = mmoo.Replace("<", "*");
  220.             mmoo = mmoo.Replace(">", "*");
  221.             if (mmoo.Length == 0)
  222.             {
  223.                 return "";
  224.             }
  225.             else
  226.             {
  227.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  228.                 {
  229.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  230.                 }
  231.                 return mmoo;
  232.             }
  233.         }
  234.         ////////////////////////////////////////////////////////////////////////////////
  235.         //16
  236.         ////////////////////////////////////////////////////////////////////////////////
  237.         //16
  238.         /// <summary>
  239.         /// 《16》根据子模板建立一个超级模板
  240.         /// </summary>
  241.         /// <param name="mHTMs"></param>
  242.         /// <returns></returns>
  243.         private string aass16BuilderModel(Hashtable mHTMs)
  244.         {
  245.             //得到最短的串
  246.             string oneModel = "";
  247.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  248.             {
  249.                 if (oneModel.Length == 0)
  250.                 {
  251.                     oneModel = de.Value.ToString();
  252.                 }
  253.                 else
  254.                 {
  255.                     if (oneModel.Length > de.Value.ToString().Length)
  256.                     {
  257.                         oneModel = de.Value.ToString();
  258.                     }
  259.                 }
  260.             }
  261.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  262.             {
  263.                 if (oneModel != de.Value.ToString())                    //不相同
  264.                 {
  265.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  266.                     {
  267.                         goto cXStart;
  268.                     }
  269.                 }
  270.             }
  271.             return oneModel;
  272.         cXStart:
  273.             //得到匹配临时模板的原始长度
  274.             int onemLong = oneModel.Length;
  275.             Hashtable tdict = new Hashtable();
  276.             int tdictI = 0; //字典序号
  277.             tdict.Clear();
  278.             Hashtable oneModels = new Hashtable();
  279.             oneModels.Clear();
  280.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  281.             //存放临时碎片
  282.             Hashtable newModels = new Hashtable();
  283.             newModels.Clear();
  284.             oneModel = "";
  285.         NewStart: //开始遍历匹配串
  286.             if (oneModel.Length > 0)
  287.             {
  288.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  289.             }
  290.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  291.             {
  292.                 if (oneModels.Contains(de.Key) == false)
  293.                 {
  294.                     oneModels.Add(de.Key, "0");
  295.                 }
  296.             }
  297.             newModels.Clear();
  298.             foreach (System.Collections.DictionaryEntry de in oneModels)
  299.             {
  300.                 oneModel = de.Key.ToString();
  301.                 if (oneModel.Length > 2)
  302.                 {
  303.                     int h = oneModel.Length;
  304.                     while (true)
  305.                     {
  306.                         if (h < 3)         //最短字符不能小于5  >=四
  307.                         { goto nextcmd2; }
  308.                         int st = 0;
  309.                         while (true)
  310.                         {
  311.                             if (st + h > oneModel.Length)
  312.                             { goto nextcmd1; }
  313.                             string a1 = oneModel.Substring(st, 1);
  314.                             string a2 = oneModel.Substring(st + h - 1, 1);
  315.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  316.                             {
  317.                                 goto nextcmd3;
  318.                             }
  319.                             string onestr = oneModel.Substring(st, h);
  320.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  321.                             {
  322.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  323.                             }
  324.                             //遍历数据  是否符合全部数据
  325.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  326.                             {
  327.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  328.                                 {
  329.                                     goto nextcmd3;
  330.                                 }
  331.                             }
  332.                             //符合所有项都存在的条件 压入字典  
  333.                             tdict.Add(tdictI, onestr);
  334.                             //数据替换
  335.                             Hashtable mtmpp = new Hashtable();
  336.                             mtmpp.Clear();
  337.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  338.                             {
  339.                               //  mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  340.                                 string tmp_str = de2.Value.ToString();
  341.                                 if (tmp_str == null)
  342.                                 {
  343.                                 }
  344.                                 else
  345.                                 {
  346.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  347.                                 }
  348.                             }
  349.                             mHTMs = mtmpp;
  350.                             tdictI = tdictI + 1;  //字典序号
  351.                             //oneModel  截取   取出碎片 压入 newModels
  352.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  353.                             string[] mykc = oneModelTmp.Split('*');
  354.                             foreach (string ddee in mykc)
  355.                             {
  356.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  357.                                 {
  358.                                     newModels.Add(ddee, "0");
  359.                                 }
  360.                             }
  361.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  362.                         nextcmd3:
  363.                             st = st + 1;
  364.                         }
  365.                     nextcmd1:
  366.                         h = h - 1;
  367.                     }
  368.                 }
  369.             nextcmd2: ;
  370.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  371.             }
  372.             //mHTMs  处理新的 网页  只留下 *0*
  373.             Hashtable mtmppC = new Hashtable();
  374.             mtmppC.Clear();
  375.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  376.             {
  377.                 string cckc = de2.Value.ToString();
  378.                 //把cckc中的*0*提取出来
  379.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  380.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  381.             }
  382.             mHTMs = mtmppC;
  383.             //从模板得到一个项目模板
  384.             //string mmoo = aass17BuilderModel(mHTMs);
  385.             string mmoo = GetComDataEND(mHTMs, tdict);
  386.             if (mmoo.Length == 0)
  387.             {
  388.                 //从模板得到一个项目模板
  389.                 mmoo = aass3BuilderModel(mHTMs);
  390.             }
  391.             mmoo = mmoo.Replace("<", "*");
  392.             mmoo = mmoo.Replace(">", "*");
  393.             if (mmoo.Length == 0)
  394.             {
  395.                 return "";
  396.             }
  397.             else
  398.             {
  399.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  400.                 {
  401.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  402.                 }
  403.                 return mmoo;
  404.             }
  405.         }
  406.         ////////////////////////////////////////////////////////////////////////////////
  407.         //17
  408.         ////////////////////////////////////////////////////////////////////////////////
  409.         //17
  410.         /// <summary>
  411.         /// 《17》根据子模板建立一个超级模板
  412.         /// </summary>
  413.         /// <param name="mHTMs"></param>
  414.         /// <returns></returns>
  415.         private string aass17BuilderModel(Hashtable mHTMs)
  416.         {
  417.             //得到最短的串
  418.             string oneModel = "";
  419.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  420.             {
  421.                 if (oneModel.Length == 0)
  422.                 {
  423.                     oneModel = de.Value.ToString();
  424.                 }
  425.                 else
  426.                 {
  427.                     if (oneModel.Length > de.Value.ToString().Length)
  428.                     {
  429.                         oneModel = de.Value.ToString();
  430.                     }
  431.                 }
  432.             }
  433.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  434.             {
  435.                 if (oneModel != de.Value.ToString())                    //不相同
  436.                 {
  437.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  438.                     {
  439.                         goto cXStart;
  440.                     }
  441.                 }
  442.             }
  443.             return oneModel;
  444.         cXStart:
  445.             //得到匹配临时模板的原始长度
  446.             int onemLong = oneModel.Length;
  447.             Hashtable tdict = new Hashtable();
  448.             int tdictI = 0; //字典序号
  449.             tdict.Clear();
  450.             Hashtable oneModels = new Hashtable();
  451.             oneModels.Clear();
  452.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  453.             //存放临时碎片
  454.             Hashtable newModels = new Hashtable();
  455.             newModels.Clear();
  456.             oneModel = "";
  457.         NewStart: //开始遍历匹配串
  458.             if (oneModel.Length > 0)
  459.             {
  460.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  461.             }
  462.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  463.             {
  464.                 if (oneModels.Contains(de.Key) == false)
  465.                 {
  466.                     oneModels.Add(de.Key, "0");
  467.                 }
  468.             }
  469.             newModels.Clear();
  470.             foreach (System.Collections.DictionaryEntry de in oneModels)
  471.             {
  472.                 oneModel = de.Key.ToString();
  473.                 if (oneModel.Length > 2)
  474.                 {
  475.                     int h = oneModel.Length;
  476.                     while (true)
  477.                     {
  478.                         if (h < 3)         //最短字符不能小于5  >=四
  479.                         { goto nextcmd2; }
  480.                         int st = 0;
  481.                         while (true)
  482.                         {
  483.                             if (st + h > oneModel.Length)
  484.                             { goto nextcmd1; }
  485.                             string a1 = oneModel.Substring(st, 1);
  486.                             string a2 = oneModel.Substring(st + h - 1, 1);
  487.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  488.                             {
  489.                                 goto nextcmd3;
  490.                             }
  491.                             string onestr = oneModel.Substring(st, h);
  492.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  493.                             {
  494.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  495.                             }
  496.                             //遍历数据  是否符合全部数据
  497.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  498.                             {
  499.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  500.                                 {
  501.                                     goto nextcmd3;
  502.                                 }
  503.                             }
  504.                             //符合所有项都存在的条件 压入字典  
  505.                             tdict.Add(tdictI, onestr);
  506.                             //数据替换
  507.                             Hashtable mtmpp = new Hashtable();
  508.                             mtmpp.Clear();
  509.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  510.                             {
  511.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  512.                                 string tmp_str = de2.Value.ToString();
  513.                                 if (tmp_str == null)
  514.                                 {
  515.                                 }
  516.                                 else
  517.                                 {
  518.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  519.                                 }
  520.                             }
  521.                             mHTMs = mtmpp;
  522.                             tdictI = tdictI + 1;  //字典序号
  523.                             //oneModel  截取   取出碎片 压入 newModels
  524.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  525.                             string[] mykc = oneModelTmp.Split('*');
  526.                             foreach (string ddee in mykc)
  527.                             {
  528.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  529.                                 {
  530.                                     newModels.Add(ddee, "0");
  531.                                 }
  532.                             }
  533.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  534.                         nextcmd3:
  535.                             st = st + 1;
  536.                         }
  537.                     nextcmd1:
  538.                         h = h - 1;
  539.                     }
  540.                 }
  541.             nextcmd2: ;
  542.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  543.             }
  544.             //mHTMs  处理新的 网页  只留下 *0*
  545.             Hashtable mtmppC = new Hashtable();
  546.             mtmppC.Clear();
  547.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  548.             {
  549.                 string cckc = de2.Value.ToString();
  550.                 //把cckc中的*0*提取出来
  551.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  552.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  553.             }
  554.             mHTMs = mtmppC;
  555.             //从模板得到一个项目模板
  556.             //string mmoo = aass18BuilderModel(mHTMs);
  557.             string mmoo = GetComDataEND(mHTMs, tdict);
  558.             if (mmoo.Length == 0)
  559.             {
  560.                 //从模板得到一个项目模板
  561.                 mmoo = aass3BuilderModel(mHTMs);
  562.             }
  563.             mmoo = mmoo.Replace("<", "*");
  564.             mmoo = mmoo.Replace(">", "*");
  565.             if (mmoo.Length == 0)
  566.             {
  567.                 return "";
  568.             }
  569.             else
  570.             {
  571.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  572.                 {
  573.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  574.                 }
  575.                 return mmoo;
  576.             }
  577.         }
  578.         ////////////////////////////////////////////////////////////////////////////////
  579.         //18
  580.         ////////////////////////////////////////////////////////////////////////////////
  581.         //18
  582.         /// <summary>
  583.         /// 《18》根据子模板建立一个超级模板
  584.         /// </summary>
  585.         /// <param name="mHTMs"></param>
  586.         /// <returns></returns>
  587.         private string aass18BuilderModel(Hashtable mHTMs)
  588.         {
  589.             //得到最短的串
  590.             string oneModel = "";
  591.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  592.             {
  593.                 if (oneModel.Length == 0)
  594.                 {
  595.                     oneModel = de.Value.ToString();
  596.                 }
  597.                 else
  598.                 {
  599.                     if (oneModel.Length > de.Value.ToString().Length)
  600.                     {
  601.                         oneModel = de.Value.ToString();
  602.                     }
  603.                 }
  604.             }
  605.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  606.             {
  607.                 if (oneModel != de.Value.ToString())                    //不相同
  608.                 {
  609.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  610.                     {
  611.                         goto cXStart;
  612.                     }
  613.                 }
  614.             }
  615.             return oneModel;
  616.         cXStart:
  617.             //得到匹配临时模板的原始长度
  618.             int onemLong = oneModel.Length;
  619.             Hashtable tdict = new Hashtable();
  620.             int tdictI = 0; //字典序号
  621.             tdict.Clear();
  622.             Hashtable oneModels = new Hashtable();
  623.             oneModels.Clear();
  624.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  625.             //存放临时碎片
  626.             Hashtable newModels = new Hashtable();
  627.             newModels.Clear();
  628.             oneModel = "";
  629.         NewStart: //开始遍历匹配串
  630.             if (oneModel.Length > 0)
  631.             {
  632.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  633.             }
  634.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  635.             {
  636.                 if (oneModels.Contains(de.Key) == false)
  637.                 {
  638.                     oneModels.Add(de.Key, "0");
  639.                 }
  640.             }
  641.             newModels.Clear();
  642.             foreach (System.Collections.DictionaryEntry de in oneModels)
  643.             {
  644.                 oneModel = de.Key.ToString();
  645.                 if (oneModel.Length > 2)
  646.                 {
  647.                     int h = oneModel.Length;
  648.                     while (true)
  649.                     {
  650.                         if (h < 3)         //最短字符不能小于5  >=四
  651.                         { goto nextcmd2; }
  652.                         int st = 0;
  653.                         while (true)
  654.                         {
  655.                             if (st + h > oneModel.Length)
  656.                             { goto nextcmd1; }
  657.                             string a1 = oneModel.Substring(st, 1);
  658.                             string a2 = oneModel.Substring(st + h - 1, 1);
  659.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  660.                             {
  661.                                 goto nextcmd3;
  662.                             }
  663.                             string onestr = oneModel.Substring(st, h);
  664.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  665.                             {
  666.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  667.                             }
  668.                             //遍历数据  是否符合全部数据
  669.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  670.                             {
  671.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  672.                                 {
  673.                                     goto nextcmd3;
  674.                                 }
  675.                             }
  676.                             //符合所有项都存在的条件 压入字典  
  677.                             tdict.Add(tdictI, onestr);
  678.                             //数据替换
  679.                             Hashtable mtmpp = new Hashtable();
  680.                             mtmpp.Clear();
  681.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  682.                             {
  683.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  684.                                 string tmp_str = de2.Value.ToString();
  685.                                 if (tmp_str == null)
  686.                                 {
  687.                                 }
  688.                                 else
  689.                                 {
  690.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  691.                                 }
  692.                             }
  693.                             mHTMs = mtmpp;
  694.                             tdictI = tdictI + 1;  //字典序号
  695.                             //oneModel  截取   取出碎片 压入 newModels
  696.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  697.                             string[] mykc = oneModelTmp.Split('*');
  698.                             foreach (string ddee in mykc)
  699.                             {
  700.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  701.                                 {
  702.                                     newModels.Add(ddee, "0");
  703.                                 }
  704.                             }
  705.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  706.                         nextcmd3:
  707.                             st = st + 1;
  708.                         }
  709.                     nextcmd1:
  710.                         h = h - 1;
  711.                     }
  712.                 }
  713.             nextcmd2: ;
  714.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  715.             }
  716.             //mHTMs  处理新的 网页  只留下 *0*
  717.             Hashtable mtmppC = new Hashtable();
  718.             mtmppC.Clear();
  719.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  720.             {
  721.                 string cckc = de2.Value.ToString();
  722.                 //把cckc中的*0*提取出来
  723.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  724.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  725.             }
  726.             mHTMs = mtmppC;
  727.             //从模板得到一个项目模板
  728.             //string mmoo = aass19BuilderModel(mHTMs);
  729.             string mmoo = GetComDataEND(mHTMs, tdict);
  730.             if (mmoo.Length == 0)
  731.             {
  732.                 //从模板得到一个项目模板
  733.                 mmoo = aass3BuilderModel(mHTMs);
  734.             }
  735.             mmoo = mmoo.Replace("<", "*");
  736.             mmoo = mmoo.Replace(">", "*");
  737.             if (mmoo.Length == 0)
  738.             {
  739.                 return "";
  740.             }
  741.             else
  742.             {
  743.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  744.                 {
  745.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  746.                 }
  747.                 return mmoo;
  748.             }
  749.         }
  750.         ////////////////////////////////////////////////////////////////////////////////
  751.         //19
  752.         ////////////////////////////////////////////////////////////////////////////////
  753.         //19
  754.         /// <summary>
  755.         /// 《19》根据子模板建立一个超级模板
  756.         /// </summary>
  757.         /// <param name="mHTMs"></param>
  758.         /// <returns></returns>
  759.         private string aass19BuilderModel(Hashtable mHTMs)
  760.         {
  761.             //得到最短的串
  762.             string oneModel = "";
  763.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  764.             {
  765.                 if (oneModel.Length == 0)
  766.                 {
  767.                     oneModel = de.Value.ToString();
  768.                 }
  769.                 else
  770.                 {
  771.                     if (oneModel.Length > de.Value.ToString().Length)
  772.                     {
  773.                         oneModel = de.Value.ToString();
  774.                     }
  775.                 }
  776.             }
  777.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  778.             {
  779.                 if (oneModel != de.Value.ToString())                    //不相同
  780.                 {
  781.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  782.                     {
  783.                         goto cXStart;
  784.                     }
  785.                 }
  786.             }
  787.             return oneModel;
  788.         cXStart:
  789.             //得到匹配临时模板的原始长度
  790.             int onemLong = oneModel.Length;
  791.             Hashtable tdict = new Hashtable();
  792.             int tdictI = 0; //字典序号
  793.             tdict.Clear();
  794.             Hashtable oneModels = new Hashtable();
  795.             oneModels.Clear();
  796.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  797.             //存放临时碎片
  798.             Hashtable newModels = new Hashtable();
  799.             newModels.Clear();
  800.             oneModel = "";
  801.         NewStart: //开始遍历匹配串
  802.             if (oneModel.Length > 0)
  803.             {
  804.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  805.             }
  806.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  807.             {
  808.                 if (oneModels.Contains(de.Key) == false)
  809.                 {
  810.                     oneModels.Add(de.Key, "0");
  811.                 }
  812.             }
  813.             newModels.Clear();
  814.             foreach (System.Collections.DictionaryEntry de in oneModels)
  815.             {
  816.                 oneModel = de.Key.ToString();
  817.                 if (oneModel.Length > 2)
  818.                 {
  819.                     int h = oneModel.Length;
  820.                     while (true)
  821.                     {
  822.                         if (h < 3)         //最短字符不能小于5  >=四
  823.                         { goto nextcmd2; }
  824.                         int st = 0;
  825.                         while (true)
  826.                         {
  827.                             if (st + h > oneModel.Length)
  828.                             { goto nextcmd1; }
  829.                             string a1 = oneModel.Substring(st, 1);
  830.                             string a2 = oneModel.Substring(st + h - 1, 1);
  831.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  832.                             {
  833.                                 goto nextcmd3;
  834.                             }
  835.                             string onestr = oneModel.Substring(st, h);
  836.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  837.                             {
  838.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  839.                             }
  840.                             //遍历数据  是否符合全部数据
  841.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  842.                             {
  843.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  844.                                 {
  845.                                     goto nextcmd3;
  846.                                 }
  847.                             }
  848.                             //符合所有项都存在的条件 压入字典  
  849.                             tdict.Add(tdictI, onestr);
  850.                             //数据替换
  851.                             Hashtable mtmpp = new Hashtable();
  852.                             mtmpp.Clear();
  853.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  854.                             {
  855.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  856.                                 string tmp_str = de2.Value.ToString();
  857.                                 if (tmp_str == null)
  858.                                 {
  859.                                 }
  860.                                 else
  861.                                 {
  862.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  863.                                 }
  864.                             }
  865.                             mHTMs = mtmpp;
  866.                             tdictI = tdictI + 1;  //字典序号
  867.                             //oneModel  截取   取出碎片 压入 newModels
  868.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  869.                             string[] mykc = oneModelTmp.Split('*');
  870.                             foreach (string ddee in mykc)
  871.                             {
  872.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  873.                                 {
  874.                                     newModels.Add(ddee, "0");
  875.                                 }
  876.                             }
  877.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  878.                         nextcmd3:
  879.                             st = st + 1;
  880.                         }
  881.                     nextcmd1:
  882.                         h = h - 1;
  883.                     }
  884.                 }
  885.             nextcmd2: ;
  886.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  887.             }
  888.             //mHTMs  处理新的 网页  只留下 *0*
  889.             Hashtable mtmppC = new Hashtable();
  890.             mtmppC.Clear();
  891.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  892.             {
  893.                 string cckc = de2.Value.ToString();
  894.                 //把cckc中的*0*提取出来
  895.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  896.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  897.             }
  898.             mHTMs = mtmppC;
  899.             //从模板得到一个项目模板
  900.             //string mmoo = aass20BuilderModel(mHTMs);
  901.             string mmoo = GetComDataEND(mHTMs, tdict);
  902.             if (mmoo.Length == 0)
  903.             {
  904.                 //从模板得到一个项目模板
  905.                 mmoo = aass3BuilderModel(mHTMs);
  906.             }
  907.             mmoo = mmoo.Replace("<", "*");
  908.             mmoo = mmoo.Replace(">", "*");
  909.             if (mmoo.Length == 0)
  910.             {
  911.                 return "";
  912.             }
  913.             else
  914.             {
  915.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  916.                 {
  917.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  918.                 }
  919.                 return mmoo;
  920.             }
  921.         }
  922.         ////////////////////////////////////////////////////////////////////////////////
  923.         //20
  924.         ////////////////////////////////////////////////////////////////////////////////
  925.         //20
  926.         /// <summary>
  927.         /// 《20》根据子模板建立一个超级模板
  928.         /// </summary>
  929.         /// <param name="mHTMs"></param>
  930.         /// <returns></returns>
  931.         private string aass20BuilderModel(Hashtable mHTMs)
  932.         {
  933.             //得到最短的串
  934.             string oneModel = "";
  935.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  936.             {
  937.                 if (oneModel.Length == 0)
  938.                 {
  939.                     oneModel = de.Value.ToString();
  940.                 }
  941.                 else
  942.                 {
  943.                     if (oneModel.Length > de.Value.ToString().Length)
  944.                     {
  945.                         oneModel = de.Value.ToString();
  946.                     }
  947.                 }
  948.             }
  949.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  950.             {
  951.                 if (oneModel != de.Value.ToString())                    //不相同
  952.                 {
  953.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  954.                     {
  955.                         goto cXStart;
  956.                     }
  957.                 }
  958.             }
  959.             return oneModel;
  960.         cXStart:
  961.             //得到匹配临时模板的原始长度
  962.             int onemLong = oneModel.Length;
  963.             Hashtable tdict = new Hashtable();
  964.             int tdictI = 0; //字典序号
  965.             tdict.Clear();
  966.             Hashtable oneModels = new Hashtable();
  967.             oneModels.Clear();
  968.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  969.             //存放临时碎片
  970.             Hashtable newModels = new Hashtable();
  971.             newModels.Clear();
  972.             oneModel = "";
  973.         NewStart: //开始遍历匹配串
  974.             if (oneModel.Length > 0)
  975.             {
  976.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  977.             }
  978.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  979.             {
  980.                 if (oneModels.Contains(de.Key) == false)
  981.                 {
  982.                     oneModels.Add(de.Key, "0");
  983.                 }
  984.             }
  985.             newModels.Clear();
  986.             foreach (System.Collections.DictionaryEntry de in oneModels)
  987.             {
  988.                 oneModel = de.Key.ToString();
  989.                 if (oneModel.Length > 2)
  990.                 {
  991.                     int h = oneModel.Length;
  992.                     while (true)
  993.                     {
  994.                         if (h < 3)         //最短字符不能小于5  >=四
  995.                         { goto nextcmd2; }
  996.                         int st = 0;
  997.                         while (true)
  998.                         {
  999.                             if (st + h > oneModel.Length)
  1000.                             { goto nextcmd1; }
  1001.                             string a1 = oneModel.Substring(st, 1);
  1002.                             string a2 = oneModel.Substring(st + h - 1, 1);
  1003.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  1004.                             {
  1005.                                 goto nextcmd3;
  1006.                             }
  1007.                             string onestr = oneModel.Substring(st, h);
  1008.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  1009.                             {
  1010.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  1011.                             }
  1012.                             //遍历数据  是否符合全部数据
  1013.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  1014.                             {
  1015.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  1016.                                 {
  1017.                                     goto nextcmd3;
  1018.                                 }
  1019.                             }
  1020.                             //符合所有项都存在的条件 压入字典  
  1021.                             tdict.Add(tdictI, onestr);
  1022.                             //数据替换
  1023.                             Hashtable mtmpp = new Hashtable();
  1024.                             mtmpp.Clear();
  1025.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1026.                             {
  1027.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  1028.                                 string tmp_str = de2.Value.ToString();
  1029.                                 if (tmp_str == null)
  1030.                                 {
  1031.                                 }
  1032.                                 else
  1033.                                 {
  1034.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  1035.                                 }
  1036.                             }
  1037.                             mHTMs = mtmpp;
  1038.                             tdictI = tdictI + 1;  //字典序号
  1039.                             //oneModel  截取   取出碎片 压入 newModels
  1040.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  1041.                             string[] mykc = oneModelTmp.Split('*');
  1042.                             foreach (string ddee in mykc)
  1043.                             {
  1044.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  1045.                                 {
  1046.                                     newModels.Add(ddee, "0");
  1047.                                 }
  1048.                             }
  1049.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  1050.                         nextcmd3:
  1051.                             st = st + 1;
  1052.                         }
  1053.                     nextcmd1:
  1054.                         h = h - 1;
  1055.                     }
  1056.                 }
  1057.             nextcmd2: ;
  1058.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  1059.             }
  1060.             //mHTMs  处理新的 网页  只留下 *0*
  1061.             Hashtable mtmppC = new Hashtable();
  1062.             mtmppC.Clear();
  1063.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1064.             {
  1065.                 string cckc = de2.Value.ToString();
  1066.                 //把cckc中的*0*提取出来
  1067.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  1068.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  1069.             }
  1070.             mHTMs = mtmppC;
  1071.             //从模板得到一个项目模板
  1072.             //string mmoo = aass21BuilderModel(mHTMs);
  1073.             string mmoo = GetComDataEND(mHTMs, tdict);
  1074.             if (mmoo.Length == 0)
  1075.             {
  1076.                 //从模板得到一个项目模板
  1077.                 mmoo = aass3BuilderModel(mHTMs);
  1078.             }
  1079.             mmoo = mmoo.Replace("<", "*");
  1080.             mmoo = mmoo.Replace(">", "*");
  1081.             if (mmoo.Length == 0)
  1082.             {
  1083.                 return "";
  1084.             }
  1085.             else
  1086.             {
  1087.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  1088.                 {
  1089.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  1090.                 }
  1091.                 return mmoo;
  1092.             }
  1093.         }
  1094.         ////////////////////////////////////////////////////////////////////////////////
  1095.         //21
  1096.         ////////////////////////////////////////////////////////////////////////////////
  1097.         //21
  1098.         /// <summary>
  1099.         /// 《21》根据子模板建立一个超级模板
  1100.         /// </summary>
  1101.         /// <param name="mHTMs"></param>
  1102.         /// <returns></returns>
  1103.         private string aass21BuilderModel(Hashtable mHTMs)
  1104.         {
  1105.             //得到最短的串
  1106.             string oneModel = "";
  1107.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1108.             {
  1109.                 if (oneModel.Length == 0)
  1110.                 {
  1111.                     oneModel = de.Value.ToString();
  1112.                 }
  1113.                 else
  1114.                 {
  1115.                     if (oneModel.Length > de.Value.ToString().Length)
  1116.                     {
  1117.                         oneModel = de.Value.ToString();
  1118.                     }
  1119.                 }
  1120.             }
  1121.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1122.             {
  1123.                 if (oneModel != de.Value.ToString())                    //不相同
  1124.                 {
  1125.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  1126.                     {
  1127.                         goto cXStart;
  1128.                     }
  1129.                 }
  1130.             }
  1131.             return oneModel;
  1132.         cXStart:
  1133.             //得到匹配临时模板的原始长度
  1134.             int onemLong = oneModel.Length;
  1135.             Hashtable tdict = new Hashtable();
  1136.             int tdictI = 0; //字典序号
  1137.             tdict.Clear();
  1138.             Hashtable oneModels = new Hashtable();
  1139.             oneModels.Clear();
  1140.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  1141.             //存放临时碎片
  1142.             Hashtable newModels = new Hashtable();
  1143.             newModels.Clear();
  1144.             oneModel = "";
  1145.         NewStart: //开始遍历匹配串
  1146.             if (oneModel.Length > 0)
  1147.             {
  1148.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  1149.             }
  1150.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  1151.             {
  1152.                 if (oneModels.Contains(de.Key) == false)
  1153.                 {
  1154.                     oneModels.Add(de.Key, "0");
  1155.                 }
  1156.             }
  1157.             newModels.Clear();
  1158.             foreach (System.Collections.DictionaryEntry de in oneModels)
  1159.             {
  1160.                 oneModel = de.Key.ToString();
  1161.                 if (oneModel.Length > 2)
  1162.                 {
  1163.                     int h = oneModel.Length;
  1164.                     while (true)
  1165.                     {
  1166.                         if (h < 3)         //最短字符不能小于5  >=四
  1167.                         { goto nextcmd2; }
  1168.                         int st = 0;
  1169.                         while (true)
  1170.                         {
  1171.                             if (st + h > oneModel.Length)
  1172.                             { goto nextcmd1; }
  1173.                             string a1 = oneModel.Substring(st, 1);
  1174.                             string a2 = oneModel.Substring(st + h - 1, 1);
  1175.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  1176.                             {
  1177.                                 goto nextcmd3;
  1178.                             }
  1179.                             string onestr = oneModel.Substring(st, h);
  1180.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  1181.                             {
  1182.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  1183.                             }
  1184.                             //遍历数据  是否符合全部数据
  1185.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  1186.                             {
  1187.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  1188.                                 {
  1189.                                     goto nextcmd3;
  1190.                                 }
  1191.                             }
  1192.                             //符合所有项都存在的条件 压入字典  
  1193.                             tdict.Add(tdictI, onestr);
  1194.                             //数据替换
  1195.                             Hashtable mtmpp = new Hashtable();
  1196.                             mtmpp.Clear();
  1197.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1198.                             {
  1199.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  1200.                                 string tmp_str = de2.Value.ToString();
  1201.                                 if (tmp_str == null)
  1202.                                 {
  1203.                                 }
  1204.                                 else
  1205.                                 {
  1206.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  1207.                                 }
  1208.                             }
  1209.                             mHTMs = mtmpp;
  1210.                             tdictI = tdictI + 1;  //字典序号
  1211.                             //oneModel  截取   取出碎片 压入 newModels
  1212.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  1213.                             string[] mykc = oneModelTmp.Split('*');
  1214.                             foreach (string ddee in mykc)
  1215.                             {
  1216.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  1217.                                 {
  1218.                                     newModels.Add(ddee, "0");
  1219.                                 }
  1220.                             }
  1221.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  1222.                         nextcmd3:
  1223.                             st = st + 1;
  1224.                         }
  1225.                     nextcmd1:
  1226.                         h = h - 1;
  1227.                     }
  1228.                 }
  1229.             nextcmd2: ;
  1230.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  1231.             }
  1232.             //mHTMs  处理新的 网页  只留下 *0*
  1233.             Hashtable mtmppC = new Hashtable();
  1234.             mtmppC.Clear();
  1235.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1236.             {
  1237.                 string cckc = de2.Value.ToString();
  1238.                 //把cckc中的*0*提取出来
  1239.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  1240.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  1241.             }
  1242.             mHTMs = mtmppC;
  1243.             //从模板得到一个项目模板
  1244.             //string mmoo = aass22BuilderModel(mHTMs);
  1245.             string mmoo = GetComDataEND(mHTMs, tdict);
  1246.             if (mmoo.Length == 0)
  1247.             {
  1248.                 //从模板得到一个项目模板
  1249.                 mmoo = aass3BuilderModel(mHTMs);
  1250.             }
  1251.             mmoo = mmoo.Replace("<", "*");
  1252.             mmoo = mmoo.Replace(">", "*");
  1253.             if (mmoo.Length == 0)
  1254.             {
  1255.                 return "";
  1256.             }
  1257.             else
  1258.             {
  1259.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  1260.                 {
  1261.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  1262.                 }
  1263.                 return mmoo;
  1264.             }
  1265.         }
  1266.         ////////////////////////////////////////////////////////////////////////////////
  1267.         //22
  1268.         ////////////////////////////////////////////////////////////////////////////////
  1269.         //22
  1270.         /// <summary>
  1271.         /// 《22》根据子模板建立一个超级模板
  1272.         /// </summary>
  1273.         /// <param name="mHTMs"></param>
  1274.         /// <returns></returns>
  1275.         private string aass22BuilderModel(Hashtable mHTMs)
  1276.         {
  1277.             //得到最短的串
  1278.             string oneModel = "";
  1279.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1280.             {
  1281.                 if (oneModel.Length == 0)
  1282.                 {
  1283.                     oneModel = de.Value.ToString();
  1284.                 }
  1285.                 else
  1286.                 {
  1287.                     if (oneModel.Length > de.Value.ToString().Length)
  1288.                     {
  1289.                         oneModel = de.Value.ToString();
  1290.                     }
  1291.                 }
  1292.             }
  1293.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1294.             {
  1295.                 if (oneModel != de.Value.ToString())                    //不相同
  1296.                 {
  1297.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  1298.                     {
  1299.                         goto cXStart;
  1300.                     }
  1301.                 }
  1302.             }
  1303.             return oneModel;
  1304.         cXStart:
  1305.             //得到匹配临时模板的原始长度
  1306.             int onemLong = oneModel.Length;
  1307.             Hashtable tdict = new Hashtable();
  1308.             int tdictI = 0; //字典序号
  1309.             tdict.Clear();
  1310.             Hashtable oneModels = new Hashtable();
  1311.             oneModels.Clear();
  1312.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  1313.             //存放临时碎片
  1314.             Hashtable newModels = new Hashtable();
  1315.             newModels.Clear();
  1316.             oneModel = "";
  1317.         NewStart: //开始遍历匹配串
  1318.             if (oneModel.Length > 0)
  1319.             {
  1320.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  1321.             }
  1322.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  1323.             {
  1324.                 if (oneModels.Contains(de.Key) == false)
  1325.                 {
  1326.                     oneModels.Add(de.Key, "0");
  1327.                 }
  1328.             }
  1329.             newModels.Clear();
  1330.             foreach (System.Collections.DictionaryEntry de in oneModels)
  1331.             {
  1332.                 oneModel = de.Key.ToString();
  1333.                 if (oneModel.Length > 2)
  1334.                 {
  1335.                     int h = oneModel.Length;
  1336.                     while (true)
  1337.                     {
  1338.                         if (h < 3)         //最短字符不能小于5  >=四
  1339.                         { goto nextcmd2; }
  1340.                         int st = 0;
  1341.                         while (true)
  1342.                         {
  1343.                             if (st + h > oneModel.Length)
  1344.                             { goto nextcmd1; }
  1345.                             string a1 = oneModel.Substring(st, 1);
  1346.                             string a2 = oneModel.Substring(st + h - 1, 1);
  1347.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  1348.                             {
  1349.                                 goto nextcmd3;
  1350.                             }
  1351.                             string onestr = oneModel.Substring(st, h);
  1352.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  1353.                             {
  1354.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  1355.                             }
  1356.                             //遍历数据  是否符合全部数据
  1357.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  1358.                             {
  1359.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  1360.                                 {
  1361.                                     goto nextcmd3;
  1362.                                 }
  1363.                             }
  1364.                             //符合所有项都存在的条件 压入字典  
  1365.                             tdict.Add(tdictI, onestr);
  1366.                             //数据替换
  1367.                             Hashtable mtmpp = new Hashtable();
  1368.                             mtmpp.Clear();
  1369.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1370.                             {
  1371.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  1372.                                 string tmp_str = de2.Value.ToString();
  1373.                                 if (tmp_str == null)
  1374.                                 {
  1375.                                 }
  1376.                                 else
  1377.                                 {
  1378.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  1379.                                 }
  1380.                             }
  1381.                             mHTMs = mtmpp;
  1382.                             tdictI = tdictI + 1;  //字典序号
  1383.                             //oneModel  截取   取出碎片 压入 newModels
  1384.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  1385.                             string[] mykc = oneModelTmp.Split('*');
  1386.                             foreach (string ddee in mykc)
  1387.                             {
  1388.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  1389.                                 {
  1390.                                     newModels.Add(ddee, "0");
  1391.                                 }
  1392.                             }
  1393.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  1394.                         nextcmd3:
  1395.                             st = st + 1;
  1396.                         }
  1397.                     nextcmd1:
  1398.                         h = h - 1;
  1399.                     }
  1400.                 }
  1401.             nextcmd2: ;
  1402.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  1403.             }
  1404.             //mHTMs  处理新的 网页  只留下 *0*
  1405.             Hashtable mtmppC = new Hashtable();
  1406.             mtmppC.Clear();
  1407.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1408.             {
  1409.                 string cckc = de2.Value.ToString();
  1410.                 //把cckc中的*0*提取出来
  1411.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  1412.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  1413.             }
  1414.             mHTMs = mtmppC;
  1415.             //从模板得到一个项目模板
  1416.             //string mmoo = aass23BuilderModel(mHTMs);
  1417.             string mmoo = GetComDataEND(mHTMs, tdict);
  1418.             if (mmoo.Length == 0)
  1419.             {
  1420.                 //从模板得到一个项目模板
  1421.                 mmoo = aass3BuilderModel(mHTMs);
  1422.             }
  1423.             mmoo = mmoo.Replace("<", "*");
  1424.             mmoo = mmoo.Replace(">", "*");
  1425.             if (mmoo.Length == 0)
  1426.             {
  1427.                 return "";
  1428.             }
  1429.             else
  1430.             {
  1431.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  1432.                 {
  1433.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  1434.                 }
  1435.                 return mmoo;
  1436.             }
  1437.         }
  1438.         ////////////////////////////////////////////////////////////////////////////////
  1439.         //23
  1440.         ////////////////////////////////////////////////////////////////////////////////
  1441.         //23
  1442.         /// <summary>
  1443.         /// 《23》根据子模板建立一个超级模板
  1444.         /// </summary>
  1445.         /// <param name="mHTMs"></param>
  1446.         /// <returns></returns>
  1447.         private string aass23BuilderModel(Hashtable mHTMs)
  1448.         {
  1449.             //得到最短的串
  1450.             string oneModel = "";
  1451.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1452.             {
  1453.                 if (oneModel.Length == 0)
  1454.                 {
  1455.                     oneModel = de.Value.ToString();
  1456.                 }
  1457.                 else
  1458.                 {
  1459.                     if (oneModel.Length > de.Value.ToString().Length)
  1460.                     {
  1461.                         oneModel = de.Value.ToString();
  1462.                     }
  1463.                 }
  1464.             }
  1465.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1466.             {
  1467.                 if (oneModel != de.Value.ToString())                    //不相同
  1468.                 {
  1469.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  1470.                     {
  1471.                         goto cXStart;
  1472.                     }
  1473.                 }
  1474.             }
  1475.             return oneModel;
  1476.         cXStart:
  1477.             //得到匹配临时模板的原始长度
  1478.             int onemLong = oneModel.Length;
  1479.             Hashtable tdict = new Hashtable();
  1480.             int tdictI = 0; //字典序号
  1481.             tdict.Clear();
  1482.             Hashtable oneModels = new Hashtable();
  1483.             oneModels.Clear();
  1484.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  1485.             //存放临时碎片
  1486.             Hashtable newModels = new Hashtable();
  1487.             newModels.Clear();
  1488.             oneModel = "";
  1489.         NewStart: //开始遍历匹配串
  1490.             if (oneModel.Length > 0)
  1491.             {
  1492.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  1493.             }
  1494.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  1495.             {
  1496.                 if (oneModels.Contains(de.Key) == false)
  1497.                 {
  1498.                     oneModels.Add(de.Key, "0");
  1499.                 }
  1500.             }
  1501.             newModels.Clear();
  1502.             foreach (System.Collections.DictionaryEntry de in oneModels)
  1503.             {
  1504.                 oneModel = de.Key.ToString();
  1505.                 if (oneModel.Length > 2)
  1506.                 {
  1507.                     int h = oneModel.Length;
  1508.                     while (true)
  1509.                     {
  1510.                         if (h < 3)         //最短字符不能小于5  >=四
  1511.                         { goto nextcmd2; }
  1512.                         int st = 0;
  1513.                         while (true)
  1514.                         {
  1515.                             if (st + h > oneModel.Length)
  1516.                             { goto nextcmd1; }
  1517.                             string a1 = oneModel.Substring(st, 1);
  1518.                             string a2 = oneModel.Substring(st + h - 1, 1);
  1519.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  1520.                             {
  1521.                                 goto nextcmd3;
  1522.                             }
  1523.                             string onestr = oneModel.Substring(st, h);
  1524.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  1525.                             {
  1526.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  1527.                             }
  1528.                             //遍历数据  是否符合全部数据
  1529.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  1530.                             {
  1531.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  1532.                                 {
  1533.                                     goto nextcmd3;
  1534.                                 }
  1535.                             }
  1536.                             //符合所有项都存在的条件 压入字典  
  1537.                             tdict.Add(tdictI, onestr);
  1538.                             //数据替换
  1539.                             Hashtable mtmpp = new Hashtable();
  1540.                             mtmpp.Clear();
  1541.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1542.                             {
  1543.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  1544.                                 string tmp_str = de2.Value.ToString();
  1545.                                 if (tmp_str == null)
  1546.                                 {
  1547.                                 }
  1548.                                 else
  1549.                                 {
  1550.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  1551.                                 }
  1552.                             }
  1553.                             mHTMs = mtmpp;
  1554.                             tdictI = tdictI + 1;  //字典序号
  1555.                             //oneModel  截取   取出碎片 压入 newModels
  1556.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  1557.                             string[] mykc = oneModelTmp.Split('*');
  1558.                             foreach (string ddee in mykc)
  1559.                             {
  1560.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  1561.                                 {
  1562.                                     newModels.Add(ddee, "0");
  1563.                                 }
  1564.                             }
  1565.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  1566.                         nextcmd3:
  1567.                             st = st + 1;
  1568.                         }
  1569.                     nextcmd1:
  1570.                         h = h - 1;
  1571.                     }
  1572.                 }
  1573.             nextcmd2: ;
  1574.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  1575.             }
  1576.             //mHTMs  处理新的 网页  只留下 *0*
  1577.             Hashtable mtmppC = new Hashtable();
  1578.             mtmppC.Clear();
  1579.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1580.             {
  1581.                 string cckc = de2.Value.ToString();
  1582.                 //把cckc中的*0*提取出来
  1583.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  1584.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  1585.             }
  1586.             mHTMs = mtmppC;
  1587.             //从模板得到一个项目模板
  1588.             //string mmoo = aass24BuilderModel(mHTMs);
  1589.             string mmoo = GetComDataEND(mHTMs, tdict);
  1590.             if (mmoo.Length == 0)
  1591.             {
  1592.                 //从模板得到一个项目模板
  1593.                 mmoo = aass3BuilderModel(mHTMs);
  1594.             }
  1595.             mmoo = mmoo.Replace("<", "*");
  1596.             mmoo = mmoo.Replace(">", "*");
  1597.             if (mmoo.Length == 0)
  1598.             {
  1599.                 return "";
  1600.             }
  1601.             else
  1602.             {
  1603.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  1604.                 {
  1605.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  1606.                 }
  1607.                 return mmoo;
  1608.             }
  1609.         }
  1610.         ////////////////////////////////////////////////////////////////////////////////
  1611.         //24
  1612.         ////////////////////////////////////////////////////////////////////////////////
  1613.         /// <summary>
  1614.         /// 《24》根据子模板建立一个超级模板
  1615.         /// </summary>
  1616.         /// <param name="mHTMs"></param>
  1617.         /// <returns></returns>
  1618.         private string aass24BuilderModel(Hashtable mHTMs)
  1619.         {
  1620.             //得到最短的串
  1621.             string oneModel = "";
  1622.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1623.             {
  1624.                 if (oneModel.Length == 0)
  1625.                 {
  1626.                     oneModel = de.Value.ToString();
  1627.                 }
  1628.                 else
  1629.                 {
  1630.                     if (oneModel.Length > de.Value.ToString().Length)
  1631.                     {
  1632.                         oneModel = de.Value.ToString();
  1633.                     }
  1634.                 }
  1635.             }
  1636.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1637.             {
  1638.                 if (oneModel != de.Value.ToString())                    //不相同
  1639.                 {
  1640.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  1641.                     {
  1642.                         goto cXStart;
  1643.                     }
  1644.                 }
  1645.             }
  1646.             return oneModel;
  1647.         cXStart:
  1648.             //得到匹配临时模板的原始长度
  1649.             int onemLong = oneModel.Length;
  1650.             Hashtable tdict = new Hashtable();
  1651.             int tdictI = 0; //字典序号
  1652.             tdict.Clear();
  1653.             Hashtable oneModels = new Hashtable();
  1654.             oneModels.Clear();
  1655.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  1656.             //存放临时碎片
  1657.             Hashtable newModels = new Hashtable();
  1658.             newModels.Clear();
  1659.             oneModel = "";
  1660.         NewStart: //开始遍历匹配串
  1661.             if (oneModel.Length > 0)
  1662.             {
  1663.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  1664.             }
  1665.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  1666.             {
  1667.                 if (oneModels.Contains(de.Key) == false)
  1668.                 {
  1669.                     oneModels.Add(de.Key, "0");
  1670.                 }
  1671.             }
  1672.             newModels.Clear();
  1673.             foreach (System.Collections.DictionaryEntry de in oneModels)
  1674.             {
  1675.                 oneModel = de.Key.ToString();
  1676.                 if (oneModel.Length > 2)
  1677.                 {
  1678.                     int h = oneModel.Length;
  1679.                     while (true)
  1680.                     {
  1681.                         if (h < 3)         //最短字符不能小于5  >=四
  1682.                         { goto nextcmd2; }
  1683.                         int st = 0;
  1684.                         while (true)
  1685.                         {
  1686.                             if (st + h > oneModel.Length)
  1687.                             { goto nextcmd1; }
  1688.                             string a1 = oneModel.Substring(st, 1);
  1689.                             string a2 = oneModel.Substring(st + h - 1, 1);
  1690.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  1691.                             {
  1692.                                 goto nextcmd3;
  1693.                             }
  1694.                             string onestr = oneModel.Substring(st, h);
  1695.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  1696.                             {
  1697.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  1698.                             }
  1699.                             //遍历数据  是否符合全部数据
  1700.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  1701.                             {
  1702.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  1703.                                 {
  1704.                                     goto nextcmd3;
  1705.                                 }
  1706.                             }
  1707.                             //符合所有项都存在的条件 压入字典  
  1708.                             tdict.Add(tdictI, onestr);
  1709.                             //数据替换
  1710.                             Hashtable mtmpp = new Hashtable();
  1711.                             mtmpp.Clear();
  1712.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1713.                             {
  1714.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  1715.                                 string tmp_str = de2.Value.ToString();
  1716.                                 if (tmp_str == null)
  1717.                                 {
  1718.                                 }
  1719.                                 else
  1720.                                 {
  1721.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  1722.                                 }
  1723.                             }
  1724.                             mHTMs = mtmpp;
  1725.                             tdictI = tdictI + 1;  //字典序号
  1726.                             //oneModel  截取   取出碎片 压入 newModels
  1727.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  1728.                             string[] mykc = oneModelTmp.Split('*');
  1729.                             foreach (string ddee in mykc)
  1730.                             {
  1731.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  1732.                                 {
  1733.                                     newModels.Add(ddee, "0");
  1734.                                 }
  1735.                             }
  1736.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  1737.                         nextcmd3:
  1738.                             st = st + 1;
  1739.                         }
  1740.                     nextcmd1:
  1741.                         h = h - 1;
  1742.                     }
  1743.                 }
  1744.             nextcmd2: ;
  1745.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  1746.             }
  1747.             //mHTMs  处理新的 网页  只留下 *0*
  1748.             Hashtable mtmppC = new Hashtable();
  1749.             mtmppC.Clear();
  1750.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1751.             {
  1752.                 string cckc = de2.Value.ToString();
  1753.                 //把cckc中的*0*提取出来
  1754.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  1755.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  1756.             }
  1757.             mHTMs = mtmppC;
  1758.             //从模板得到一个项目模板
  1759.             //string mmoo = aass25BuilderModel(mHTMs);
  1760.             string mmoo = GetComDataEND(mHTMs, tdict);
  1761.             if (mmoo.Length == 0)
  1762.             {
  1763.                 //从模板得到一个项目模板
  1764.                 mmoo = aass3BuilderModel(mHTMs);
  1765.             }
  1766.             mmoo = mmoo.Replace("<", "*");
  1767.             mmoo = mmoo.Replace(">", "*");
  1768.             if (mmoo.Length == 0)
  1769.             {
  1770.                 return "";
  1771.             }
  1772.             else
  1773.             {
  1774.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  1775.                 {
  1776.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  1777.                 }
  1778.                 return mmoo;
  1779.             }
  1780.         }
  1781.         ////////////////////////////////////////////////////////////////////////////////
  1782.         //25
  1783.         ////////////////////////////////////////////////////////////////////////////////
  1784.         /// <summary>
  1785.         /// 《25》根据子模板建立一个超级模板
  1786.         /// </summary>
  1787.         /// <param name="mHTMs"></param>
  1788.         /// <returns></returns>
  1789.         private string aass25BuilderModel(Hashtable mHTMs)
  1790.         {
  1791.             //得到最短的串
  1792.             string oneModel = "";
  1793.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1794.             {
  1795.                 if (oneModel.Length == 0)
  1796.                 {
  1797.                     oneModel = de.Value.ToString();
  1798.                 }
  1799.                 else
  1800.                 {
  1801.                     if (oneModel.Length > de.Value.ToString().Length)
  1802.                     {
  1803.                         oneModel = de.Value.ToString();
  1804.                     }
  1805.                 }
  1806.             }
  1807.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1808.             {
  1809.                 if (oneModel != de.Value.ToString())                    //不相同
  1810.                 {
  1811.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  1812.                     {
  1813.                         goto cXStart;
  1814.                     }
  1815.                 }
  1816.             }
  1817.             return oneModel;
  1818.         cXStart:
  1819.             //得到匹配临时模板的原始长度
  1820.             int onemLong = oneModel.Length;
  1821.             Hashtable tdict = new Hashtable();
  1822.             int tdictI = 0; //字典序号
  1823.             tdict.Clear();
  1824.             Hashtable oneModels = new Hashtable();
  1825.             oneModels.Clear();
  1826.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  1827.             //存放临时碎片
  1828.             Hashtable newModels = new Hashtable();
  1829.             newModels.Clear();
  1830.             oneModel = "";
  1831.         NewStart: //开始遍历匹配串
  1832.             if (oneModel.Length > 0)
  1833.             {
  1834.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  1835.             }
  1836.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  1837.             {
  1838.                 if (oneModels.Contains(de.Key) == false)
  1839.                 {
  1840.                     oneModels.Add(de.Key, "0");
  1841.                 }
  1842.             }
  1843.             newModels.Clear();
  1844.             foreach (System.Collections.DictionaryEntry de in oneModels)
  1845.             {
  1846.                 oneModel = de.Key.ToString();
  1847.                 if (oneModel.Length > 2)
  1848.                 {
  1849.                     int h = oneModel.Length;
  1850.                     while (true)
  1851.                     {
  1852.                         if (h < 3)         //最短字符不能小于5  >=四
  1853.                         { goto nextcmd2; }
  1854.                         int st = 0;
  1855.                         while (true)
  1856.                         {
  1857.                             if (st + h > oneModel.Length)
  1858.                             { goto nextcmd1; }
  1859.                             string a1 = oneModel.Substring(st, 1);
  1860.                             string a2 = oneModel.Substring(st + h - 1, 1);
  1861.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  1862.                             {
  1863.                                 goto nextcmd3;
  1864.                             }
  1865.                             string onestr = oneModel.Substring(st, h);
  1866.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  1867.                             {
  1868.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  1869.                             }
  1870.                             //遍历数据  是否符合全部数据
  1871.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  1872.                             {
  1873.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  1874.                                 {
  1875.                                     goto nextcmd3;
  1876.                                 }
  1877.                             }
  1878.                             //符合所有项都存在的条件 压入字典  
  1879.                             tdict.Add(tdictI, onestr);
  1880.                             //数据替换
  1881.                             Hashtable mtmpp = new Hashtable();
  1882.                             mtmpp.Clear();
  1883.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1884.                             {
  1885.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  1886.                                 string tmp_str = de2.Value.ToString();
  1887.                                 if (tmp_str == null)
  1888.                                 {
  1889.                                 }
  1890.                                 else
  1891.                                 {
  1892.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  1893.                                 }
  1894.                             }
  1895.                             mHTMs = mtmpp;
  1896.                             tdictI = tdictI + 1;  //字典序号
  1897.                             //oneModel  截取   取出碎片 压入 newModels
  1898.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  1899.                             string[] mykc = oneModelTmp.Split('*');
  1900.                             foreach (string ddee in mykc)
  1901.                             {
  1902.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  1903.                                 {
  1904.                                     newModels.Add(ddee, "0");
  1905.                                 }
  1906.                             }
  1907.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  1908.                         nextcmd3:
  1909.                             st = st + 1;
  1910.                         }
  1911.                     nextcmd1:
  1912.                         h = h - 1;
  1913.                     }
  1914.                 }
  1915.             nextcmd2: ;
  1916.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  1917.             }
  1918.             //mHTMs  处理新的 网页  只留下 *0*
  1919.             Hashtable mtmppC = new Hashtable();
  1920.             mtmppC.Clear();
  1921.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  1922.             {
  1923.                 string cckc = de2.Value.ToString();
  1924.                 //把cckc中的*0*提取出来
  1925.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  1926.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  1927.             }
  1928.             mHTMs = mtmppC;
  1929.             //从模板得到一个项目模板
  1930.             //string mmoo = aass26BuilderModel(mHTMs);
  1931.             string mmoo = GetComDataEND(mHTMs, tdict);
  1932.             if (mmoo.Length == 0)
  1933.             {
  1934.                 //从模板得到一个项目模板
  1935.                 mmoo = aass3BuilderModel(mHTMs);
  1936.             }
  1937.             mmoo = mmoo.Replace("<", "*");
  1938.             mmoo = mmoo.Replace(">", "*");
  1939.             if (mmoo.Length == 0)
  1940.             {
  1941.                 return "";
  1942.             }
  1943.             else
  1944.             {
  1945.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  1946.                 {
  1947.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  1948.                 }
  1949.                 return mmoo;
  1950.             }
  1951.         }
  1952.         ////////////////////////////////////////////////////////////////////////////////
  1953.         //26
  1954.         ////////////////////////////////////////////////////////////////////////////////
  1955.         /// <summary>
  1956.         /// 《26》根据子模板建立一个超级模板
  1957.         /// </summary>
  1958.         /// <param name="mHTMs"></param>
  1959.         /// <returns></returns>
  1960.         private string aass26BuilderModel(Hashtable mHTMs)
  1961.         {
  1962.             //得到最短的串
  1963.             string oneModel = "";
  1964.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1965.             {
  1966.                 if (oneModel.Length == 0)
  1967.                 {
  1968.                     oneModel = de.Value.ToString();
  1969.                 }
  1970.                 else
  1971.                 {
  1972.                     if (oneModel.Length > de.Value.ToString().Length)
  1973.                     {
  1974.                         oneModel = de.Value.ToString();
  1975.                     }
  1976.                 }
  1977.             }
  1978.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  1979.             {
  1980.                 if (oneModel != de.Value.ToString())                    //不相同
  1981.                 {
  1982.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  1983.                     {
  1984.                         goto cXStart;
  1985.                     }
  1986.                 }
  1987.             }
  1988.             return oneModel;
  1989.         cXStart:
  1990.             //得到匹配临时模板的原始长度
  1991.             int onemLong = oneModel.Length;
  1992.             Hashtable tdict = new Hashtable();
  1993.             int tdictI = 0; //字典序号
  1994.             tdict.Clear();
  1995.             Hashtable oneModels = new Hashtable();
  1996.             oneModels.Clear();
  1997.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  1998.             //存放临时碎片
  1999.             Hashtable newModels = new Hashtable();
  2000.             newModels.Clear();
  2001.             oneModel = "";
  2002.         NewStart: //开始遍历匹配串
  2003.             if (oneModel.Length > 0)
  2004.             {
  2005.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  2006.             }
  2007.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  2008.             {
  2009.                 if (oneModels.Contains(de.Key) == false)
  2010.                 {
  2011.                     oneModels.Add(de.Key, "0");
  2012.                 }
  2013.             }
  2014.             newModels.Clear();
  2015.             foreach (System.Collections.DictionaryEntry de in oneModels)
  2016.             {
  2017.                 oneModel = de.Key.ToString();
  2018.                 if (oneModel.Length > 2)
  2019.                 {
  2020.                     int h = oneModel.Length;
  2021.                     while (true)
  2022.                     {
  2023.                         if (h < 3)         //最短字符不能小于5  >=四
  2024.                         { goto nextcmd2; }
  2025.                         int st = 0;
  2026.                         while (true)
  2027.                         {
  2028.                             if (st + h > oneModel.Length)
  2029.                             { goto nextcmd1; }
  2030.                             string a1 = oneModel.Substring(st, 1);
  2031.                             string a2 = oneModel.Substring(st + h - 1, 1);
  2032.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  2033.                             {
  2034.                                 goto nextcmd3;
  2035.                             }
  2036.                             string onestr = oneModel.Substring(st, h);
  2037.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  2038.                             {
  2039.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  2040.                             }
  2041.                             //遍历数据  是否符合全部数据
  2042.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  2043.                             {
  2044.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  2045.                                 {
  2046.                                     goto nextcmd3;
  2047.                                 }
  2048.                             }
  2049.                             //符合所有项都存在的条件 压入字典  
  2050.                             tdict.Add(tdictI, onestr);
  2051.                             //数据替换
  2052.                             Hashtable mtmpp = new Hashtable();
  2053.                             mtmpp.Clear();
  2054.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  2055.                             {
  2056.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  2057.                                 string tmp_str = de2.Value.ToString();
  2058.                                 if (tmp_str == null)
  2059.                                 {
  2060.                                 }
  2061.                                 else
  2062.                                 {
  2063.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  2064.                                 }
  2065.                             }
  2066.                             mHTMs = mtmpp;
  2067.                             tdictI = tdictI + 1;  //字典序号
  2068.                             //oneModel  截取   取出碎片 压入 newModels
  2069.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  2070.                             string[] mykc = oneModelTmp.Split('*');
  2071.                             foreach (string ddee in mykc)
  2072.                             {
  2073.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  2074.                                 {
  2075.                                     newModels.Add(ddee, "0");
  2076.                                 }
  2077.                             }
  2078.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  2079.                         nextcmd3:
  2080.                             st = st + 1;
  2081.                         }
  2082.                     nextcmd1:
  2083.                         h = h - 1;
  2084.                     }
  2085.                 }
  2086.             nextcmd2: ;
  2087.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  2088.             }
  2089.             //mHTMs  处理新的 网页  只留下 *0*
  2090.             Hashtable mtmppC = new Hashtable();
  2091.             mtmppC.Clear();
  2092.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  2093.             {
  2094.                 string cckc = de2.Value.ToString();
  2095.                 //把cckc中的*0*提取出来
  2096.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  2097.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  2098.             }
  2099.             mHTMs = mtmppC;
  2100.             //从模板得到一个项目模板
  2101.             //string mmoo = aass27BuilderModel(mHTMs);
  2102.             string mmoo = GetComDataEND(mHTMs, tdict);
  2103.             if (mmoo.Length == 0)
  2104.             {
  2105.                 //从模板得到一个项目模板
  2106.                 mmoo = aass3BuilderModel(mHTMs);
  2107.             }
  2108.             mmoo = mmoo.Replace("<", "*");
  2109.             mmoo = mmoo.Replace(">", "*");
  2110.             if (mmoo.Length == 0)
  2111.             {
  2112.                 return "";
  2113.             }
  2114.             else
  2115.             {
  2116.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  2117.                 {
  2118.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  2119.                 }
  2120.                 return mmoo;
  2121.             }
  2122.         }
  2123.         ////////////////////////////////////////////////////////////////////////////////
  2124.         //27
  2125.         ////////////////////////////////////////////////////////////////////////////////
  2126.         /// <summary>
  2127.         /// 《27》根据子模板建立一个超级模板
  2128.         /// </summary>
  2129.         /// <param name="mHTMs"></param>
  2130.         /// <returns></returns>
  2131.         private string aass27BuilderModel(Hashtable mHTMs)
  2132.         {
  2133.             //得到最短的串
  2134.             string oneModel = "";
  2135.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  2136.             {
  2137.                 if (oneModel.Length == 0)
  2138.                 {
  2139.                     oneModel = de.Value.ToString();
  2140.                 }
  2141.                 else
  2142.                 {
  2143.                     if (oneModel.Length > de.Value.ToString().Length)
  2144.                     {
  2145.                         oneModel = de.Value.ToString();
  2146.                     }
  2147.                 }
  2148.             }
  2149.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  2150.             {
  2151.                 if (oneModel != de.Value.ToString())                    //不相同
  2152.                 {
  2153.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  2154.                     {
  2155.                         goto cXStart;
  2156.                     }
  2157.                 }
  2158.             }
  2159.             return oneModel;
  2160.         cXStart:
  2161.             //得到匹配临时模板的原始长度
  2162.             int onemLong = oneModel.Length;
  2163.             Hashtable tdict = new Hashtable();
  2164.             int tdictI = 0; //字典序号
  2165.             tdict.Clear();
  2166.             Hashtable oneModels = new Hashtable();
  2167.             oneModels.Clear();
  2168.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  2169.             //存放临时碎片
  2170.             Hashtable newModels = new Hashtable();
  2171.             newModels.Clear();
  2172.             oneModel = "";
  2173.         NewStart: //开始遍历匹配串
  2174.             if (oneModel.Length > 0)
  2175.             {
  2176.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  2177.             }
  2178.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  2179.             {
  2180.                 if (oneModels.Contains(de.Key) == false)
  2181.                 {
  2182.                     oneModels.Add(de.Key, "0");
  2183.                 }
  2184.             }
  2185.             newModels.Clear();
  2186.             foreach (System.Collections.DictionaryEntry de in oneModels)
  2187.             {
  2188.                 oneModel = de.Key.ToString();
  2189.                 if (oneModel.Length > 2)
  2190.                 {
  2191.                     int h = oneModel.Length;
  2192.                     while (true)
  2193.                     {
  2194.                         if (h < 3)         //最短字符不能小于5  >=四
  2195.                         { goto nextcmd2; }
  2196.                         int st = 0;
  2197.                         while (true)
  2198.                         {
  2199.                             if (st + h > oneModel.Length)
  2200.                             { goto nextcmd1; }
  2201.                             string a1 = oneModel.Substring(st, 1);
  2202.                             string a2 = oneModel.Substring(st + h - 1, 1);
  2203.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  2204.                             {
  2205.                                 goto nextcmd3;
  2206.                             }
  2207.                             string onestr = oneModel.Substring(st, h);
  2208.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  2209.                             {
  2210.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  2211.                             }
  2212.                             //遍历数据  是否符合全部数据
  2213.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  2214.                             {
  2215.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  2216.                                 {
  2217.                                     goto nextcmd3;
  2218.                                 }
  2219.                             }
  2220.                             //符合所有项都存在的条件 压入字典  
  2221.                             tdict.Add(tdictI, onestr);
  2222.                             //数据替换
  2223.                             Hashtable mtmpp = new Hashtable();
  2224.                             mtmpp.Clear();
  2225.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  2226.                             {
  2227.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  2228.                                 string tmp_str = de2.Value.ToString();
  2229.                                 if (tmp_str == null)
  2230.                                 {
  2231.                                 }
  2232.                                 else
  2233.                                 {
  2234.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  2235.                                 }
  2236.                             }
  2237.                             mHTMs = mtmpp;
  2238.                             tdictI = tdictI + 1;  //字典序号
  2239.                             //oneModel  截取   取出碎片 压入 newModels
  2240.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  2241.                             string[] mykc = oneModelTmp.Split('*');
  2242.                             foreach (string ddee in mykc)
  2243.                             {
  2244.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  2245.                                 {
  2246.                                     newModels.Add(ddee, "0");
  2247.                                 }
  2248.                             }
  2249.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  2250.                         nextcmd3:
  2251.                             st = st + 1;
  2252.                         }
  2253.                     nextcmd1:
  2254.                         h = h - 1;
  2255.                     }
  2256.                 }
  2257.             nextcmd2: ;
  2258.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  2259.             }
  2260.             //mHTMs  处理新的 网页  只留下 *0*
  2261.             Hashtable mtmppC = new Hashtable();
  2262.             mtmppC.Clear();
  2263.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  2264.             {
  2265.                 string cckc = de2.Value.ToString();
  2266.                 //把cckc中的*0*提取出来
  2267.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  2268.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  2269.             }
  2270.             mHTMs = mtmppC;
  2271.             //从模板得到一个项目模板
  2272.             //string mmoo = aass28BuilderModel(mHTMs);
  2273.             string mmoo = GetComDataEND(mHTMs, tdict);
  2274.             if (mmoo.Length == 0)
  2275.             {
  2276.                 //从模板得到一个项目模板
  2277.                 mmoo = aass3BuilderModel(mHTMs);
  2278.             }
  2279.             mmoo = mmoo.Replace("<", "*");
  2280.             mmoo = mmoo.Replace(">", "*");
  2281.             if (mmoo.Length == 0)
  2282.             {
  2283.                 return "";
  2284.             }
  2285.             else
  2286.             {
  2287.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  2288.                 {
  2289.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  2290.                 }
  2291.                 return mmoo;
  2292.             }
  2293.         }
  2294.         ////////////////////////////////////////////////////////////////////////////////
  2295.         //28
  2296.         ////////////////////////////////////////////////////////////////////////////////
  2297.         /// <summary>
  2298.         /// 《28》根据子模板建立一个超级模板
  2299.         /// </summary>
  2300.         /// <param name="mHTMs"></param>
  2301.         /// <returns></returns>
  2302.         private string aass28BuilderModel(Hashtable mHTMs)
  2303.         {
  2304.             //得到最短的串
  2305.             string oneModel = "";
  2306.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  2307.             {
  2308.                 if (oneModel.Length == 0)
  2309.                 {
  2310.                     oneModel = de.Value.ToString();
  2311.                 }
  2312.                 else
  2313.                 {
  2314.                     if (oneModel.Length > de.Value.ToString().Length)
  2315.                     {
  2316.                         oneModel = de.Value.ToString();
  2317.                     }
  2318.                 }
  2319.             }
  2320.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  2321.             {
  2322.                 if (oneModel != de.Value.ToString())                    //不相同
  2323.                 {
  2324.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  2325.                     {
  2326.                         goto cXStart;
  2327.                     }
  2328.                 }
  2329.             }
  2330.             return oneModel;
  2331.         cXStart:
  2332.             //得到匹配临时模板的原始长度
  2333.             int onemLong = oneModel.Length;
  2334.             Hashtable tdict = new Hashtable();
  2335.             int tdictI = 0; //字典序号
  2336.             tdict.Clear();
  2337.             Hashtable oneModels = new Hashtable();
  2338.             oneModels.Clear();
  2339.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  2340.             //存放临时碎片
  2341.             Hashtable newModels = new Hashtable();
  2342.             newModels.Clear();
  2343.             oneModel = "";
  2344.         NewStart: //开始遍历匹配串
  2345.             if (oneModel.Length > 0)
  2346.             {
  2347.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  2348.             }
  2349.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  2350.             {
  2351.                 if (oneModels.Contains(de.Key) == false)
  2352.                 {
  2353.                     oneModels.Add(de.Key, "0");
  2354.                 }
  2355.             }
  2356.             newModels.Clear();
  2357.             foreach (System.Collections.DictionaryEntry de in oneModels)
  2358.             {
  2359.                 oneModel = de.Key.ToString();
  2360.                 if (oneModel.Length > 2)
  2361.                 {
  2362.                     int h = oneModel.Length;
  2363.                     while (true)
  2364.                     {
  2365.                         if (h < 3)         //最短字符不能小于5  >=四
  2366.                         { goto nextcmd2; }
  2367.                         int st = 0;
  2368.                         while (true)
  2369.                         {
  2370.                             if (st + h > oneModel.Length)
  2371.                             { goto nextcmd1; }
  2372.                             string a1 = oneModel.Substring(st, 1);
  2373.                             string a2 = oneModel.Substring(st + h - 1, 1);
  2374.                             if ((a1 != "<") | (a2 != ">"))   //判断是否合法 含有 <  >
  2375.                             {
  2376.                                 goto nextcmd3;
  2377.                             }
  2378.                             string onestr = oneModel.Substring(st, h);
  2379.                             if ((onestr.Substring(0, 1) != "<") | (onestr.Substring(onestr.Length - 1, 1) != ">") | (onestr.IndexOf(">") == -1) | (onestr.IndexOf("<") == -1))
  2380.                             {
  2381.                                 goto nextcmd3;         //取开头和末尾在<>中的数据
  2382.                             }
  2383.                             //遍历数据  是否符合全部数据
  2384.                             foreach (System.Collections.DictionaryEntry de1 in mHTMs)
  2385.                             {
  2386.                                 if ((de1.Value.ToString().IndexOf(onestr) == -1) & (de1.Value.ToString().Length > 0))
  2387.                                 {
  2388.                                     goto nextcmd3;
  2389.                                 }
  2390.                             }
  2391.                             //符合所有项都存在的条件 压入字典  
  2392.                             tdict.Add(tdictI, onestr);
  2393.                             //数据替换
  2394.                             Hashtable mtmpp = new Hashtable();
  2395.                             mtmpp.Clear();
  2396.                             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  2397.                             {
  2398.                                // mtmpp.Add(de2.Key, de2.Value.ToString().Replace(onestr, "*" + tdictI.ToString() + "*"));
  2399.                                 string tmp_str = de2.Value.ToString();
  2400.                                 if (tmp_str == null)
  2401.                                 {
  2402.                                 }
  2403.                                 else
  2404.                                 {
  2405.                                     mtmpp.Add(de2.Key, tmp_str.Replace(onestr, "*" + tdictI.ToString() + "*"));
  2406.                                 }
  2407.                             }
  2408.                             mHTMs = mtmpp;
  2409.                             tdictI = tdictI + 1;  //字典序号
  2410.                             //oneModel  截取   取出碎片 压入 newModels
  2411.                             string oneModelTmp = oneModel.Replace(onestr, "*");
  2412.                             string[] mykc = oneModelTmp.Split('*');
  2413.                             foreach (string ddee in mykc)
  2414.                             {
  2415.                                 if ((ddee.Length > 4) & (newModels.Contains(ddee) == false))
  2416.                                 {
  2417.                                     newModels.Add(ddee, "0");
  2418.                                 }
  2419.                             }
  2420.                             goto NewStart;             //因为碎片变化  所以重新开始扫描
  2421.                         nextcmd3:
  2422.                             st = st + 1;
  2423.                         }
  2424.                     nextcmd1:
  2425.                         h = h - 1;
  2426.                     }
  2427.                 }
  2428.             nextcmd2: ;
  2429.                 goto NewStart;  //本次遍历结束  去掉本字符串   
  2430.             }
  2431.             //mHTMs  处理新的 网页  只留下 *0*
  2432.             Hashtable mtmppC = new Hashtable();
  2433.             mtmppC.Clear();
  2434.             foreach (System.Collections.DictionaryEntry de2 in mHTMs)
  2435.             {
  2436.                 string cckc = de2.Value.ToString();
  2437.                 //把cckc中的*0*提取出来
  2438.                 mtmppC.Add(de2.Key, getXnX(de2.Value.ToString()));
  2439.                 // mtmppC.Add(de2.Key, de2.Value.ToString());
  2440.             }
  2441.             mHTMs = mtmppC;
  2442.             //从模板得到一个项目模板
  2443.            // string mmoo = aass29BuilderModel(mHTMs);
  2444.             string mmoo = GetComDataEND(mHTMs, tdict);
  2445.             if (mmoo.Length == 0)
  2446.             {
  2447.                 //从模板得到一个项目模板
  2448.                 mmoo = aass3BuilderModel(mHTMs);
  2449.             }
  2450.             mmoo = mmoo.Replace("<", "*");
  2451.             mmoo = mmoo.Replace(">", "*");
  2452.             if (mmoo.Length == 0)
  2453.             {
  2454.                 return "";
  2455.             }
  2456.             else
  2457.             {
  2458.                 foreach (System.Collections.DictionaryEntry dec in tdict)
  2459.                 {
  2460.                     mmoo = mmoo.Replace("*" + dec.Key.ToString() + "*", dec.Value.ToString());
  2461.                 }
  2462.                 return mmoo;
  2463.             }
  2464.         }
  2465.         ////////////////////////////////////////////////////////////////////////////////
  2466.         //29
  2467.         ////////////////////////////////////////////////////////////////////////////////
  2468.         /// <summary>
  2469.         /// 《29》根据子模板建立一个超级模板
  2470.         /// </summary>
  2471.         /// <param name="mHTMs"></param>
  2472.         /// <returns></returns>
  2473.         private string aass29BuilderModel(Hashtable mHTMs)
  2474.         {
  2475.             //得到最短的串
  2476.             string oneModel = "";
  2477.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  2478.             {
  2479.                 if (oneModel.Length == 0)
  2480.                 {
  2481.                     oneModel = de.Value.ToString();
  2482.                 }
  2483.                 else
  2484.                 {
  2485.                     if (oneModel.Length > de.Value.ToString().Length)
  2486.                     {
  2487.                         oneModel = de.Value.ToString();
  2488.                     }
  2489.                 }
  2490.             }
  2491.             foreach (System.Collections.DictionaryEntry de in mHTMs)
  2492.             {
  2493.                 if (oneModel != de.Value.ToString())                    //不相同
  2494.                 {
  2495.                     if (de.Value.ToString().IndexOf(oneModel) == -1)    //不包含
  2496.                     {
  2497.                         goto cXStart;
  2498.                     }
  2499.                 }
  2500.             }
  2501.             return oneModel;
  2502.         cXStart:
  2503.             //得到匹配临时模板的原始长度
  2504.             int onemLong = oneModel.Length;
  2505.             Hashtable tdict = new Hashtable();
  2506.             int tdictI = 0; //字典序号
  2507.             tdict.Clear();
  2508.             Hashtable oneModels = new Hashtable();
  2509.             oneModels.Clear();
  2510.             oneModels.Add(oneModel, "0");  //碎片如果相同 就不用继续寻找添加     
  2511.             //存放临时碎片
  2512.             Hashtable newModels = new Hashtable();
  2513.             newModels.Clear();
  2514.             oneModel = "";
  2515.         NewStart: //开始遍历匹配串
  2516.             if (oneModel.Length > 0)
  2517.             {
  2518.                 oneModels.Remove(oneModel);       //移除旧的字符串  压入分解后的字符串
  2519.             }
  2520.             foreach (System.Collections.DictionaryEntry de in newModels)    //加入新的碎片项
  2521.             {
  2522.                 if (oneModels.Contains(de.Key) == false)
  2523.                 {
  2524.                     oneModels.Add(de.Key, "0");
  2525.                 }
  2526.             }
  2527.             newModels.Clear();
  2528.             foreach (System.Collections.DictionaryEntry de in oneModels)
  2529.             {
  2530.                 oneModel = de.Key.ToString();
  2531.                 if (oneModel.Length > 2)
  2532.                 {
  2533.                     int h = oneModel.Length;
  2534.                     while (true)
  2535.                     {
  2536.                         if (h < 3)         //最短字符不能小于5  >=四
  2537.                         { goto nextcmd2; }
  2538.                         int st = 0;
  2539.                         while (true)
  2540.                         {
  2541.                             if (st + h > oneModel.Length)
  2542.                             { goto nextcmd1; }