|
Private Sub SMSSending(ByVal SmsContent As String, ByVal Mobileno As Int64) Try If SmsContent.Length > 155 Then SmsContent = SmsContent.Substring(0, 150) End If Dim client As WebClient = New WebClient Dim IDStatus As String client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)") client.QueryString.Add("user", "pemmasani") client.QueryString.Add("password", "0123456") client.QueryString.Add("api_id", "012345") client.QueryString.Add("to", Mobileno) client.QueryString.Add("text", SmsContent) Dim baseurl As String = "http://api.clickatell.com/http/sendmsg" Dim data As Stream = client.OpenRead(baseurl) Dim reader As StreamReader = New StreamReader(data) Dim s As String = reader.ReadToEnd() data.Close() reader.Close() IDStatus = s.Substring(0, 2) 'IDStatus = "ID" If IDStatus = "ID" Then Label1.Text = "ok" End If
Catch ex As Exception Response.Write(ex.Message) Exit Sub
------------------------------------------------------
Private Sub SendSMS() Try 'UpdateOldNewsStatus() Dim str As String Dim Count As Int64 Dim da As New SqlDataAdapter Dim subDs As New DataSet 'Dim cnn As New SqlConnection(dbname) str = "select * from cnn" da.SelectCommand = New SqlCommand(str, cnn) da.Fill(subDs, "table1") Count = subDs.Tables("table1").Rows.Count Dim i, j, z, subi, smsi As Int64 Dim Userid, SubCode, SMSContent As String Dim MobileNo As Int64 i = subDs.Tables("table1").Rows.Count - 1 If Count > 0 Then For i = 0 To Count Userid = subDs.Tables("table1").Rows(i)("Username") MobileNo = subDs.Tables("table1").Rows(i)("PhoneNo") str = "select * from SubscribedGames where UserId='" & Userid & "'" If i > 0 Then subDs.Tables("SubGames").Clear() End If da.SelectCommand = New SqlCommand(str, cnn) da.Fill(subDs, "SubGames") subi = subDs.Tables("SubGames").Rows.Count For j = 0 To subi - 1 SubCode = subDs.Tables("SubGames").Rows(j)("SubScribedGame") If j > 0 Then subDs.Tables("News").Clear() End If str = "select * from news where Category='" & SubCode & "' and status='New'" da.SelectCommand = New SqlCommand(str, cnn) da.Fill(subDs, "News") smsi = subDs.Tables("News").Rows.Count For z = 0 To smsi - 1 SMSContent = subDs.Tables("News").Rows(z)("Header") SMSSending(SMSContent, MobileNo)
Next Next Next UpdateOldNewsStatus() End If
---------------------------------------------------------------------
Private Sub UpdateOldNewsStatus(ByVal Category As String) 'Dim cnn As New SqlConnection(dbname) Dim cmd As SqlCommand Dim str As String If cnn.State = ConnectionState.Open Then cnn.Close() End If cnn.Open() str = "update News set status='Old' where Category='" & Category & "'" cmd = New SqlCommand(str, cnn) cmd.ExecuteScalar() cnn.Close() End Sub Private Sub UpdateOldNewsStatus() Dim cmd As SqlCommand Dim str As String If cnn.State = ConnectionState.Open Then cnn.Close() End If cnn.Open() str = "update News set status='Old'" cmd = New SqlCommand(str, cnn) cmd.ExecuteScalar() cnn.Close() End Sub
bye.... Pemmasani....
|