Exemple #1
0
 public ResultInfo Search(Cpic.Cprs2010.Search.SearchPattern _searchPattern)
 {
     throw new NotImplementedException();
 }
Exemple #2
0
        /// <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(Cpic.Cprs2010.Search.SearchPattern sp, int PageSize, int PageIndex, string SortExpression)
        {
            try
            {

                List<GeneralDataInfo> ien = new List<GeneralDataInfo>();
                List<xmlDataInfo> lstXml = GetResultList(sp, PageSize, PageIndex, SortExpression);

                GeneralDataInfo genTmp = null;
                foreach (xmlDataInfo xmlItem in lstXml)
                {
                    genTmp = new GeneralDataInfo();
                    genTmp.NCPIC = long.Parse(xmlItem.CPIC);
                    genTmp.StrTI = xmlItem.StrTitle;
                    genTmp.StrPubID = xmlItem.StrPubNo;
                    genTmp.StrPtCode = xmlItem.StrANX;
                    genTmp.StrAD = xmlItem.StrApDate;
                    genTmp.StrIPC = xmlItem.StrIpc;
                    genTmp.NID = long.Parse(xmlItem.StrSerialNo);
                    genTmp.StrAN = xmlItem.StrApNo;

                    ien.Add(genTmp);
                }

                return ien;
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                return null;
            }
        }
Exemple #3
0
        private string FormatQueryPattenrn(string strPattern, Cpic.Cprs2010.Search.SearchDbType _SDbType)
        {
            string strRs = strPattern;
            try
            {
                Regex reg = new Regex("(.*?)(@..=.*|@YX.*|@SX.*)");

                Match rs = reg.Match(strPattern);
                string strQ1 = "";
                string strQ2 = "";
                string strEndFlag = "";
                if (rs.Success)
                {
                    strQ1 = rs.Groups[1].Value.Trim();
                    strQ2 = rs.Groups[2].Value.Trim().ToUpper();

                    List<string> lst = new List<string>();

                    switch (_SDbType)
                    {
                        case Cpic.Cprs2010.Search.SearchDbType.Cn:
                            lst = lstCnLx;
                            break;
                        case Cpic.Cprs2010.Search.SearchDbType.DocDB:
                            lst = lstEnCC;
                            break;
                    }

                    foreach (string strItem in lst)
                    {
                        strEndFlag += strQ2.Contains(strItem) ? "1" : "0";
                    }

                    //第一位:发明标识,0全,1,公开,2,SQ
                    //第二位:新型标识,0,无,1启用
                    //第三位:外观标识,0,无,1启用
                    if (_SDbType == Cpic.Cprs2010.Search.SearchDbType.Cn)
                    {
                        switch (strEndFlag.Substring(0, 2))
                        {
                            case "00":
                                strEndFlag = "0" + strEndFlag.Substring(2);
                                break;
                            case "01":
                                strEndFlag = "2" + strEndFlag.Substring(2);
                                break;
                            case "10":
                                strEndFlag = "1" + strEndFlag.Substring(2);
                                break;
                            case "11":
                                strEndFlag = "1" + strEndFlag.Substring(2);
                                break;
                            default:
                                break;
                        }

                        if (strQ2.Contains("@YX") || strQ2.Contains("@SX"))  //EG法律状态标识,0,全,1,YX.eee, 2,SX.eee
                        {
                            if (strEndFlag.Equals("000"))
                            {
                                strEndFlag = "111";
                            }

                            strEndFlag += strQ2.Contains("@YX") ? "1" : "2";
                        }
                    }

                    strEndFlag = _SDbType == Cpic.Cprs2010.Search.SearchDbType.DocDB ? Convert.ToInt32(strEndFlag, 2).ToString().PadLeft(4, '0') : strEndFlag;
                    strRs = strQ1 + "###" + strEndFlag + "###";
                }
            }
            catch (Exception ex)
            {
            }

            return strRs.Replace("、", " ");
        }
