| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SiteCore.Handler
- {
- public partial class app
- {
- public void get_indexmenu()
- {
- int r = getDecodeInt("r");
- if (r == 0) conError("无登录");
- //string r = GetPostString("r");
- DataTable dt = WebCache.GetIndexMenu(r);
- conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_indexnav()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("title like '%{0}%'", key));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Order = "sort asc";
- DataTable dt = WebCache.GetData("s_indexnav", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- //首页动态
- public void get_indextrends2()
- {
- /*
- 1:闲置出售
- 2.求购专区
- 3.校园招聘
- 4.赏金大厅
- 5.社团
- 6.校园资讯
- 7.合伙人
- 8.勤工俭学
- */
- int uid = getDecodeInt("uid");
- //int uid = 35;
- DataTable resultDt = new DataTable();
- resultDt.Columns.Add(new DataColumn("type", typeof(int)));
- resultDt.Columns.Add(new DataColumn("tname", typeof(string)));
- resultDt.Columns.Add(new DataColumn("items", typeof(string)));
- //resultDt.Columns.Add(new DataColumn("time", typeof(string)));
- //resultDt.Columns.Add(new DataColumn("tid", typeof(int)));
- //resultDt.Columns.Add(new DataColumn("mainid", typeof(int)));
- //resultDt.Columns.Add(new DataColumn("title", typeof(string)));
- //resultDt.Columns.Add(new DataColumn("img", typeof(string)));
- //resultDt.Columns.Add(new DataColumn("con", typeof(string)));
- DataRow nDr = null;
- StringBuilder sql = new StringBuilder();
- //sql.Append("select top 3 id,id as mainid,title,addtime,coverimage as img,sectitle as con,'' as page from S_News order by AddTime desc ;");
- sql.Append("select top 3 id,id as mainid,title,addtime,coverimage as img,sectitle as con,'' as page from S_News order by AddTime desc ;");
- //sql.Append("select top 1 3 as type,'校园招聘' as tname,publishtime as time,id as tid,id as mainid,jobtitle as title,'' as img,comname as con from S_Recruit order by PublishTime desc ;");
- if (uid > 0)
- {
- sql.AppendFormat("select top 5 id,goodsid,goodsname,username,addtime,gcontent,CoverImage,(select count(0) from S_Tiding where isRead=0 and mainid=view_GoodsComment.goodsid group by mainid) as rcount from view_GoodsComment where ID in (select max(tid) from S_Tiding where isRead=0 and typecode='ewu' and ToUserID={0} group by mainid) order by addtime desc ;", uid);
- sql.AppendFormat("select top 3 id,roomid,discussid,roomname,discussname,starttime,r,c,posname from view_laborder where datediff(minute,starttime,getdate())>=-15 and datediff(minute,starttime,getdate())<=15 and state=0 and userid={0} ;",uid);
- //sql.AppendFormat("select top 1 id,wishsid,wishsname,username,addtime,con,userid from view_WishsComment where WishsID in (select id from S_Wishs where UserID={0} and State=1) order by AddTime desc ;", uid);
- //sql.AppendFormat("select top 1 ");
- }
- DataSet ds = DbHelper.DbConn.ExecuteDataset(sql.ToString());
- StringBuilder uStr = new StringBuilder();
- int uc = 0;
- int j = 0;
- if (uid > 0)
- {
- int idx = 1;
- DataTable gDt = ds.Tables[idx++];
- if (gDt != null && gDt.Rows.Count > 0)
- {
- if (uc == 0) uStr.Append("{");
- else uStr.Append(",{");
- uStr.AppendFormat("\"type\":\"{0}\"", 1);
- uStr.AppendFormat(",\"tname\":\"{0}\"", "闲置出售·最新回复");
- uStr.Append(",\"items\":[");
- j = 0;
- foreach (DataRow idr in gDt.Rows)
- {
- if (j == 0) uStr.Append("{");
- else uStr.Append(",{");
- uStr.AppendFormat("\"tid\":\"{0}\"", idr["id"]);
- uStr.AppendFormat(",\"mainid\":\"{0}\"", idr["goodsid"]);
- uStr.AppendFormat(",\"time\":\"{0}\"", Convert.ToDateTime(idr["addtime"]).ToString("yyyy-MM-dd HH:mm"));
- uStr.AppendFormat(",\"title\":\"{0}\"", idr["goodsname"]);
- uStr.AppendFormat(",\"img\":\"{0}\"", idr["CoverImage"]);
- uStr.AppendFormat(",\"rcount\":\"{0}\"", idr["rcount"]);
- uStr.AppendFormat(",\"con\":\"{0}\"", idr["username"] + ": " + idr["gcontent"]);
- uStr.Append("}");
- j++;
- }
- uStr.Append("]");
- uStr.Append("}");
- uc++;
- }
- gDt = ds.Tables[idx++];
- if (gDt != null && gDt.Rows.Count > 0)
- {
- if (uc == 0) uStr.Append("{");
- else uStr.Append(",{");
- uStr.AppendFormat("\"type\":\"{0}\"", 2);
- uStr.AppendFormat(",\"tname\":\"{0}\"", "图书馆预约提醒");
- uStr.Append(",\"items\":[");
- j = 0;
- foreach (DataRow idr in gDt.Rows)
- {
- if (j == 0) uStr.Append("{");
- else uStr.Append(",{");
- uStr.AppendFormat("\"tid\":\"{0}\"", idr["id"]);
- if (Convert.ToInt32(idr["roomid"]) > 0)
- {
- uStr.AppendFormat(",\"mainid\":\"{0}\"", idr["roomid"]);
- uStr.AppendFormat(",\"title\":\"{0}\"", idr["roomname"]);
- uStr.AppendFormat(",\"con\":\"{0}\"", idr["r"] + "排" + idr["c"] + "桌" + idr["posname"] + ",可签到使用了");
- }
- else
- {
- uStr.AppendFormat(",\"mainid\":\"{0}\"", idr["discussid"]);
- uStr.AppendFormat(",\"title\":\"{0}\"", idr["discussname"]);
- uStr.AppendFormat(",\"con\":\"{0}\"", "可以签到使用了");
- }
- uStr.AppendFormat(",\"time\":\"{0}\"", Convert.ToDateTime(idr["starttime"]).ToString("yyyy-MM-dd HH:mm"));
- uStr.AppendFormat(",\"rcount\":\"{0}\"", "");
- uStr.AppendFormat(",\"img\":\"{0}\"", "");
- uStr.Append("}");
- j++;
- }
- uStr.Append("]");
- uStr.Append("}");
- uc++;
- }
- }
- DataTable dt = ds.Tables[0];
- nDr = resultDt.NewRow();
- nDr["type"] = 6;
- nDr["tname"] = "校园热点";
- if (uc == 0) uStr.Append("{");
- else uStr.Append(",{");
- uStr.AppendFormat("\"type\":\"{0}\"", 6);
- uStr.AppendFormat(",\"tname\":\"{0}\"", "校园热点");
- uStr.Append(",\"items\":[");
- j = 0;
- foreach (DataRow idr in dt.Rows)
- {
- if (j == 0) uStr.Append("{");
- else uStr.Append(",{");
- uStr.AppendFormat("\"tid\":\"{0}\"", idr["id"]);
- uStr.AppendFormat(",\"mainid\":\"{0}\"", idr["mainid"]);
- uStr.AppendFormat(",\"time\":\"{0}\"", Convert.ToDateTime(idr["addtime"]).ToString("yyyy-MM-dd HH:mm"));
- uStr.AppendFormat(",\"title\":\"{0}\"", idr["title"]);
- uStr.AppendFormat(",\"rcount\":\"{0}\"", "");
- uStr.AppendFormat(",\"img\":\"{0}\"", idr["img"]);
- uStr.AppendFormat(",\"con\":\"{0}\"", "");
- uStr.AppendFormat(",\"page\":\"{0}\"", idr["page"]);
- uStr.Append("}");
- j++;
- }
- uStr.Append("]");
- uStr.Append("}");
- conGridJson(resultDt.Rows.Count, "[" + uStr.ToString() + "]");
- //dt = ds.Tables[1];
- //foreach (DataRow idr in dt.Rows)
- //{
- // resultDt.Rows.Add(idr.ItemArray);
- //}
- //conGridJson(resultDt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(resultDt));
- }
- //首页动态
- public void get_indextrends()
- {
- /*
- 1:闲置出售
- 2.求购专区
- 3.校园招聘
- 4.赏金大厅
- 5.社团
- 6.校园资讯
- 7.合伙人
- 8.勤工俭学
- */
- int uid = getDecodeInt("uid");
-
- DataTable resultDt = new DataTable();
- resultDt.Columns.Add(new DataColumn("type", typeof(int)));
- resultDt.Columns.Add(new DataColumn("tname", typeof(string)));
- resultDt.Columns.Add(new DataColumn("time", typeof(string)));
- resultDt.Columns.Add(new DataColumn("tid", typeof(int)));
- resultDt.Columns.Add(new DataColumn("mainid", typeof(int)));
- resultDt.Columns.Add(new DataColumn("title", typeof(string)));
- resultDt.Columns.Add(new DataColumn("img", typeof(string)));
- resultDt.Columns.Add(new DataColumn("con", typeof(string)));
- DataRow nDr = null;
- StringBuilder sql = new StringBuilder();
- sql.Append("select top 2 6 as type,'校园热点' as tname,addtime as time,id as tid,id as mainid,title,coverimage as img,sectitle as con,'' as page from S_News order by AddTime desc ;");
- //sql.Append("select top 1 3 as type,'校园招聘' as tname,publishtime as time,id as tid,id as mainid,jobtitle as title,'' as img,comname as con from S_Recruit order by PublishTime desc ;");
- if (uid > 0)
- {
- sql.AppendFormat("select top 1 id,goodsid,goodsname,username,addtime,gcontent,userid from view_GoodsComment where GoodsID in (select id from S_Goods where UserID={0} and State=1) order by AddTime desc ;", uid);
- sql.AppendFormat("select top 1 id,wishsid,wishsname,username,addtime,con,userid from view_WishsComment where WishsID in (select id from S_Wishs where UserID={0} and State=1) order by AddTime desc ;", uid);
- //sql.AppendFormat("select top 1 ");
- }
- DataSet ds = DbHelper.DbConn.ExecuteDataset(sql.ToString());
- DataRow dr = null;
- //DataTable dt = ds.Tables[1];
- int uc = 0;
- if (uid>0)
- {
- int idx = 1;
- DataTable gDt = ds.Tables[idx++];
- if (gDt != null && gDt.Rows.Count > 0)
- {
- dr = gDt.Rows[0];
- if (Convert.ToInt32(dr["userid"]) != uid)
- {
- nDr = resultDt.NewRow();
- nDr["type"] = 1;
- nDr["tid"] = dr["id"];
- nDr["mainid"] = dr["goodsid"];
- nDr["tname"] = "闲置出售·最新回复";
- nDr["time"] = Convert.ToDateTime(dr["addtime"]).ToString("yyyy-MM-dd HH:mm");
- nDr["title"] = dr["goodsname"];
- nDr["con"] = "@" + dr["username"] + ": " + dr["gcontent"];
- uc++;
- resultDt.Rows.Add(nDr);
- }
- }
- DataTable wDt = ds.Tables[idx++];
- if (wDt != null && wDt.Rows.Count > 0)
- {
- dr = wDt.Rows[0];
- if (Convert.ToInt32(dr["userid"]) != uid)
- {
- nDr = resultDt.NewRow();
- nDr["type"] = 2;
- nDr["tid"] = dr["id"];
- nDr["mainid"] = dr["wishsid"];
- nDr["tname"] = "求购专区·最新回复";
- nDr["time"] = Convert.ToDateTime(dr["addtime"]).ToString("yyyy-MM-dd HH:mm");
- nDr["title"] = dr["wishsname"];
- nDr["con"] = "@" + dr["username"] + ": " + dr["con"];
- uc++;
- resultDt.Rows.Add(nDr);
- }
- }
- }
- DataTable dt = ds.Tables[0];
- int i = 1;
- foreach (DataRow idr in dt.Rows)
- {
- resultDt.Rows.Add(idr.ItemArray);
- if (uc > 0 && i > 1) break;
- i++;
- }
- //dt = ds.Tables[1];
- //foreach (DataRow idr in dt.Rows)
- //{
- // resultDt.Rows.Add(idr.ItemArray);
- //}
- conGridJson(resultDt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(resultDt));
- }
- }
- }
|