/// <summary> /// 发送消息 /// </summary> /// <param name="dr"></param> /// <param name="strMsg"></param> private static void SendUserMessage(DataRow dr, string strMsg) { Action send = (() => { //根据设备 编号取得对应小区的发送人 DevinfoBLL devinfo = new DevinfoBLL(); DataTable userDt = devinfo.GetUserByDev(dr["devID"].ToString()); if (userDt != null && userDt.Rows.Count > 0) { SendMessageBLL msg = new SendMessageBLL(); SendMessageModel sendModel = new SendMessageModel(); sendModel.createTime = DateTime.Now; foreach (DataRow userDr in userDt.Rows) { string strPhone = userDr["mobile"].ToString(); SMSReceiveModel resultModel = YunRongSDK.SendSMS(strPhone, strMsg); if (resultModel != null) { sendModel.sendResult = resultModel.statusMsg; } else { sendModel.sendResult = ""; } sendModel.devID = Convert.ToInt32(dr["devID"].ToString()); sendModel.alarmCode = dr["alarmCode"].ToString(); sendModel.alarmState = Convert.ToInt32(dr["alarmState"]); sendModel.content = strMsg; sendModel.mobile = strPhone; msg.Add(sendModel); } } }); Task.Factory.StartNew(send); }
/// <summary> /// 发送消息 /// </summary> /// <param name="dr"></param> /// <param name="strMsg"></param> private void SendUserMessage(Model.AlarmElevatorModel model, string strMsg) { Action send = (() => { BLL.ElevatorInfoBLL _infoBLL = new BLL.ElevatorInfoBLL(); DataTable userDt = _infoBLL.GetUserMobile(model.registrationCode); if (userDt != null && userDt.Rows.Count > 0) { foreach (DataRow userDr in userDt.Rows) { Model.SendMessageElevatorModel sendModel = new Model.SendMessageElevatorModel(); string strPhone = userDr["mobile"].ToString(); SMSReceiveModel resultModel = YunRongSDK.SendSMS(strPhone, strMsg); if (resultModel != null) { sendModel.sendResult = resultModel.statusMsg; } else { sendModel.sendResult = ""; } sendModel.aID = model.aID; sendModel.registrationCode = model.registrationCode; sendModel.errorCodeType = model.errorCodeType; sendModel.customCode = model.customCode; sendModel.content = strMsg; sendModel.mobile = strPhone; sendModel.createTime = DateTime.Now; _sendBLL.Add(sendModel); } } }); Task.Factory.StartNew(send); }
private static SMSReceiveModel GetPostReturn(string postReturn) { SMSReceiveModel ResultModel = null; switch (postReturn) { case "0": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "发送成功" }; break; case "-1": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "用户名或口令错误" }; break; case "-2": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "IP验证错误" }; break; case "-3": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "定时日期错误" }; break; case "-10": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "余额不足" }; break; case "-101": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "userId为空" }; break; case "-102": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "目标号码为空" }; break; case "-103": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "内容为空" }; break; case "200": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "目标号码错误" }; break; case "201": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "目标号码在黑名单中" }; break; case "202": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "内容包含敏感单词" }; break; case "203": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "特服号未分配" }; break; case "204": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "分配通道错误" }; break; case "999": ResultModel = new SMSReceiveModel { statusCode = postReturn, statusMsg = "发送三次都超时" }; break; } return(ResultModel); }