在一个旧项目中,我与DevShock.Smpp进行了SMSC集成。现在对该工具的支持不再可用,我遇到了必须发送PayLoad SMS的情况。
下面是我的代码
private static SmppSubmitSmRes Sendbin(byte[] bbin, bool multiMsg, string aNumber, string bNumber, bool isUniCode, long messageType, SmppConnection _mySmppClient)
{
SmppSubmitSmReq.BodyPdu reqSubmitSm = new SmppSubmitSmReq.BodyPdu
{
EsmClass = multiMsg ? new BitBuilder(Convert.ToByte(0x40)) : new BitBuilder(Convert.ToByte(0x0))
};
//Dim ResSubmit_Sm As SmppSubmitSmRes
// ReqSubmit_Sm.ShortMessage.SetValue(bbin)
//if it is unicode use 0x08 like for arabic or other unicode lang.
if (isUniCode)
{
reqSubmitSm.ShortMessage.DataCoding = messageType == 1 ? SmppDataCoding.FromValue(24) : SmppDataCoding.Unicode;
//reqSubmitSm.ShortMessage.DataCoding = SmppDataCoding.Unicode;
//.FromValue(CByte(&H8))
reqSubmitSm.SourceAddressNpi = new BitBuilder(1).Value;
}
else
{
reqSubmitSm.SourceAddressNpi = Convert.ToByte(0);
reqSubmitSm.ShortMessage.DataCoding = SmppDataCoding.Default;
reqSubmitSm.ShortMessage.DataCoding = messageType == 1 ? SmppDataCoding.FromValue(240) : SmppDataCoding.Default;
}
if (IsNumeric(aNumber))
{
reqSubmitSm.SourceAddressTon = isUniCode ? new BitBuilder(2).Value : (byte)0;
}
else
{
reqSubmitSm.SourceAddressTon = Convert.ToByte(5);
}
reqSubmitSm.DestinationAddressTon = Convert.ToByte(1);
reqSubmitSm.DestinationAddressNpi = Convert.ToByte(1);
reqSubmitSm.DestinationAddress = bNumber;
reqSubmitSm.SourceAddress = aNumber;
reqSubmitSm.ShortMessage.Value = bbin;
reqSubmitSm.SourceAddress = aNumber;
if (true)//delivery
{
reqSubmitSm.RegisteredDelivery = new BitBuilder(1);
}
var submitResponse = _mySmppClient.SubmitSm(new SmppSubmitSmReq(reqSubmitSm));
return submitResponse;
}