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 = ReplyHelper.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 : ((num3 == 1) ? MatchType.Like : MatchType.NoMatch) }; if (reply.Keys == "*") { reply.ReplyType = ReplyType.NoMatch; if (ReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { this.ShowMsg("无关键字回复回复内容已存在!", false); return; } } else if (this.type == "subscribe") { if (ReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复内容已存在!", false); return; } reply.ReplyType = ReplyType.Subscribe; reply.Keys = ""; } else { reply.ReplyType = ReplyType.Keys; if (ReplyHelper.HasReplyKey(reply.Keys, this.replyID)) { this.ShowMsg("该关键词已存在!", false); return; } } reply.MessageType = msgtype; reply.IsDisable = false; reply.ArticleID = articleIDByOldArticle; string str = Regex.Replace(Regex.Replace(Regex.Replace(this.fkContent.Text, "</?([^>^a^p]*)>", ""), "<img([^>]*)>", ""), "<ul([^>]*)>", ""); reply.Text = str; reply.Id = this.replyID; if (string.IsNullOrEmpty(reply.Text)) { this.ShowMsg("请填写文本内容!", false); return; } if (this.replyID > 0) { ReplyHelper.UpdateReply(reply); } else { ReplyHelper.SaveReply(reply); } goto Label_03D5; } this.ShowMsg("回复内容必须1000字以内!", false); return; case MessageType.News: case MessageType.List: info = new NewsReplyInfo { Keys = this.txtKeys.Text.Trim(), MatchType = (num3 == 2) ? MatchType.Equal : ((num3 == 1) ? MatchType.Like : MatchType.NoMatch) }; if (!(info.Keys == "*")) { if (this.type == "subscribe") { info.ReplyType = ReplyType.Subscribe; info.Keys = ""; if (ReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复已存在!", false); return; } } else { info.ReplyType = ReplyType.Keys; if (ReplyHelper.HasReplyKey(info.Keys, this.replyID)) { this.ShowMsg("该关键词已存在!", false); return; } } break; } info.ReplyType = ReplyType.NoMatch; if (ReplyHelper.GetNoMatchReplyID(this.replyID) <= 0) { break; } this.ShowMsg("无关键词回复已存在!", false); return; default: goto Label_03D5; } info.MessageType = msgtype; info.IsDisable = false; info.ArticleID = articleIDByOldArticle; info.Id = this.replyID; if (num3 < 1) { this.ShowMsg("请选择类型!", false); return; } if (this.replyID > 0) { ReplyHelper.UpdateReply(info); } else { ReplyHelper.SaveReply(info); } Label_03D5: if (this.replyID > 0) { this.ShowMsgAndReUrl("自动回复修改成功!", true, "replyonkey.aspx"); } else { this.ShowMsgAndReUrl("自动回复添加成功!", true, "replyonkey.aspx"); } }
protected void Page_Load(object sender, System.EventArgs e) { if (!base.IsPostBack) { if (this.type == "getarticleinfo") { base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; int num = Globals.RequestFormNum("articleid"); if (num > 0) { ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(num); if (articleInfo != null) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); switch (articleInfo.ArticleType) { case ArticleType.News: s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", ReplyEdit.String2Json(articleInfo.Title), "\",\"date\":\"", ReplyEdit.String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", ReplyEdit.String2Json(articleInfo.ImageUrl), "\",\"memo\":\"", ReplyEdit.String2Json(articleInfo.Memo), "\"}" }); goto IL_301; case ArticleType.List: { System.Collections.Generic.IList <ArticleItemsInfo> itemsInfo = articleInfo.ItemsInfo; foreach (ArticleItemsInfo current in itemsInfo) { stringBuilder.Append(string.Concat(new string[] { "{\"title\":\"", ReplyEdit.String2Json(current.Title), "\",\"imgurl\":\"", ReplyEdit.String2Json(current.ImageUrl), "\"}," })); } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", ReplyEdit.String2Json(articleInfo.Title), "\",\"date\":\"", ReplyEdit.String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", ReplyEdit.String2Json(articleInfo.ImageUrl), "\",\"items\":[", stringBuilder.ToString().Trim(new char[] { ',' }), "]}" }); goto IL_301; } } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", ReplyEdit.String2Json(articleInfo.Title), "\",\"date\":\"", ReplyEdit.String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", ReplyEdit.String2Json(articleInfo.ImageUrl), "\",\"memo\":\"", ReplyEdit.String2Json(articleInfo.Content), "\"}" }); } } IL_301: base.Response.Write(s); base.Response.End(); } else if (this.type == "subscribe" && this.replyID == 0) { this.replyID = ReplyHelper.GetSubscribeID(0); if (this.replyID > 0) { base.Response.Redirect("replyedit.aspx?type=subscribe&id=" + this.replyID); base.Response.End(); } this.rbtlMatchType.SelectedIndex = 0; if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } else { if (this.replyID > 0) { this.htmlTitle = "修改自动回复"; Hidistro.Entities.VShop.ReplyInfo reply = ReplyHelper.GetReply(this.replyID); if (reply != null) { MessageType messageType = reply.MessageType; if (ReplyType.NoMatch == reply.ReplyType) { this.txtKeys.Text = "*"; } else if (ReplyType.Subscribe == reply.ReplyType) { this.txtKeys.Text = ""; if (this.type != "subscribe") { base.Response.Redirect("replyedit.aspx?type=subscribe&id=" + this.replyID); base.Response.End(); } } else { this.txtKeys.Text = reply.Keys.Trim(); } for (int i = 0; i < this.rbtlMatchType.Items.Count; i++) { if (this.rbtlMatchType.Items[i].Value == ((int)reply.MatchType).ToString()) { this.rbtlMatchType.Items[i].Selected = true; break; } } this.hdfMessageType.Value = ((int)reply.MessageType).ToString(); this.hdfArticleID.Value = reply.ArticleID.ToString(); int articleID = reply.ArticleID; switch (messageType) { case MessageType.Text: { TextReplyInfo textReplyInfo = ReplyHelper.GetReply(this.replyID) as TextReplyInfo; if (textReplyInfo != null) { string text = textReplyInfo.Text; text = System.Text.RegularExpressions.Regex.Replace(text, "</?([^>^a^p]*)>", ""); text = System.Text.RegularExpressions.Regex.Replace(text, "<img([^>]*)>", ""); text = text.Replace("</p>", "\r\n"); text = text.Replace("<p>", ""); this.fkContent.Text = text; } break; } case MessageType.News: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.replyID) as NewsReplyInfo; if (newsReplyInfo != null && newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count != 0) { this.htmlInfo = string.Concat(new string[] { "<div class=\"mate-inner\"><h3 id=\"singelTitle\">", newsReplyInfo.NewsMsg[0].Title, "</h3><span>", newsReplyInfo.LastEditDate.ToString("M月d日"), "</span><div class=\"mate-img\"><img id=\"img1\" src=\"", newsReplyInfo.NewsMsg[0].PicUrl, "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">", newsReplyInfo.NewsMsg[0].Description, "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">></em></div></div>" }); } } break; case MessageType.List: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo2 = ReplyHelper.GetReply(this.replyID) as NewsReplyInfo; if (newsReplyInfo2 != null) { System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); if (newsReplyInfo2.NewsMsg != null && newsReplyInfo2.NewsMsg.Count > 0) { int num2 = 0; foreach (NewsMsgInfo current2 in newsReplyInfo2.NewsMsg) { num2++; if (num2 == 1) { stringBuilder2.Append(string.Concat(new string[] { "<div class=\"mate-inner top\"> <div class=\"mate-img\" > <img id=\"img1\" src=\"", current2.PicUrl, "\" class=\"img-responsive\"> <div class=\"title\" id=\"title1\">", current2.Title, "</div> </div> </div>" })); } else { stringBuilder2.Append(string.Concat(new string[] { " <div class=\"mate-inner\"> <div class=\"child-mate\"> <div class=\"child-mate-title clearfix\"> <div class=\"title\">", current2.Title, "</div> <div class=\"img\"> <img src=\"", current2.PicUrl, "\" class=\"img-responsive\"> </div> </div> </div> </div>" })); } } this.htmlInfo = stringBuilder2.ToString(); } } } break; } } else { base.Response.Redirect("replyonkey.aspx"); base.Response.End(); } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } if (ReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { for (int j = 0; j < this.rbtlMatchType.Items.Count; j++) { if (this.rbtlMatchType.Items[j].Value == "4") { this.rbtlMatchType.Items[j].Enabled = false; } } } } }
protected void Page_Load(object sender, EventArgs e) { if (base.IsPostBack) { return; } if (!(this.type == "getarticleinfo")) { if ((this.type == "subscribe") && (this.replyID == 0)) { this.replyID = ReplyHelper.GetSubscribeID(0); if (this.replyID > 0) { base.Response.Redirect("replyedit.aspx?type=subscribe&id=" + this.replyID); base.Response.End(); } this.rbtlMatchType.SelectedIndex = 0; if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } else { if (this.replyID > 0) { this.htmlTitle = "修改自动回复"; Hidistro.Entities.VShop.ReplyInfo reply = ReplyHelper.GetReply(this.replyID); if (reply == null) { base.Response.Redirect("replyonkey.aspx"); base.Response.End(); } else { MessageType messageType = reply.MessageType; if (ReplyType.NoMatch == reply.ReplyType) { this.txtKeys.Text = "*"; } else if (ReplyType.Subscribe == reply.ReplyType) { this.txtKeys.Text = ""; if (this.type != "subscribe") { base.Response.Redirect("replyedit.aspx?type=subscribe&id=" + this.replyID); base.Response.End(); } } else { this.txtKeys.Text = reply.Keys.Trim(); } for (int i = 0; i < this.rbtlMatchType.Items.Count; i++) { if (this.rbtlMatchType.Items[i].Value == ((int)reply.MatchType).ToString()) { this.rbtlMatchType.Items[i].Selected = true; break; } } this.hdfMessageType.Value = ((int)reply.MessageType).ToString(); this.hdfArticleID.Value = reply.ArticleID.ToString(); int articleID = reply.ArticleID; switch (messageType) { case MessageType.Text: { TextReplyInfo info7 = ReplyHelper.GetReply(this.replyID) as TextReplyInfo; if (info7 != null) { string str2 = Regex.Replace(Regex.Replace(info7.Text, "</?([^>^a^p]*)>", ""), "<img([^>]*)>", ""); this.fkContent.Text = str2; } break; } case MessageType.News: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo info6 = ReplyHelper.GetReply(this.replyID) as NewsReplyInfo; if (((info6 != null) && (info6.NewsMsg != null)) && (info6.NewsMsg.Count != 0)) { this.htmlInfo = "<div class=\"mate-inner\"><h3 id=\"singelTitle\">" + info6.NewsMsg[0].Title + "</h3><span>" + info6.LastEditDate.ToString("M月d日") + "</span><div class=\"mate-img\"><img id=\"img1\" src=\"" + info6.NewsMsg[0].PicUrl + "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">" + info6.NewsMsg[0].Description + "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">></em></div></div>"; } } break; case MessageType.List: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo info4 = ReplyHelper.GetReply(this.replyID) as NewsReplyInfo; if (info4 != null) { StringBuilder builder2 = new StringBuilder(); if ((info4.NewsMsg != null) && (info4.NewsMsg.Count > 0)) { int num4 = 0; foreach (NewsMsgInfo info5 in info4.NewsMsg) { num4++; if (num4 == 1) { builder2.Append("<div class=\"mate-inner top\"> <div class=\"mate-img\" > <img id=\"img1\" src=\"" + info5.PicUrl + "\" class=\"img-responsive\"> <div class=\"title\" id=\"title1\">" + info5.Title + "</div> </div> </div>"); } else { builder2.Append(" <div class=\"mate-inner\"> <div class=\"child-mate\"> <div class=\"child-mate-title clearfix\"> <div class=\"title\">" + info5.Title + "</div> <div class=\"img\"> <img src=\"" + info5.PicUrl + "\" class=\"img-responsive\"> </div> </div> </div> </div>"); } } this.htmlInfo = builder2.ToString(); } } } break; } } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } goto Label_0800; } base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; int articleid = Globals.RequestFormNum("articleid"); if (articleid > 0) { ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid); if (articleInfo != null) { StringBuilder builder = new StringBuilder(); switch (articleInfo.ArticleType) { case ArticleType.News: s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", String2Json(articleInfo.Title), "\",\"date\":\"", String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", String2Json(articleInfo.ImageUrl), "\",\"memo\":\"", String2Json(articleInfo.Memo), "\"}" }); goto Label_0301; case ArticleType.List: foreach (ArticleItemsInfo info2 in articleInfo.ItemsInfo) { builder.Append("{\"title\":\"" + String2Json(info2.Title) + "\",\"imgurl\":\"" + String2Json(info2.ImageUrl) + "\"},"); } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", String2Json(articleInfo.Title), "\",\"date\":\"", String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", String2Json(articleInfo.ImageUrl), "\",\"items\":[", builder.ToString().Trim(new char[] { ',' }), "]}" }); goto Label_0301; } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", String2Json(articleInfo.Title), "\",\"date\":\"", String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", String2Json(articleInfo.ImageUrl), "\",\"memo\":\"", String2Json(articleInfo.Content), "\"}" }); } } Label_0301: base.Response.Write(s); base.Response.End(); Label_0800: if (ReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { for (int j = 0; j < this.rbtlMatchType.Items.Count; j++) { if (this.rbtlMatchType.Items[j].Value == "4") { this.rbtlMatchType.Items[j].Enabled = false; } } } }
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 = ReplyHelper.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 : ((num3 == 1) ? MatchType.Like : MatchType.NoMatch)); if (textReplyInfo.Keys == "*") { textReplyInfo.ReplyType = ReplyType.NoMatch; if (ReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { this.ShowMsg("无关键字回复回复内容已存在!", false); return; } } else if (this.type == "subscribe") { if (ReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复内容已存在!", false); return; } textReplyInfo.ReplyType = ReplyType.Subscribe; textReplyInfo.Keys = ""; } else { textReplyInfo.ReplyType = ReplyType.Keys; if (ReplyHelper.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) { ReplyHelper.UpdateReply(textReplyInfo); } else { ReplyHelper.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 : ((num3 == 1) ? MatchType.Like : MatchType.NoMatch)); if (newsReplyInfo.Keys == "*") { newsReplyInfo.ReplyType = ReplyType.NoMatch; if (ReplyHelper.GetNoMatchReplyID(this.replyID) > 0) { this.ShowMsg("无关键词回复已存在!", false); return; } } else if (this.type == "subscribe") { newsReplyInfo.ReplyType = ReplyType.Subscribe; newsReplyInfo.Keys = ""; if (ReplyHelper.GetSubscribeID(this.replyID) > 0) { this.ShowMsg("首次关注回复已存在!", false); return; } } else { newsReplyInfo.ReplyType = ReplyType.Keys; if (ReplyHelper.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) { ReplyHelper.UpdateReply(newsReplyInfo); } else { ReplyHelper.SaveReply(newsReplyInfo); } break; } } if (this.replyID > 0) { this.ShowMsgAndReUrl("自动回复修改成功!", true, "replyonkey.aspx"); return; } this.ShowMsgAndReUrl("自动回复添加成功!", true, "replyonkey.aspx"); }