protected void btSubmit_Click(object sender, EventArgs e) { SmsFormat format = new SmsFormat(); bool validate = true; if (tbPhone.Text.Trim() != "") { format.phone = tbPhone.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } else { validate = false; cleanLabel(); Label1.Text = "電話號碼不能空白!!"; } format.subject = tbSubject.Text; format.content = tbContent.Text; //時間全空白表示立刻傳送 if ((tbYear.Text.Trim() == "") && (tbMonth.Text.Trim() == "") && (tbDay.Text.Trim() == "") && (tbHour.Text.Trim() == "") && (tbMinute.Text.Trim() == "") && (tbSec.Text.Trim() == "")) { format.sendFormat = (int)EnumSendFormat.NOW; } else { DateTime dt = new DateTime(); if (DateTime.TryParse(tbYear.Text + "/" + tbMonth.Text + "/" + tbDay.Text + " " + tbHour.Text + ":" + tbMinute.Text + ":" + tbSec.Text, out dt)) { format.datetime = dt; format.sendFormat = (int)EnumSendFormat.RESERVE; } else { validate = false; cleanLabel(); Label1.Text = "請輸入合法日期"; } } if (validate) { try { cleanLabel(); Sms1wayModule.SmsSvc svc = new Sms1wayModule.SmsSvc(); Utility.Result result = svc.authAccount("n+ABj+1w6e1Ht2A2ziBh0Q==", "367f7deaa1ce47b185a0c91cb6d8f714", "Sms1wayModule"); Label1.Text = result.success.ToString() + result.description; Utility.Result sendResult = svc.sendSms(format); Label2.Text = sendResult.success.ToString() + sendResult.description + svc.getMsgId().ToString(); lbMsgID.Text = "MsgID=" + svc.getMsgId().ToString(); } catch (Exception err) { cleanLabel(); Label1.Text = err.Message; } } }
public bool Send(string phone, string sms, SmsFormat format) { lock (lockItem) { MakeSureConnection(); sms = sms.Replace("\r\n", ""); string[] contentSet = CutMessageFromContent(sms); if (ChinaMobile && contentSet.Length > 1) { return(SendMobile(phone, sms, format)); } for (int i = 0; i < contentSet.Length; i++) { string content = contentSet[i]; var messageFromat = new SetSmsFromatCommand(format); AbstractCommand resultCommand = Send(messageFromat); if (!resultCommand.Success) { return(false); } var cmgsCommand = new CmgsCommand(); if (format == SmsFormat.Pdu) { var info = new SmsInfo(ServiceCenterNumber, phone, content); int smsLen = 0; content = info.EncodingSMS(out smsLen); cmgsCommand.Argument = string.Format(smsLen.ToString("D2")); } else { cmgsCommand.Argument = phone; } resultCommand = Send(cmgsCommand); if (!resultCommand.Success) { return(false); } var directCommand = new SendContent { Content = content }; resultCommand = Send(directCommand); if (!resultCommand.Success) { return(false); } Thread.Sleep(1000); } Thread.Sleep(1000); } return(true); }
public void Send(string mobile, string content, SmsFormat type) { try { _vider.Send(mobile, content, type); } catch (Exception ex) { log.Error(ex.Message, ex); throw; } }
public void Send(string mobile, string content, SmsFormat type) { try { bool sendSms = true; if (_handler != null) { _log.InfoFormat("send a new message, content:{0}, target mobile:{1},SmsFromat:{2}", content, mobile, type); sendSms = _handler.OnSending(mobile, content, type); } if (sendSms) { ThreadPool.QueueUserWorkItem(state => ((SmsService)state).Send(mobile, content, type), _service); } } catch (Exception ex) { _log.Error("Send sms fail.", ex); } }
private bool SendMobile(string phone, string sms, SmsFormat format) { int rem = 0; int count = Math.DivRem(sms.Length, maxSmsLength, out rem); if (rem > 0) { count++; } var messageFromat = new SetSmsFromatCommand(format); AbstractCommand resultCommand = Send(messageFromat); this._log.Debug("Set format command is " + resultCommand.Success); if (!resultCommand.Success) { return(false); } sms = PDUdecoding.EncodingOther(sms); this._log.Debug("send long sms's length " + count); for (int i = 0; i < count; i++) { _log.Info("Send the " + i); string length; string sendMessage = PDUdecoding.EncodingSMS(ServiceCenterNumber, phone, count, i + 1, sms, out length); var cmgs = new CmgsCommand { Argument = length }; Send(cmgs); var directCommand = new SendContent { Content = sendMessage }; var s = Send(directCommand); } return(true); }
public bool OnSending(string mobile, string content, SmsFormat format) { return(true); }
protected void btnQuery_Click(object sender, EventArgs e) { SmsFormat format = new SmsFormat(); bool validate = true; if (tbPhoneq.Text.Trim() != "") { format.phone = tbPhoneq.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } else { validate = false; cleanLabel(); lbMsgQuery.Text = "電話號碼不能空白!!"; } if (tbMsgIDq.Text.Trim() == "") { validate = false; cleanLabel(); lbMsgQuery.Text = "請輸入要查的MsgID"; } if (validate) { try { cleanLabel(); Sms1wayModule.SmsSvc svc = new Sms1wayModule.SmsSvc(); Utility.Result result = svc.authAccount("n+ABj+1w6e1Ht2A2ziBh0Q==", "367f7deaa1ce47b185a0c91cb6d8f714", "Sms1wayModule"); Utility.QueryPackage qpg = svc.getSmsDeliveryStatusEx(tbMsgIDq.Text, format.phone); string statusc = ""; switch (qpg.packageStatus) { case "0": statusc = "等待傳送中"; break; case "1": statusc = "正在傳送中"; break; case "2": statusc = "已傳送完畢"; break; case "3": statusc = "傳送失敗"; break; case "4": statusc = "已取消傳送"; break; case "10": statusc = "預約待傳送"; break; case "20": statusc = "等待接收中"; break; } lbMsgQuery.Text = statusc; for (int i = 0; i < qpg.recvStatusList.Count(); i++) { lbMsgQuery.Text += "<br/>"; lbMsgQuery.Text += "pkgrecvphone:" + (qpg.recvStatusList[i]).telephone + " " + "pkgrecvreceiveTime:" + (qpg.recvStatusList[i].receiveTime) + " " + "pkgrecvstatus:" + (qpg.recvStatusList[i]).status + " " + "pkgrecvdescription:" + (qpg.recvStatusList[i]).description; } } catch (Exception err) { cleanLabel(); Label1.Text = err.Message; } } }
public SetSmsFromatCommand(SmsFormat smsFormat) { Format = smsFormat; }
public bool OnSending(string mobile, string content, SmsFormat format) { return true; }