7d45 SMS Gateway - SMS Order System, ASP Script

                

Search the manual:

Overview Quick start Download Manual How to buy FAQ Contact Us
OZEKI NG SMS Gateway - Product Guide

Database Contents | SearchLeast Cost Routing

Home > Product Manual > Examples and Solutions > SMS Order System > ASP Script

SMS Gateway SMS Gateway Home

  Product Manual
  Introduction
  SMS technology
  Installation Guide
  User Guide
  Developers Guide
  Examples and Solutions
  Telephone networks
  Pin game
  E-mail to SMS Alerts
  2 way SMS to Email gateway
  SMS Order System
  Database
  ASP Script
  Least Cost Routing
  Load Balancing
  Asterisk PBX SMS
  SQL SMS Gateway
  SMS Service Provider
  Service Provider
  SMS PIN code query
  SMS Counter game
  SMS newsgroup
  Distributed SMS
  SMS Menu
  Google maps
  Forwarding
  Birthday greeting - SQL Express
  Birthday greeting - MySQL
  Birthday greeting - Oracle
  Instant brochure - MMS autoreply
  Alphabet letter game
  SMS sport betting service
  E-mail about outgoing SMS messages
  SMS Information Menu
  Email to SMS feature
  Reminder example
  Bulk SMS Client
  Bulk SMS to a given phone number range
  Filtering phone numbers
  Appendix
  FAQ
  Feature list
  Commercial Information
  Search
 



Contact Us!
If you wish to get further information, do not hesitate to contact us!

E-mail: info@ozekisms.com

If you have a technical question, please submit a support request on-line.


Callcenter developers
If you are working on telephone solutions, please check out the Ozeki VoIP SIP SDK.
It can be used to create:

Webphone solutions:
- Adobe Flash video phone
- Silverlight video phone
- Web to web calls
- Web to VoIP calls

Custom SIP clients:
- Silverlight SIP VoIP client
- Flash SIP VoIP client
- C# .net SIP VoIP client
- ASP .net SIP VoIP client
- Web based SIP VoIP client

Custom VoIP solutions:
- VoIP SIP softphones
- VoIP call center clients
- VoIP IVR systems
- VoIP predictive dialer systems
- VoIP auto dialer systems
- VoIP call assistant
- VoIP call recording systems
- VoIP intercom solutions

Sample ASP script for SMS Order System


The following script is called by Ozeki NG when a new SMS message arrives. The script processes the text of the incoming SMS messages and creates an SQL INSERT statement that is used to place a record into the orders database table. This script is an attachment of the ASP SMS Order System case study.

Download: asp_sms_example_order_system.zip

The script should be saved into the following director:

C:\Program Files\Ozeki\OzekiNG - SMS Gateway\config\ordersystem\sample.aspx

<%@ Page Language="C#"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<%
//************************************************************
//Copy the properties of the incoming SMS into local variables
//************************************************************

string sender = Request.QueryString["sender"];
string receiver = Request.QueryString["receiver"];
string messagedata = Request.QueryString["messagedata"];
string messageid = Request.QueryString["messageid"];
string messagetype = Request.QueryString["messagetype"];
string senttime = Request.QueryString["senttime"];
string receivedtime = Request.QueryString["receivedtime"];
string serviceprovider = Request.QueryString["operatornames"];

//************************************************************
//Process incoming message
//example: "Order: Lipton 1 box, Nescafe 2 box, Sugar 10 kg";
//************************************************************
bool messageFormatOk = true;


string columnames = "";
string values = "";
string sql = "";
//messagedata = "Order: Lipton 1 box, Nescafe 2 box, Sugar 10 kg";

messagedata = messagedata.ToLower();
if (messagedata.StartsWith("order:")) messagedata = messagedata.Substring(6);
try
{
        string[] items = messagedata.Trim().Split(new char[] { ',', ';' });
        for (int x = 0; x < items.Length; x++)
        {
                string[] itementry = items[x].Trim().Split(new char[] { ' ' }, 2);
                string itemname = itementry[0];
                string itemquantity = itementry[1];

                if ((itemname == "lipton") || (itemname == "nescafe") || (itemname == "sugar"))
                {
                        if (columnames.Length > 0) columnames += ",";
                        columnames += itemname;
                        if (values.Length > 0) values += ",";
                        values += "'" + itemquantity + "'";
                }
                else
                {
                        //invalid item name
                        messageFormatOk = false;
                }
        }

        if ((columnames.Length > 0) && (messageFormatOk)) {
                sql = "INSERT INTO orders (shop,orderdate," + columnames + ") " +
                          "VALUES ('"+sender+"',getdate()," + values + ")";
        }
}
catch
{
        messageFormatOk = false;
}

//************************************************************
//Connect to the database and insert the record
//************************************************************
if (messageFormatOk)
{
        string sServer = ".\\SQLEXPRESS";
        string sUser="ozekiuser";
        string sPwd="ozekipass";
        string sDB="ozeki";
        string sConStr = "Server="+sServer+";User ID=" + sUser + ";"+
        "password=" + sPwd + ";Database=" + sDB        +";Persist Security Info=True";

        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = sConStr;
        conn.Open();
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = sql;
        cmd.ExecuteNonQuery();
        conn.Close();
}

//************************************************************
//create the response message(s) in the following format:
//http://www.ozekisms.com/index.php?owpn=355
//************************************************************
string respmsg = "";
if (messageFormatOk) {
    respmsg = "Your order has been accepted at " + receivedtime;
} else {
    respmsg = "Invalid format. Please send you order again. Correct "+
    "format example: Lipton 1 box, Nescafe 2 box, Sugar 10 kg";
}

string destnum = sender;
string resptype = "SMS:TEXT";
string resp = "{"+resptype+"}{}{}{"+destnum+"}{"+respmsg+"}";

Response.Write(resp);

%>


Dig deeper!
People who read this also read...





Next page: Least Cost Routing
Copyright © 2000 - 2013 Ozeki Informatics Ltd.
All rights reserved

Software PBX for Windows | VoIP SDK   |   Legal information   |   Privacy policy   |   Terms of use
Please, address your inquiries to info@ozekisms.com


0