예제 #1
0
        /// <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;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
    private static string Merge(SearchPattern sp, string NodeId, string type, string stype)
    {
        ResultServices res = new ResultServices();
        List<int> fResult = res.GetResultList(sp, "");
        List<int> dbResult = ztHelper.GetResultList(NodeId,type);
        List<int> sresult ;
        if (stype == "1")
        {
            sresult = dbResult.Intersect(fResult).ToList<int>();
        }
        else
        {
            sresult = dbResult.Except(fResult).ToList<int>();
        }
        //结果文件绝对目录
        string file = res.getResultFilePath(sp).Replace(sp.SearchNo+ ".cnp","998.cnp");
        if (File.Exists(file)) File.Delete(file);

        using (FileStream fs = new System.IO.FileStream(file, FileMode.CreateNew))
        {
            foreach (var id in sresult)
            {
                byte[] fmlNo = BitConverter.GetBytes(id);
                fs.Write(fmlNo, 0, fmlNo.Length);
            }
        }
        return sresult.Count().ToString();
    }
예제 #4
0
    /// <summary>
    /// 对专题库节点添加检索式&并对检索式进行检索入库。
    /// 注:大于5000条的检索式 不允许插入。
    /// </summary>
    /// <param name="NodeId">节点id</param>
    /// <param name="SearchPattern">检索式</param>
    /// <param name="Hit">命中篇数</param>
    /// <param name="type">数据类型 cn en</param>
    /// <returns></returns>
    public static string addSearchPattern1(string NodeId, string SearchPattern, string Hit, string type, string zid)
    {
        string result = "succ";

        try
        {
            //检索
            int intCount = 0;
            //int userid = Convert.ToInt32(System.Web.HttpContext.Current.Session["Userid"].ToString());
            int userid = 1;
            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
            string strHits = search.GetSearchDataHits("", SearchPattern, userid, type.ToUpper());
            if (strHits == "ERROR") return "ERROR";
            string strNo = string.Empty;
            if (strHits.IndexOf("(") >= 0 && strHits.IndexOf(")") > 0)
            {
                strNo = strHits.Substring(strHits.IndexOf("(") + 1, strHits.IndexOf(")") - strHits.IndexOf("(") - 1);
            }
            if (strHits.IndexOf("<hits:") >= 0 && strHits.IndexOf(">") > 0)
            {
                intCount = Convert.ToInt32(strHits.Substring(strHits.IndexOf("<hits:") + 6).Trim('>').Trim());
            }
            //判断结果是否太大
            if (intCount > 50000)
            {
                result = "对不起,检索式检索结果大于50000,请缩小修改检索式,缩小检索结果范围";
                return result;
            }
            //获取检索结果
            SearchPattern schPatItem = new SearchPattern();
            schPatItem.SearchNo = strNo; ;  //检索编号[001-999]
            //检索式:F XX 2010/AD
            schPatItem.UserId = userid;   //用户ID
            if (type.ToUpper() == "CN")
            {
                schPatItem.DbType = SearchDbType.Cn;
            }
            else
            {
                schPatItem.DbType = SearchDbType.DocDB;
            }
            ResultServices res = new ResultServices();
            List<int> lst = res.GetResultList(schPatItem, "");
            List<string> nodids = new List<string>();
            nodids.Add(NodeId);
            //添加到ztdb中
            using (SqlConnection conn = DBA.SqlDbAccess.GetSqlConnection())
            {
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                if (intCount > 0)
                {
                    //AddToTH(tran, lst, nodids, "检索式", userid.ToString(), type);
                    WriteZTCNP(NodeId, type, "0", lst);
                }
                string SQL = string.Format("insert into ztsp (Nid,sp,Hit,Type,isdel,zid) values ('{0}','{1}',{2},'{3}',0,'{4}')", NodeId, SearchPattern, intCount, type, zid);
                DBA.SqlDbAccess.ExecNoQuery(tran, CommandType.Text, SQL);
                tran.Commit();
            }

        }
        catch (Exception ex)
        {
            result = "失败:" + ex.Message;
        }
        return result;
    }
