天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ModemLib.SMS;
using ModemLib.Voice;
namespace QM.Exchange.Adapters.SMS
{
/// <summary>
/// 短信猫适配器
/// </summary>
public class SMSAdapter
{
//com口名称
private string _portName = "";
public SMSAdapter(string portName)
{
_portName = portName;
}
/// <summary>
/// 发送手机短信
/// </summary>
/// <param name="telephoneNumber">手机号码</param>
/// <param name="msg">短信</param>
public void SendMsg(string telephoneNumber, string msg)
{
using (SMSHelper sms = new SMSHelper(_portName))
{
sms.Send(telephoneNumber, msg);//发送
}
}
/// <summary>
/// 拨打电话播放语音
/// </summary>
/// <param name="telephoneNumber">电话号码</param>
/// <param name="msg">文字</param>
public void Speak(string telephoneNumber, string msg)
{
using (PhoneHelper phone = new PhoneHelper(_portName))
{
phone.VoiceName = "Microsoft Lili";//语音包名称
if (!phone.DialUp(telephoneNumber)) return;//拨打电话
phone.Speak(msg);//发送语音
phone.HangUp();//挂断电话
}
}
}
}