示例#1
0
    public static App.CustomModels.SendSmsStatus SendSms(String commaSeparaterTelephoneIDs, String messageText)
    {
        //return new App.CustomModels.SendSmsStatus();
        _DataContext  = new OMMDataContext();
        _ErrorMessage = String.Empty;
        //Get Int array from the receipients list
        int[] telephoneIDs = WebUtil.GetIntArray(commaSeparaterTelephoneIDs);
        ///Create the Web Service Object for Sending SMS
        _SmsService = new SMSService.TextAnywhere_SMS();
        //at first save the message to Messages Table
        Message message = SaveMessage(messageText.Trim());

        //Now save details message for individual reciepents in : Message_Recipients TABLE
        SaveMessageRecipients(message.ID, telephoneIDs);
        //Finally send message to the reciepents mobile
        String sentCells = SendMessage(telephoneIDs, message);

        App.CustomModels.SendSmsStatus reply = new App.CustomModels.SendSmsStatus();
        if (String.IsNullOrEmpty(_ErrorMessage))
        {
            reply.StatusID = 1;
            reply.Message  = sentCells;
        }
        else
        {
            reply.StatusID = -1;
            reply.Message  = _ErrorMessage;
        }
        return(reply);
    }
示例#2
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);
    }