using BizCom; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; using Utils.ImageUtils; namespace SiteCore.Handler { public partial class app { public void get_concealtype() { DataTable dt = WebCache.GetConcealType(); conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); } public void get_conceal() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } DataStruct dStruct = GetPostStruct(); List lw = new List(); string tag = GetPostString("tag"); if (tag.Length > 0) { lw.Add(string.Format("tag like '%{0}%'", tag)); } int tid = GetPostInt("tid"); if (tid > 0) { lw.Add(string.Format(" typeid={0}", tid)); } lw.Add("duration<=0 or datediff(second,endtime,getdate())<=0"); //lw.Add(" duration<=0 or datediff(minute,endtime,getdate())<=0 ") //lw.Add("state=1"); dStruct.MainWhere = string.Join(" and ", lw.ToArray()); 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"; dStruct.Order = "pubtime desc"; DataTable dt = WebCache.GetData("s_conceal", dStruct); string con = ""; foreach(DataRow dr in dt.Rows) { con = dr["con"].ToString(); dr["con"]= con.Replace(" ", " ").Replace("
", "\n"); } conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } public void upload_concealimg() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } HttpPostedFile postFile = null; List lstFile = new List(); int c = con.Request.Files.Count; if (c > 0) { for (int i = 0; i < c; i++) { string errMsg = ""; postFile = con.Request.Files[i]; if (!ImageHandler.CheckImage(postFile, out errMsg)) { conError(errMsg); return; } string fileName = uid + DateTime.Now.ToString("MMddHHmmssfff") + ".jpg"; string saveFile = Path.Combine(webConfig.conPath, fileName); string result = ""; using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream)) { result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 600, "", 9, 3); } lstFile.Add(fileName); } } string fs = ""; if (lstFile.Count > 0) fs = string.Join(",", lstFile.ToArray()); conSuccess("上传成功", "{\"fname\":\"" + fs + "\"}"); } public void ins_conceal() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("con")) { int tid = GetPostInt("tid"); string tag = GetPostString("tag"); string con = GetPostString("con"); double dur = GetPostDouble("dur"); string imgs = GetPostString("imgs"); con = con.Replace("\r\n", "
").Replace("\n", "
"); con = con.Replace(" ", " "); SConceal entity = new SConceal(); entity.PubTime = DateTime.Now; entity.UserID = uid; entity.TypeID = tid; entity.Tag = tag; entity.Con = con; entity.Imgs = imgs; if (dur > 0) { entity.Duration = dur; entity.EndTime = DateTime.Now.AddMinutes(dur); } entity.Create(); if (dur <= 0) { //string bon = LotteryHelper.getLuckyWithUpdate("conceal", uid, entity.ID); //if (bon != "" && bon != "0") //{ // conSuccess("cg|" +GetDoubleString(bon) + "|己发送!"); //} //else //{ // conSuccess("己发送!"); //} } else { conSuccess("己发送!"); } return; } conError("错误的参数"); } public void get_concealreply() { if (UrlPostParmsCheck("cid")) { DataStruct dStruct = GetPostStruct(); List lw = new List(); int id = GetPostInt("cid"); //id = 92; int sort = GetPostInt("sort"); if (id > 0) { lw.Add("ConcealID=" + id); lw.Add("ParentID=0"); if (sort == 1) dStruct.Order = "addtime desc"; else dStruct.Order = "addtime asc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); 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"; DataTable dt = WebCache.GetData("view_concealreply", dStruct); conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } } conError("错误的参数"); } public void get_concealreplysec() { if (UrlPostParmsCheck("crid,cid")) { DataStruct dStruct = GetPostStruct(); List lw = new List(); int cid = GetPostInt("cid"); int crid = GetPostInt("crid"); //id = 92; int sort = GetPostInt("sort"); lw.Add("ConcealID=" + cid); lw.Add("parentid=" + crid); //lw.Add("ParentID=0"); if (sort == 1) dStruct.Order = "addtime desc"; else dStruct.Order = "addtime asc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); dStruct.Fileds = "id,parentid as pid,con,addtime"; DataTable dt = WebCache.GetData("s_concealreply", dStruct); conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } conError("错误的参数"); } public void ins_concealreply() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("cid,con")) { int cid = GetPostInt("cid"); int pid = GetPostInt("pid"); string con = GetPostString("con"); string imgs = GetPostString("images"); SConceal entity = SConceal.Get(cid); if (entity == null) { conError("找不到该贴!"); return; } SConcealReply reply = new SConcealReply(); reply.AddTime = DateTime.Now; reply.UserID = uid; reply.Con = con; reply.ParentID = pid; //reply.Images = imgs.TrimEnd(','); reply.ConcealID = cid; reply.Create(); entity.replyNum += 1; entity.Update(); //string bon = LotteryHelper.getLuckyWithUpdate("conceal_reply",uid,entity.ID); //if (bon != "" && bon != "0") //{ // conSuccess("cg|" + GetDoubleString(bon) + "|己评论!"); //} //else //{ // conSuccess("己评论!"); //} return; } conError("错误的参数"); } public void ins_conceallike() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("cid")) { int cid = GetPostInt("cid"); try { SqlParameter[] sqlParameter ={ new SqlParameter("@cid", SqlDbType.Int, 4), new SqlParameter("@uid", SqlDbType.Int, 4), new SqlParameter("@result",SqlDbType.NVarChar,100)}; sqlParameter[0].Value = cid; sqlParameter[1].Value = uid; sqlParameter[2].Direction = ParameterDirection.Output; SConceal.ExecuteNonQueryStore("sp_ins_conceallike", sqlParameter); string result = sqlParameter[2].Value.ToString(); if (result == "") result = "己点赞"; conSuccess(result); return; } catch { conError("无法点赞!"); return; } } conError("错误的参数"); } public void del_conceal() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if(UrlPostParmsCheck("cid")) { int cid = GetPostInt("cid"); SConceal.Del(uid, cid); conSuccess("己删除!"); return; } conError("错误的参数"); } } }