private string SavePostData(int msgType, int articleid, string title, string content, int isoldarticle, int sendid, bool isonlycheck) { string str = string.Empty; if (string.IsNullOrEmpty(title)) { return("请输入标题!"); } MessageType msgtype = (MessageType)msgType; if ((articleid < 1) && (msgtype != MessageType.Text)) { if (isoldarticle == 0) { return("请先选择图文!"); } if ((sendid > 0) && !isonlycheck) { articleid = ReplyHelper.GetArticleIDByOldArticle(sendid, msgtype); } } if (!isonlycheck) { SendAllInfo sendAllInfo = new SendAllInfo(); if (sendid > 0) { sendAllInfo = WeiXinHelper.GetSendAllInfo(sendid); } sendAllInfo.Title = title; sendAllInfo.MessageType = msgtype; sendAllInfo.ArticleID = articleid; sendAllInfo.Content = content; sendAllInfo.SendState = 0; sendAllInfo.SendTime = DateTime.Now; sendAllInfo.SendCount = 0; sendAllInfo.wid = this.wid; int num = Globals.ToNum(WeiXinHelper.SaveSendAllInfo(sendAllInfo)); if (num == 0) { return("微信群发保存失败!"); } if (num > 0) { str = num.ToString(); } } return(str); }
private string SavePostData(int msgType, int articleid, string title, string content, int isoldarticle, int sendid, bool isonlycheck) { string result = string.Empty; if (string.IsNullOrEmpty(title)) { return("请输入标题!"); } if (articleid < 1 && msgType != 1) { if (isoldarticle == 0) { return("请先选择图文!"); } if (sendid > 0 && !isonlycheck) { articleid = ReplyHelper.GetArticleIDByOldArticle(sendid, (MessageType)msgType); } } if (!isonlycheck) { SendAllInfo sendAllInfo = new SendAllInfo(); if (sendid > 0) { sendAllInfo = WeiXinHelper.GetSendAllInfo(sendid); } sendAllInfo.Title = title; sendAllInfo.MessageType = (MessageType)msgType; sendAllInfo.ArticleID = articleid; sendAllInfo.Content = content; sendAllInfo.SendState = 0; sendAllInfo.SendTime = System.DateTime.Now; sendAllInfo.SendCount = 0; string s = WeiXinHelper.SaveSendAllInfo(sendAllInfo, 0); int num = Globals.ToNum(s); if (num == 0) { return("微信群发保存失败!"); } if (num > 0) { result = num.ToString(); } } return(result); }
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 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"); }