protected void btnSave_Click(object sender, EventArgs e) { NewsReplyInfo info; int num = Globals.ToNum(this.hdfMessageType.Value); int articleIDByOldArticle = Globals.ToNum(this.hdfArticleID.Value); MessageType msgtype = (MessageType)num; int num3 = Globals.ToNum(this.rbtlMatchType.SelectedValue); if (string.IsNullOrEmpty(this.txtKeys.Text.Trim()) && (this.type != "subscribe")) { this.ShowMsg("请输入关键词!", false); return; } if (this.txtKeys.Text.Trim().Length > 50) { this.ShowMsg("关键词必须少于50个字!", false); return; } if (num3 == 0) { this.ShowMsg("请选择匹配类型!", false); return; } if ((articleIDByOldArticle < 1) && (msgtype != MessageType.Text)) { if (this.hdfIsOldArticle.Value == "0") { this.ShowMsg("请先选择图文!", false); return; } if (this.replyID > 0) { articleIDByOldArticle = AliFuwuReplyHelper.GetArticleIDByOldArticle(this.replyID, msgtype); } } switch (msgtype) { case MessageType.Text: if (this.fkContent.Text.Length <= 0x3e8) { TextReplyInfo reply = new TextReplyInfo { Keys = this.txtKeys.Text.Trim(), MatchType = (num3 == 2) ? MatchType.Equal : MatchType.Like }; if (reply.Keys == "*") { reply.ReplyType = ReplyType.NoMatch; if (AliFuwuReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { this.ShowMsg("无关键字回复回复内容已存在!", false); return; } } else if (this.type == "subscribe") { if (AliFuwuReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复内容已存在!", false); return; } reply.ReplyType = ReplyType.Subscribe; reply.Keys = ""; } else { reply.ReplyType = ReplyType.Keys; if (AliFuwuReplyHelper.HasReplyKey(reply.Keys, this.replyID)) { this.ShowMsg("该关键词已存在!", false); return; } } reply.MessageType = msgtype; reply.IsDisable = false; reply.ArticleID = articleIDByOldArticle; string str = Regex.Replace(Regex.Replace(this.fkContent.Text, "</?([^>^a^p]*)>", ""), "<img([^>]*)>", "").Replace("<p>", "").Replace("</p>", "\r").Trim(new char[] { '\r' }).Replace("\r", "\r\n"); reply.Text = str; reply.Id = this.replyID; if (string.IsNullOrEmpty(reply.Text)) { this.ShowMsg("请填写文本内容!", false); return; } if (this.replyID > 0) { AliFuwuReplyHelper.UpdateReply(reply); } else { AliFuwuReplyHelper.SaveReply(reply); } goto Label_0406; } this.ShowMsg("回复内容必须1000字以内!", false); return; case MessageType.News: case MessageType.List: info = new NewsReplyInfo { Keys = this.txtKeys.Text.Trim(), MatchType = (num3 == 2) ? MatchType.Equal : MatchType.Like }; if (!(info.Keys == "*")) { if (this.type == "subscribe") { info.ReplyType = ReplyType.Subscribe; info.Keys = ""; if (AliFuwuReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复已存在!", false); return; } } else { info.ReplyType = ReplyType.Keys; if (AliFuwuReplyHelper.HasReplyKey(info.Keys, this.replyID)) { this.ShowMsg("该关键词已存在!", false); return; } } break; } info.ReplyType = ReplyType.NoMatch; if (AliFuwuReplyHelper.GetNoMatchReplyID(this.replyID) <= 0) { break; } this.ShowMsg("无关键词回复已存在!", false); return; default: goto Label_0406; } info.MessageType = msgtype; info.IsDisable = false; info.ArticleID = articleIDByOldArticle; info.Id = this.replyID; if (num3 < 1) { this.ShowMsg("请选择类型!", false); return; } if (this.replyID > 0) { AliFuwuReplyHelper.UpdateReply(info); } else { AliFuwuReplyHelper.SaveReply(info); } Label_0406: if (this.replyID > 0) { this.ShowMsgAndReUrl("自动回复修改成功!", true, "replyonkey.aspx"); } else { this.ShowMsgAndReUrl("自动回复添加成功!", true, "replyonkey.aspx"); } }
protected void btnSave_Click(object sender, System.EventArgs e) { int num = Globals.ToNum(this.hdfMessageType.Value); int num2 = Globals.ToNum(this.hdfArticleID.Value); MessageType messageType = (MessageType)num; int num3 = Globals.ToNum(this.rbtlMatchType.SelectedValue); if (string.IsNullOrEmpty(this.txtKeys.Text.Trim()) && this.type != "subscribe") { this.ShowMsg("请输入关键词!", false); return; } if (this.txtKeys.Text.Trim().Length > 50) { this.ShowMsg("关键词必须少于50个字!", false); return; } if (num3 == 0) { this.ShowMsg("请选择匹配类型!", false); return; } if (num2 < 1 && messageType != MessageType.Text) { if (this.hdfIsOldArticle.Value == "0") { this.ShowMsg("请先选择图文!", false); return; } if (this.replyID > 0) { num2 = AliFuwuReplyHelper.GetArticleIDByOldArticle(this.replyID, messageType); } } switch (messageType) { case MessageType.Text: { if (this.fkContent.Text.Length > 1000) { this.ShowMsg("回复内容必须1000字以内!", false); return; } TextReplyInfo textReplyInfo = new TextReplyInfo(); textReplyInfo.Keys = this.txtKeys.Text.Trim(); textReplyInfo.MatchType = ((num3 == 2) ? MatchType.Equal : MatchType.Like); if (textReplyInfo.Keys == "*") { textReplyInfo.ReplyType = ReplyType.NoMatch; if (AliFuwuReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { this.ShowMsg("无关键字回复回复内容已存在!", false); return; } } else if (this.type == "subscribe") { if (AliFuwuReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复内容已存在!", false); return; } textReplyInfo.ReplyType = ReplyType.Subscribe; textReplyInfo.Keys = ""; } else { textReplyInfo.ReplyType = ReplyType.Keys; if (AliFuwuReplyHelper.HasReplyKey(textReplyInfo.Keys, this.replyID)) { this.ShowMsg("该关键词已存在!", false); return; } } textReplyInfo.MessageType = messageType; textReplyInfo.IsDisable = false; textReplyInfo.ArticleID = num2; string text = this.fkContent.Text; text = System.Text.RegularExpressions.Regex.Replace(text, "</?([^>^a^p]*)>", ""); text = System.Text.RegularExpressions.Regex.Replace(text, "<img([^>]*)>", ""); text = text.Replace("<p>", ""); text = text.Replace("</p>", "\r"); text = text.Trim(new char[] { '\r' }); text = text.Replace("\r", "\r\n"); textReplyInfo.Text = text; textReplyInfo.Id = this.replyID; if (string.IsNullOrEmpty(textReplyInfo.Text)) { this.ShowMsg("请填写文本内容!", false); return; } if (this.replyID > 0) { AliFuwuReplyHelper.UpdateReply(textReplyInfo); } else { AliFuwuReplyHelper.SaveReply(textReplyInfo); } break; } case MessageType.News: case MessageType.List: { NewsReplyInfo newsReplyInfo = new NewsReplyInfo(); newsReplyInfo.Keys = this.txtKeys.Text.Trim(); newsReplyInfo.MatchType = ((num3 == 2) ? MatchType.Equal : MatchType.Like); if (newsReplyInfo.Keys == "*") { newsReplyInfo.ReplyType = ReplyType.NoMatch; if (AliFuwuReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { this.ShowMsg("无关键词回复已存在!", false); return; } } else if (this.type == "subscribe") { newsReplyInfo.ReplyType = ReplyType.Subscribe; newsReplyInfo.Keys = ""; if (AliFuwuReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复已存在!", false); return; } } else { newsReplyInfo.ReplyType = ReplyType.Keys; if (AliFuwuReplyHelper.HasReplyKey(newsReplyInfo.Keys, this.replyID)) { this.ShowMsg("该关键词已存在!", false); return; } } newsReplyInfo.MessageType = messageType; newsReplyInfo.IsDisable = false; newsReplyInfo.ArticleID = num2; newsReplyInfo.Id = this.replyID; if (num3 < 1) { this.ShowMsg("请选择类型!", false); return; } if (this.replyID > 0) { AliFuwuReplyHelper.UpdateReply(newsReplyInfo); } else { AliFuwuReplyHelper.SaveReply(newsReplyInfo); } break; } } if (this.replyID > 0) { this.ShowMsgAndReUrl("自动回复修改成功!", true, "replyonkey.aspx"); return; } this.ShowMsgAndReUrl("自动回复添加成功!", true, "replyonkey.aspx"); }