示例#1
0
        static void Main(string[] args)
        {
            SmsProtocolGsm    objGsmProtocol = new xssmsmms.SmsProtocolGsm();
            SmsMessage        objSmsMessage  = new xssmsmms.SmsMessage();
            SmsConstants      objConstants   = new xssmsmms.SmsConstants();
            SmsDeliveryStatus objDeliveryStatus;
            object            obj;
            string            strMessageRef;

            // 选择连接设备
            objGsmProtocol.Device = ReadDevice(objGsmProtocol);
            // 定义日志文件
            objGsmProtocol.LogFile = "C:\\SMSLog.txt";



            // 短信息参数设置
            objSmsMessage.Recipient             = ReadInput("增加发送号码(号码必须以+86开头): ", false);
            objSmsMessage.Format                = objConstants.asMESSAGEFORMAT_UNICODE_MULTIPART; // 支持中文超长短信
            objSmsMessage.Data                  = "这是一条测试信息";
            objSmsMessage.RequestDeliveryStatus = ReadYesNo("是否需要短信回执(y/n)? ") ? -1 : 0;

            // 发送信息
            Console.WriteLine("正在发送...");
            obj           = objSmsMessage;
            strMessageRef = objGsmProtocol.Send(ref obj);
            Console.WriteLine("发所结果: " + objGsmProtocol.LastError + " (" + objGsmProtocol.GetErrorDescription(objGsmProtocol.LastError) + ")");

            if (objGsmProtocol.LastError == 0)
            {
                Console.WriteLine("信息回执: " + strMessageRef);
                do
                {
                    if ((objDeliveryStatus = (SmsDeliveryStatus)objGsmProtocol.QueryStatus(strMessageRef)) == null)
                    {
                        Console.WriteLine("检测回执失败");
                    }
                    else
                    {
                        Console.WriteLine("接收状态 (" + strMessageRef + "): " + objDeliveryStatus.Status.ToString() + " (" + objDeliveryStatus.StatusDescription + ")");
                        if (objDeliveryStatus.IsCompleted == 0)
                        {
                            System.Threading.Thread.Sleep(5000);
                        }
                    }
                } while (objDeliveryStatus != null && objDeliveryStatus.IsCompleted == 0);
            }

            Console.WriteLine("等待...");
            System.Threading.Thread.Sleep(3000);
        }
示例#2
0
文件: Program.cs 项目: ym1623/ym1623
        static void Main(string[] args)
        {
            SmsProtocolGsm objGsmProtocol = new xssmsmms.SmsProtocolGsm();
            SmsMessage objSmsMessage = new xssmsmms.SmsMessage();
            SmsConstants objConstants = new xssmsmms.SmsConstants();
            SmsDeliveryStatus objDeliveryStatus;
            object obj;
            string strMessageRef;

            // 选择连接设备
            objGsmProtocol.Device = ReadDevice(objGsmProtocol);
            // 定义日志文件
            objGsmProtocol.LogFile = "C:\\SMSLog.txt";

            // 短信息参数设置
            objSmsMessage.Recipient = ReadInput("增加发送号码(号码必须以+86开头): ", false);
            objSmsMessage.Format = objConstants.asMESSAGEFORMAT_UNICODE_MULTIPART; // 支持中文超长短信
            objSmsMessage.Data = "这是一条测试信息";
            objSmsMessage.RequestDeliveryStatus = ReadYesNo("是否需要短信回执(y/n)? ") ? -1 : 0;

            // 发送信息
            Console.WriteLine("正在发送...");
            obj = objSmsMessage;
            strMessageRef = objGsmProtocol.Send(ref obj);
            Console.WriteLine("发所结果: " + objGsmProtocol.LastError + " (" + objGsmProtocol.GetErrorDescription(objGsmProtocol.LastError) + ")");

            if (objGsmProtocol.LastError == 0)
            {
                Console.WriteLine("信息回执: " + strMessageRef);
                do
                {
                    if ((objDeliveryStatus = (SmsDeliveryStatus)objGsmProtocol.QueryStatus(strMessageRef)) == null)
                    {
                        Console.WriteLine("检测回执失败");
                    }
                    else
                    {
                        Console.WriteLine("接收状态 (" + strMessageRef + "): " + objDeliveryStatus.Status.ToString() + " (" + objDeliveryStatus.StatusDescription + ")");
                        if (objDeliveryStatus.IsCompleted == 0)
                            System.Threading.Thread.Sleep(5000);
                    }
                } while (objDeliveryStatus != null && objDeliveryStatus.IsCompleted == 0);
            }

            Console.WriteLine("等待...");
            System.Threading.Thread.Sleep(3000);
        }