/// <summary> /// 互亿无线 /// </summary> /// <param name="request"></param> /// <returns></returns> internal static Result SendMessage(DataContract.Request request) { string url = WebConfigurationManager.AppSettings["SMSSendURL"].ToString(); var para = request.GetParameters <SendSmsReqPara>(); SMSSendBLL bll = new SMSSendBLL(new JIT.Utility.BasicUserInfo()); SMSCustomerBLL smsCustomerBll = new SMSCustomerBLL(new JIT.Utility.BasicUserInfo()); var smsCustomer = smsCustomerBll.GetByID(null, para.Sign); var entity = new SMSSendEntity() { MobileNO = para.MobileNO, Sign = para.Sign, SMSContent = para.SMSContent, Account = smsCustomer.Account, Password = smsCustomer.Password }; //调用短信接口直接发送 var result = GetResult(entity.GetSMS().Send2(JIT.Utility.SMS.Base.SendType.Get, url));//GetSMS确定了是用的HuYiSMS if (result.IsSuccess) { entity.Status = 1; entity.SendCount = (entity.SendCount ?? 0) + 1; entity.Mtmsgid = result.SMSID; entity.RegularlySendTime = DateTime.Now; Loggers.Debug(new DebugLogInfo() { Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, entity.MobileNO, entity.SMSContent, result.ToJSON()) }); } else { entity.SendCount = (entity.SendCount ?? 0) + 1; Loggers.Debug(new DebugLogInfo() { Message = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, entity.MobileNO, entity.SMSContent, result.ToJSON()) }); } //保存数据库 bll.Create(entity); return(result); }
/// <summary> /// 获取TOP数据短信实体 /// </summary> /// <param name="topCount"></param> /// <returns></returns> public SMSSendEntity[] GetNoSend(int topCount = 100) { string sql = "select top {0} * from SMS_Send where Status=0 and isnull(Send_Count,0)<3 order by SMS_send_id desc".Fmt(topCount); List <SMSSendEntity> list = new List <SMSSendEntity> { }; JITMemoryCache jitCache = new JITMemoryCache(); System.Web.Caching.Cache objCache = HttpRuntime.Cache; using (SqlDataReader dr = this.SQLHelper.ExecuteReader(sql.ToString())) { objCache.Insert("SMSCustomerID", (Object)string.Empty); while (dr.Read()) { SMSSendEntity m; this.Load(dr, out m); // update by:wuwen 20141020 增加适用多账号 //1:账号id放入缓存 缓存不存在,则添加缓存 //2:根据短信账号id,获取账号用户名和密码 cf_jieyt kLhNMF //客户id缓存不为空,并且客户id不为空,当前的客户id缓存不等于当前的客户id,则获取客户名称和客户密码 if ((!objCache["SMSCustomerID"].Equals(string.Empty)) && (!string.IsNullOrWhiteSpace(m.SMSCustomerID)) && (objCache["SMSCustomerID"].ToString().Equals(m.SMSCustomerID))) { //获取短信账号和密码 SMSCustomerBLL SMSCustomerBLL = new SMSCustomerBLL(new BasicUserInfo()); SMSCustomerEntity SMSCustomerEntity = SMSCustomerBLL.GetByID(m.SMSCustomerID, null); m.Account = SMSCustomerEntity.Account; m.Password = SMSCustomerEntity.Password; objCache.Insert("Account", (Object)m.Account); objCache.Insert("Password", (Object)m.Password); } //用于用户领取会员卡,会员云程序中没有设置对应客户id,用sign签名关联客户表和发送消息表 else if (string.IsNullOrWhiteSpace(m.SMSCustomerID)) { //获取短信账号和密码 SMSCustomerBLL SMSCustomerBLL = new SMSCustomerBLL(new BasicUserInfo()); SMSCustomerEntity SMSCustomerEntity = SMSCustomerBLL.GetByID(null, m.Sign); m.Account = SMSCustomerEntity.Account; m.Password = SMSCustomerEntity.Password; m.SMSCustomerID = SMSCustomerEntity.SMSCustomerID.ToString(); objCache.Insert("Account", (Object)m.Account); objCache.Insert("Password", (Object)m.Password); } //客户id缓存不为空,并且客户id不为空,则获取客户名称和客户密码,第一次进入方法时操作 //else if ((objCache["SMSCustomerID"].Equals(string.Empty)) && (!string.IsNullOrWhiteSpace(m.SMSCustomerID))) else if ((!string.IsNullOrWhiteSpace(m.SMSCustomerID))) { //获取短信账号和密码 SMSCustomerBLL SMSCustomerBLL = new SMSCustomerBLL(new BasicUserInfo()); SMSCustomerEntity SMSCustomerEntity = SMSCustomerBLL.GetByID(m.SMSCustomerID, null); m.Account = SMSCustomerEntity.Account; m.Password = SMSCustomerEntity.Password; objCache.Insert("Account", (Object)m.Account); objCache.Insert("Password", (Object)m.Password); } else//获取客户账号和客户密码 { m.Account = objCache["Account"].ToString(); m.Password = objCache["Password"].ToString(); } objCache.Insert("SMSCustomerID", (Object)m.SMSCustomerID); list.Add(m); } } Loggers.Debug(new DebugLogInfo() { Message = sql }); return(list.ToArray()); }