public async Task <JsonResult> GetClientFull([FromHeader] string Authorization) { var user = (from aa in _context.Clients join bb in _context.Tokens on aa.id_user equals bb.user_id join cc in _context.conctereDays on aa.id equals cc.client_id select cc).ToList(); if (user.Count == 0) { return(new JsonResult(_responce.Return_Responce(System.Net.HttpStatusCode.NotFound, null, null))); } var client = await _context.Clients.FindAsync(user[0].client_id); List <SendAllInfo> send = new List <SendAllInfo>(); foreach (var a in user) { var serv = await _context.Services.FindAsync(a.services_id); var temp = new SendAllInfo { services_name = serv.name, end_dttm = a.dttm_end, start_dttm = a.dttm_start, comment_service = a.services_comment, iscanceled = a.iscanceled, comment_client = a.comment }; send.Add(temp); } return(new JsonResult(_responce.Return_Responce(System.Net.HttpStatusCode.OK, send, null))); }
public SendAllInfo GetSendAllInfo(int sendID) { SendAllInfo info = null; if (sendID > 0) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM WeiXin_SendAll WHERE ID = @ID"); this.database.AddInParameter(sqlStringCommand, "ID", DbType.Int32, sendID); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { info = new SendAllInfo(); if (!reader.Read()) { return(info); } info.Id = sendID; info.Title = reader["Title"].ToString(); object obj2 = reader["MessageType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.MessageType = (MessageType)obj2; } obj2 = reader["ArticleID"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.ArticleID = (int)obj2; } info.Content = reader["Content"].ToString(); obj2 = reader["SendState"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.SendState = (int)obj2; } obj2 = reader["SendTime"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.SendTime = (DateTime)obj2; } obj2 = reader["SendCount"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.SendCount = (int)obj2; } obj2 = reader["msgid"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.MsgID = obj2.ToString(); } } } return(info); }
public SendAllInfo GetSendAllInfo(int sendID) { SendAllInfo sendAllInfo = null; if (sendID > 0) { System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM WeiXin_SendAll WHERE ID = @ID"); this.database.AddInParameter(sqlStringCommand, "ID", System.Data.DbType.Int32, sendID); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { sendAllInfo = new SendAllInfo(); if (dataReader.Read()) { sendAllInfo.Id = sendID; sendAllInfo.Title = dataReader["Title"].ToString(); object obj = dataReader["MessageType"]; if (obj != null && obj != DBNull.Value) { sendAllInfo.MessageType = (MessageType)obj; } obj = dataReader["ArticleID"]; if (obj != null && obj != DBNull.Value) { sendAllInfo.ArticleID = (int)obj; } sendAllInfo.Content = dataReader["Content"].ToString(); obj = dataReader["SendState"]; if (obj != null && obj != DBNull.Value) { sendAllInfo.SendState = (int)obj; } obj = dataReader["SendTime"]; if (obj != null && obj != DBNull.Value) { sendAllInfo.SendTime = (DateTime)obj; } obj = dataReader["SendCount"]; if (obj != null && obj != DBNull.Value) { sendAllInfo.SendCount = (int)obj; } obj = dataReader["msgid"]; if (obj != null && obj != DBNull.Value) { sendAllInfo.MsgID = obj.ToString(); } } } } return(sendAllInfo); }
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); }
public string SaveSendAllInfo(SendAllInfo sendAllInfo) { string str = string.Empty; DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO WeiXin_SendAll (Title,MessageType,ArticleID,Content,SendState,SendTime,SendCount,wid) VALUES(@Title,@MessageType,@ArticleID,@Content,@SendState,@SendTime,@SendCount,@wid);select @@identity"); this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, sendAllInfo.Title); this.database.AddInParameter(sqlStringCommand, "MessageType", DbType.Int32, (int)sendAllInfo.MessageType); this.database.AddInParameter(sqlStringCommand, "ArticleID", DbType.Int32, sendAllInfo.ArticleID); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, sendAllInfo.Content); this.database.AddInParameter(sqlStringCommand, "SendState", DbType.Int32, sendAllInfo.SendState); this.database.AddInParameter(sqlStringCommand, "SendTime", DbType.DateTime, DateTime.Now.ToString()); this.database.AddInParameter(sqlStringCommand, "SendCount", DbType.Int32, sendAllInfo.SendCount); this.database.AddInParameter(sqlStringCommand, "wid", DbType.String, sendAllInfo.wid); int num = Globals.ToNum(this.database.ExecuteScalar(sqlStringCommand)); if (num > 0) { str = num.ToString(); } return(str); }
protected void Page_Load(object sender, EventArgs e) { string str2; if (base.IsPostBack) { return; } if (!(this.type == "getarticleinfo")) { if (!(this.type == "postdata")) { if (this.sendID > 0) { this.hdfSendID.Value = this.sendID.ToString(); SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID); if (sendAllInfo != null) { MessageType messageType = sendAllInfo.MessageType; this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString(); int articleID = sendAllInfo.ArticleID; this.hdfArticleID.Value = articleID.ToString(); this.txtTitle.Text = sendAllInfo.Title; switch (messageType) { case MessageType.Text: this.fkContent.Text = sendAllInfo.Content; break; case MessageType.News: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo reply = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo; if (((reply != null) && (reply.NewsMsg != null)) && (reply.NewsMsg.Count != 0)) { this.htmlInfo = "<div class=\"mate-inner\"><h3 id=\"singelTitle\">" + reply.NewsMsg[0].Title + "</h3><span>" + reply.LastEditDate.ToString("M月d日") + "</span><div class=\"mate-img\"><img id=\"img1\" src=\"" + reply.NewsMsg[0].PicUrl + "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">" + reply.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 info6 = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo; if (info6 != null) { StringBuilder builder2 = new StringBuilder(); if ((info6.NewsMsg != null) && (info6.NewsMsg.Count > 0)) { int num15 = 0; foreach (NewsMsgInfo info7 in info6.NewsMsg) { num15++; if (num15 == 1) { builder2.Append("<div class=\"mate-inner top\"> <div class=\"mate-img\" > <img id=\"img1\" src=\"" + info7.PicUrl + "\" class=\"img-responsive\"> <div class=\"title\" id=\"title1\">" + info7.Title + "</div> </div> </div>"); } else { builder2.Append(" <div class=\"mate-inner\"> <div class=\"child-mate\"> <div class=\"child-mate-title clearfix\"> <div class=\"title\">" + info7.Title + "</div> <div class=\"img\"> <img src=\"" + info7.PicUrl + "\" class=\"img-responsive\"> </div> </div> </div> </div>"); } } this.htmlInfo = builder2.ToString(); } } } break; } } else { base.Response.Redirect("sendalllist.aspx"); base.Response.End(); } } else if (this.LocalArticleID > 0) { ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.LocalArticleID); if (articleInfo != null) { this.hdfArticleID.Value = this.LocalArticleID.ToString(); this.hdfMessageType.Value = ((int)articleInfo.ArticleType).ToString(); } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; return; } base.Response.ContentType = "application/json"; str2 = "{\"type\":\"1\",\"tips\":\"操作成功\"}"; this.sendID = Globals.RequestFormNum("sendid"); int num2 = Globals.RequestFormNum("sendtype"); int msgType = Globals.RequestFormNum("msgtype"); int num4 = Globals.RequestFormNum("articleid"); string title = Globals.RequestFormStr("title"); string content = Globals.RequestFormStr("content"); int isoldarticle = Globals.RequestFormNum("isoldarticle"); string str5 = this.SavePostData(msgType, num4, title, content, isoldarticle, this.sendID, true); if (!string.IsNullOrEmpty(str5)) { str2 = "{\"type\":\"0\",\"tips\":\"" + str5 + "\"}"; } else { MessageType type = (MessageType)msgType; string str6 = string.Empty; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); string str7 = JsonConvert.DeserializeObject <Token>(TokenApi.GetToken(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret)).access_token; switch (type) { case MessageType.News: case MessageType.List: { bool flag = true; ArticleInfo info3 = ArticleHelper.GetArticleInfo(num4); if (info3.MediaId.Length < 1) { string jsonValue = NewsApi.GetJsonValue(NewsApi.GetMedia_IDByPath(str7, info3.ImageUrl), "media_id"); if (string.IsNullOrEmpty(jsonValue)) { flag = false; str2 = "{\"type\":\"2\",\"tips\":\"" + NewsApi.GetErrorCodeMsg(NewsApi.GetJsonValue(jsonValue, "errcode")) + "111111\"}"; } else { ArticleHelper.UpdateMedia_Id(0, info3.ArticleId, jsonValue); } } if (type == MessageType.List) { foreach (ArticleItemsInfo info4 in info3.ItemsInfo) { if ((info4.MediaId == null) || (info4.MediaId.Length < 1)) { string msg = NewsApi.GetMedia_IDByPath(str7, info4.ImageUrl); string mediaid = NewsApi.GetJsonValue(msg, "media_id"); if (mediaid.Length == 0) { this.errcode = NewsApi.GetJsonValue(msg, "errcode"); msg = ""; flag = false; str2 = "{\"type\":\"2\",\"tips\":\"" + NewsApi.GetErrorCodeMsg(this.errcode) + "\"}"; break; } ArticleHelper.UpdateMedia_Id(1, info4.Id, mediaid); } } } if (flag) { string articlesJsonStr = this.GetArticlesJsonStr(info3); string str12 = NewsApi.UploadNews(str7, articlesJsonStr); this.sendID = Globals.ToNum(this.SavePostData(msgType, num4, title, content, isoldarticle, this.sendID, false)); string str13 = NewsApi.GetJsonValue(str12, "media_id"); if (str13.Length > 0) { if (num2 == 1) { str6 = NewsApi.SendAll(str7, NewsApi.CreateImageNewsJson(str13)); if (!string.IsNullOrWhiteSpace(str6)) { string str14 = NewsApi.GetJsonValue(str6, "msg_id"); if (!string.IsNullOrEmpty(str14)) { WeiXinHelper.UpdateMsgId(this.sendID, str14, 0, 0, 0, ""); } else { this.errcode = NewsApi.GetJsonValue(str6, "errcode"); string errorCodeMsg = NewsApi.GetErrorCodeMsg(this.errcode); WeiXinHelper.UpdateMsgId(this.sendID, str14, 2, 0, 0, errorCodeMsg); str2 = "{\"type\":\"2\",\"tips\":\"" + errorCodeMsg + "!!\"}"; } } else { str2 = "{\"type\":\"2\",\"tips\":\"type参数错误\"}"; } } else { DataTable rencentOpenID = WeiXinHelper.GetRencentOpenID(100); int count = rencentOpenID.Rows.Count; int sendcount = 0; string returnjsondata = string.Empty; for (int i = 0; i < rencentOpenID.Rows.Count; i++) { string str17 = NewsApi.KFSend(str7, this.GetKFSendImageJson(rencentOpenID.Rows[i][0].ToString(), info3)); this.errcode = NewsApi.GetJsonValue(str17, "errcode"); if (this.errcode == "0") { sendcount++; } else { returnjsondata = NewsApi.GetErrorCodeMsg(this.errcode); } } int sendstate = (sendcount > 0) ? 1 : 2; WeiXinHelper.UpdateMsgId(this.sendID, "", sendstate, sendcount, count, returnjsondata); } } else { this.errcode = NewsApi.GetJsonValue(str12, "errcode"); str2 = "{\"type\":\"2\",\"tips\":\"" + NewsApi.GetErrorCodeMsg(this.errcode) + "!\"}"; } } goto Label_091D; } } this.sendID = Globals.ToNum(this.SavePostData(msgType, num4, title, content, isoldarticle, this.sendID, false)); if (num2 == 1) { str6 = NewsApi.SendAll(str7, this.CreateTxtNewsJson(content)); if (!string.IsNullOrWhiteSpace(str6)) { string msgid = NewsApi.GetJsonValue(str6, "msg_id"); if (msgid.Length == 0) { this.errcode = NewsApi.GetJsonValue(str6, "errcode"); string str19 = NewsApi.GetErrorCodeMsg(this.errcode); WeiXinHelper.UpdateMsgId(this.sendID, msgid, 2, 0, 0, str19); str2 = "{\"type\":\"2\",\"tips\":\"" + str19 + "\"}"; } else { WeiXinHelper.UpdateMsgId(this.sendID, msgid, 0, 0, 0, ""); } } else { str2 = "{\"type\":\"2\",\"tips\":\"type参数错误\"}"; } } else { DataTable table2 = WeiXinHelper.GetRencentOpenID(100); int totalcount = table2.Rows.Count; int num11 = 0; string str20 = string.Empty; for (int j = 0; j < table2.Rows.Count; j++) { string str21 = NewsApi.KFSend(str7, NewsApi.CreateKFTxtNewsJson(table2.Rows[j][0].ToString(), this.String2Json(this.FormatSendContent(content)))); this.errcode = NewsApi.GetJsonValue(str21, "errcode"); if (this.errcode == "0") { num11++; } else { str20 = NewsApi.GetErrorCodeMsg(this.errcode); } } int num13 = (num11 > 0) ? 1 : 2; WeiXinHelper.UpdateMsgId(this.sendID, "", num13, num11, totalcount, str20); if (num11 == 0) { str2 = "{\"type\":\"0\",\"tips\":\"发送失败\"}"; } } } goto Label_091D; } base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; int articleid = Globals.RequestFormNum("articleid"); if (articleid > 0) { ArticleInfo info = ArticleHelper.GetArticleInfo(articleid); if (info != null) { StringBuilder builder = new StringBuilder(); switch (info.ArticleType) { case ArticleType.News: s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)info.ArticleType, ",\"title\":\"", this.String2Json(info.Title), "\",\"date\":\"", this.String2Json(info.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(info.ImageUrl), "\",\"memo\":\"", this.String2Json(info.Memo), "\"}" }); goto Label_030E; case ArticleType.List: foreach (ArticleItemsInfo info2 in info.ItemsInfo) { builder.Append("{\"title\":\"" + this.String2Json(info2.Title) + "\",\"imgurl\":\"" + this.String2Json(info2.ImageUrl) + "\"},"); } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)info.ArticleType, ",\"title\":\"", this.String2Json(info.Title), "\",\"date\":\"", this.String2Json(info.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(info.ImageUrl), "\",\"items\":[", builder.ToString().Trim(new char[] { ',' }), "]}" }); goto Label_030E; } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)info.ArticleType, ",\"title\":\"", this.String2Json(info.Title), "\",\"date\":\"", this.String2Json(info.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(info.ImageUrl), "\",\"memo\":\"", this.String2Json(info.Content), "\"}" }); } } Label_030E: base.Response.Write(s); base.Response.End(); return; Label_091D: base.Response.Write(str2); base.Response.End(); }
public static string SaveSendAllInfo(SendAllInfo sendAllInfo, [Optional, DefaultParameterValue(0)] int platform) { return(new SendAllDao().SaveSendAllInfo(sendAllInfo, platform)); }
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 articleInfo3 = ArticleHelper.GetArticleInfo(num); if (articleInfo3 != null) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); switch (articleInfo3.ArticleType) { case ArticleType.News: s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo3.ArticleType, ",\"title\":\"", this.String2Json(articleInfo3.Title), "\",\"date\":\"", this.String2Json(articleInfo3.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(articleInfo3.ImageUrl), "\",\"memo\":\"", this.String2Json(articleInfo3.Memo), "\"}" }); goto IL_30E; case ArticleType.List: { System.Collections.Generic.IList <ArticleItemsInfo> itemsInfo = articleInfo3.ItemsInfo; foreach (ArticleItemsInfo current in itemsInfo) { stringBuilder.Append(string.Concat(new string[] { "{\"title\":\"", this.String2Json(current.Title), "\",\"imgurl\":\"", this.String2Json(current.ImageUrl), "\"}," })); } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo3.ArticleType, ",\"title\":\"", this.String2Json(articleInfo3.Title), "\",\"date\":\"", this.String2Json(articleInfo3.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(articleInfo3.ImageUrl), "\",\"items\":[", stringBuilder.ToString().Trim(new char[] { ',' }), "]}" }); goto IL_30E; } } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo3.ArticleType, ",\"title\":\"", this.String2Json(articleInfo3.Title), "\",\"date\":\"", this.String2Json(articleInfo3.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(articleInfo3.ImageUrl), "\",\"memo\":\"", this.String2Json(articleInfo3.Content), "\"}" }); } } IL_30E: base.Response.Write(s); base.Response.End(); return; } if (this.type == "postdata") { base.Response.ContentType = "application/json"; string ReturnResult = "{\"type\":\"1\",\"tips\":\"操作成功\"}"; this.sendID = Globals.RequestFormNum("sendid"); int num2 = Globals.RequestFormNum("sendtype"); int num3 = Globals.RequestFormNum("msgtype"); int articleid = Globals.RequestFormNum("articleid"); string title = Globals.RequestFormStr("title"); string content = Globals.RequestFormStr("content"); int isoldarticle = Globals.RequestFormNum("isoldarticle"); string text = this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, true); if (string.IsNullOrEmpty(text)) { MessageType messageType = (MessageType)num3; string text2 = string.Empty; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); string access_token = TokenApi.GetToken(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret); access_token = JsonConvert.DeserializeObject <Token>(access_token).access_token; switch (messageType) { case MessageType.News: case MessageType.List: { bool flag = true; ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid); if (articleInfo.MediaId.Length < 1) { string text3 = NewsApi.GetMedia_IDByPath(access_token, articleInfo.ImageUrl); text3 = NewsApi.GetJsonValue(text3, "media_id"); if (!string.IsNullOrEmpty(text3)) { ArticleHelper.UpdateMedia_Id(0, articleInfo.ArticleId, text3); } else { flag = false; ReturnResult = "{\"type\":\"2\",\"tips\":\"" + NewsApi.GetErrorCodeMsg(NewsApi.GetJsonValue(text3, "errcode")) + "111111\"}"; } } if (messageType == MessageType.List) { foreach (ArticleItemsInfo current2 in articleInfo.ItemsInfo) { if (current2.MediaId == null || current2.MediaId.Length < 1) { string media_IDByPath = NewsApi.GetMedia_IDByPath(access_token, current2.ImageUrl); string jsonValue = NewsApi.GetJsonValue(media_IDByPath, "media_id"); if (jsonValue.Length == 0) { this.errcode = NewsApi.GetJsonValue(media_IDByPath, "errcode"); flag = false; ReturnResult = "{\"type\":\"2\",\"tips\":\"" + NewsApi.GetErrorCodeMsg(this.errcode) + "\"}"; break; } ArticleHelper.UpdateMedia_Id(1, current2.Id, jsonValue); } } } if (!flag) { goto IL_91B; } string articlesJsonStr = this.GetArticlesJsonStr(articleInfo); string msg = NewsApi.UploadNews(access_token, articlesJsonStr); this.sendID = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false)); string jsonValue2 = NewsApi.GetJsonValue(msg, "media_id"); if (jsonValue2.Length <= 0) { this.errcode = NewsApi.GetJsonValue(msg, "errcode"); ReturnResult = "{\"type\":\"2\",\"tips\":\"" + NewsApi.GetErrorCodeMsg(this.errcode) + "!\"}"; goto IL_91B; } if (num2 != 1) { System.Data.DataTable dt = WeiXinHelper.GetRencentOpenID(0); int icount = dt.Rows.Count; int sendcount = 0; string retjson = string.Empty; Task.Factory.StartNew(delegate { try { for (int i = 0; i < dt.Rows.Count; i++) { string msg2 = NewsApi.KFSend(access_token, this.GetKFSendImageJson(dt.Rows[i][0].ToString(), articleInfo)); this.errcode = NewsApi.GetJsonValue(msg2, "errcode"); if (this.errcode == "0") { sendcount++; } else { retjson = NewsApi.GetErrorCodeMsg(this.errcode); } } int sendstate = (sendcount > 0) ? 1 : 2; WeiXinHelper.UpdateMsgId(this.sendID, "", sendstate, sendcount, icount, retjson); } catch (System.Exception ex) { Globals.Debuglog(ex.ToString(), "_DebuglogSendAllEdit.txt"); } }); goto IL_91B; } text2 = NewsApi.SendAll(access_token, NewsApi.CreateImageNewsJson(jsonValue2)); if (string.IsNullOrWhiteSpace(text2)) { ReturnResult = "{\"type\":\"2\",\"tips\":\"type参数错误\"}"; goto IL_91B; } string jsonValue3 = NewsApi.GetJsonValue(text2, "msg_id"); if (!string.IsNullOrEmpty(jsonValue3)) { WeiXinHelper.UpdateMsgId(this.sendID, jsonValue3, 0, 0, 0, ""); goto IL_91B; } this.errcode = NewsApi.GetJsonValue(text2, "errcode"); string errorCodeMsg = NewsApi.GetErrorCodeMsg(this.errcode); WeiXinHelper.UpdateMsgId(this.sendID, jsonValue3, 2, 0, 0, errorCodeMsg); ReturnResult = "{\"type\":\"2\",\"tips\":\"" + errorCodeMsg + "!!\"}"; goto IL_91B; } } this.sendID = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false)); if (num2 == 1) { text2 = NewsApi.SendAll(access_token, this.CreateTxtNewsJson(content)); if (!string.IsNullOrWhiteSpace(text2)) { string jsonValue4 = NewsApi.GetJsonValue(text2, "msg_id"); if (jsonValue4.Length == 0) { this.errcode = NewsApi.GetJsonValue(text2, "errcode"); string errorCodeMsg2 = NewsApi.GetErrorCodeMsg(this.errcode); WeiXinHelper.UpdateMsgId(this.sendID, jsonValue4, 2, 0, 0, errorCodeMsg2); ReturnResult = "{\"type\":\"2\",\"tips\":\"" + errorCodeMsg2 + "\"}"; } else { WeiXinHelper.UpdateMsgId(this.sendID, jsonValue4, 0, 0, 0, ""); } } else { ReturnResult = "{\"type\":\"2\",\"tips\":\"type参数错误\"}"; } } else { System.Data.DataTable dt = WeiXinHelper.GetRencentOpenID(0); int icount = dt.Rows.Count; int sendcount = 0; string retjson = string.Empty; Task.Factory.StartNew(delegate { try { for (int i = 0; i < dt.Rows.Count; i++) { string msg2 = NewsApi.KFSend(access_token, NewsApi.CreateKFTxtNewsJson(dt.Rows[i][0].ToString(), this.String2Json(this.FormatSendContent(content)))); this.errcode = NewsApi.GetJsonValue(msg2, "errcode"); if (this.errcode == "0") { sendcount++; } else { retjson = NewsApi.GetErrorCodeMsg(this.errcode); } } int sendstate = (sendcount > 0) ? 1 : 2; WeiXinHelper.UpdateMsgId(this.sendID, "", sendstate, sendcount, icount, retjson); if (sendcount == 0) { ReturnResult = "{\"type\":\"0\",\"tips\":\"发送失败\"}"; } } catch (System.Exception ex) { Globals.Debuglog(ex.ToString(), "_DebuglogSendAllEdit.txt"); } }); } } else { ReturnResult = "{\"type\":\"0\",\"tips\":\"" + text + "\"}"; } IL_91B: base.Response.Write(ReturnResult); base.Response.End(); return; } if (this.sendID > 0) { this.hdfSendID.Value = this.sendID.ToString(); SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID); if (sendAllInfo != null) { MessageType messageType2 = sendAllInfo.MessageType; this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString(); int articleID = sendAllInfo.ArticleID; this.hdfArticleID.Value = articleID.ToString(); this.txtTitle.Text = sendAllInfo.Title; switch (messageType2) { case MessageType.Text: this.fkContent.Text = sendAllInfo.Content; break; case MessageType.News: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) 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.sendID) as NewsReplyInfo; if (newsReplyInfo2 != null) { System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); if (newsReplyInfo2.NewsMsg != null && newsReplyInfo2.NewsMsg.Count > 0) { int num4 = 0; foreach (NewsMsgInfo current3 in newsReplyInfo2.NewsMsg) { num4++; if (num4 == 1) { stringBuilder2.Append(string.Concat(new string[] { "<div class=\"mate-inner top\"> <div class=\"mate-img\" > <img id=\"img1\" src=\"", current3.PicUrl, "\" class=\"img-responsive\"> <div class=\"title\" id=\"title1\">", current3.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\">", current3.Title, "</div> <div class=\"img\"> <img src=\"", current3.PicUrl, "\" class=\"img-responsive\"> </div> </div> </div> </div>" })); } } this.htmlInfo = stringBuilder2.ToString(); } } } break; } } else { base.Response.Redirect("sendalllist.aspx"); base.Response.End(); } } else if (this.LocalArticleID > 0) { ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(this.LocalArticleID); if (articleInfo2 != null) { this.hdfArticleID.Value = this.LocalArticleID.ToString(); this.hdfMessageType.Value = ((int)articleInfo2.ArticleType).ToString(); } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } }
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\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", this.String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(articleInfo.ImageUrl), "\",\"memo\":\"", this.String2Json(articleInfo.Memo), "\"}" }); goto IL_30E; case ArticleType.List: { System.Collections.Generic.IList <ArticleItemsInfo> itemsInfo = articleInfo.ItemsInfo; foreach (ArticleItemsInfo current in itemsInfo) { stringBuilder.Append(string.Concat(new string[] { "{\"title\":\"", this.String2Json(current.Title), "\",\"imgurl\":\"", this.String2Json(current.ImageUrl), "\"}," })); } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", this.String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(articleInfo.ImageUrl), "\",\"items\":[", stringBuilder.ToString().Trim(new char[] { ',' }), "]}" }); goto IL_30E; } } s = string.Concat(new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", this.String2Json(articleInfo.PubTime.ToString("M月d日")), "\",\"imgurl\":\"", this.String2Json(articleInfo.ImageUrl), "\",\"memo\":\"", this.String2Json(articleInfo.Content), "\"}" }); } } IL_30E: base.Response.Write(s); base.Response.End(); return; } if (this.type == "postdata") { base.Response.ContentType = "application/json"; this.sendID = Globals.RequestFormNum("sendid"); int num2 = Globals.RequestFormNum("sendtype"); int num3 = Globals.RequestFormNum("msgtype"); int articleid = Globals.RequestFormNum("articleid"); string title = Globals.RequestFormStr("title"); string content = Globals.RequestFormStr("content"); int isoldarticle = Globals.RequestFormNum("isoldarticle"); string text = this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, true); string s2; if (string.IsNullOrEmpty(text)) { MessageType messageType = (MessageType)num3; string arg_3DF_0 = string.Empty; Articles Articles = new Articles(); Articles.msgType = "text"; string storeUrl = Globals.HostPath(System.Web.HttpContext.Current.Request.Url); if (messageType == MessageType.List || messageType == MessageType.News) { this.sendID = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false)); ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(articleid); if (articleInfo2 == null) { s2 = "{\"type\":\"0\",\"tips\":\"素材不存在了\"}"; base.Response.Write(s2); base.Response.End(); } Articles = this.GetAlipayArticlesFromArticleInfo(articleInfo2, storeUrl); } else { this.sendID = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false)); Articles.text = new MessageText { content = Globals.StripHtmlXmlTags(content) }; } SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); if (AlipayFuwuConfig.appId.Length < 15) { AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, base.Server.MapPath("~/"), "GBK"); } if (num2 == 1) { AlipayMobilePublicMessageTotalSendResponse alipayMobilePublicMessageTotalSendResponse = AliOHHelper.TotalSend(Articles); if (!alipayMobilePublicMessageTotalSendResponse.IsError && alipayMobilePublicMessageTotalSendResponse.Code == "200") { s2 = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}"; string msgid = ""; if (!string.IsNullOrEmpty(alipayMobilePublicMessageTotalSendResponse.Data) && alipayMobilePublicMessageTotalSendResponse.Data.Length > 50) { msgid = alipayMobilePublicMessageTotalSendResponse.Data.Substring(0, 49); } int alypayUserNum = WeiXinHelper.getAlypayUserNum(); WeiXinHelper.UpdateMsgId(this.sendID, msgid, 1, alypayUserNum, alypayUserNum, ""); } else { s2 = "{\"type\":\"0\",\"tips\":\"" + alipayMobilePublicMessageTotalSendResponse.Msg + "\"}"; WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, alipayMobilePublicMessageTotalSendResponse.Body); } } else { System.Collections.Generic.List <string> sendList = new System.Collections.Generic.List <string>(); System.Data.DataTable rencentAliOpenID = WeiXinHelper.GetRencentAliOpenID(); if (rencentAliOpenID != null) { for (int i = 0; i < rencentAliOpenID.Rows.Count; i++) { sendList.Add(rencentAliOpenID.Rows[i][0].ToString()); } } if (sendList.Count > 0) { WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, sendList.Count, ""); new System.Threading.Thread(() => { try { bool flag = false; foreach (string current3 in sendList) { if (current3.Length > 16) { Articles.toUserId = current3; AlipayMobilePublicMessageCustomSendResponse alipayMobilePublicMessageCustomSendResponse = AliOHHelper.CustomSend(Articles); if (alipayMobilePublicMessageCustomSendResponse != null && alipayMobilePublicMessageCustomSendResponse.IsError) { AliOHHelper.log(alipayMobilePublicMessageCustomSendResponse.Body); } else { flag = true; WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1); } System.Threading.Thread.Sleep(10); } } if (flag) { WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1); } else { WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2); } System.Threading.Thread.Sleep(10); } catch (System.Exception ex) { AliOHHelper.log(ex.Message.ToString()); } }).Start(); s2 = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}"; } else { s2 = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}"; } } } else { s2 = "{\"type\":\"0\",\"tips\":\"" + text + "\"}"; } base.Response.Write(s2); base.Response.End(); return; } if (this.sendID > 0) { this.hdfSendID.Value = this.sendID.ToString(); SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID); if (sendAllInfo != null) { MessageType messageType2 = sendAllInfo.MessageType; this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString(); int articleID = sendAllInfo.ArticleID; this.hdfArticleID.Value = articleID.ToString(); this.txtTitle.Text = sendAllInfo.Title; switch (messageType2) { case MessageType.Text: this.fkContent.Text = sendAllInfo.Content; break; case MessageType.News: if (articleID <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) 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.sendID) as NewsReplyInfo; if (newsReplyInfo2 != null) { System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); if (newsReplyInfo2.NewsMsg != null && newsReplyInfo2.NewsMsg.Count > 0) { int num4 = 0; foreach (NewsMsgInfo current2 in newsReplyInfo2.NewsMsg) { num4++; if (num4 == 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("sendalllist.aspx"); base.Response.End(); } } else if (this.LocalArticleID > 0) { ArticleInfo articleInfo3 = ArticleHelper.GetArticleInfo(this.LocalArticleID); if (articleInfo3 != null) { this.hdfArticleID.Value = this.LocalArticleID.ToString(); this.hdfMessageType.Value = ((int)articleInfo3.ArticleType).ToString(); } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } }
public static string SaveSendAllInfo(SendAllInfo sendAllInfo) { return(new SendAllDao().SaveSendAllInfo(sendAllInfo)); }
protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack) { return; } if (this.type == "getarticleinfo") { this.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 stringBuilder = new StringBuilder(); switch (articleInfo.ArticleType) { case ArticleType.News: s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"memo\":\"" + this.String2Json(articleInfo.Memo) + "\"}"; break; case ArticleType.List: foreach (ArticleItemsInfo articleItemsInfo in (IEnumerable <ArticleItemsInfo>)articleInfo.ItemsInfo) { stringBuilder.Append("{\"title\":\"" + this.String2Json(articleItemsInfo.Title) + "\",\"imgurl\":\"" + this.String2Json(articleItemsInfo.ImageUrl) + "\"},"); } s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"items\":[" + ((object)stringBuilder).ToString().Trim(',') + "]}"; break; default: s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"memo\":\"" + this.String2Json(articleInfo.Content) + "\"}"; break; } } } this.Response.Write(s); this.Response.End(); } else if (this.type == "postdata") { this.Response.ContentType = "application/json"; this.sendID = Globals.RequestFormNum("sendid"); int num = Globals.RequestFormNum("sendtype"); int msgType = Globals.RequestFormNum("msgtype"); int articleid = Globals.RequestFormNum("articleid"); string title = Globals.RequestFormStr("title"); string content = Globals.RequestFormStr("content"); int isoldarticle = Globals.RequestFormNum("isoldarticle"); string str1 = this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, true); string s; if (string.IsNullOrEmpty(str1)) { MessageType messageType = (MessageType)msgType; string str2 = string.Empty; Articles Articles = new Articles(); Articles.msgType = "text"; string storeUrl = Globals.HostPath(HttpContext.Current.Request.Url); if (messageType == MessageType.List || messageType == MessageType.News) { this.sendID = Globals.ToNum((object)this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, false)); ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid); if (articleInfo == null) { this.Response.Write("{\"type\":\"0\",\"tips\":\"素材不存在了\"}"); this.Response.End(); } Articles = this.GetAlipayArticlesFromArticleInfo(articleInfo, storeUrl); } else { this.sendID = Globals.ToNum((object)this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, false)); Articles.text = new MessageText() { content = Globals.StripHtmlXmlTags(content) }; } SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); if (AlipayFuwuConfig.appId.Length < 15) { AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, this.Server.MapPath("~/"), "GBK"); } if (num == 1) { AlipayMobilePublicMessageTotalSendResponse totalSendResponse = AliOHHelper.TotalSend(Articles); if (!totalSendResponse.IsError && totalSendResponse.Code == "200") { s = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}"; string msgid = ""; if (!string.IsNullOrEmpty(totalSendResponse.Data) && totalSendResponse.Data.Length > 50) { msgid = totalSendResponse.Data.Substring(0, 49); } int alypayUserNum = WeiXinHelper.getAlypayUserNum(); WeiXinHelper.UpdateMsgId(this.sendID, msgid, 1, alypayUserNum, alypayUserNum, ""); } else { s = "{\"type\":\"0\",\"tips\":\"" + totalSendResponse.Msg + "\"}"; WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, totalSendResponse.Body); } } else { List <string> sendList = new List <string>(); DataTable rencentAliOpenId = WeiXinHelper.GetRencentAliOpenID(); if (rencentAliOpenId != null) { for (int index = 0; index < rencentAliOpenId.Rows.Count; ++index) { sendList.Add(rencentAliOpenId.Rows[index][0].ToString()); } } if (sendList.Count > 0) { WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, sendList.Count, ""); new Thread((ThreadStart)(() => { try { bool flag = false; foreach (string str in sendList) { if (str.Length > 16) { Articles.toUserId = str; AlipayMobilePublicMessageCustomSendResponse customSendResponse = AliOHHelper.CustomSend(Articles); if (customSendResponse != null && customSendResponse.IsError) { AliOHHelper.log(customSendResponse.Body); } else { flag = true; WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1); } Thread.Sleep(10); } } if (flag) { WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1); } else { WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2); } Thread.Sleep(10); } catch (Exception ex) { AliOHHelper.log(((object)ex.Message).ToString()); } })).Start(); s = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}"; } else { s = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}"; } } } else { s = "{\"type\":\"0\",\"tips\":\"" + str1 + "\"}"; } this.Response.Write(s); this.Response.End(); } else { if (this.sendID > 0) { this.hdfSendID.Value = this.sendID.ToString(); SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID); if (sendAllInfo != null) { MessageType messageType = sendAllInfo.MessageType; this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString(); int articleId = sendAllInfo.ArticleID; this.hdfArticleID.Value = articleId.ToString(); this.txtTitle.Text = sendAllInfo.Title; switch (messageType) { case MessageType.Text: this.fkContent.Text = sendAllInfo.Content; break; case MessageType.News: if (articleId <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo; if (newsReplyInfo != null && newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count != 0) { this.htmlInfo = "<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; } else { break; } } else { break; } case MessageType.List: if (articleId <= 0) { this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo; if (newsReplyInfo != null) { StringBuilder stringBuilder = new StringBuilder(); if (newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count > 0) { int num = 0; foreach (NewsMsgInfo newsMsgInfo in (IEnumerable <NewsMsgInfo>)newsReplyInfo.NewsMsg) { ++num; if (num == 1) { stringBuilder.Append("<div class=\"mate-inner top\"> <div class=\"mate-img\" > <img id=\"img1\" src=\"" + newsMsgInfo.PicUrl + "\" class=\"img-responsive\"> <div class=\"title\" id=\"title1\">" + newsMsgInfo.Title + "</div> </div> </div>"); } else { stringBuilder.Append(" <div class=\"mate-inner\"> <div class=\"child-mate\"> <div class=\"child-mate-title clearfix\"> <div class=\"title\">" + newsMsgInfo.Title + "</div> <div class=\"img\"> <img src=\"" + newsMsgInfo.PicUrl + "\" class=\"img-responsive\"> </div> </div> </div> </div>"); } } this.htmlInfo = ((object)stringBuilder).ToString(); break; } else { break; } } else { break; } } else { break; } } } else { this.Response.Redirect("sendalllist.aspx"); this.Response.End(); } } else if (this.LocalArticleID > 0) { ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.LocalArticleID); if (articleInfo != null) { this.hdfArticleID.Value = this.LocalArticleID.ToString(); this.hdfMessageType.Value = ((int)articleInfo.ArticleType).ToString(); } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } }
public static string SaveSendAllInfo(SendAllInfo sendAllInfo, int platform = 0) { return((new SendAllDao()).SaveSendAllInfo(sendAllInfo, platform)); }
protected void Page_Load(object sender, System.EventArgs e) { if (!base.IsPostBack) { if (this.type == "getarticleinfo") { base.Response.ContentType = "application/json"; string str1 = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; int num = Globals.RequestFormNum("articleid"); if (num > 0) { ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(num); if (articleInfo != null) { StringBuilder stringBuilder = new StringBuilder(); switch (articleInfo.ArticleType) { case ArticleType.News: { object[] articleType = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null }; DateTime pubTime = articleInfo.PubTime; articleType[5] = this.String2Json(pubTime.ToString("M月d日")); articleType[6] = "\",\"imgurl\":\""; articleType[7] = this.String2Json(articleInfo.ImageUrl); articleType[8] = "\",\"memo\":\""; articleType[9] = this.String2Json(articleInfo.Memo); articleType[10] = "\"}"; str1 = string.Concat(articleType); break; } case ArticleType.Text | ArticleType.News: { object[] objArray = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null }; DateTime dateTime = articleInfo.PubTime; objArray[5] = this.String2Json(dateTime.ToString("M月d日")); objArray[6] = "\",\"imgurl\":\""; objArray[7] = this.String2Json(articleInfo.ImageUrl); objArray[8] = "\",\"memo\":\""; objArray[9] = this.String2Json(articleInfo.Content); objArray[10] = "\"}"; str1 = string.Concat(objArray); break; } case ArticleType.List: { foreach (ArticleItemsInfo itemsInfo in articleInfo.ItemsInfo) { string[] strArrays = new string[] { "{\"title\":\"", this.String2Json(itemsInfo.Title), "\",\"imgurl\":\"", this.String2Json(itemsInfo.ImageUrl), "\"}," }; stringBuilder.Append(string.Concat(strArrays)); } object[] articleType1 = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null }; DateTime pubTime1 = articleInfo.PubTime; articleType1[5] = this.String2Json(pubTime1.ToString("M月d日")); articleType1[6] = "\",\"imgurl\":\""; articleType1[7] = this.String2Json(articleInfo.ImageUrl); articleType1[8] = "\",\"items\":["; string str2 = stringBuilder.ToString(); char[] chrArray = new char[] { ',' }; articleType1[9] = str2.Trim(chrArray); articleType1[10] = "]}"; str1 = string.Concat(articleType1); break; } default: { goto case ArticleType.Text | ArticleType.News; } } } } base.Response.Write(str1); base.Response.End(); return; } if (this.type == "postdata") { base.Response.ContentType = "application/json"; string str3 = "{\"type\":\"1\",\"tips\":\"操作成功\"}"; this.sendID = Globals.RequestFormNum("sendid"); int num1 = Globals.RequestFormNum("sendtype"); int num2 = Globals.RequestFormNum("msgtype"); int num3 = Globals.RequestFormNum("articleid"); string str4 = Globals.RequestFormStr("title"); string str5 = Globals.RequestFormStr("content"); int num4 = Globals.RequestFormNum("isoldarticle"); string str6 = this.SavePostData(num2, num3, str4, str5, num4, this.sendID, true); if (!string.IsNullOrEmpty(str6)) { str3 = string.Concat("{\"type\":\"0\",\"tips\":\"", str6, "\"}"); } else { MessageType messageType = (MessageType)num2; string empty = string.Empty; Articles article = new Articles() { msgType = "text" }; string str7 = Globals.HostPath(HttpContext.Current.Request.Url); if (messageType == MessageType.List || messageType == MessageType.News) { this.sendID = Globals.ToNum(this.SavePostData(num2, num3, str4, str5, num4, this.sendID, false)); ArticleInfo articleInfo1 = ArticleHelper.GetArticleInfo(num3); if (articleInfo1 == null) { str3 = "{\"type\":\"0\",\"tips\":\"素材不存在了\"}"; base.Response.Write(str3); base.Response.End(); } article = this.GetAlipayArticlesFromArticleInfo(articleInfo1, str7); } else { this.sendID = Globals.ToNum(this.SavePostData(num2, num3, str4, str5, num4, this.sendID, false)); Articles article1 = article; MessageText messageText = new MessageText() { content = Globals.StripHtmlXmlTags(str5) }; article1.text = messageText; } SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); if (AlipayFuwuConfig.appId.Length < 15) { AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, base.Server.MapPath("~/"), "GBK"); } if (num1 != 1) { List <string> strs = new List <string>(); DataTable rencentAliOpenID = WeiXinHelper.GetRencentAliOpenID(); if (rencentAliOpenID != null) { for (int i = 0; i < rencentAliOpenID.Rows.Count; i++) { strs.Add(rencentAliOpenID.Rows[i][0].ToString()); } } if (strs.Count <= 0) { str3 = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}"; } else { WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, strs.Count, ""); (new Thread(() => { try { bool flag = false; foreach (string str in strs) { if (str.Length <= 16) { continue; } article.toUserId = str; AlipayMobilePublicMessageCustomSendResponse alipayMobilePublicMessageCustomSendResponse = AliOHHelper.CustomSend(article); if (alipayMobilePublicMessageCustomSendResponse == null || !alipayMobilePublicMessageCustomSendResponse.IsError) { flag = true; WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1); } else { AliOHHelper.log(alipayMobilePublicMessageCustomSendResponse.Body); } Thread.Sleep(10); } if (!flag) { WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2); } else { WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1); } Thread.Sleep(10); } catch (Exception exception) { AliOHHelper.log(exception.Message.ToString()); } })).Start(); str3 = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}"; } } else { AlipayMobilePublicMessageTotalSendResponse alipayMobilePublicMessageTotalSendResponse = AliOHHelper.TotalSend(article); if (alipayMobilePublicMessageTotalSendResponse.IsError || !(alipayMobilePublicMessageTotalSendResponse.Code == "200")) { str3 = string.Concat("{\"type\":\"0\",\"tips\":\"", alipayMobilePublicMessageTotalSendResponse.Msg, "\"}"); WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, alipayMobilePublicMessageTotalSendResponse.Body); } else { str3 = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}"; string str8 = ""; if (!string.IsNullOrEmpty(alipayMobilePublicMessageTotalSendResponse.Data) && alipayMobilePublicMessageTotalSendResponse.Data.Length > 50) { str8 = alipayMobilePublicMessageTotalSendResponse.Data.Substring(0, 49); } int alypayUserNum = WeiXinHelper.getAlypayUserNum(); WeiXinHelper.UpdateMsgId(this.sendID, str8, 1, alypayUserNum, alypayUserNum, ""); } } } base.Response.Write(str3); base.Response.End(); return; } if (this.sendID > 0) { this.hdfSendID.Value = this.sendID.ToString(); SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID); if (sendAllInfo == null) { base.Response.Redirect("sendalllist.aspx"); base.Response.End(); } else { MessageType messageType1 = sendAllInfo.MessageType; this.hdfMessageType.Value = sendAllInfo.MessageType.ToString(); int articleID = sendAllInfo.ArticleID; this.hdfArticleID.Value = articleID.ToString(); this.txtTitle.Text = sendAllInfo.Title; switch (messageType1) { case MessageType.Text: { this.fkContent.Text = sendAllInfo.Content; break; } case MessageType.News: { if (articleID > 0) { break; } this.hdfIsOldArticle.Value = "1"; NewsReplyInfo reply = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo; if (reply == null || reply.NewsMsg == null || reply.NewsMsg.Count == 0) { break; } string[] title = new string[] { "<div class=\"mate-inner\"><h3 id=\"singelTitle\">", reply.NewsMsg[0].Title, "</h3><span>", null, null, null, null, null, null }; title[3] = reply.LastEditDate.ToString("M月d日"); title[4] = "</span><div class=\"mate-img\"><img id=\"img1\" src=\""; title[5] = reply.NewsMsg[0].PicUrl; title[6] = "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">"; title[7] = reply.NewsMsg[0].Description; title[8] = "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">></em></div></div>"; this.htmlInfo = string.Concat(title); break; } case MessageType.List: { if (articleID > 0) { break; } this.hdfIsOldArticle.Value = "1"; NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo; if (newsReplyInfo == null) { break; } StringBuilder stringBuilder1 = new StringBuilder(); if (newsReplyInfo.NewsMsg == null || newsReplyInfo.NewsMsg.Count <= 0) { break; } int num5 = 0; foreach (NewsMsgInfo newsMsg in newsReplyInfo.NewsMsg) { num5++; if (num5 != 1) { string[] title1 = new string[] { " <div class=\"mate-inner\"> <div class=\"child-mate\"> <div class=\"child-mate-title clearfix\"> <div class=\"title\">", newsMsg.Title, "</div> <div class=\"img\"> <img src=\"", newsMsg.PicUrl, "\" class=\"img-responsive\"> </div> </div> </div> </div>" }; stringBuilder1.Append(string.Concat(title1)); } else { string[] picUrl = new string[] { "<div class=\"mate-inner top\"> <div class=\"mate-img\" > <img id=\"img1\" src=\"", newsMsg.PicUrl, "\" class=\"img-responsive\"> <div class=\"title\" id=\"title1\">", newsMsg.Title, "</div> </div> </div>" }; stringBuilder1.Append(string.Concat(picUrl)); } } this.htmlInfo = stringBuilder1.ToString(); break; } } } } else if (this.LocalArticleID > 0) { ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(this.LocalArticleID); if (articleInfo2 != null) { this.hdfArticleID.Value = this.LocalArticleID.ToString(); this.hdfMessageType.Value = articleInfo2.ArticleType.ToString(); } } if (string.IsNullOrEmpty(this.htmlInfo)) { this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>"; } this.litInfo.Text = this.htmlInfo; } }