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

搜索引擎

开发平台:

C#

  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Collections;
  6. /*
  7.       '       迅龙中文分类搜索引擎  v0.6
  8.       '
  9.       '        LGPL  许可发行
  10.       '
  11.       '       宁夏大学  张冬 康彩  zd4004@163.com
  12.       ' 
  13.       '        官网 http://blog.163.com/zd4004/
  14.  */
  15. namespace XunLong.CongifData
  16. {
  17.     /// <summary>
  18.     /// 节点_系统配置文件
  19.     /// </summary>
  20.     public static class Config
  21.     {
  22.         /// <summary>
  23.         /// 工作目录
  24.         /// </summary>
  25.         public static string Main_DIR = "";
  26.         /// <summary>
  27.         /// 索引文件存储地址D:\XunLong\XunLong.BIN\XLDICT\Index
  28.         /// </summary>
  29.         public static string  IndexData="";
  30.         /// <summary>
  31.         /// 索引文件存储地址D:\XunLong\XunLong.BIN\XLDICT\Index
  32.         /// </summary>
  33.         public static string IndexData2 = "";
  34.         /// <summary>
  35.         /// 监控频率 分钟
  36.         /// </summary>
  37.         public static int IndexDataTIME = 0;
  38.         /// <summary>
  39.         /// 已经获得的数据的url
  40.         /// </summary>
  41.         public static string Had_Url_Data = "";
  42.         /// <summary>
  43.         /// 蜘蛛数据存储D:\XunLong\XunLong.BIN\XLDICT\SpiderData
  44.         /// </summary>
  45.         public static string SpiderData = "";
  46.         /// <summary>
  47.         /// WebSiteD:\XunLong\XunLong.BIN\XLDICT\WebSite
  48.         /// </summary>
  49.         public static string WebSite = "";
  50.        
  51.         /// <summary>
  52.         /// 分词缓存地址D:\XunLong\XunLong.BIN\XLDICT\xWordData.XL
  53.         /// </summary>
  54.         public static string xWordCacheData = "";
  55.        
  56.         /// <summary>
  57.         /// 停止词地址D:\XunLong\XunLong.BIN\XLDICT\CnStopWord.XL
  58.         /// </summary>
  59.         public static string StopWordData = "";
  60.         
  61.         
  62.         /// <summary>
  63.         /// URL起始地址D:\XunLong\XunLong.BIN\XLDICT\urlsSource.dat
  64.         /// </summary>
  65.         public static string UrlSourceData = "";
  66.         
  67.         /// <summary>
  68.         /// URL缓存地址D:\XunLong\XunLong.BIN\XLDICT\urlsCache.dat
  69.         /// </summary>
  70.         public static string UrlCahceData = "";
  71.         /// <summary>
  72.         /// 分词缓存服务器邦定地址127.0.0.1
  73.         /// </summary>
  74.         public static string xWordCacheServer = "";
  75.         /// <summary>
  76.         /// 分词缓存服务器邦定端口 19830
  77.         /// </summary>
  78.         public static int xWordCacheServerPort =0;
  79.         /// <summary>
  80.         /// 分词服务器地址127.0.0.1
  81.         /// </summary>
  82.         public static string xWordServer = "";
  83.         // 
  84.         /// <summary>
  85.         /// 分词服务器端口范围起始 19800  + 9  --- 19809  19700  19600 19500 19400 19000  
  86.         /// </summary>
  87.         public static int  xWordServer_Port ;//= 19100 
  88.         /// <summary>
  89.         /// 需要建立模版的样例页面列表D:\XunLong\XunLong.BIN\XLDICT\modelSource.dat
  90.         /// </summary>
  91.         public static string modelSource = "";
  92.         /// <summary>
  93.         /// 需要建立模版的样例页面列表OLDD:\XunLong\XunLong.BIN\XLDICT\modelSourceOLD.dat
  94.         /// </summary>
  95.         public static string modelSourceOLD = "";
  96.         /// <summary>
  97.         /// 模版加载地址D:\XunLong\XunLong.BIN\XLDICT\Model
  98.         /// </summary>
  99.         public static string ModelData = "";
  100.         /// <summary>
  101.         /// New模版加载地址D:\XunLong\XunLong.BIN\XLDICT\NewModel
  102.         /// </summary>
  103.         public static string NewModelData = "";
  104.         /// 是否直接索引数据  不通过存储环节 (适合于在模版建立完成之后) 0 存储  1 不存储
  105.         public static string xlDirectIndex = "";
  106.         /// <summary>
  107.         /// 类聚文本
  108.         /// </summary>
  109.         public static string main_s_type =""; //Main_DIR文本文档.txt
  110.         /// <summary>
  111.         /// web服务器绑定端口800
  112.         /// </summary>
  113.         public static int WebPort = 0;
  114.         /// <summary>
  115.         /// web服务器绑定地址127.0.0.1
  116.         /// </summary>
  117.         public static string WebIP = "";
  118.          /// <summary>
  119.         /// 初始化配置数据  名称为 TuDou.kc 放在本地路径下 
  120.         /// </summary>
  121.         /// <param name="path"></param>
  122.         public static void InitConfigData(string sPath)
  123.         {
  124.             Hashtable c = new Hashtable();
  125.             StreamReader reader = null;
  126.             try
  127.             {
  128.                 reader = new StreamReader(sPath, System.Text.Encoding.GetEncoding("gb2312"));
  129.                 for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
  130.                 {
  131.                     if ((line.Length > 0) & (line.IndexOf('=') > 0))
  132.                     {
  133.                         string[] x = line.Split('=');
  134.                         if (x.Length == 2)
  135.                         {
  136.                             //先取出 Main_DIR
  137.                             string a_one = x[0].ToString().ToLower().Trim();
  138.                             a_one = a_one.Replace("t", "");
  139.                             a_one = a_one.Replace(" ", "");
  140.                             a_one = a_one.Replace("r", "");
  141.                             a_one = a_one.Replace("n", "");
  142.                             if (a_one == "main_dir")
  143.                             {
  144.                                 Main_DIR = x[1].ToString().Trim();
  145.                             }
  146.                             else
  147.                             {
  148.                                 c.Add(x[0], x[1]);
  149.                             }
  150.                             
  151.                         }
  152.                     }
  153.                 }
  154.                 reader.Close();
  155.             }
  156.             catch (IOException e)
  157.             {
  158.                 Console.WriteLine(e.Message);
  159.             }
  160.             finally
  161.             {
  162.                 if (reader != null)
  163.                     reader.Close();
  164.             }
  165.             foreach (DictionaryEntry a in c)
  166.             {
  167.                 string a_one = a.Key.ToString().ToLower().Trim();
  168.                 a_one =a_one.Replace("t","");
  169.                   a_one =a_one.Replace(" ","");
  170.                   a_one =a_one.Replace("r","");
  171.                   a_one =a_one.Replace("n","");
  172.                 // 索引文件存储地址
  173.                 //D:XunLongXunLong.BINXLDICTIndex
  174.                   if (a_one == "indexdata")
  175.                   {
  176.                     IndexData = a.Value.ToString().ToLower().Trim().Replace("main_dir",Main_DIR);
  177.                   }
  178.                   if (a_one == "indexdata2")
  179.                   {
  180.                       IndexData2 = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  181.                   }
  182.                  // 蜘蛛数据存储
  183.                  // D:XunLongXunLong.BINXLDICTWeb
  184.                 if (a_one == "spiderdata")
  185.                 {
  186.                     SpiderData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  187.                 }
  188.                 // WebSite
  189.                 // D:XunLongXunLong.BINXLDICTWebSite
  190.                 if (a_one == "website")
  191.                 {
  192.                     WebSite = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  193.                 }
  194.                 // 分词缓存地址
  195.                 // D:XunLongXunLong.BINXLDICTxWordData.XL
  196.                 if (a_one == "xwordcachedata")
  197.                 {
  198.                     xWordCacheData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  199.                 }
  200.                 // 停止词地址
  201.                 // D:XunLongXunLong.BINXLDICTCnStopWord.XL
  202.                 if (a_one == "stopworddata")
  203.                 {
  204.                     StopWordData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  205.                 }
  206.                 // URL起始地址
  207.                 // D:XunLongXunLong.BINXLDICTurlsSource.dat
  208.                 if (a_one == "urlsourcedata")
  209.                 {
  210.                     UrlSourceData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  211.                 }
  212.                 // URL缓存地址
  213.                 // D:XunLongXunLong.BINXLDICTurlsCache.dat
  214.                 if (a_one == "urlcahcedata")
  215.                 {
  216.                     UrlCahceData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  217.                 }
  218.                 // 分词缓存服务器邦定地址
  219.                 // 127.0.0.1
  220.                 if (a_one == "xwordcacheserver")
  221.                 {
  222.                     xWordCacheServer = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  223.                 }
  224.                 // 分词缓存服务器邦定端口
  225.                 // 19830
  226.                 if (a_one == "xwordcacheserverport")
  227.                 {
  228.                     xWordCacheServerPort  = Int32.Parse(a.Value.ToString().Trim());
  229.                 }
  230.                 // 分词服务器地址
  231.                 // 127.0.0.1
  232.                 if (a_one == "xwordserver")
  233.                 {
  234.                     xWordServer = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  235.                 }
  236.                 /// 分词服务器端口范围起始 19800  + 9  --- 19809  19700  19600 19500 19400 19000  
  237.                 if (a_one == "xwordserver_port")
  238.                 {
  239.                     xWordServer_Port = Int32.Parse(a.Value.ToString().Trim());
  240.                 }
  241.                 /// 监控频率 分钟
  242.                 if (a_one == "indexdatatime")
  243.                 {
  244.                     IndexDataTIME = Int32.Parse(a.Value.ToString().Trim());
  245.                 }
  246.                 // 模版加载地址
  247.                 // D:XunLongXunLong.BINXLDICTModel
  248.                 if (a_one == "modeldata")
  249.                 {
  250.                     ModelData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  251.                 }
  252.                 // New模版加载地址
  253.                 // D:XunLongXunLong.BINXLDICTNewModel
  254.                 if (a_one == "newmodeldata")
  255.                 {
  256.                     NewModelData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  257.                 }
  258.                 ///// 已经获得的数据的url
  259.                 //Had_Url_Data = Main_DIRdaturls_had.dat
  260.                 if (a_one == "had_url_data")
  261.                 {
  262.                     Had_Url_Data = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  263.                 }
  264.                 // 需要建立模版的样例页面列表
  265.                 //modelSource = D:XunLongXunLong.BINXLDICTmodelSource.dat
  266.                 if (a_one == "modelsource")
  267.                 {
  268.                     modelSource = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  269.                 }
  270.                 // 需要建立模版的样例页面列表OLD
  271.                 // = D:XunLongXunLong.BINXLDICTmodelSourceOLD.dat
  272.                 if (a_one == "modelsourceold")
  273.                 {
  274.                     modelSourceOLD = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  275.                 }
  276.                 ///// 是否直接索引数据  不通过存储环节 (适合于在模版建立完成之后) 0 存储  1 不存储
  277.                 if (a_one == "xldirectindex")
  278.                 {
  279.                     xlDirectIndex = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  280.                 }
  281.                 ///web服务器绑定地址
  282.                 if (a_one == "webip")
  283.                 {
  284.                     WebIP = a.Value.ToString().Trim();
  285.                 }
  286.                 /// web服务器绑定端口
  287.                 if (a_one == "webport")
  288.                 {
  289.                     WebPort = Int32.Parse(a.Value.ToString().Trim());
  290.                 }
  291.                 // WebSite
  292.                 // D:XunLongXunLong.BINXLDICTWebSite
  293.                 if (a_one == "website")
  294.                 {
  295.                     WebSite = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  296.                 }
  297.                 //类聚文本
  298.                 //main_s_type = Main_DIR文本文档.txt
  299.                 if (a_one == "main_s_type")
  300.                 {
  301.                     main_s_type = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
  302.                 }
  303.             }
  304.         }
  305.     }
  306. }