using BizCom; using SQLData; using System; using System.Collections.Generic; using System.Data; 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_expert() { DataStruct dStruct = GetPostStruct(); List lw = new List(); string key = GetPostString("key"); if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key)); dStruct.MainWhere = string.Join(" and ", lw.ToArray()); dStruct.Order = "sort asc"; DataTable dt = WebCache.GetData("s_expert", dStruct); conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); } public void upload_expert_imgs() { UserObj uo = GetUserEntity(); if (uo == null) return; int uid = uo.userid; string tag = GetPostString("tag"); 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.ToFileTimeUtc() + ".jpg"; string sourceExt = Path.GetExtension(postFile.FileName); if (sourceExt == ".gif") { fileName = uid + DateTime.Now.ToFileTimeUtc() + ".gif"; postFile.SaveAs(webConfig.expertPath + "\\" + fileName); } else { string saveFile = Path.Combine(webConfig.expertPath, fileName); string result = ""; using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream)) { result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 800, "", 9, 3); } } lstFile.Add(fileName); } } string fs = ""; if (lstFile.Count > 0) fs = string.Join(",", lstFile.ToArray()); conSuccess("上传成功", "{\"fname\":\"" + fs + "\"}"); } public void expert_question() { UserObj uo = GetUserEntity(); if (uo == null) return; int uid = uo.userid; if (UrlPostParmsCheck("eid,con")) { int eid = GetPostInt("eid"); string sex = GetPostString("sex"); string birthday = GetPostString("birthday"); string mobile = GetPostString("mobile"); string con = GetPostString("con"); con = con.Replace("\r\n", "
").Replace("\n", "
"); con = con.Replace(" ", " "); string images = GetPostString("images").TrimEnd(','); SExpertQuestion entity = new SExpertQuestion(); entity.AddTime = DateTime.Now; entity.UserID = uid; entity.ExpertID = eid; entity.Sex = sex; entity.Mobile = mobile; entity.BirthDay = birthday; entity.Con = con; entity.Imgs = images; entity.Create(); conSuccess("提交提问!"); return; } conError("错误的参数"); } public void get_expertquestion() { if (UrlPostParmsCheck("eid")) { int eid = GetPostInt("eid"); DataStruct dStruct = GetPostStruct(); List lw = new List(); lw.Add("ExpertID=" + eid); dStruct.Order = "addtime desc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); dStruct.Fileds = "id,nickname,userpic,con,repnum,imgs,addtime,sex,answer,ansmp3,mp3len,anstime,STUFF((select top 2 '§'+userpic+'№'+nickname+'№'+convert(varchar(20),addtime,120)+'№'+convert(varchar(1),sex)+'№'+con from view_expertquestionreply as b where b.questionid=view_expertquestion.id order by AddTime desc for xml path('')),1,1,'') as items"; DataTable dt = WebCache.GetData("view_expertquestion", dStruct); conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } } public void upload_expert_mp3() { UserObj uo = GetUserEntity(); if (uo == null) return; int uid = uo.userid; string tag = GetPostString("tag"); 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.CheckMp3(postFile, out errMsg)) { conError(errMsg); return; } // string fileName = uid + DateTime.Now.ToFileTimeUtc() + ".mp3"; //string sourceExt = Path.GetExtension(postFile.FileName); //fileName = uid + DateTime.Now.ToFileTimeUtc() + ".mp3"; postFile.SaveAs(webConfig.expertPath + "\\" + fileName); lstFile.Add(fileName); } } string fs = ""; if (lstFile.Count > 0) fs = string.Join(",", lstFile.ToArray()); conSuccess("上传成功", "{\"fname\":\"" + fs + "\"}"); } public void reply_expertquestion() { UserObj uo = GetUserEntity(); if (uo == null) return; int uid = uo.userid; if (UrlPostParmsCheck("qid")) { int qid = GetPostInt("qid"); string con = GetPostString("con"); string mp3 = GetPostString("mp3"); string mp3len = GetPostString("mp3len"); SExpertQuestion entity = SExpertQuestion.Get(qid);//,uo.expertid if (entity == null) { conError("只允许该专家回复!"); return; } else { entity.AnsMp3 = mp3; entity.Mp3Len = mp3len; entity.Answer = con; entity.AnsTime = DateTime.Now; entity.Update(); conSuccess("回复完成!"); return; } } conError("错误的参数"); } public void ins_expertquestionreply() { UserObj uo = GetUserEntity(); if (uo == null) return; int uid = uo.userid; int expid = uo.expertid; if (UrlPostParmsCheck("qid,con")) { successFlag = true; int qid = GetPostInt("qid"); int pid = GetPostInt("pid"); string con = GetPostString("con"); string imgs = GetPostString("images"); string mp3 = GetPostString("mp3"); SExpertQuestion entity = SExpertQuestion.Get(qid); if (entity == null) { conError("找不到问题!"); return; } if (entity.ExpertID == uo.expertid || uid == entity.UserID) { SExpertQuestionReply reply = new SExpertQuestionReply(); reply.AddTime = DateTime.Now; reply.ParentID = pid; reply.UserID = uid; reply.Con = con; reply.QuestionID = qid; reply.Mp3 = mp3; reply.Create(); entity.repNum += 1; entity.Update(); conSuccess("已回复"); return; } else { conError("只允许该问题的提问者及专家回复问题"); return; } //if(entity.ExpertID) } conError("错误的参数"); } public void get_expertquestionreply() { if(UrlPostParmsCheck("qid")) { int eid = GetPostInt("qid"); DataStruct dStruct = GetPostStruct(); List lw = new List(); lw.Add("QuestionID=" + eid); dStruct.Order = "addtime desc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); dStruct.Fileds = "id,nickname,userpic,con,addtime,0 as likenum,sex"; DataTable dt = WebCache.GetData("view_expertquestionreply", dStruct); conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } } } }