neu
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports com.esendex.sdk.messaging
|
||||
Imports com.esendex.sdk.sent
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class cSMS
|
||||
@@ -11,17 +13,27 @@ Public Class cSMS
|
||||
Property sms_KundenNr As Object = Nothing
|
||||
Property sms_Kunde As Object = Nothing
|
||||
|
||||
|
||||
|
||||
|
||||
Property sms_Vorwahl As Object = Nothing
|
||||
Property sms_Handynummer As Object = Nothing
|
||||
Property sms_Nachricht As Object = Nothing
|
||||
Property sms_BatchId As Object = Nothing
|
||||
Property sms_MessageIds As Object = Nothing
|
||||
Property sms_Uris As Object = Nothing
|
||||
Property sms_Sachbearbeiter As String = Nothing
|
||||
Property sms_SachbearbeiterId As Integer
|
||||
Property sms_AvisoId As Object = Nothing
|
||||
|
||||
Property sms_Status As Integer = -1
|
||||
Property sms_Queued As Object = Nothing
|
||||
Property sms_Sent As Object = Nothing
|
||||
Property sms_Delivered As Object = Nothing
|
||||
Property sms_Failure As Object = Nothing
|
||||
|
||||
|
||||
Dim ESENDEX_USER As String = "al@verag.ag"
|
||||
Dim ESENDEX_PWD As String = "Developer#2"
|
||||
|
||||
Dim SQL As New SQL
|
||||
|
||||
@@ -54,9 +66,15 @@ Public Class cSMS
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Nachricht", sms_Nachricht))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_BatchId", sms_BatchId))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_MessageIds", sms_MessageIds))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Uris", sms_Uris))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Sachbearbeiter", sms_Sachbearbeiter))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_SachbearbeiterId", sms_SachbearbeiterId))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_AvisoId", sms_AvisoId))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Status", sms_Status))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Queued", sms_Queued))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Sent", sms_Sent))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Delivered", sms_Delivered))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sms_Failure", sms_Failure))
|
||||
|
||||
|
||||
Return list
|
||||
@@ -68,7 +86,7 @@ Public Class cSMS
|
||||
Public Function SAVE() As Boolean
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
|
||||
|
||||
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblSMS WITH(updlock,serializable) WHERE sms_id=@sms_id) " &
|
||||
" BEGIN " & getUpdateCmd() & " END " &
|
||||
" Else " &
|
||||
@@ -154,6 +172,71 @@ Public Class cSMS
|
||||
Return SQL.doSQL(sqlstr, "FMZOLL")
|
||||
End Function
|
||||
|
||||
Function sendSMS() As Boolean
|
||||
Try
|
||||
|
||||
Dim messagingService As New MessagingService(ESENDEX_USER, ESENDEX_PWD)
|
||||
'SENDEN DER SMS
|
||||
Dim result = messagingService.SendMessage(New SmsMessage(Me.sms_Handynummer, Me.sms_Nachricht, Me.sms_Account))
|
||||
|
||||
Dim Uris As String = ""
|
||||
Dim msgIDs As String = ""
|
||||
Try
|
||||
Me.sms_BatchId = result.BatchId
|
||||
|
||||
If result.MessageIds IsNot Nothing Then
|
||||
For Each m In result.MessageIds
|
||||
Uris &= m.Uri & ";;"
|
||||
msgIDs &= m.Id.ToString & ";;"
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
While Uris.EndsWith(";;")
|
||||
Uris = Uris.Substring(0, Uris.Length - 2)
|
||||
End While
|
||||
While msgIDs.EndsWith(";;")
|
||||
msgIDs = msgIDs.Substring(0, msgIDs.Length - 2)
|
||||
End While
|
||||
|
||||
Me.sms_MessageIds = msgIDs
|
||||
Me.sms_Uris = Uris
|
||||
|
||||
If Not Me.SAVE() Then
|
||||
MsgBox("Fehler: SMS Daten wurden nicht gespeichert!")
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler beim Senden der SMS!" & vbNewLine & ex.Message & ex.StackTrace)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Function checkSMSStatus() As String
|
||||
Try
|
||||
If Me.sms_Status >= 3 Then Return Me.sms_Status ' Bereits finaler Status, keine Abfrage nötig
|
||||
If If(Me.sms_MessageIds, "") = "" Then MsgBox("Keine MessageId gefunden!") : Return False ' Keine MsgId
|
||||
|
||||
Dim sendService As New SentService(ESENDEX_USER, ESENDEX_PWD)
|
||||
|
||||
'Send a message and retrieve the message ID
|
||||
Dim MSG = sendService.GetMessage(New Guid(Me.sms_MessageIds.ToString))
|
||||
Dim messageStatus = MSG.Status
|
||||
MsgBox(MSG.Status)
|
||||
'Status in DB Ubdaten
|
||||
Me.sms_Status = messageStatus
|
||||
Me.sms_Sent = MSG.SentAt
|
||||
Me.sms_Delivered = MSG.DeliveredAt
|
||||
If MSG.FailureReason IsNot Nothing Then Me.sms_Failure = MSG.FailureReason.Description
|
||||
Me.SAVE()
|
||||
|
||||
Return messageStatus
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler beim Prüfen des SMS Status!" & vbNewLine & ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user