| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- 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<string> lw = new List<string>();
- 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("<br>", "\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<string> lstFile = new List<string>();
- 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", "<br>").Replace("\n", "<br>");
- 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<string> lw = new List<string>();
- 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<string> lw = new List<string>();
- 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("错误的参数");
- }
- }
- }
|