Example #1
0
 public FileMeerySearch(int id, string Ip, string Port, SearchDbType type)
 {
     _id = id;
     _Ip = Ip;
     _Port = Port;
     _Type = type;
     Ini();
 }
Example #2
0
 public FileSearchPool(int min, int max, int growth, string ip, string port, int waitsecond, SearchDbType type)
 {
     IP = ip;
     Port = port;
     _Min = min;
     _Max = max;
     _Growth = growth;
     _type = type;
     this.WaitSecond = waitsecond;
     Ini();
 }
Example #3
0
 // ConfigurationManager.AppSettings["DY_CnpFileBasePath"]
 /// <summary>
 /// 将号单转成cnp文件
 /// </summary>
 /// <param name="strTxt">txt文件路径</param>
 /// <param name="UName">用户ID</param>
 /// <param name="strSno">检索编号</param>
 /// <param name="SearchDbType">数据源:Cn/DocDB</param>
 /// <returns></returns>
 public ResultInfo ImportLis2tResult( string strTxt, int UName,string strSno, SearchDbType SearchDbType )
 {
     if ( Enum.GetName (typeof (SearchDbType), SearchDbType).ToUpper () == "CN" )
     {
         return ImportLis2tResult_CN (strTxt, UName, strSno,SearchDbType);
     }
     else
     {
         return ImportLis2tResult_DocDB (strTxt, UName, strSno, SearchDbType);
     }
 }
Example #4
0
        public ResultInfoWebService Search(string strPattern, int UserID, int nSNo, SearchDbType _SDbType)
        {
            SearchPattern schPatItem = new Cpic.Cprs2010.Search.SearchPattern();

            schPatItem.SearchNo = nSNo.ToString().PadLeft(3, '0');  //检索编号
            schPatItem.Pattern = strPattern;      //检索式:F XX 2010/AD
            schPatItem.UserId = UserID;   //用户ID
            schPatItem.DbType = _SDbType;

            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
            ResultInfo res = search.DoSearch(SearchInterface.XmPatentComm.strWebSearchGroupName, strPattern, Convert.ToInt32(UserID), schPatItem.SearchNo, _SDbType);

            // Cpic.Cprs2010.Search.ResultInfo res = Cpic.Cprs2010.Search.SearchManager.SearchFactory.CreatDoSearch(schPatItem);

            ResultInfoWebService resultInfoWebService = new ResultInfoWebService();
            resultInfoWebService.ResultInfo = res;

            ResultServices result = new ResultServices();
            string resultFilePath = result.getResultFilePath(schPatItem);
            resultInfoWebService.ResultSearchFilePath = resultFilePath;

            return resultInfoWebService;
        }
Example #5
0
 /// <summary>
 /// 得到用户的检索历史文件路径
 /// </summary>
 public string getSearchHisPath(SearchDbType DBType)
 {
     string hisFilePath = UserPath + "\\" + DBType;
     string hisFile = hisFilePath + "\\SearchHistory.lst";
     string SearchHis = "";
     if (File.Exists(hisFile))
     {
         SearchHis = hisFile;
     }
     return SearchHis;
 }
Example #6
0
        /// <summary>
        /// 得到用户的检索历史List
        /// </summary>
        public System.Collections.Generic.List<string> getSearchHis(SearchDbType DBType)
        {
            string hisFilePath = UserPath + "\\" + DBType;
            string hisFile = hisFilePath + "\\SearchHistory.lst";
            List<string> SearchHis = new List<string>();
            if (File.Exists(hisFile))
            {

                //创建流
                using (StreamReader sr = new StreamReader(new FileStream(hisFile, FileMode.Open)))
                {
                    while (!sr.EndOfStream)
                    {
                        SearchHis.Add(sr.ReadLine());
                    }
                }
            }
            return SearchHis;
        }
Example #7
0
 /// <summary>
 /// 清除用户检索历史
 /// </summary>
 public bool clearSearchHis(SearchDbType DBType)
 {
     return UserManager.clearSearchHis(ID, DBType) && UserManager.clearSearchHisData(ID, DBType);
 }
