| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- 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<string> lw = new List<string>();
- 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<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.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", "<br>").Replace("\n", "<br>");
- 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<string> lw = new List<string>();
- 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<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.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<string> lw = new List<string>();
- 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;
- }
- }
- }
- }
|