Exemple #4
0
        /// <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<xmlDataInfo> GetResultList(Cpic.Cprs2010.Search.SearchPattern sp, int PageSize, int PageIndex, string SortExpression)
        {
            List<xmlDataInfo> ien = new List<xmlDataInfo>();
            try
            {
                ResultServices res = new ResultServices();

                List<int> lstNo = res.GetResultListByEnd(sp, PageSize, PageIndex, SortExpression);
                if (sp.DbType == Cpic.Cprs2010.Search.SearchDbType.Cn)
                {
                    ien = GetResult(lstNo, "CN");
                }
                else if (sp.DbType == Cpic.Cprs2010.Search.SearchDbType.DocDB)
                {
                    ien = GetResult(lstNo, "DocDB");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                //return null;
            }
            return ien;
        }
Exemple #5
0
        /// <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, Cpic.Cprs2010.Search.SearchDbType _SDbType)
        {
            string strSearchNo = GetSearchNo(UserID, _SDbType);   //检索编号[001-999]

            if (strPattern.ToLower().EndsWith(".txt") || strPattern.ToLower().EndsWith(".ini"))
            {
                Cpic.Cprs2010.Search.SearchManager.SearchFactory.del_OldCnpFile(UserID, strSearchNo, _SDbType);
                ImporResult im = new ImporResult();
                //@"D:\XZQ\src\源代码\Patentquery\ZtHeadImg\201405\c4b881d8fff1413fa8316f5300deb808.txt"
                return im.ImportLis2tResult(System.Web.HttpContext.Current.Server.MapPath("~/ZtHeadImg/" + strPattern), UserID, strSearchNo, _SDbType);
                //strPattern,strSearchNo,_SDbType
            }

            return DoSearch(strGroupName, strPattern, UserID, strSearchNo, _SDbType);
        }
Exemple #6
0
        /// <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;
        }
Exemple #7
0
        /// <summary>
        /// 检索编号生成程序
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        private string GetSearchNo(int UserID, Cpic.Cprs2010.Search.SearchDbType _SDbType)
        {
            string SearchNo = "";
            DataTable dt = new DataTable();
            //string sql = "select top 1 SearchNo from TbSearchNo  Where UserId=" + UserID + " Order By ID DESC";

            string sql = string.Format("select top 1 Number as SearchNo from TLC_Patterns  Where UserId={0} and [Types]={1} order by CreateDate desc",
                UserID, Convert.ToByte(_SDbType.GetHashCode()));
            try
            {
                dt = DBA.SqlDbAccess.GetDataTable(CommandType.Text, sql);
            }
            catch (Exception ex)
            {
                return "001";
            }

            if (dt.Rows.Count <= 0)
            {
                SearchNo = "001";
            }
            else
            {
                SearchNo = dt.Rows[0]["SearchNo"].ToString().Trim();
                SearchNo = ((Convert.ToInt32(SearchNo) % 999) + 1).ToString().Trim();
            }

            //编号存入数据库
            //SearNoInDB(SearchNo, UserID);

            return SearchNo.ToString().PadLeft(3, '0');
        }
Exemple #8
0
        /// <summary>
        /// 得到检索结果
        /// </summary>
        /// <returns></returns>
        public Cpic.Cprs2010.Search.ResultInfo Search(Cpic.Cprs2010.Search.SearchPattern _searchPattern, FileFinder fd)
        {
            string ResultFile = string.Format(resultfile, CprsConfig.GetUserPath(_searchPattern.UserId, _searchPattern.GroupName), Enum.GetName(typeof(SearchDbType), _searchPattern.DbType), _searchPattern.SearchNo);
            SearchCommand = _searchPattern.Pattern;
            ResultInfo re = new ResultInfo();
            re.SearchPattern = _searchPattern;
            Result rs;

            try
            {
                //初始化
                Init();
                //检索
                DoSearch(fd);
                rs = GetResult();
                // 创建文件夹
                if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(ResultFile)))
                {
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(ResultFile));
                }
                else
                {
                    if (System.IO.File.Exists(ResultFile))
                    {
                        System.IO.File.Delete(ResultFile);
                    }
                }

                using (System.IO.FileStream fsw = new System.IO.FileStream(ResultFile, System.IO.FileMode.Create, System.IO.FileAccess.Write))
                {
                    foreach (int i in rs.Content)
                    {
                        byte[] byhis = BitConverter.GetBytes(i);
                        fsw.Write(byhis, 0, byhis.Length);
                    }
                }
                re.HitCount = rs.Content.Count();
                re.HitMsg = "(" + _searchPattern.SearchNo + ")" + SearchCommand + " <hits: " + re.HitCount + ">";
            }
            catch (Exception ex)
            {
                re.HitCount =0;
                re.HitMsg = "(" + _searchPattern.SearchNo + ")" + SearchCommand + " <hits: " + re.HitCount + ">";
            }
            return re;
        }