using PMS.BusinessModels.Account; using PMS.BusinessModels.ComplaintManage; using PMS.EntityModels.PersonManager; using PMS.Interface; using PMS.Interface.BaseCode; using PMS.Interface.ComplaintManage; using PMS.Interface.SysManager; using QWPlatform.SystemLibrary.Security; using QWPlatform.SystemLibrary.Web; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; using Newtonsoft.Json; using QWPlatform.SystemLibrary.Utils; namespace PMS.WebUI.Controllers { [CheckLogin("/MobileAccount/ComplaintLogin")] public class ComplaintController : BaseController { IComplaintList Complaint_List = InterfaceFactory.CreateBusinessInstance(); IBaseCode BaseCode_obj = InterfaceFactory.CreateBusinessInstance(); // GET: Complaint public ActionResult ComplaintUser() { return View(); } public ActionResult NewComplaint() { return View(); } public ActionResult QueryComplaint() { return View(); } public ActionResult ComplaintDetail(string id) { ViewBag.id = id; return View(); } /// /// 投诉登记 /// /// 种类 /// 标题 /// 描述 /// [HttpPost] public ActionResult ComplaintRegistration(string typeCode,string events,string detail) { var UserInfo = GetCurrentUser(); var r = Complaint_List.ComplaintRegistration( typeCode, events, detail, UserInfo.PersonID); if (!String.IsNullOrEmpty(r)) { return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, r, null).ToString(), "application/json"); } else { return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "投诉失败!请查看日志", null).ToString(), "application/json"); } } /// /// 上传投诉图片 /// /// 投诉ID /// public ActionResult ImageUpload(string CompliantID) { var result = "0"; var tt = this.Request.Files; var basePath = HttpRuntime.BinDirectory.TrimEnd('\\');// basePath = basePath.Substring(0, basePath.Length - 4);//移除\bin var date = DateTime.Now.ToString("yyyyMMdd"); var src = "/UploadFile/" + date + "/" + CompliantID + "/"; var path = basePath + "\\UploadFile\\" + date + "\\" + CompliantID + "\\"; if (this.Request.Files.Count > 0) { var uploadFile = this.Request.Files[0]; if (uploadFile != null) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path);//创建文件夹 } var fileName = uploadFile.FileName; var fileLen = uploadFile.ContentLength; byte[] fileContent = new byte[fileLen]; src += fileName; path += fileName; uploadFile.InputStream.Read(fileContent, 0, fileLen); System.IO.File.WriteAllBytes(path, fileContent); var r= Complaint_List.ImageUpload(CompliantID, src); if (r) { result = "1"; } } } return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, result, null).ToString(), "application/json"); } /// /// 上传图片到FTP /// /// /// public ActionResult ImageUploadFTP(string CompliantID) { var result = "0"; var files = this.Request.Files; if (this.Request.Files.Count > 0) { using (BinaryReader br = new BinaryReader(files[0].InputStream)) { byte[] byteData = br.ReadBytes((int)files[0].InputStream.Length); var uploadFile = files[0]; var fileName = uploadFile.FileName; var fileLen = uploadFile.ContentLength; string _tp = System.IO.Path.GetExtension(fileName); var UplodResult = UploadFile(byteData, fileName, _tp); if (UplodResult.code == 100) { ///数据库存储ID var Complete= Complaint_List.ImageUpload(CompliantID, UplodResult.data); if (Complete) { result = "1"; } } } } return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, result, null).ToString(), "application/json"); } /// /// 获取投诉种类Combobox /// /// /// public ActionResult GetCodeCombobox(string ClassificationID) { var json = BaseCode_obj.GetCodeCombobox(ClassificationID); return Content(json, "application/json"); } /// /// 根据ID获取投诉人详细信息 /// /// [HttpPost] public ActionResult GetCUserInfo() { var UserInfo = GetCurrentUser(); var json = Complaint_List.GetComplaintPerson(UserInfo.PersonID); return Content(json, "application/json"); } /// /// 个人投诉记录查询 /// /// 查询条件 /// public ActionResult QueryPersonelComplaint(QueryComplaintModel model) { var UserInfo = GetCurrentUser(); model.UserId = UserInfo.PersonID; var json = Complaint_List.QueryComplaint(model); return Content(json, "application/json"); } /// /// 通过ID获取投诉详情信息 /// /// 投诉ID /// public ActionResult GetComplaintDetail(string id) { var json = Complaint_List.GetComplaintDetail(id); return Content(json, "application/json"); } /// /// 撤销投诉 /// /// 投诉ID /// public ActionResult DeleteComplaint(string id) { var r = Complaint_List.DeleteComplaint(id); if (r) {//删除成功 return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "撤销成功", null).ToString(), "application/json"); } else {//删除失败 return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "撤销失败,投诉正在受理中!", null).ToString(), "application/json"); } } } }