Example #8
0
        /// <summary>
        /// 导入世界专利号单,生成cnp文件
        /// </summary>
        /// <param name="strTxt">号单文件路径</param>
        /// <param name="UName">用户ID</param>
        /// <param name="strSearchNo">检索编号</param>
        /// <param name="SearchDbType">数据源: Cn/DocDB</param>
        /// <returns></returns>
        private ResultInfo ImportLis2tResult_DocDB( string strTxt, int UName,string strSearchNo, SearchDbType SearchDbType )
        {
            Cpic.Cprs2010.Search.ResultInfo res = new ResultInfo ();

            if ( !File.Exists (strTxt) )
            {
                return res;
            }

            #region 生成cnp目录

            string ConfigCC = ConfigurationManager.AppSettings["CnpCC"].ToString ();
            string ConfigCCCount = ConfigurationManager.AppSettings["CnpCCCount"].ToString ();
            AryCC = ConfigCC.Split ('|');
            AryCnpCount =  ConfigCCCount.Split ('|');
            //Dictionary<string, string> dict = new Dictionary<string, string> ();

            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch ();
            //ResultInfo res = search.DoSearch ("", Convert.ToInt32 (UName), SearchDbType);
            string SearchNo = strSearchNo;// res.SearchPattern.SearchNo.ToString ();
            string strPath = CprsConfig.GetUserPath (Convert.ToInt32 (UName),XmPatentComm.strWebSearchGroupName);

            if ( !strPath.EndsWith (@"\") )
            {
                strPath += @"\";
            }

            cnpPath = strPath + Enum.GetName (typeof (SearchDbType), SearchDbType).ToUpper () + @"\" + "Set" + SearchNo + @"\";

            foreach ( string s in AryCC )
            {
                cnpFilePathDocDB = cnpPath + s + @"\";

                if ( !System.IO.Directory.Exists (cnpFilePathDocDB) )
                {
                    System.IO.Directory.CreateDirectory (cnpFilePathDocDB);
                }
            }

            #endregion

            #region 生成cnp空文件

            for ( int i = 0; i < AryCC.Length; i++ )
            {
                int CnpCountCC = Convert.ToInt16 (AryCnpCount[i]);
                for ( int j = 1; j <= CnpCountCC; j++ )
                {
                    string strCnpName = "00000" + Convert.ToString (j);
                    strCnpName = strCnpName.Substring (strCnpName.Length - 5, 5) + ".CNP";

                    strCnpName = cnpPath + AryCC[i] + @"\" + strCnpName;

                    //if ( !File.Exists (strCnpName) )
                    //{
                    //    File.Create (strCnpName).Close (); ;
                    //}

                    if ( File.Exists (strCnpName) )
                    {
                        File.Delete (strCnpName);
                    }

                    File.Create (strCnpName).Close ();
                }
            }

            #endregion

            #region 从文本中读号单在数据库中查询
            List<string> txtlist = new List<string> ();//文本中号单
            //{ "CH", "CN", "DE", "EP", "FR", "GB", "JP", "KR", "OT", "RU", "US","WO" };
            List<int> hitlistCH = new List<int> ();//命中号单
            List<int> hitlistCN = new List<int> ();//命中号单
            List<int> hitlistDE = new List<int> ();//命中号单
            List<int> hitlistEP = new List<int> ();//命中号单
            List<int> hitlistFR = new List<int> ();//命中号单
            List<int> hitlistGB = new List<int> ();//命中号单
            List<int> hitlistJP = new List<int> ();//命中号单
            List<int> hitlistKR = new List<int> ();//命中号单
            List<int> hitlistOT = new List<int> ();//命中号单
            List<int> hitlistRU = new List<int> ();//命中号单
            List<int> hitlistUS = new List<int> ();//命中号单
            List<int> hitlistWO = new List<int> ();//命中号单
            txtlist = ReadText2List (strTxt);
            txtlist.Sort ();
            int hitCount = 0;
            foreach ( var x in txtlist )
            {
                string PubNo = FormatPubNo (x);
                string txtCC = x.Substring (0, 2).ToString ();
                string strSQLCC = "";
                if ( Array.IndexOf (AryCC, txtCC) >= 0 )//在国家数组里存在
                {
                    strSQLCC = "[DataInfo].[dbo].[DocdbDocInfo_" + txtCC + "]";
                }
                else
                {
                    strSQLCC = "[DataInfo].[dbo].[DocdbDocInfo_OT]";
                }

                DataTable dt = new DataTable ();
                string SQL = "select ID  sid from " + strSQLCC + "  where docid =(select id from [DataInfo].[dbo].[DocdbDocInfo] where PubID=@PubID )";

                SqlParameter[] parms =
                    new SqlParameter[1] { new System.Data.SqlClient.SqlParameter ("@PubID", SqlDbType.NVarChar, 16) };
                parms[0].Value = PubNo.Trim ();
                dt = SqlDbAccess.GetDataTable (CommandType.Text, SQL, parms);
                if ( dt == null || dt.Rows.Count == 0 )
                {
                    //记录日志
                    string cnpPath1 = strPath + Enum.GetName (typeof (SearchDbType), SearchDbType).ToUpper () + @"\";
                    WriteLog (cnpPath1 + SearchNo + "_no.txt", x);
                }
                else
                {
                    int it = Convert.ToInt32 (dt.Rows[0][0].ToString ());

                    //{ "CH", "CN", "DE", "EP", "FR", "GB", "JP", "KR", "OT", "RU", "US","WO" };
                    //保存数组
                    switch ( txtCC )
                    {
                        case "CH":
                            hitlistCH.Add (it);
                            break;
                        case "CN":
                            hitlistCN.Add (it);
                            break;
                        case "DE":
                            hitlistDE.Add (it);
                            break;
                        case "EP":
                            hitlistEP.Add (it);
                            break;
                        case "FR":
                            hitlistFR.Add (it);
                            break;
                        case "GB":
                            hitlistGB.Add (it);
                            break;
                        case "JP":
                            hitlistJP.Add (it);
                            break;
                        case "KR":
                            hitlistKR.Add (it);
                            break;
                        case "RU":
                            hitlistRU.Add (it);
                            break;
                        case "US":
                            hitlistUS.Add (it);
                            break;
                        case "WO":
                            hitlistWO.Add (it);
                            break;
                        default:
                            hitlistOT.Add (it);
                            break;
                    }
                    hitCount++;

                }

            }

            //hitlistCH.Add (500003);
            //hitlistCH.Add (300003);
            //hitlistCH.Add (700003);

            //hitlistEP.Add (4000334);
            //hitlistEP.Add (4000834);
            //hitlistEP.Add (4000134);
            //hitlistEP.Add (40134);

            //hitlistWO.Add (1000003);
            //hitlistWO.Add (200003);
            //hitlistWO.Add (100003);
            //hitlistWO.Add (1000018);
            //hitlistWO.Add (1000020);

            hitlistCH.Sort ();
            hitlistCN.Sort ();
            hitlistDE.Sort ();
            hitlistEP.Sort ();
            hitlistFR.Sort ();
            hitlistGB.Sort ();
            hitlistJP.Sort ();
            hitlistKR.Sort ();
            hitlistOT.Sort ();
            hitlistUS.Sort ();
            hitlistWO.Sort ();
            hitlistRU.Sort ();

            #endregion

            #region 保存为cnp文件

            //{ "CH", "CN", "DE", "EP", "FR", "GB", "JP", "KR", "OT", "RU", "US","WO" };
            Save2Cnp (hitlistCH,"CH");
            Save2Cnp (hitlistCN, "CN");
            Save2Cnp (hitlistDE, "DE");
            Save2Cnp (hitlistEP, "EP");
            Save2Cnp (hitlistFR, "FR");
            Save2Cnp (hitlistGB, "GB");
            Save2Cnp (hitlistJP, "JP");
            Save2Cnp (hitlistKR, "KR");
            Save2Cnp (hitlistOT, "OT");
            Save2Cnp (hitlistRU, "RU");
            Save2Cnp (hitlistUS, "US");
            Save2Cnp (hitlistWO, "WO");

            #endregion

            int i1 = strTxt.LastIndexOf (@"\");
            int i2 = strTxt.LastIndexOf (@"/");
            string strTxtName = "";
            if ( i1 >= 0 )
            {
                strTxtName = strTxt.Substring (i1+1);
            }
            if ( i2 >= 0 )
            {
                strTxtName = strTxt.Substring (i2 + 1);
            }
            Cpic.Cprs2010.Search.SearchPattern schPatItem = new Cpic.Cprs2010.Search.SearchPattern ();

            schPatItem.SearchNo = strSearchNo.PadLeft (3, '0');  //检索编号[001-999]
            schPatItem.Pattern = strTxtName;      //检索式:txt文件名
            schPatItem.UserId = UName;   //用户ID
            schPatItem.DbType = SearchDbType;

            res.SearchPattern = schPatItem;
            res.HitMsg = string.Format("({0})F XX {1} <hits:{2}>", schPatItem.SearchNo, strTxtName, hitCount);
            res.HitCount = hitCount;

            return res;
        }
Example #9
0
        /// <summary>
        /// 导入中文号单,生成cnp文件
        /// </summary>
        /// <param name="strTxt">文件路径</param>
        /// <param name="UName">用户名</param>
        /// <param name="strSearchNo">检索编号</param>
        /// <param name="SearchDbType">数据源 CN/DocDB</param>
        /// <returns></returns>
        private ResultInfo ImportLis2tResult_CN( string strTxt, int UName,string strSearchNo, SearchDbType SearchDbType )
        {
            Cpic.Cprs2010.Search.ResultInfo res = new ResultInfo ();

            if ( !File.Exists (strTxt) )
            {
                return res;
            }

            #region 生成cnp的目录

            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch ();

            string SearchNo = strSearchNo;//136
            //\\192.168.131.10\VPath\User_Search_Base\1\000\066
            //\\192.168.131.10\VPath\User_Search_Base\1\000\066\CN\Set136\

            string strPath = CprsConfig.GetUserPath (Convert.ToInt32 (UName),XmPatentComm.strWebSearchGroupName);

            if ( !strPath.EndsWith (@"\") )
            {
                strPath += @"\";
            }

            cnpPath = strPath + Enum.GetName (typeof (SearchDbType), SearchDbType).ToUpper () + @"\" + "Set" + SearchNo + @"\";

            if ( !System.IO.Directory.Exists (cnpPath) )
            {
                System.IO.Directory.CreateDirectory (cnpPath);
            }

            #endregion

            #region 从文本中读号单在数据库中查询

            string SQL = "";
            List<string> txtlist = new List<string> ();//文本中号单
            List<int> hitlist = new List<int> ();//命中号单
            txtlist = ReadText2List (strTxt);
            txtlist.Sort ();
            int hitCount=0;
            foreach ( var x in txtlist )
            {
                string apno = FormatApno (x);//去掉校验位和CN
                DataTable dt = new DataTable ();
                SQL = "select SerialNo from [DataInfo].[dbo].[CnGeneral_Info] where ApNo=@ApNo";

                SqlParameter[] parms =
                    new SqlParameter[1] { new System.Data.SqlClient.SqlParameter ("@ApNo", SqlDbType.NVarChar, 16) };
                parms[0].Value = apno.Trim ();
                dt = SqlDbAccess.GetDataTable (CommandType.Text, SQL, parms);
                if ( dt == null || dt.Rows.Count == 0 )
                {
                    //记录日志
                    string cnpPath1 = strPath + Enum.GetName (typeof (SearchDbType), SearchDbType).ToUpper () + @"\";
                    WriteLog (cnpPath1 + SearchNo + "_no.txt", x);
                }
                else
                {
                    //保存数组
                    hitlist.Add (Convert.ToInt32 (dt.Rows[0]["SerialNo"].ToString ()));
                    hitCount++;

                }
            }

            #endregion

            #region 生成空cnp文件

            if ( hitlist.Count > 0 )
            {
                for ( int i = 1; i <= CnpCountCN; i++ )
                {
                    string strCnpName = "00000" + Convert.ToString (i);
                    strCnpName = strCnpName.Substring (strCnpName.Length - 5, 5) + ".CNP";

                    strCnpName = cnpPath + strCnpName;
                    if ( File.Exists (strCnpName) )
                    {
                        File.Delete (strCnpName);
                    }

                    File.Create (strCnpName).Close ();

                }
                hitlist.Sort ();
            }

            #endregion

            #region 保存为cnp文件

            int cnp1 = 0;

            List<int> cnplist = new List<int> ();
            int j = 0;
            cnp1 = hitlist[0] / 500000 + 1;

            foreach ( var y in hitlist )
            {
                int cnp = y / 500000 + 1;

                if ( j == 0 )
                {
                    cnplist.Add (Convert.ToInt32 (y));
                }
                else
                {
                    if ( cnp != cnp1 )//下一个cnp文件
                    {
                        InsertCNP (cnp1, cnplist);
                        cnplist.Clear ();
                        cnp1 = cnp;
                        cnplist.Add (y);
                        continue;

                    }

                    cnplist.Add (y);
                    cnp1 = cnp;
                }

                j++;
            }

            InsertCNP (cnp1, cnplist);

            #endregion

            #region 返回的参数

            int i1 = strTxt.LastIndexOf (@"\");
            int i2 = strTxt.LastIndexOf (@"/");
            string strTxtName = "";
            if ( i1 >= 0 )
            {
                strTxtName = strTxt.Substring (i1 + 1);
            }
            if ( i2 >= 0 )
            {
                strTxtName = strTxt.Substring (i2 + 1);
            }

            Cpic.Cprs2010.Search.SearchPattern schPatItem = new Cpic.Cprs2010.Search.SearchPattern ();

            schPatItem.SearchNo = strSearchNo.PadLeft (3, '0');  //检索编号[001-999]
            schPatItem.Pattern = strTxtName;      //检索式:txt文件名
            schPatItem.UserId = UName;   //用户ID
            schPatItem.DbType = SearchDbType;

            res.SearchPattern = schPatItem;
            res.HitMsg = string.Format("({0})F XX {1} <hits:{2}>",schPatItem.SearchNo,strTxtName,hitCount);
            res.HitCount = hitCount;

            #endregion
            return res;
        }
Example #10
0
        /// <summary>
        /// Finder初始化
        /// </summary>
        /// <returns></returns>
        public bool Ini()
        {
            //IndexDirectory = Path.GetDirectoryName(ConfigFilePath) + "\\" + reginfo.VYear + "\\" + Lib.reginfo.UserSelected;

            _Indexs = new Dictionary<string, List<FileIndex>>();
            _Config = new DataInterfaceConfig(ConfigFilePath);
            Type = _Config.Type;
            List<Key> lstKey = Config.GetSearchEnterKey();

            //1.得到所有的索引分段文件夹
            foreach (Key key in lstKey)
            {
                //得到所有的文件
                List<string> indexfiles = Directory.GetFiles(IndexDirectory, key.Name + ".eee", SearchOption.AllDirectories).ToList<string>();
                indexfiles.Sort();
                List<FileIndex> lstIndex = new List<FileIndex>();
                foreach (string indexfile in indexfiles)
                {

                    //实例化索引
                    FileIndex ix = new FileIndex(indexfile, key);
                    //添加到集合里
                    lstIndex.Add(ix);
                }
                //添加到字典中
                _Indexs.Add(key.Name, lstIndex);

            }
            return true;
        }