PDA

View Full Version : سوال: ارسال SMS بیش از 140 کاراکتر با pdu



neegar
یک شنبه 14 اسفند 1390, 10:42 صبح
با سلام من یک پروژه sms نوشته و می خواستم در آن متن طولانی را ارسال کنم که sms طولانی ارسال نکرد
و پیغام زیر را به من داد
http://barnamenevis.org/attachment.php?attachmentid=79616&d=1324713174
و کدم هم به صورت زیر است :


Private Sub tmSendSMS_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmSendSMS.Tick
Me.Output("Process SMS sendings ... ")
Try
'1- Retrive passwords that is not send
Dim lsUser As New List(Of user)
lsUser = GetNotSents()

'2- for each record send sms to destination
For Each u As user In lsUser
'u.SMS = (Now.Ticks Mod 10000).ToString("0000")
If SendPass(u.MobileNo, u.SMS) Then
UpdateUser(u)
End If
Threading.Thread.Sleep(100)
Next

Catch ex As Exception

End Try
End Sub

Public Class user
Public MobileNo As String
Public SMS As String
Public ID As Integer
End Class

Dim ConnStr As String = "Data Source=TEB506\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True"

Private Function GetNotSents() As List(Of user)

Dim conn As New SqlClient.SqlConnection(ConnStr)
Dim cmd As New SqlClient.SqlCommand("Select MobileNo, SMS , ID From tblSMS Where IsSend =0", conn)
Dim lsuser As New List(Of user)

conn.Open()
Dim dr As SqlClient.SqlDataReader
dr = cmd.ExecuteReader
If dr.HasRows Then
While dr.Read
Dim u As New user
u.MobileNo = dr.Item("MobileNo").ToString().Trim
u.SMS = dr.Item("SMS").ToString()
u.ID = dr.Item("ID")

lsuser.Add(u)

End While

End If
conn.Close()
GetNotSents = lsuser
End Function

Private Function SendPass(ByVal MobileNo As String, ByVal SMS As String) As Boolean

Try
Dim pdu As SmsSubmitPdu
Dim alert As Boolean = False
Dim unicode As Boolean = True
If Not (alert OrElse [unicode]) Then
pdu = New SmsSubmitPdu(SMS, MobileNo, "")
Else
Dim dcs As Byte
If Not (alert OrElse Not [unicode]) Then
dcs = DataCodingScheme.NoClass_16Bit
ElseIf Not (Not alert OrElse [unicode]) Then
dcs = DataCodingScheme.Class0_7Bit
ElseIf (alert AndAlso [unicode]) Then
dcs = DataCodingScheme.Class0_16Bit
Else
dcs = DataCodingScheme.NoClass_7Bit
End If
pdu = New SmsSubmitPdu(SMS, MobileNo, dcs)
End If

CommSetting.comm.SendMessage(pdu)
Me.Output("Message sent to " + MobileNo)
Return True
Catch ex As Exception
Me.Output("failed to send message to " + MobileNo + " error : " + ex.Message)
Return False
End Try

End Function

Private Sub UpdateUser(ByVal u As user)

Try
Dim conn As New SqlClient.SqlConnection(ConnStr)
Dim cmd As New SqlClient.SqlCommand("UPDATE tblSMS set IsSend = 1 Where ID=" & u.ID, conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
Me.Output("Failed to Update DB , Error: " & ex.Message)
End Try
End Sub
لطفا کمکم کنید سریع :ناراحت::ناراحت:

sehm67
پنج شنبه 02 آذر 1391, 23:36 عصر
سلام

میدونم تاپیک قدیمیه اما من یه تاپیک زدم با عنوان مدیریت سیم کارت با gsm مودم و موبایل (http://barnamenevis.org/showthread.php?369658-%D9%85%D8%AF%DB%8C%D8%B1%DB%8C%D8%AA-%D8%B3%DB%8C%D9%85-%DA%A9%D8%A7%D8%B1%D8%AA-%D8%A7%D8%B2-%D8%B7%D8%B1%DB%8C%D9%82-GSM-%D9%85%D9%88%D8%AF%D9%85-%D9%88-%D9%85%D9%88%D8%A8%D8%A7%DB%8C%D9%84)

من هم با قضیه بالا مشکل دارم دوستان لطفا کمکم کنید