using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Text; using System.IO; using System.Net; using System.Web.Services; using System.Web.Security; using System.Configuration; using System.Threading; using System.Data; using System.Data.SqlClient; public partial class VehicleEnforaGPSSchedule : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public void Application_Init(Object sender, EventArgs e) { Threading(); } public string GetConnectionString() { return ConfigurationManager.ConnectionStrings["EnforaTrackerConnectionString"].ConnectionString; } protected void Threading() { using(SqlConnection connection = new SqlConnection(GetConnectionString())) { string command = "SELECT [VehiclePhoneNumber] FROM [tbl_Vehicle_Data]"; SqlCommand cmd = new SqlCommand(command, connection); cmd.CommandType = System.Data.CommandType.Text; SqlDataReader reader; try { connection.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader.HasRows) { for (int i = 0; i < reader.FieldCount; i++) { GistMeGps g = new GistMeGps(); Thread thread = new Thread(new ThreadStart(g.RequestGPSCoordinate(i.ToString()))); thread.Start(i.ToString()); return; } } } } catch (SqlException sqlex) { lblError.Text = sqlex.ToString(); } } } } public class GistMeGps { public void RequestGPSCoordinate(string phoneNo) { UriBuilder urlBuilder = new UriBuilder(); urlBuilder.Host = "192.168.1.125"; urlBuilder.Port = 8800; string PhoneNumber = phoneNo; string message = ">RSP=T;ID=011252000596969;AT$GPSRD=10<"; urlBuilder.Query = string.Format("PhoneNumber=%2B" + PhoneNumber + "&Text=" + message); HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(urlBuilder.ToString(), false)); HttpWebResponse httpResponse = (HttpWebResponse)(httpReq.GetResponse()); } }
for
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)