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

搜索引擎

开发平台:

C#

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