/// <summary> /// 返回资讯高级搜索的Terms /// </summary> /// <param name="date"></param> /// <param name="title"></param> /// <param name="text"></param> /// <param name="authornames"></param> /// <param name="authorgroup"></param> /// <returns></returns> private static String GetTerms(String date, String title, String text, String authornames, String authorgroup) { String terms = String.Empty; String authornamesstr = String.Empty; String authorgroupsstr = String.Empty; String authquery = String.Empty; if (!String.IsNullOrEmpty(date)) { //add by lym try { date = date.Replace("99:99:99", "23:59:59"); String startdate = String.Empty; String enddate = String.Empty; startdate = Convert.ToDateTime(date.Substring(0, date.IndexOf(" TO ")).Split(new char[] { 'T' })[0]).ToString("yyyy-MM-dd") + "T00:00:00Z"; enddate = Convert.ToDateTime(date.Substring(date.IndexOf(" TO ") + 4).Split(new char[] { 'T' })[0]).ToString("yyyy-MM-dd") + "T23:59:59Z"; date = startdate + " TO " + enddate; } catch (Exception ex) { } terms += "datetime:[" + date + "]"; } if (!String.IsNullOrEmpty(title)) { if (!String.IsNullOrEmpty(terms)) { terms += " AND (title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(title)) + ")"; } else { terms += "(title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(title)) + ")"; } } if (!String.IsNullOrEmpty(text)) { if (!String.IsNullOrEmpty(terms)) { terms += " AND (text:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + " OR title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + ")"; } else { terms += "(text:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + " OR title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + ")"; } } foreach (String item in GetParams(authornames)) { authornamesstr += " OR author:" + item; } foreach (String item in GetParams(authorgroup)) { authorgroupsstr += " OR (" + item + ")"; } if (!String.IsNullOrEmpty(authornamesstr)) { authornamesstr = authornamesstr.Remove(0, 4); } if (!String.IsNullOrEmpty(authorgroupsstr)) { if (!String.IsNullOrEmpty(authornamesstr)) { authquery = "(" + authornamesstr + ")" + authorgroupsstr; } else { authquery = authorgroupsstr.Remove(0, 4);; } } else { if (!String.IsNullOrEmpty(authornamesstr)) { authquery = authornamesstr; } else { authquery = String.Empty; } } if (!String.IsNullOrEmpty(authquery)) { if (!String.IsNullOrEmpty(terms)) { terms += " AND (" + authquery + ")"; } else { terms += authquery; } } return(terms); }
/// <summary> /// 新通道的高级搜索 /// </summary> /// <param name="types">栏目id集合</param> /// <param name="securitycodes">证券代码集合</param> /// <param name="date">日期</param> /// <param name="title">标题</param> /// <param name="text">正文</param> /// <param name="columnType">栏目类型</param> /// <param name="pageIndex">页码</param> /// <param name="limit">记录数</param> /// <returns></returns> public object GetNoticeBySearch(String types, String securitycodes, String date, String title, String text, String columnType, String pageIndex, String limit) { String terms = String.Empty; if (!String.IsNullOrEmpty(date)) { //add by lym try { date = date.Replace("99:99:99", "23:59:59"); String startdate = String.Empty; String enddate = String.Empty; startdate = Convert.ToDateTime(date.Substring(0, date.IndexOf(" TO ")).Split(new char[] { 'T' })[0]).ToString("yyyy-MM-dd") + "T00:00:00Z"; enddate = Convert.ToDateTime(date.Substring(date.IndexOf(" TO ") + 4).Split(new char[] { 'T' })[0]).ToString("yyyy-MM-dd") + "T23:59:59Z"; date = startdate + " TO " + enddate; } catch (Exception ex) { } terms += "datetime:[" + date + "]"; } if (!String.IsNullOrEmpty(title)) { if (!String.IsNullOrEmpty(terms)) { terms += "AND (title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(title)) + ")"; } else { terms += "(title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(title)) + ")"; } } if (!String.IsNullOrEmpty(text)) { if (!String.IsNullOrEmpty(terms)) { terms += "AND (text:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + " OR title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + ")"; } else { terms += "(text:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + " OR title:" + CommDao.SafeToIndexString(HttpUtility.UrlDecode(text)) + ")"; } } SktSrhModel <NoticeSktSrhQryModel> queryModel = new SktSrhModel <NoticeSktSrhQryModel>("H2", pageIndex, limit, new NoticeSktSrhQryModel(GetParams(types), GetParams(securitycodes), terms, columnType)); String result = String.Empty; try { result = (String)DataAccess.QueryIndex(JsonConvert.SerializeObject(queryModel)); } catch (Exception ex) { LogHelper.WriteLog("GetNoticeBySearch.do发生异常", ex); throw ex; } return(result); }