app.conceal.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Web;
  11. using Utils.ImageUtils;
  12. namespace SiteCore.Handler
  13. {
  14. public partial class app
  15. {
  16. public void get_concealtype()
  17. {
  18. DataTable dt = WebCache.GetConcealType();
  19. conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  20. }
  21. public void get_conceal()
  22. {
  23. int uid = getDecodeInt("uid");
  24. if (uid == 0)
  25. {
  26. conError("找不到会员");
  27. return;
  28. }
  29. DataStruct dStruct = GetPostStruct();
  30. List<string> lw = new List<string>();
  31. string tag = GetPostString("tag");
  32. if (tag.Length > 0)
  33. {
  34. lw.Add(string.Format("tag like '%{0}%'", tag));
  35. }
  36. int tid = GetPostInt("tid");
  37. if (tid > 0)
  38. {
  39. lw.Add(string.Format(" typeid={0}", tid));
  40. }
  41. lw.Add("duration<=0 or datediff(second,endtime,getdate())<=0");
  42. //lw.Add(" duration<=0 or datediff(minute,endtime,getdate())<=0 ")
  43. //lw.Add("state=1");
  44. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  45. dStruct.Fileds = "id,con,pubtime as ptime,imgs,tag,replynum as rn,likenum as ln,(select count(0) from s_conceallike where ccid=s_conceal.id and userid=" + uid + ") as mlike";
  46. dStruct.Order = "pubtime desc";
  47. DataTable dt = WebCache.GetData("s_conceal", dStruct);
  48. string con = "";
  49. foreach(DataRow dr in dt.Rows)
  50. {
  51. con = dr["con"].ToString();
  52. dr["con"]= con.Replace("&nbsp;", " ").Replace("<br>", "\n");
  53. }
  54. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  55. return;
  56. }
  57. public void upload_concealimg()
  58. {
  59. int uid = getDecodeInt("uid");
  60. if (uid == 0)
  61. {
  62. conError("找不到会员");
  63. return;
  64. }
  65. HttpPostedFile postFile = null;
  66. List<string> lstFile = new List<string>();
  67. int c = con.Request.Files.Count;
  68. if (c > 0)
  69. {
  70. for (int i = 0; i < c; i++)
  71. {
  72. string errMsg = "";
  73. postFile = con.Request.Files[i];
  74. if (!ImageHandler.CheckImage(postFile, out errMsg))
  75. {
  76. conError(errMsg);
  77. return;
  78. }
  79. string fileName = uid + DateTime.Now.ToString("MMddHHmmssfff") + ".jpg";
  80. string saveFile = Path.Combine(webConfig.conPath, fileName);
  81. string result = "";
  82. using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream))
  83. {
  84. result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 600, "", 9, 3);
  85. }
  86. lstFile.Add(fileName);
  87. }
  88. }
  89. string fs = "";
  90. if (lstFile.Count > 0) fs = string.Join(",", lstFile.ToArray());
  91. conSuccess("上传成功", "{\"fname\":\"" + fs + "\"}");
  92. }
  93. public void ins_conceal()
  94. {
  95. int uid = getDecodeInt("uid");
  96. if (uid == 0)
  97. {
  98. conError("找不到会员");
  99. return;
  100. }
  101. if (UrlPostParmsCheck("con"))
  102. {
  103. int tid = GetPostInt("tid");
  104. string tag = GetPostString("tag");
  105. string con = GetPostString("con");
  106. double dur = GetPostDouble("dur");
  107. string imgs = GetPostString("imgs");
  108. con = con.Replace("\r\n", "<br>").Replace("\n", "<br>");
  109. con = con.Replace(" ", "&nbsp;");
  110. SConceal entity = new SConceal();
  111. entity.PubTime = DateTime.Now;
  112. entity.UserID = uid;
  113. entity.TypeID = tid;
  114. entity.Tag = tag;
  115. entity.Con = con;
  116. entity.Imgs = imgs;
  117. if (dur > 0)
  118. {
  119. entity.Duration = dur;
  120. entity.EndTime = DateTime.Now.AddMinutes(dur);
  121. }
  122. entity.Create();
  123. if (dur <= 0)
  124. {
  125. //string bon = LotteryHelper.getLuckyWithUpdate("conceal", uid, entity.ID);
  126. //if (bon != "" && bon != "0")
  127. //{
  128. // conSuccess("cg|" +GetDoubleString(bon) + "|己发送!");
  129. //}
  130. //else
  131. //{
  132. // conSuccess("己发送!");
  133. //}
  134. }
  135. else {
  136. conSuccess("己发送!");
  137. }
  138. return;
  139. }
  140. conError("错误的参数");
  141. }
  142. public void get_concealreply()
  143. {
  144. if (UrlPostParmsCheck("cid"))
  145. {
  146. DataStruct dStruct = GetPostStruct();
  147. List<string> lw = new List<string>();
  148. int id = GetPostInt("cid");
  149. //id = 92;
  150. int sort = GetPostInt("sort");
  151. if (id > 0)
  152. {
  153. lw.Add("ConcealID=" + id);
  154. lw.Add("ParentID=0");
  155. if (sort == 1) dStruct.Order = "addtime desc";
  156. else dStruct.Order = "addtime asc";
  157. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  158. dStruct.Fileds = "id,parentid as pid,con,sex,addtime,(select count(0) from s_concealreply as c where c.parentid=view_concealreply.id) as rc,STUFF((select top 2 '§'+convert(varchar(20),addtime,120)+'№'+convert(varchar(1),sex)+'№'+con from view_concealreply as b where b.parentid=view_concealreply.id order by AddTime desc for xml path('')),1,1,'') as items";
  159. DataTable dt = WebCache.GetData("view_concealreply", dStruct);
  160. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  161. return;
  162. }
  163. }
  164. conError("错误的参数");
  165. }
  166. public void get_concealreplysec()
  167. {
  168. if (UrlPostParmsCheck("crid,cid"))
  169. {
  170. DataStruct dStruct = GetPostStruct();
  171. List<string> lw = new List<string>();
  172. int cid = GetPostInt("cid");
  173. int crid = GetPostInt("crid");
  174. //id = 92;
  175. int sort = GetPostInt("sort");
  176. lw.Add("ConcealID=" + cid);
  177. lw.Add("parentid=" + crid);
  178. //lw.Add("ParentID=0");
  179. if (sort == 1) dStruct.Order = "addtime desc";
  180. else dStruct.Order = "addtime asc";
  181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  182. dStruct.Fileds = "id,parentid as pid,con,addtime";
  183. DataTable dt = WebCache.GetData("s_concealreply", dStruct);
  184. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  185. return;
  186. }
  187. conError("错误的参数");
  188. }
  189. public void ins_concealreply()
  190. {
  191. int uid = getDecodeInt("uid");
  192. if (uid == 0)
  193. {
  194. conError("找不到会员");
  195. return;
  196. }
  197. if (UrlPostParmsCheck("cid,con"))
  198. {
  199. int cid = GetPostInt("cid");
  200. int pid = GetPostInt("pid");
  201. string con = GetPostString("con");
  202. string imgs = GetPostString("images");
  203. SConceal entity = SConceal.Get(cid);
  204. if (entity == null)
  205. {
  206. conError("找不到该贴!");
  207. return;
  208. }
  209. SConcealReply reply = new SConcealReply();
  210. reply.AddTime = DateTime.Now;
  211. reply.UserID = uid;
  212. reply.Con = con;
  213. reply.ParentID = pid;
  214. //reply.Images = imgs.TrimEnd(',');
  215. reply.ConcealID = cid;
  216. reply.Create();
  217. entity.replyNum += 1;
  218. entity.Update();
  219. //string bon = LotteryHelper.getLuckyWithUpdate("conceal_reply",uid,entity.ID);
  220. //if (bon != "" && bon != "0")
  221. //{
  222. // conSuccess("cg|" + GetDoubleString(bon) + "|己评论!");
  223. //}
  224. //else
  225. //{
  226. // conSuccess("己评论!");
  227. //}
  228. return;
  229. }
  230. conError("错误的参数");
  231. }
  232. public void ins_conceallike()
  233. {
  234. int uid = getDecodeInt("uid");
  235. if (uid == 0)
  236. {
  237. conError("找不到会员");
  238. return;
  239. }
  240. if (UrlPostParmsCheck("cid"))
  241. {
  242. int cid = GetPostInt("cid");
  243. try {
  244. SqlParameter[] sqlParameter ={
  245. new SqlParameter("@cid", SqlDbType.Int, 4),
  246. new SqlParameter("@uid", SqlDbType.Int, 4),
  247. new SqlParameter("@result",SqlDbType.NVarChar,100)};
  248. sqlParameter[0].Value = cid;
  249. sqlParameter[1].Value = uid;
  250. sqlParameter[2].Direction = ParameterDirection.Output;
  251. SConceal.ExecuteNonQueryStore("sp_ins_conceallike", sqlParameter);
  252. string result = sqlParameter[2].Value.ToString();
  253. if (result == "") result = "己点赞";
  254. conSuccess(result);
  255. return;
  256. }
  257. catch
  258. {
  259. conError("无法点赞!");
  260. return;
  261. }
  262. }
  263. conError("错误的参数");
  264. }
  265. public void del_conceal()
  266. {
  267. int uid = getDecodeInt("uid");
  268. if (uid == 0)
  269. {
  270. conError("找不到会员");
  271. return;
  272. }
  273. if(UrlPostParmsCheck("cid"))
  274. {
  275. int cid = GetPostInt("cid");
  276. SConceal.Del(uid, cid);
  277. conSuccess("己删除!");
  278. return;
  279. }
  280. conError("错误的参数");
  281. }
  282. }
  283. }