/// <summary> /// 得到某一结果文件的全部数据 /// </summary> /// <param name="sp">检索式</param> /// <param name="SortExpression">排序</param> /// <returns>list int</returns> public IEnumerable GetResultList(SearchPattern sp, string SortExpression) { ResultServices res = new ResultServices(); List<int> lstNo = res.GetResultList(sp, SortExpression); IEnumerable ien = GetResult(lstNo); return ien; }
protected void Button1_Click(object sender, EventArgs e) { //检索式 SearchPattern sp = new SearchPattern(); sp.Pattern = txtSearchPattern.Text.Trim(); sp.DbType = (SearchDbType)Enum.Parse(typeof(SearchDbType), ddlDBType.SelectedValue.Trim()); sp.SearchNo = "001"; //用户 Cpic.Cprs2010.User.User user; // 判断用户是否登录 if (Session["UserInfo"] == null) { //user = UserManager.getGuestUser(Session.SessionID); //Session["UserInfo"] = user; } else { //user = (Cpic.Cprs2010.User.User)Session["UserInfo"]; } sp.UserId = Convert.ToInt32(Session["UserID"]); // user.ID; //user.addSearchHis(sp); //得到检索连接 ISearch mySearch; mySearch = SearchFactory.CreatSearch(sp.DbType); if (mySearch == null) { this.lblmessage.Text = "已超最大连接!请等待!"; } else { ResultInfo rs = mySearch.Search(sp); this.lblmessage.Text = Server.HtmlEncode(rs.HitMsg) + "<br/>"; SearchFactory.FreeSearch(mySearch); } }
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; }
/// <summary> /// 得到某一结果文件的全部数据 /// </summary> /// <param name="sp">检索式</param> /// <param name="SortExpression">排序</param> /// <returns>list int</returns> public IEnumerable GetResultList(SearchPattern sp, string SortExpression) { ResultDataManagerDataContext db = new ResultDataManagerDataContext(); Table<DocdbFamilyInfo> tbCnDocInfo = db.DocdbFamilyInfo; ResultServices res = new ResultServices(); List<int> lstNo = res.GetResultList(sp, SortExpression); var result = from item in tbCnDocInfo where lstNo.Contains(Convert.ToInt32(item.CPIC)) select new { TI = item.Title, AN = item.AppNo, AD = item.AppDate, IPC = item.IPC, }; //paging... (LINQ) //IEnumerable ien = result.Skip((PageNumber - 1) * PageSize).Take(PageSize); IEnumerable ien = result.DefaultIfEmpty(); return ien; }
/// <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; }
/// <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; }
/// <summary> /// 得到某一结果文件的某一页数据 并按某一字段排序 /// </summary> /// <param name="sp">检索式</param> /// <param name="PageIndex">要取的页数</param> /// <param name="PageSize">页数大小</param> /// <param name="SortExpression">排序字段</param> /// <returns>list(int)</int></returns> public IEnumerable GetResultList(SearchPattern sp, int PageSize, int PageIndex, string SortExpression) { try { ResultDataManagerDataContext db = new ResultDataManagerDataContext(); Table<DwpiAccessionNoSerialNo> tbCnDocInfo = db.DwpiAccessionNoSerialNo; ResultServices res = new ResultServices(); List<int> lstNo = res.GetResultListByEnd(sp, PageSize, PageIndex, SortExpression); var result = from item in tbCnDocInfo where lstNo.Contains(Convert.ToInt32(item.SerialNo)) orderby item.SerialNo descending select new { //TI = item.Title.Substring(0,100)+"......",//标题 //AN = GetString(item.AppNo,";",1), //申请号 //AD = GetString(item.PublicNo,";",3),//公开号 //IPC = GetString(item.IPC,";",4), //IPC //CPIC=item.AccessionNo, //入藏号 TI = item.Title,//标题 AN = item.AppNo, //申请号 AD = item.PublicNo,//公开号 IPC = item.IPC, //IPC CPIC = item.AccessionNo, //入藏号 }; //paging... (LINQ) //IEnumerable ien = result.Skip((PageNumber - 1) * PageSize).Take(PageSize); IEnumerable ien = result.DefaultIfEmpty(); return ien; } catch (Exception ex) { logger.Error(ex.ToString()); return null; } }
/// <summary> /// 得到某一结果文件的某一页数据 并按某一字段排序 /// </summary> /// <param name="sp">检索式</param> /// <param name="PageIndex">要取的页数</param> /// <param name="PageSize">页数大小</param> /// <param name="SortExpression">排序字段</param> /// <returns>list(int)</int></returns> public IEnumerable GetResultList(SearchPattern sp, int PageSize, int PageIndex, string SortExpression) { try { ResultServices res = new ResultServices(); List<int> lstNo = res.GetResultListByEnd(sp, PageSize, PageIndex, SortExpression); IEnumerable ien = GetResult(lstNo); return ien; } catch (Exception ex) { logger.Error(ex.ToString()); return null; } }
/// <summary> /// 读取检索结果的概要信息,按页读取 /// </summary> /// <param name="SearchNo">检索编号(3位数字)</param> /// <param name="UserID">用户ID,7位,数据库中用户表存放的ID</param> /// <param name="strSearchDbType">中国专利检索为CN,世界EN</param> /// <param name="PageSize">每页显示的记录数</param> /// <param name="PageIndex">读取数据页码</param> /// <param name="SortExpression">排序字段,不排序可输入空字符串</param> /// <returns></returns> public List<xmlDataInfo> getSearchData(string strGroupName, string SearchNo, int UserID, string strSearchDbType, int PageSize, int PageIndex, string SortExpression) { List<xmlDataInfo> lstXml = new List<xmlDataInfo>(); xmlDataInfo item = new xmlDataInfo(); Cpic.Cprs2010.Search.SearchPattern schPatItem = new Cpic.Cprs2010.Search.SearchPattern(); schPatItem.SearchNo = SearchNo; ; //检索编号[001-999] //检索式:F XX 2010/AD schPatItem.UserId = UserID; //用户ID schPatItem.GroupName = strGroupName; strSearchDbType = strSearchDbType.ToUpper(); switch (strSearchDbType.ToUpper()) { case "CN": schPatItem.DbType = Cpic.Cprs2010.Search.SearchDbType.Cn; break; case "EN": case "WD": schPatItem.DbType = Cpic.Cprs2010.Search.SearchDbType.DocDB; //检索数据 break; default: return null; } lstXml = GetResultList(schPatItem, PageSize, PageIndex, SortExpression); return lstXml; }
/// <summary> /// /// </summary> /// <param name="strPattern">检索式,页面生成的检索式</param> /// <param name="UserID">用户ID,7位,数据库中用户表存放的ID</param> /// <param name="strSearchDbType">中国专利检索为CN,世界EN</param> /// <returns></returns> public Cpic.Cprs2010.Search.ResultInfo DoSearch(string strGroupName, string strPattern, int UserID, string nSNO, Cpic.Cprs2010.Search.SearchDbType _SDbType) { if (_SDbType == Cpic.Cprs2010.Search.SearchDbType.Cn) { Regex reg = new Regex(@"(\d{12}\.?[\d|x|X])\s*\/AN|AN\s+(\d{12}\.?[\d|x|X])", RegexOptions.IgnoreCase); MatchCollection mc = reg.Matches(strPattern); foreach (Match m in mc) { string eachAn = m.Groups[1].Value; if (eachAn == "" || eachAn == null) eachAn = m.Groups[2].Value; // 送验证 bool ifValidate = CnAppLicationNo.Check_ApNoAddVCode(eachAn); if (!ifValidate) { return new Cpic.Cprs2010.Search.ResultInfo() { HitMsg = "申请号校验位错误" }; } string newAn = eachAn.Length == 13 ? eachAn.Substring(0, 12) : eachAn.Substring(0, eachAn.IndexOf('.')); strPattern = strPattern.Replace(eachAn, newAn); } //处理CS:DS Regex regCs = new Regex(@"(\w*)\s*\/([C|D]S)|([C|D]S)\s+(\w*)", RegexOptions.IgnoreCase); MatchCollection mcCs = regCs.Matches(strPattern); foreach (Match m in mcCs) { string strWord = m.Groups[1].Value; string strKey = m.Groups[2].Value; if (strWord == "" || strWord == null) { strWord = m.Groups[3].Value; strKey = m.Groups[4].Value; } // 送验证 string strRs = getNewSearchWord(strWord, strKey); if (string.IsNullOrEmpty(strRs)) { //return new Cpic.Cprs2010.Search.ResultInfo() { HitMsg = "申请号校验位错误" }; } else { strPattern = strPattern.Replace(m.Groups[0].Value, strRs); } } } Cpic.Cprs2010.Search.SearchPattern schPatItem = new Cpic.Cprs2010.Search.SearchPattern(); schPatItem.SearchNo = nSNO.PadLeft(3, '0'); //检索编号[001-999] schPatItem.Pattern = FormatQueryPattenrn(strPattern, _SDbType); //检索式:F XX 2010/AD schPatItem.UserId = UserID; //用户ID schPatItem.DbType = _SDbType; schPatItem.GroupName = strGroupName; Cpic.Cprs2010.Search.ResultInfo res = Cpic.Cprs2010.Search.SearchManager.SearchFactory.CreatDoSearch(schPatItem); res.SearchPattern.Pattern = strPattern; return res; }
/// <summary> /// 得到某一结果文件的某一页数据 并按某一字段排序 /// </summary> /// <param name="sp">检索式</param> /// <param name="PageIndex">要取的页数</param> /// <param name="PageSize">页数大小</param> /// <param name="SortExpression">排序字段</param> /// <returns>list(int)</int></returns> public List<GeneralDataInfo> GetResultListDocInfo(SearchPattern sp, int PageSize, int PageIndex, string SortExpression) { try { ResultServices res = new ResultServices(); List<int> lstNo = res.GetResultList(sp, PageSize, PageIndex, SortExpression); List<GeneralDataInfo> ien = GetResulDoctListDataInfo(lstNo, lstNo.Count, 1, SortExpression); return ien; } catch (Exception ex) { logger.Error(ex.ToString()); return null; } }