/// <summary> /// 发表回复 /// </summary> /// <param name="replyInfo"></param> /// <returns></returns> public static bool CreateProductReviewReply(Product_ReplyDetail replyInfo, int SoSysNo) { string cacheKey = CommonFacade.GenerateKey("CreateProductReviewReply", replyInfo.Customer.SysNo.ToString(), replyInfo.ReviewSysNo.ToString()); DateTime now = DateTime.Now; int nowTimePoint = now.Hour * 3600 + now.Minute * 60 + now.Second; if (HttpRuntime.Cache[cacheKey] != null) { int preTimePoint = (int)HttpRuntime.Cache[cacheKey]; if (nowTimePoint - preTimePoint < 60) { throw new BusinessException("很抱歉,您发表评论的频率过快,请稍后再试。"); } } else { HttpRuntime.Cache.Insert(cacheKey, 0, null, DateTime.Now.AddSeconds(CacheTime.Shortest), Cache.NoSlidingExpiration); } bool result = ReviewDA.CreateProductReviewReply(replyInfo); //确认不需要发邮件 //if (result) //{ // SendMailReviewReply(replyInfo, SoSysNo); //} if (result) { now = DateTime.Now; nowTimePoint = now.Hour * 3600 + now.Minute * 60 + now.Second; HttpRuntime.Cache[cacheKey] = nowTimePoint; } return(result); }
/// <summary> /// 发表回复 /// </summary> /// <param name="replyInfo"></param> /// <returns></returns> public static bool CreateProductReviewReply(Product_ReplyDetail replyInfo) { DataCommand dataCommand = DataCommandManager.GetDataCommand("CreateProductReviewReply"); dataCommand.SetParameterValue("@ReviewSysNo", replyInfo.ReviewSysNo); dataCommand.SetParameterValue("@CustomerSysNo", replyInfo.Customer.SysNo); dataCommand.SetParameterValue("@Content", replyInfo.Content); SetCommandDefaultParameters(dataCommand); return(dataCommand.ExecuteNonQuery() > 0); }
/// <summary> /// 评论回复发邮件 /// </summary> public static void SendMailReviewReply(Product_ReplyDetail replyInfo, int sosysno) { AsyncEmail email = new AsyncEmail(); email.MailAddress = replyInfo.Customer.Email; email.CustomerID = replyInfo.Customer.CustomerID; email.Status = (int)EmailStatus.NotSend; email.ImgBaseUrl = ConfigurationManager.AppSettings["CDNWebDomain"].ToString(); string subject = string.Empty; email.MailBody = MailHelper.GetMailTemplateBody("ReviewReply", out subject); email.MailSubject = subject; email.MailBody = email.MailBody.Replace("[SOSysNo]", sosysno.ToString()) .Replace("[ImgBaseUrl]", email.ImgBaseUrl) .Replace("[WebBaseUrl]", ConstValue.WebDomain) .Replace("[CurrentDateTime]", DateTime.Now.ToString("yyyy-MM-dd")) .Replace("[ReplyContent]", StringUtility.RemoveHtmlTag(replyInfo.Content)); EmailDA.SendEmail(email); }
/// <summary> /// 发表回复 /// </summary> /// <param name="replyInfo"></param> /// <returns></returns> public JsonResult CreateProductReviewReply() { Product_ReplyDetail replyInfo = new Product_ReplyDetail(); replyInfo.ReviewSysNo = int.Parse(Request["ReviewSysNo"].ToString()); replyInfo.Content = Request["Content"].ToString(); replyInfo.Customer.SysNo = this.CurrUser.UserSysNo; int ProductSysNo = int.Parse(Request["ProductSysNo"].ToString()); replyInfo.Customer.CustomerID = this.CurrUser.UserID; int SoSysNo = int.Parse(Request["SOSysNo"].ToString()); replyInfo.Customer.Email = Request["Mail"].ToString(); bool IsSuccess = ReviewFacade.CreateProductReviewReply(replyInfo, SoSysNo); if (IsSuccess) { return(Json("1", JsonRequestBehavior.AllowGet)); } else { return(Json("发表评论失败!", JsonRequestBehavior.AllowGet)); } }