Ejemplo n.º 1
0
        public JsonResult DeleteFeedback(int id)
        {
            JsonModel    jm          = new JsonModel();
            IFeedbackBLL feedbackBll = BLLFactory <IFeedbackBLL> .GetBLL("FeedbackBLL");

            T_Feedback feedback = feedbackBll.GetEntity(u => u.Id == id);

            if (feedback != null)
            {
                if (feedbackBll.Delete(feedback))
                {
                    if (!string.IsNullOrEmpty(feedback.Img))
                    {
                        //删除图片
                        string[] Imgs = feedback.Img.Split(';');

                        for (int i = 0; i < Imgs.Count(); i++)
                        {
                            DelFile(Imgs[i]);
                        }
                    }
                    jm.Content = "删除意见反馈" + feedback.Content + "成功";
                }
            }
            else
            {
                jm.Msg = "该意见反馈不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult FeedbackList(FeedbackSearchModel model)
        {
            //初始化默认查询模型
            DateTime today = DateTime.Today;

            if (model.StartTime == null)
            {
                model.StartTime = today.AddDays(-today.Day + 1);
            }
            if (model.EndTime == null)
            {
                model.EndTime = today;
            }

            //根据提报时间查询
            DateTime endTime = model.EndTime.Value.AddDays(1);

            Expression <Func <T_Feedback, bool> > where = u => u.UploadTime >= model.StartTime.Value && u.UploadTime < endTime;

            //根据查询条件调用BLL层 获取分页数据
            IFeedbackBLL feedbackBll = BLLFactory <IFeedbackBLL> .GetBLL("FeedbackBLL");

            var sortName = this.SettingSorting("Id", false);

            model.DataList = feedbackBll.GetPageList(where, sortName.SortName, sortName.IsAsc, model.PageIndex) as PagedList <T_Feedback>;
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult FeedbackDetail(int id)
        {
            IFeedbackBLL feedbackBll = BLLFactory <IFeedbackBLL> .GetBLL("FeedbackBLL");

            T_Feedback feedback = feedbackBll.GetEntity(u => u.Id == id);

            if (feedback != null)
            {
                return(View(feedback));
            }
            else
            {
                return(RedirectToAction("FeedbackList"));
            }
        }
Ejemplo n.º 4
0
        public ApiResultModel AddFeedback(FeedbackModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户Id查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //如果业主不存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.result = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //意见反馈信息上传
                    T_Feedback feedback = new T_Feedback()
                    {
                        UserId     = model.UserId,
                        UploadTime = DateTime.Now,
                        Content    = model.Content
                    };

                    //意见反馈 图片保存目录
                    string directory = HttpContext.Current.Server.MapPath(ConstantParam.FEEDBACK);
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }

                    //意见反馈 图片上传
                    if (!string.IsNullOrEmpty(model.PicList))
                    {
                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".zip";
                        string filepath = Path.Combine(directory, fileName);

                        using (FileStream fs = new FileStream(filepath, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                byte[] datas = Convert.FromBase64String(model.PicList);
                                bw.Write(datas);
                                bw.Close();
                            }
                        }

                        //图片集保存路径
                        feedback.Img = PropertyUtils.UnZip(filepath, directory, ConstantParam.FEEDBACK);
                    }

                    //保存意见反馈
                    IFeedbackBLL feedbackBll = BLLFactory <IFeedbackBLL> .GetBLL("FeedbackBLL");

                    feedbackBll.Save(feedback);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }