Esempio n. 1
0
    public static IEnumerable tableSearch(string strSearchQuery, string NodeId,string type,string stype)
    {
        string strResutlMsg = "";
        try
        {

           // string strQuery = System.Web.HttpUtility.UrlDecode(strSearchQuery.Trim());
            string strQuery =strSearchQuery.Trim();
            //检索
            int intCount = 0;
            int userid = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserID"]);
            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
            string strHits = search.GetSearchDataHits(SearchInterface.XmPatentComm.strWebSearchGroupName,strQuery, userid, type.ToUpper());
            string strNo = string.Empty;

            if (strHits == "ERROR")
            {
                return "请求错误";
            }

            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 == 0) return "0";

            SearchPattern sp = new SearchPattern();
            sp.SearchNo = strNo;
            sp.Pattern = strQuery;
            if (type.ToUpper() == "CN")
            {
                sp.DbType = SearchDbType.Cn;
            }
            else
            {
                sp.DbType = SearchDbType.DocDB;
            }
            sp.UserId = userid;
            strResutlMsg = Merge(sp, NodeId, type, stype);

        }
        catch (Exception ex)
        {
            strResutlMsg = "请求错误";

        }
        return strResutlMsg;
    }
Esempio n. 2
0
    public static string Search(string strSearchQuery, string type)
    {
        string strResutlMsg = "";
        try
        {

            string strQuery = System.Web.HttpUtility.UrlDecode(strSearchQuery.Trim());
            //检索
            int intCount = 0;
            int userid = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserID"]);
            SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
            string strHits = search.GetSearchDataHits(SearchInterface.XmPatentComm.strWebSearchGroupName, strQuery, userid, type.ToUpper());
            string strNo = string.Empty;

            if (strHits == "ERROR")
            {
                return "请求错误";
            }
            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());
            }

            return intCount.ToString();

        }
        catch (Exception ex)
        {
            strResutlMsg = "请求错误";

        }
        return strResutlMsg;
    }
Esempio n. 3
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;
    }
Esempio n. 4
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;
    }