| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Utils;
- namespace SiteCore.Handler
- {
- public partial class app
- {
- public void get_indexnews()
- {
- //string session_id = con.Request.Headers["session-id"];
- //if (session_id == "")
- //{
- // conError("请重新登录");
- // return;
- //}
- //object re = RedisHelper.StringGet(session_id);
- //if (re == null)
- //{
- // conError("请重新登录");
- // return;
- //}
- //RedisHelper.StringGet()
- DataStruct dStruct = GetPostStruct();
- dStruct.PageSize = 3;
- List<string> lw = new List<string>();
- //lw.Add("state=1");
- string order = "";
- string key = GetString("key");
- if (key.Length > 0) lw.Add(string.Format("title like '%{0}%'", key));
- dStruct.Order = "addtime desc";
- //lw.Add(" newstypeid=1 ");
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Fileds = "id,title,sectitle,coverimage as img,addtime as pubtime";
- DataTable dt = WebCache.GetData("s_news", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_news()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- //lw.Add("state=1");
- int tid = GetPostInt("tid");
- if (tid > 0)
- {
- lw.Add(string.Format("newstypeid={0}", tid));
- }
-
- string key = GetString("key");
- if (key.Length > 0) lw.Add(string.Format("title like '%{0}%'", key));
- dStruct.Order = "addtime desc";
- //lw.Add(" newstypeid=1 ");
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Fileds = "id,title,sectitle,coverimage as img,addtime as pubtime";
- DataTable dt = WebCache.GetData("s_news", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_newstype()
- {
- string sql = "select id,name from s_newstype order by sort";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_news_info()
- {
- if (UrlPostParmsCheck("nid"))
- {
- int nid = GetPostInt("nid");
- //int nid = 3;
- string sql = "select title,sectitle,coverimage as img,addtime as pubtime,summary from s_news where id=" + nid;
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- //foreach (DataRow dr in dt.Rows)
- //{
- // dr["summary"] = ReplaceHtmlTag(dr["summary"].ToString());
- //}
- conGridJson(1, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- return;
- }
- }
- conError("找不到该资讯");
- }
- public static string ReplaceHtmlTag(string html, int length = 0)
- {
- string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
- strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
- if (length > 0 && strText.Length > length)
- return strText.Substring(0, length);
- return strText;
- }
- }
- }
|