Ejemplo n.º 1
0
        public ActionResult Create(FeedBackView feedBackView)
        {
            string strContent = feedBackView.Content;
            string lillyId    = ViewBag.LillyId;

            if (string.IsNullOrEmpty(strContent) || strContent.Trim().Length < 5)
            {
                return(Json(new { str = "Insert Failed.", msg = "请输入您的问题,并且至少5个字符哦。" }));
            }

            if (strContent.Length > 500)
            {
                return(Json(new { str = "Insert Failed.", msg = "您的问题太长啦,老板日理万机,没空看哦。" }));
            }

            if (string.IsNullOrEmpty(lillyId))
            {
                return(Redirect("/notauthed.html"));
            }

            feedBackView.FeedBackUserId   = lillyId;
            feedBackView.FeedBackDateTime = DateTime.Now;

            _BaseService.InsertView(feedBackView);
            var feedback = _objService.feedbackList();

            if (feedback == null)
            {
                return(ErrorNotification("Sysconfig表中feedback字段值为空!"));
            }
            var feedbackInfo = feedback.Where(x => x.menuKey == "DEFAULT").FirstOrDefault();

            if (feedbackInfo == null)
            {
                return(ErrorNotification("Sysconfig表中未找到menukey:DEFAULT的数据!"));
            }
            if (!string.IsNullOrEmpty(feedbackInfo.Email))
            {
                var emailList = _objService.EmailList(feedbackInfo.Email);
                var emailInfo = emailList.Where(x => x.Appid == feedBackView.AppID.ToString() &&
                                                x.menuCode == feedBackView.MenuCode).FirstOrDefault();
                if (emailInfo == null)
                {
                    return(ErrorNotification("Sysconfig表中未找到menukey:emailInfo的数据!"));
                }
                if (!string.IsNullOrEmpty(emailInfo.EmailCode))
                {
                    SendITFeedbackMailForApply(emailInfo.EmailCode, feedBackView.Content, feedBackView.AppID.ToString(), feedBackView.MenuCode);
                }
            }
            return(Json(new { str = "Insert Success.", msg = feedbackInfo.hint }));
        }