コード例 #1
0
    public static App.CustomModels.SendSmsStatus SendSms(String telephoneNumber, String messageText)
    {
        String userName = ConfigReader.TextAnywhereClientID;
        String password = ConfigReader.TextAnywhereClientPassword;

        String[] serviceReplyArray = null;
        String   serviceReply      = String.Empty;

        ///Create the Web Service Object for Sending SMS
        _SmsService = new SMSService.TextAnywhere_SMS();
        if (IsSmsServiceRunning())
        {
            if (ConfigReader.SendSmsToClient)
            {
                OMMDataContext context       = new OMMDataContext();
                SMS_Message    smsMessageRef = context.dalSMSMessagesInsert(String.Empty, DateTime.Now).SingleOrDefault();
                //SMSService.TextAnywhere_SMS smsService = new SMSService.TextAnywhere_SMS();
                serviceReply = _SmsService.SendSMSEx(userName, password,
                                                     smsMessageRef.Client_Ref, ConfigReader.BILLING_REF,
                                                     (int)CONNECTION_TYPES.LOW_VOLUME, ConfigReader.ORIGINATOR,
                                                     (int)ORIGINATOR_TYPES.NAME, telephoneNumber,
                                                     messageText, 0, (int)REPLY_TYPES.NONE, String.Empty);
            }
            // Extract return codes
            serviceReplyArray = serviceReply.Split(COMMA_SEPARATOR);

            if (serviceReplyArray.Length != 1) //receivers.Count)
            {
                _ErrorMessage = "Unable to send SMS message. SMS Service did not return the expected response.";
            }
        }
        App.CustomModels.SendSmsStatus reply = new App.CustomModels.SendSmsStatus();
        if (String.IsNullOrEmpty(_ErrorMessage))
        {
            reply.StatusID = 1;
            reply.Message  = telephoneNumber;
        }
        else
        {
            reply.StatusID = -1;
            reply.Message  = _ErrorMessage;
        }
        return(reply);
    }
コード例 #2
0
ファイル: SendSMS.aspx.cs プロジェクト: hazdik/bdomm
    private static bool SendFinalMessage(Message message, IList <TelephoneNumber> receivers)
    {
        //String BILLING_REF = ConfigReader.BILLING_REF;
        //String ORIGINATOR = ConfigReader.ORIGINATOR;

        ///Generate a New Message Reference by Executing a Stored Procedure (dalSMSMessagesInsert) as in Win App.
        ///[Note: Don't Know Why We are Doing This]
        SMS_Message smsMessageRef = _DataContext.dalSMSMessagesInsert(String.Empty, DateTime.Now).SingleOrDefault();
        String      userName      = ConfigReader.TextAnywhereClientID;
        String      password      = ConfigReader.TextAnywhereClientPassword;

        String[] WSSendSMSReplyArray = null;
        String   WSSendSmsReply      = String.Empty;

        //String[] returnCodePair = null;

        System.Text.StringBuilder sb = new System.Text.StringBuilder(10);

        // Check recipients list not empty
        if (receivers.Count <= 0)
        {
            return(false);
        }
        // Check SMS Service is running
        if (!IsSmsServiceRunning())
        {
            return(false);
        }

        // Build Comma Separated destination number list
        foreach (TelephoneNumber mrr in receivers)
        {
            if (sb.Length > 0)
            {
                sb.Append(COMMA_SEPARATOR);
            }

            sb.Append(mrr.Number);
        }
        if (ConfigReader.SendSmsToClient)
        {
            //SMSService.TextAnywhere_SMS smsService = new SMSService.TextAnywhere_SMS();
            WSSendSmsReply = _SmsService.SendSMSEx(userName, password,
                                                   smsMessageRef.Client_Ref, ConfigReader.BILLING_REF,
                                                   (int)CONNECTION_TYPES.LOW_VOLUME, ConfigReader.ORIGINATOR,
                                                   (int)ORIGINATOR_TYPES.NAME, sb.ToString(),
                                                   message.Text, 0, (int)REPLY_TYPES.NONE, String.Empty);
        }
        // Extract return codes
        WSSendSMSReplyArray = WSSendSmsReply.Split(COMMA_SEPARATOR);

        if (WSSendSMSReplyArray.Length != receivers.Count)
        {
            _ErrorMessage = "Unable to send SMS message. SMS Service did not return the expected response.";
            return(false);
        }
        else
        {
            ///After Successfully Sending Message Set Message status to delivered
            message.Delivered = true;
            _DataContext.SubmitChanges();
        }
        return(true);
    }