Ejemplo n.º 1
0
        public ActionResult RemoveForm(string keyValue)
        {
            FeedbackEntity entity = new FeedbackEntity
            {
                IsDelete = true
            };

            feedbackbll.SaveForm(keyValue, entity, "0");
            return(Success("删除成功。"));
        }
Ejemplo n.º 2
0
 public ActionResult SaveForm(string keyValue, FeedbackEntity opinionEntity)
 {
     newsBLL.SaveForm(keyValue, opinionEntity);
     return(Success("操作成功。"));
 }
Ejemplo n.º 3
0
        public HttpResponseMessage SubmitFeedback(FeedbackArgEntity arg)
        {
            BaseJson <string> resultMsg = new BaseJson <string> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(CommonController), arg.TryToJson(), "意见反馈-SubmitFeedback", () =>
            {
                if (!string.IsNullOrEmpty(arg.t) && !string.IsNullOrEmpty(arg.VerificationCode))
                {
                    if (arg.t.CheckTimeStamp())
                    {
                        //string cacheCode = CookieHelper.GetCookie(GlobalStaticConstant.Session_Key_Verification_Code);
                        string cacheCode = Cache.Factory.CacheFactory.Cache().GetCache <string>(GlobalStaticConstant.Session_Key_Verification_Code + "_" + arg.VerificationCode.ToUpper());
                        //写入日志
                        _logHelper.Info("\r\n传入验证码为:" + arg.VerificationCode + ",缓存验证码为:" + cacheCode + "。\r\n");

                        if (!string.IsNullOrEmpty(cacheCode))
                        {
                            if (cacheCode.Equals(arg.VerificationCode.ToUpper()))
                            {
                                string ip = NetHelper.Ip;

                                FeedbackEntity entity = new FeedbackEntity
                                {
                                    NickName = arg.NickName.ReplaceHtmlTag().SqlFilters(),
                                    Contact  = arg.Contact.ReplaceHtmlTag().SqlFilters(),
                                    Content  = arg.Content.ReplaceHtmlTag().SqlFilters(),
                                    IP       = ip,
                                    From     = NetHelper.GetAddressByIP(ip)
                                };
                                int i = feedbackBll.SaveForm("", entity);
                                if (i > 0)
                                {
                                    //验证码使用后清除缓存
                                    Cache.Factory.CacheFactory.Cache().RemoveCache(GlobalStaticConstant.Session_Key_Verification_Code + "_" + arg.VerificationCode.ToUpper());

                                    //发送邮件提醒管理员
                                    string template = @"<table style='width: 100%;height: 100%;border-collapse:collapse'>
			                            <tr>
				                            <td>昵称:{0}</td>
			                            </tr>
			                            <tr>
				                            <td>联系方式:{1}</td>
			                            </tr>
			                            <tr>
				                            <td>反馈内容:{2}</td>
			                            </tr>
		                            </table>"        ;

                                    string res     = String.Format(template, arg.NickName, arg.Contact, arg.Content);
                                    string address = ConfigHelper.GetValue("ErrorReportTo");
                                    MailHelper.SendByThread(address, "来自【" + arg.NickName + "】意见反馈,请及时处理!", res.ToString());

                                    resultMsg = new BaseJson <string>
                                    {
                                        Status  = (int)JsonObjectStatus.Success,
                                        Data    = "意见保存成功!",
                                        Message = JsonObjectStatus.Success.GetEnumText(),
                                        BackUrl = null
                                    };
                                }
                                else
                                {
                                    resultMsg = new BaseJson <string>
                                    {
                                        Status  = (int)JsonObjectStatus.Fail,
                                        Data    = "",
                                        Message = JsonObjectStatus.Fail.GetEnumText(),
                                        BackUrl = null
                                    };
                                }
                            }
                            else
                            {
                                resultMsg = new BaseJson <string>
                                {
                                    Status  = (int)JsonObjectStatus.ValidateCodeErr,
                                    Data    = null,
                                    Message = JsonObjectStatus.ValidateCodeErr.GetEnumText(),
                                    BackUrl = null
                                };
                            }
                        }
                        else
                        {
                            resultMsg = new BaseJson <string>
                            {
                                Status  = (int)JsonObjectStatus.Fail,
                                Data    = null,
                                Message = JsonObjectStatus.Fail.GetEnumText() + ",验证码失效,请重新获取!",
                                BackUrl = null
                            };
                        }
                    }
                    else
                    {
                        resultMsg = new BaseJson <string>
                        {
                            Status  = (int)JsonObjectStatus.Fail,
                            Data    = null,
                            Message = JsonObjectStatus.Fail.GetEnumText() + ",无效参数。",
                            BackUrl = null
                        };
                    }
                }
                else
                {
                    resultMsg = new BaseJson <string>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数VerificationCode为空。",
                        BackUrl = null
                    };
                }
            }, e =>
            {
                resultMsg = new BaseJson <string>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }