/// <summary> /// 获取上行信息 /// </summary> private static void GetMo() { SignLog("上行获取线程启动", true); while (true) { int moNum = 0; try { smsChannel sc = null; foreach (var item in DicSet) { if (Dic.ContainsKey(item.Value.ChannelID)) { sc = Dic[item.Value.ChannelID]; } if (sc != null) { moNum += new XwSmsApi().GetMo(sc.MchUName, sc.MchUPass, sc.MchIP, sc.MoPort, item.Value.AdminID, item.Value.ChannelID); } } } catch (Exception e) { SignLog("上行获取线程异常:" + e.Message, true); } SignLog("------上行" + moNum, true); Thread.Sleep(1000 * 60); } }
/// <summary> /// 测试短信 /// </summary> private static void TestSendSms() { SignLog("发送短信线程启动", true); while (true) { string ErrMsg = ""; int test = 0;// XwSmsApi.PostMsg("sxgy@bjsxhj2", "hj@08555", "13100000138", "我院订于2017年6月10日召开全员大会【山西高院】", out ErrMsg); //int test = XwSmsApi.PostMsg("bjjcb@bjjcb", "haijing08555", "13100000138", "我院订于2017年6月10日召开全员大会", out ErrMsg); test = XwSmsApi.PostMsg("bjsxztb@bjsxztb", "haijing08555", "211.147.239.62", 8460, 8450, "13100000138", "我院订于2017年6月10日召开全员大会【省评标专家库】", "", out ErrMsg); SignLog("发送结果" + test, true); SignLog("发送结果文本" + ErrMsg, true); /* * SzSmsApi s = new SzSmsApi * { * enterpriseID = "11343", * loginName = "admin", * password = "******", * content = "2017-08-20,通知,原定周日召开的员工大会推迟到下周一,望周知【软通信息】", * mobiles = "13100000138", * smsId = DateTime.Now.ToString("yyMMddHHmmss"), * subPort = "", * sendTime = "" * }; */ //test = SzSmsApi.SendSms(s); SignLog("发送结果--" + test, true); SignLog("发送结果文本--" + ErrMsg, true); Thread.Sleep(1000 * 60 * 60 * 24); } }
public int ToSend() { int allNum = 0; try { Dictionary <int, smsChannel> Dic = Program.Dic; List <smsStream> ls = new _SmsStream().GetSmsList(1); if (ls.Count > 0) { //通道相关信息 string MchIP = ""; string MchUName = ""; string MchUPass = ""; int channelType = 0; int MtPort = 0; int MoPort = 0; string StreamNo = ""; foreach (smsStream item in ls) { MchUName = ""; MchUPass = ""; MchIP = ""; MoPort = 0; StreamNo = item.StreamNo; string outS = ""; List <smsMx> lMx = new _SmsMx().GetSmsMxList(StreamNo, 0, out outS); List <string> lsql = new List <string>(); if (Dic.ContainsKey(item.ChannelID)) { MchUName = Dic[item.ChannelID].MchUName; MchUPass = Dic[item.ChannelID].MchUPass; channelType = Dic[item.ChannelID].ChannelType; MtPort = Dic[item.ChannelID].MtPort; MoPort = Dic[item.ChannelID].MoPort; MchIP = Dic[item.ChannelID].MchIP; } int Result = 1; string ErrMsg = ""; Program.SignLog("待发送(--" + StreamNo + "-" + outS + "-" + lMx.Count + ")条记录", true); foreach (smsMx mx in lMx) { try { if (channelType == 0) { Result = XwSmsApi.PostMsg(MchUName, MchUPass, MchIP, MoPort, MtPort, mx.Mobile, mx.Content, mx.customMsgID, out ErrMsg); } else { //深圳会员 SzSmsApi sz = new SzSmsApi { enterpriseID = MchIP, loginName = MchUName, password = MchUPass, content = mx.Content, mobiles = mx.Mobile, smsId = mx.customMsgID }; Result = SzSmsApi.SendSms(sz); } if (Result == 0) { Result = 1; } } catch (Exception e) { Result = 2; ErrMsg = e.Message.ToString(); } allNum++; helper.ExecuteSqlNoResult("update tbl_sms_mx set State = " + Result + ",SendOn = '" + DateTime.Now + "',ErrMsg = '" + ErrMsg + "' where ID = " + mx.ID); } var o = new { State = 2 }; new Main().UpdateDb(o, "tbl_sms", "StreamNo = '" + StreamNo + "'"); } //Program.SignLog("共发送(" + allNum + ")条记录", true); } } catch { } return(allNum); }