예제 #5
0
    /// <summary>
    /// 更新专题库节点绑定的检索式
    /// </summary>
    /// <param name="id">检索式id</param>
    /// <param name="SearchPattern">检索式</param>
    /// <param name="Hit">命中篇数</param>
    /// <param name="nodeid">节点id</param>
    /// <param name="type">数据类型 cn en</param>
    /// <returns></returns>
    public static string UpdateSearchPattern(string id, string SearchPattern, int Hit, string nodeid, string type)
    {
        string result = "succ";
        try
        {
            //检索
            int intCount = 0;
            //int userid = Convert.ToInt32(System.Web.HttpContext.Current.Session["Userid"].ToString());
            int userid = 1;
            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
            string strHits = search.GetSearchDataHits("", SearchPattern, userid, type.ToUpper());
            if (strHits == "ERROR") return "ERROR";
            string strNo = string.Empty;
            if (strHits.IndexOf("(") >= 0 && strHits.IndexOf(")") > 0)
            {
                strNo = strHits.Substring(strHits.IndexOf("(") + 1, strHits.IndexOf(")") - strHits.IndexOf("(") - 1);
            }
            if (strHits.IndexOf("<hits:") >= 0 && strHits.IndexOf(">") > 0)
            {
                intCount = Convert.ToInt32(strHits.Substring(strHits.IndexOf("<hits:") + 6, strHits.IndexOf(">") - strHits.IndexOf("<hits:") - 6).Trim());
            }
            //判断结果是否太大
            if (intCount > 5000)
            {
                result = "对不起,检索式检索结果大于5000,请修改检索式,缩小检索结果范围";
                return result;
            }
            //获取检索结果
            SearchPattern schPatItem = new SearchPattern();
            schPatItem.SearchNo = strNo; ;  //检索编号[001-999]
            //检索式:F XX 2010/AD
            schPatItem.UserId = userid;   //用户ID
            if (type.ToUpper() == "CN")
            {
                schPatItem.DbType = SearchDbType.Cn;
            }
            else
            {
                schPatItem.DbType = SearchDbType.DocDB;
            }
            ResultServices res = new ResultServices();
            List<int> lst = res.GetResultList(schPatItem, "");
            List<string> nodids = new List<string>();
            nodids.Add(nodeid);
            //
            // 更新 除了核心专利+来源是 “检索式” 的删除标记
            //
            using (SqlConnection conn = DBA.SqlDbAccess.GetSqlConnection())
            {
                conn.Open();
                ////删除旧的数据
                SqlTransaction trans = conn.BeginTransaction();
                //string delztdb = string.Format("update ztdb set isdel=1 where (iscore =0 and [Form] ='检索式') and Nid='{0}' and type='{1}'", nodeid, type);
                //DBA.SqlDbAccess.ExecNoQuery(trans, CommandType.Text, delztdb);

                ////添加新的数据
                //AddToTH(trans, lst, nodids, "检索式", userid.ToString(), type);
                WriteZTCNP(nodeid, type, "0", lst);

                //更新检索式
                string SQL = string.Format("update ztsp set sp ='{0}',Hit={1} where id={2}", SearchPattern.Replace("'", "''"), intCount, id.Replace("'", "''"));
                DBA.SqlDbAccess.ExecNoQuery(trans, CommandType.Text, SQL);

                trans.Commit();
            }

        }
        catch (Exception ex)
        {
            result = "failed";
        }
        return result;
    }
예제 #6
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(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;
            }
        }
예제 #7
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 IEnumerable GetResultList(SearchPattern sp, int PageSize, int PageIndex, string SortExpression)
        {
            try
            {
                ResultServices res = new ResultServices();
                List<int> lstNo = res.GetResultList(sp, PageSize, PageIndex, SortExpression);

                IEnumerable ien = GetResultFmlList(lstNo, lstNo.Count, 1, SortExpression);
                return ien;
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                return null;
            }
        }
예제 #8
0
        public static string ExportData2(string type, string db, string id, string ColNames, string beginNum, string endNum, string strSort, string FileType)
        {
            try
            {
                int userid = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserID"]);
                int bnum = Convert.ToInt32(beginNum) - 1;
                if (bnum < 0) bnum = 0;
                int endnum = Convert.ToInt32(endNum);
                int length = endnum - bnum;
                SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
                List<string> strcolnames = ColNames.Split('|').ToList<string>();
                List<int> listNo;
                List<int> fResult = new List<int>();
                switch (type.ToUpper())
                {
                    case "FI":
                    case "CN":
                    case "EN":
                        SearchPattern sp = new SearchPattern();
                        sp.SearchNo = id;
                        sp.Pattern = "";
                        if (db.ToUpper() == "CN")
                        {
                            sp.DbType = SearchDbType.Cn;
                        }
                        else
                        {
                            sp.DbType = SearchDbType.DocDB;
                        }
                        sp.UserId = userid;
                        ResultServices res = new ResultServices();
                        fResult = res.GetResultList(sp, "");
                        break;
                    case "ZT":
                    case "QY":
                        fResult = ztHelper.GetResultList(id, db);
                        break;
                    case "CO":
                        fResult = UserCollectsHelper.GetResultList(db, Convert.ToInt32(id));
                        break;
                    case "YJ0":
                    case "YJ1":
                        fResult = ProYJDLL.YJDB.getYJItemByWID(Convert.ToInt32(id), Convert.ToInt16(type.Substring(2).ToString()));
                        break;
                }

                listNo = fResult.Skip(bnum).Take(length).ToList<int>();
                List<xmlDataInfo> listXml = search.GetResult(listNo, db.ToUpper());
                string name = GlobalUtility.TimeRandomName() + "." + FileType;
                string strFileName = "/Images/Export/Patent" + name;
                string fullpath = System.Web.HttpContext.Current.Server.MapPath(strFileName);
                if (!Directory.Exists(Path.GetDirectoryName(fullpath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fullpath));
                }
                ExcelLib.NPOIHelper eh = new ExcelLib.NPOIHelper();

                fullpath = eh.DataTable2File(List2DataTable(listXml, ColNames, type, ""), fullpath, FileType);

                return name;
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                return "";
            }
        }