Config.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:12k
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Text;
- using System.Collections;
- /*
- ' 迅龙中文分类搜索引擎 v0.6
- '
- ' LGPL 许可发行
- '
- ' 宁夏大学 张冬 康彩 zd4004@163.com
- '
- ' 官网 http://blog.163.com/zd4004/
- */
- namespace XunLong.CongifData
- {
- /// <summary>
- /// 节点_系统配置文件
- /// </summary>
- public static class Config
- {
- /// <summary>
- /// 工作目录
- /// </summary>
- public static string Main_DIR = "";
- /// <summary>
- /// 索引文件存储地址D:\XunLong\XunLong.BIN\XLDICT\Index
- /// </summary>
- public static string IndexData="";
- /// <summary>
- /// 索引文件存储地址D:\XunLong\XunLong.BIN\XLDICT\Index
- /// </summary>
- public static string IndexData2 = "";
- /// <summary>
- /// 监控频率 分钟
- /// </summary>
- public static int IndexDataTIME = 0;
- /// <summary>
- /// 已经获得的数据的url
- /// </summary>
- public static string Had_Url_Data = "";
- /// <summary>
- /// 蜘蛛数据存储D:\XunLong\XunLong.BIN\XLDICT\SpiderData
- /// </summary>
- public static string SpiderData = "";
- /// <summary>
- /// WebSiteD:\XunLong\XunLong.BIN\XLDICT\WebSite
- /// </summary>
- public static string WebSite = "";
-
- /// <summary>
- /// 分词缓存地址D:\XunLong\XunLong.BIN\XLDICT\xWordData.XL
- /// </summary>
- public static string xWordCacheData = "";
-
- /// <summary>
- /// 停止词地址D:\XunLong\XunLong.BIN\XLDICT\CnStopWord.XL
- /// </summary>
- public static string StopWordData = "";
-
-
- /// <summary>
- /// URL起始地址D:\XunLong\XunLong.BIN\XLDICT\urlsSource.dat
- /// </summary>
- public static string UrlSourceData = "";
-
- /// <summary>
- /// URL缓存地址D:\XunLong\XunLong.BIN\XLDICT\urlsCache.dat
- /// </summary>
- public static string UrlCahceData = "";
- /// <summary>
- /// 分词缓存服务器邦定地址127.0.0.1
- /// </summary>
- public static string xWordCacheServer = "";
- /// <summary>
- /// 分词缓存服务器邦定端口 19830
- /// </summary>
- public static int xWordCacheServerPort =0;
- /// <summary>
- /// 分词服务器地址127.0.0.1
- /// </summary>
- public static string xWordServer = "";
- //
- /// <summary>
- /// 分词服务器端口范围起始 19800 + 9 --- 19809 19700 19600 19500 19400 19000
- /// </summary>
- public static int xWordServer_Port ;//= 19100
- /// <summary>
- /// 需要建立模版的样例页面列表D:\XunLong\XunLong.BIN\XLDICT\modelSource.dat
- /// </summary>
- public static string modelSource = "";
- /// <summary>
- /// 需要建立模版的样例页面列表OLDD:\XunLong\XunLong.BIN\XLDICT\modelSourceOLD.dat
- /// </summary>
- public static string modelSourceOLD = "";
- /// <summary>
- /// 模版加载地址D:\XunLong\XunLong.BIN\XLDICT\Model
- /// </summary>
- public static string ModelData = "";
- /// <summary>
- /// New模版加载地址D:\XunLong\XunLong.BIN\XLDICT\NewModel
- /// </summary>
- public static string NewModelData = "";
- /// 是否直接索引数据 不通过存储环节 (适合于在模版建立完成之后) 0 存储 1 不存储
- public static string xlDirectIndex = "";
- /// <summary>
- /// 类聚文本
- /// </summary>
- public static string main_s_type =""; //Main_DIR文本文档.txt
- /// <summary>
- /// web服务器绑定端口800
- /// </summary>
- public static int WebPort = 0;
- /// <summary>
- /// web服务器绑定地址127.0.0.1
- /// </summary>
- public static string WebIP = "";
- /// <summary>
- /// 初始化配置数据 名称为 TuDou.kc 放在本地路径下
- /// </summary>
- /// <param name="path"></param>
- public static void InitConfigData(string sPath)
- {
- Hashtable c = new Hashtable();
- StreamReader reader = null;
- try
- {
- reader = new StreamReader(sPath, System.Text.Encoding.GetEncoding("gb2312"));
- for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
- {
- if ((line.Length > 0) & (line.IndexOf('=') > 0))
- {
- string[] x = line.Split('=');
- if (x.Length == 2)
- {
- //先取出 Main_DIR
- string a_one = x[0].ToString().ToLower().Trim();
- a_one = a_one.Replace("t", "");
- a_one = a_one.Replace(" ", "");
- a_one = a_one.Replace("r", "");
- a_one = a_one.Replace("n", "");
- if (a_one == "main_dir")
- {
- Main_DIR = x[1].ToString().Trim();
- }
- else
- {
- c.Add(x[0], x[1]);
- }
-
- }
- }
- }
- reader.Close();
- }
- catch (IOException e)
- {
- Console.WriteLine(e.Message);
- }
- finally
- {
- if (reader != null)
- reader.Close();
- }
- foreach (DictionaryEntry a in c)
- {
- string a_one = a.Key.ToString().ToLower().Trim();
- a_one =a_one.Replace("t","");
- a_one =a_one.Replace(" ","");
- a_one =a_one.Replace("r","");
- a_one =a_one.Replace("n","");
- // 索引文件存储地址
- //D:XunLongXunLong.BINXLDICTIndex
- if (a_one == "indexdata")
- {
- IndexData = a.Value.ToString().ToLower().Trim().Replace("main_dir",Main_DIR);
- }
- if (a_one == "indexdata2")
- {
- IndexData2 = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 蜘蛛数据存储
- // D:XunLongXunLong.BINXLDICTWeb
- if (a_one == "spiderdata")
- {
- SpiderData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // WebSite
- // D:XunLongXunLong.BINXLDICTWebSite
- if (a_one == "website")
- {
- WebSite = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 分词缓存地址
- // D:XunLongXunLong.BINXLDICTxWordData.XL
- if (a_one == "xwordcachedata")
- {
- xWordCacheData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 停止词地址
- // D:XunLongXunLong.BINXLDICTCnStopWord.XL
- if (a_one == "stopworddata")
- {
- StopWordData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // URL起始地址
- // D:XunLongXunLong.BINXLDICTurlsSource.dat
- if (a_one == "urlsourcedata")
- {
- UrlSourceData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // URL缓存地址
- // D:XunLongXunLong.BINXLDICTurlsCache.dat
- if (a_one == "urlcahcedata")
- {
- UrlCahceData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 分词缓存服务器邦定地址
- // 127.0.0.1
- if (a_one == "xwordcacheserver")
- {
- xWordCacheServer = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 分词缓存服务器邦定端口
- // 19830
- if (a_one == "xwordcacheserverport")
- {
- xWordCacheServerPort = Int32.Parse(a.Value.ToString().Trim());
- }
- // 分词服务器地址
- // 127.0.0.1
- if (a_one == "xwordserver")
- {
- xWordServer = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- /// 分词服务器端口范围起始 19800 + 9 --- 19809 19700 19600 19500 19400 19000
- if (a_one == "xwordserver_port")
- {
- xWordServer_Port = Int32.Parse(a.Value.ToString().Trim());
- }
- /// 监控频率 分钟
- if (a_one == "indexdatatime")
- {
- IndexDataTIME = Int32.Parse(a.Value.ToString().Trim());
- }
- // 模版加载地址
- // D:XunLongXunLong.BINXLDICTModel
- if (a_one == "modeldata")
- {
- ModelData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // New模版加载地址
- // D:XunLongXunLong.BINXLDICTNewModel
- if (a_one == "newmodeldata")
- {
- NewModelData = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- ///// 已经获得的数据的url
- //Had_Url_Data = Main_DIRdaturls_had.dat
- if (a_one == "had_url_data")
- {
- Had_Url_Data = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 需要建立模版的样例页面列表
- //modelSource = D:XunLongXunLong.BINXLDICTmodelSource.dat
- if (a_one == "modelsource")
- {
- modelSource = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- // 需要建立模版的样例页面列表OLD
- // = D:XunLongXunLong.BINXLDICTmodelSourceOLD.dat
- if (a_one == "modelsourceold")
- {
- modelSourceOLD = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- ///// 是否直接索引数据 不通过存储环节 (适合于在模版建立完成之后) 0 存储 1 不存储
- if (a_one == "xldirectindex")
- {
- xlDirectIndex = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- ///web服务器绑定地址
- if (a_one == "webip")
- {
- WebIP = a.Value.ToString().Trim();
- }
- /// web服务器绑定端口
- if (a_one == "webport")
- {
- WebPort = Int32.Parse(a.Value.ToString().Trim());
- }
- // WebSite
- // D:XunLongXunLong.BINXLDICTWebSite
- if (a_one == "website")
- {
- WebSite = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- //类聚文本
- //main_s_type = Main_DIR文本文档.txt
- if (a_one == "main_s_type")
- {
- main_s_type = a.Value.ToString().ToLower().Trim().Replace("main_dir", Main_DIR);
- }
- }
- }
- }
- }