public void ProcessRequest(HttpContext context) { string users = context.Request.Params["users"] ?? "@all"; string content = context.Request.Params["content"] ?? ""; //QY.Entities.Article news=new QY.Entities.Article(); List<QY.Entities.Article> news_list = new List<QY.Entities.Article>(); string[] content_array = content.Split(new string[]{"$"},StringSplitOptions.None); //news.Title="这个是测试测试测试测试测试测试测试"; for (int i = 0; i < content_array.Length; i = i + 2) { QY.Entities.Article news = new QY.Entities.Article(); news.Title = content_array[i].Trim(); news.Url = content_array[i + 1].Trim(); news_list.Add(news); } context.Response.ContentType = "text/plain"; QY.CommonAPIs.AccessTokenContainer.Register("wx9b25d5460920c234", "5Iau-uGnijCNSwoQXlocce6bMBohZ2W0ZdA4bWg1x2uObwhb6fWgAK9nNLKaM5pr"); string txt = context.Request.Params["content"] ?? " "; string tk = QY.CommonAPIs.AccessTokenContainer.TryGetToken("wx9b25d5460920c234", "5Iau-uGnijCNSwoQXlocce6bMBohZ2W0ZdA4bWg1x2uObwhb6fWgAK9nNLKaM5pr"); QY.AdvancedAPIs.Mass.SendNews(tk, users, "", "", "1", news_list, 0); context.Response.Write(QY.CommonAPIs.AccessTokenContainer.CheckRegistered("wx9b25d5460920c234").ToString()); }
public static void AUTOALERT() { lock (islock) { var txLst = new SZHL_TXSXB().GetEntities(p => p.Status == "0"); foreach (var model in txLst) { try { bool canclose = false; //是否结束 bool cansend = false; //是否发送提醒 bool upcount = false; //是否更新次数 switch (model.TXType) { case "0": //立即发送 { cansend = true; canclose = true; upcount = true; } break; case "1": //仅一次 { DateTime sd = DateTime.Parse(model.Date + " " + model.Hour + ":" + model.Minute + ":00"); if (DateTime.Now >= sd) { cansend = true; canclose = true; upcount = true; } } break; case "2": //每个工作日 { DateTime sd = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + model.Hour + ":" + model.Minute + ":00"); if ((DateTime.Now.DayOfWeek == DayOfWeek.Monday || DateTime.Now.DayOfWeek == DayOfWeek.Tuesday || DateTime.Now.DayOfWeek == DayOfWeek.Wednesday || DateTime.Now.DayOfWeek == DayOfWeek.Thursday || DateTime.Now.DayOfWeek == DayOfWeek.Friday ) && DateTime.Now > sd && (model.LstSendTime == null || model.LstSendTime.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))) { upcount = true; } } break; case "3": //每天 { DateTime sd = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + model.Hour + ":" + model.Minute + ":00"); if ((DateTime.Now > sd && (model.LstSendTime == null || model.LstSendTime.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")))) { upcount = true; } } break; case "5": //每月 { DateTime sd = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-" + model.Days + " " + model.Hour + ":" + model.Minute + ":00"); if ((DateTime.Now > sd && (model.LstSendTime == null || model.LstSendTime.Value.ToString("yyyy-MM") != DateTime.Now.ToString("yyyy-MM")))) { upcount = true; } } break; case "4": //自定义 { string Days = model.Days; foreach (var d in Days.Split(',')) { if (getWkDays(d) == DateTime.Now.DayOfWeek) { DateTime sd = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + model.Hour + ":" + model.Minute + ":00"); if ((DateTime.Now > sd && (model.LstSendTime == null || model.LstSendTime.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")))) { upcount = true; } } } } break; } if (upcount) { if (model.CFType == "1") { cansend = true; } else if (model.CFType == "2" && model.CFCount.Value > model.ZXCount) //次数 { cansend = true; if (model.CFCount.Value == model.ZXCount.Value + 1) //到次数,可以结束 { canclose = true; } } else if (model.CFType == "3" && DateTime.Now < model.CFJZDate.Value) { cansend = true; } new SZHL_TXSXB().ExsSql("update SZHL_TXSX set ZXCount=isnull(ZXCount,0)+1,LstSendTime=getdate() where ID=" + model.ID); } if (cansend) { bool smsg = false; bool swx = false; bool swxapi = false; if (model.Type == "0") //短信和微信 { smsg = true; swx = true; } else if (model.Type == "1") //短信 { smsg = true; } else if (model.Type == "2") //微信 { swx = true; } else if (model.Type == "3") //调接口 { swxapi = true; } if (smsg) //发短信 { foreach (var m in model.TXUser.Split(',')) { object u = new SZHL_TXSXB().ExsSclarSql("select mobphone from JH_Auth_User where UserName='******' and comid='" + model.ComId + "'"); if (u != null) { new SZHL_DXGLB().SendSMS(u.ToString(), model.CRUserRealName + "给您添加了提醒\n" + model.TXContent, model.ComId.Value); } } } if (swx) //发微信 { Senparc.Weixin.QY.Entities.Article a = new Senparc.Weixin.QY.Entities.Article(); a.Title = "日程提醒"; a.Description = model.CRUserRealName + "给您添加了提醒\n" + model.TXContent; a.Url = model.ID.ToString(); List <Senparc.Weixin.QY.Entities.Article> al = new List <Senparc.Weixin.QY.Entities.Article>(); al.Add(a); JH_Auth_UserB.UserInfo UserInfo = new JH_Auth_UserB().GetUserInfo(model.ComId.Value, model.CRUser); try { new JH_Auth_User_CenterB().SendMsg(UserInfo, model.TXMode, model.TXContent, model.ID.ToString(), model.TXUser, "A", 0, model.ISCS); } catch (Exception) { } WXHelp wx = new WXHelp(UserInfo.QYinfo); wx.SendTH(al, model.TXMode, model.WXLink, model.TXUser); } if (swxapi) //调接口 { try { Msg_Result Model = new Msg_Result() { Action = model.FunName, ErrorMsg = "" }; var container = ServiceContainerV.Current().Resolve <IWsService>(model.APIName.ToUpper()); container.ProcessRequest(HttpContext.Current, ref Model, JsonConvert.SerializeObject(model), "", null); } catch (Exception ex) { canclose = true; new JH_Auth_LogB().Insert(new JH_Auth_Log() { LogType = "TXSX", LogContent = ex.ToString(), CRDate = DateTime.Now }); } } } if (canclose) { new SZHL_TXSXB().ExsSql("update SZHL_TXSX set Status='1' where ID=" + model.ID); } } catch (Exception ex) { string ss = ex.Message; } } } }