Project

General

Profile

MyCode.txt

atep, 02/17/2017 04:45 AM

 
1
Imports System.Collections.Generic
2
Imports System.ComponentModel
3
Imports System.Drawing
4
Imports System.Linq
5
Imports System.Text
6
Imports System.Windows.Forms
7
Imports System.IO.Ports
8
Imports System.IO
9
Imports System.Reflection
10
Imports System.Threading
11
Imports MessagingToolkit.Core
12
Imports MessagingToolkit.Core.Mobile
13
Imports MessagingToolkit.Core.Log
14
Imports MessagingToolkit.Core.Mobile.Message
15
Imports MessagingToolkit.Core.Mobile.Event
16
Imports MessagingToolkit.Core.Helper
17
Imports MessagingToolkit.Pdu
18
Imports MessagingToolkit.Pdu.Ie
19
Imports MessagingToolkit.Pdu.WapPush
20
Public Class frmGSM
21

                    
22
    Inherits Form
23
    'Private mobileGateway As IMobileGateway = MobileGatewayFactory.[Default]
24
    'Private Shared CustomDateTimeFormat As String = "dd MMM yyyy, hh:mm:ss tt"
25
    'Private Parity As New Dictionary(Of String, PortParity)() From { _
26
    ' {"None", PortParity.None}, _
27
    ' {"Odd", PortParity.Odd}, _
28
    ' {"Even", PortParity.Even}, _
29
    ' {"Mark", PortParity.Mark}, _
30
    ' {"Space", PortParity.Space} _
31
    '}
32

                    
33
    'Private StopBits As New Dictionary(Of String, PortStopBits)() From { _
34
    ' {"1", PortStopBits.One}, _
35
    ' {"1.5", PortStopBits.OnePointFive}, _
36
    ' {"2", PortStopBits.Two}, _
37
    '{"None", PortStopBits.None} _
38
    '}
39

                    
40

                    
41
    'Private Handshake As New Dictionary(Of String, PortHandshake)() From { _
42
    ' {"None", PortHandshake.None}, _
43
    '' {"RequestToSendXOnXOff", PortHandshake.RequestToSendXOnXOff}, _
44
    ' {"XOnXOff", PortHandshake.XOnXOff}, _
45
    ' {"RequestToSend", PortHandshake.RequestToSend} _
46
    '}
47

                    
48

                    
49
    'Private MessageType As New Dictionary(Of String, MessageStatusType)() From { _
50
    ' {"Received Unread Message", MessageStatusType.ReceivedUnreadMessages}, _
51
    ' {"Received Read Message", MessageStatusType.ReceivedReadMessages}, _
52
    ' {"Stored Unsent Message", MessageStatusType.StoredUnsentMessages}, _
53
    ' {"Stored Sent Message", MessageStatusType.StoredSentMessages}, _
54
    ' {"All Message", MessageStatusType.AllMessages} _
55
    '}
56

                    
57

                    
58
    'Private MessageEncoding As New Dictionary(Of String, MessageDataCodingScheme)() From { _
59
    ' {"Auto Detect", MessageDataCodingScheme.Undefined}, _
60
    ' {"Default Alphabet - 7 Bits", MessageDataCodingScheme.DefaultAlphabet}, _
61
    ' {"ANSI - 8 Bits", MessageDataCodingScheme.EightBits}, _
62
    ' {"Unicode - 16 Bits", MessageDataCodingScheme.Ucs2} _
63
    '}
64

                    
65

                    
66
    'Private MessageSplit As New Dictionary(Of String, MessageSplitOption)() From { _
67
    ' {"Truncate", MessageSplitOption.Truncate}, _
68
    ' {"Simple Split", MessageSplitOption.SimpleSplit}, _
69
    ' {"Concatenate", MessageSplitOption.Concatenate} _
70
    '}
71

                    
72
    'Private QueuePriority As New Dictionary(Of String, MessageQueuePriority)() From { _
73
    ' {"Low", MessageQueuePriority.Low}, _
74
    ' {"Normal", MessageQueuePriority.Normal}, _
75
    ' {"High", MessageQueuePriority.High} _
76
    '}
77

                    
78

                    
79
    'Private ValidityPeriod As New Dictionary(Of String, MessageValidPeriod)() From { _
80
    ' {"1 Hour", MessageValidPeriod.OneHour}, _
81
    '{"3 Hours", MessageValidPeriod.ThreeHours}, _
82
    '{"6 Hours", MessageValidPeriod.SixHours}, _
83
    '{"12 Hours", MessageValidPeriod.TwelveHours}, _
84
    '{"1 Day", MessageValidPeriod.OneDay}, _
85
    '{"1 Week", MessageValidPeriod.OneWeek}, _
86
    '{"Maximum", MessageValidPeriod.Maximum} _
87
    '}
88

                    
89
    ' Log level
90
    'Private LoggingLevel As New Dictionary(Of String, LogLevel)() From { _
91
    ' {"Error", LogLevel.[Error]}, _
92
    ' {"Warn", LogLevel.Warn}, _
93
    ' {"Info", LogLevel.Info}, _
94
    ' {"Verbose", LogLevel.Verbose} _
95
    '}
96

                    
97
    ' Message class
98
    'Private MessageClass As New Dictionary(Of String, Integer)() From { _
99
    ' {"None", 0}, _
100
    ' {"ME", PduUtils.DcsMessageClassMe}, _
101
    ' {"SIM", PduUtils.DcsMessageClassSim}, _
102
    ' {"TE", PduUtils.DcsMessageClassTe} _
103
    '}
104

                    
105
    ' DCS Message class enum lookup
106
    'Private DcsMessageClass As New Dictionary(Of String, MessageClasses)() From { _
107
    ' {"None", MessageClasses.None}, _
108
    ' {"ME", MessageClasses.[Me]}, _
109
    ' {"SIM", MessageClasses.Sim}, _
110
    ' {"TE", MessageClasses.Te} _
111
    '}
112

                    
113

                    
114

                    
115
    'Private AllStorages As New List(Of MessageStorage)() From { _
116
    ' MessageStorage.Sim, _
117
    ' MessageStorage.Phone, _
118
    ' MessageStorage.MobileTerminating _
119
    '}
120

                    
121
    'Private Models As New List(Of String)() From { _
122
    ' "Wavecom", _
123
    ' "Huawei", _
124
    ' "Sony Ericsson", _
125
    ' "Siemens" _
126
    '}
127

                    
128
    Public Delegate Sub DisplayCallLog(e As IncomingCallEventArgs)
129
    Public Delegate Sub DisplayCallEventLog(e As OutgoingCallEventArgs)
130
    'Private Delegate Sub DisplayMessageLog(e As MessageReceivedEventArgs)
131
    'Private Delegate Sub DisplayCallLog(e As IncomingCallEventArgs)
132
    'Private Delegate Sub DisplayCallEventLog(e As OutgoingCallEventArgs)
133
    'Private Delegate Sub DisplayUssdResponse(e As UssdReceivedEventArgs)
134

                    
135
    'Private _displayMessageLog As DisplayMessageLog
136
    'Private _displayUssdResponse As DisplayUssdResponse
137
    'Private _displayCallLog As DisplayCallLog
138
    'Private _displayCallEventLog As DisplayCallEventLog
139

                    
140
    Public _displayCallLog As DisplayCallLog
141
    Public _displayCallEventLog As DisplayCallEventLog
142
    'Private Const ProviderFileExtension As String = ".mm1"
143
    'Private Const MMSProviderPath As String = "MMSProviders"
144
#End Region
145
    Private Sub frmSMS_Load(sender As Object, e As EventArgs) Handles MyBase.Load
146
        ' Add the port
147
        Dim portNames As String() = SerialPort.GetPortNames()
148
        If portNames.Length > 0 Then
149

                    
150
            ' There is a bug that for high COM port there is a "c" at the back, e.g. "COM11c"
151
            Dim sortedList = portNames
152

                    
153
            Dim id As PlatformID = Environment.OSVersion.Platform
154
            If id = PlatformID.Win32Windows OrElse id = PlatformID.Win32NT Then
155
                ' This is a Windows based OS, serial port should start with COM
156
                portNames.OrderBy(Function(port) Convert.ToInt32(port.Replace("COM", String.Empty).Replace("c", String.Empty)))
157
            End If
158

                    
159
            'var sortedList = portNames.OrderBy(port => port.Replace("COM", string.Empty));
160

                    
161
            For Each port As String In sortedList
162
                If Not cboPort.Items.Contains(port) Then
163
                    cboPort.Items.Add(port)
164
                End If
165
            Next
166
            cboPort.SelectedIndex = 0
167
        End If
168
        ' Message indication option
169
        cboMessageIndicationOption.Items.AddRange(New String() {"Trigger", "Polling"})
170
        cboMessageIndicationOption.SelectedIndex = 0
171

                    
172
        _displayMessageLog = New DisplayMessageLog(AddressOf Me.ShowMessageLog)
173
        _displayCallLog = New DisplayCallLog(AddressOf Me.ShowCallLog)
174
        _displayCallEventLog = New DisplayCallEventLog(AddressOf Me.ShowCallEventLog)
175

                    
176
    End Sub
177
    Private Sub btnConnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
178
        Dim config As MobileGatewayConfiguration = MobileGatewayConfiguration.NewInstance()
179
        'string portName = cboPort.Text;
180
        'if (portName.EndsWith("c")) portName = portName.Substring(0, portName.Length - 1);
181
        config.PortName = cboPort.Text
182
        config.BaudRate = PortBaudRate.BitsPerSecond115200
183
        config.DataBits = PortDataBits.Eight
184
        config.Parity = PortParity.None
185
        config.StopBits = PortStopBits.One
186
        config.Handshake = PortHandshake.None
187
        config.DisablePinCheck = True
188

                    
189
        '  If set to true, then a dialog box will be popped up for any API errors
190
        config.DebugMode = chkDebugMode.Checked
191

                    
192
        ' Default to verbose by default
193
        config.LogLevel = LogLevel.Verbose
194

                    
195
        ' Set the connected event
196
        AddHandler config.GatewayConnected, AddressOf OnGatewayConnect
197

                    
198
        config.DtrEnable = True
199
        config.RtsEnable = True
200
        config.LicenseKey = ""
201

                    
202
        ' If we want persistence queue. Default to false
203
        'config.PersistenceQueue = true;
204

                    
205
        ' Set a different log file prefix and path
206
        'config.LogFile = "mylog";
207
        'config.LogLocation = @"c:\temp";
208

                    
209
        ' Set the log file name without the date
210
        config.LogNameFormat = LogNameFormat.Name
211

                    
212
        ' Set watch dog interval to 5 seconds. Default to 60 seconds
213
        'config.WatchDogInterval = 5000;
214
        ' You can also specify the total number of milliseconds for AT command time out
215
        ' Multiply these 2 parameters you can the number of milliseconds for command time out. 
216
        ' E.g. below is the default of 30 seconds
217
        config.CommandWaitInterval = 50
218
        config.CommandWaitRetryCount = 100
219

                    
220
        ' Do this if there is a problem you faced when device is unplug and plug in again to the server
221
        ' Most of the time you don't need to set these 2 parameter at all. They should be defaulted to FALSE.
222
        config.SafeConnect = False
223
        config.SafeDisconnect = False
224

                    
225
        ' Create the gateway for mobile
226
        Dim _messageGateway As MessageGateway(Of IMobileGateway, MobileGatewayConfiguration) = MessageGateway(Of IMobileGateway, MobileGatewayConfiguration).NewInstance()
227
        Try
228
            btnConnect.Enabled = False
229
            mobileGateway = _messageGateway.Find(config)
230
            If mobileGateway Is Nothing Then
231
                MessageBox.Show("Error connecting to gateway. Check the log file", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
232
                Return
233
            End If
234
            'mobileGateway.LogLevel = LogLevel.Verbose;
235
            'txtSmsc.Text = mobileGateway.ServiceCentreAddress.Number
236
            updSendRetries.Value = mobileGateway.Configuration.SendRetries
237
            updPollingInterval.Value = mobileGateway.Configuration.MessagePollingInterval
238
            updSendWaitInterval.Value = mobileGateway.Configuration.SendWaitInterval
239

                    
240
            chkDeleteReceivedMessage.Checked = mobileGateway.Configuration.DeleteReceivedMessage
241
            txtLogFile.Text = mobileGateway.LogFile
242
            AddHandler mobileGateway.MessageReceived, AddressOf OnMessageReceived
243
            AddHandler mobileGateway.MessageSendingFailed, AddressOf OnMessageFailed
244
            AddHandler mobileGateway.MessageSent, AddressOf OnMessageSent
245
            AddHandler mobileGateway.CallReceived, AddressOf OnCallReceived
246
            AddHandler mobileGateway.GatewayDisconnected, AddressOf OnGatewayDisconnect
247
            AddHandler mobileGateway.WatchDogFailed, AddressOf OnWatchDogFailed
248
            ' Set the serial port read time out. Default to 3 seconds
249
            'mobileGateway.ReadTimeout = 6000;
250
            mobileGateway.EnableCallNotifications()
251
            'AddHandler mobileGateway.CallDialled, New OutgoingCallEventHandler(AddressOf OnCallDialled)
252
            'mobileGateway.EnableCLIR()
253
            'mobileGateway.EnableCOLP()
254
            ' Set the serial port write time out. Default to 3 seconds
255
            'mobileGateway.WriteTimeout = 6000;
256
            lSttsGSMDevice.Text = "GSM Connected"
257
            mobileGateway.SendCommand("AT+CLCC=1")
258
          Catch ex As Exception
259
            MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
260
        Finally
261
            btnConnect.Enabled = True
262
        End Try
263
    End Sub
264
    Private Sub btnDisconnect_Click(sender As Object, e As EventArgs) Handles btnDisconnect.Click
265
        Try
266
            If mobileGateway IsNot Nothing Then
267
                btnDisconnect.Enabled = False
268
                If mobileGateway.Disconnect() Then
269
                    mobileGateway.Dispose()
270
                    mobileGateway = Nothing
271
                    mobileGateway = MobileGatewayFactory.[Default]
272
                    lSttsGSMDevice.Text = "GSM Disconnected"
273
                Else
274
                    MessageBox.Show(mobileGateway.LastError.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
275
                End If
276
            End If
277
        Finally
278
            btnDisconnect.Enabled = True
279
        End Try
280
    End Sub
281
    Private Sub btnApplyConfiguration_Click(sender As Object, e As EventArgs) Handles btnApplyConfiguration.Click
282
        Dim sendRetries As Integer = Convert.ToInt32(updSendRetries.Value)
283
        Dim pollingInterval As Integer = Convert.ToInt32(updPollingInterval.Value)
284
        Dim sendWaitInterval As Integer = Convert.ToInt32(updSendWaitInterval.Value)
285
        Dim deleteReceivedMessage As Boolean = chkDeleteReceivedMessage.Checked
286
        Dim debugMode As Boolean = chkDebugMode.Checked
287

                    
288
        If sendRetries > 0 Then
289
            mobileGateway.Configuration.SendRetries = sendRetries
290
        End If
291
        If pollingInterval > 0 Then
292
            mobileGateway.Configuration.MessagePollingInterval = pollingInterval
293
        End If
294
        If sendWaitInterval > 0 Then
295
            mobileGateway.Configuration.SendWaitInterval = sendWaitInterval
296
        End If
297

                    
298
        mobileGateway.Configuration.DebugMode = debugMode
299
        mobileGateway.Configuration.DeleteReceivedMessage = deleteReceivedMessage
300
    End Sub
301
   
302
    Private Sub chkEnableMessageIndication_CheckedChanged(sender As Object, e As EventArgs) Handles chkEnableMessageIndication.CheckedChanged
303
        cboMessageIndicationOption.Enabled = chkEnableMessageIndication.Checked
304
    End Sub
305
    Private Sub btnApplyMessageSettings_Click(sender As Object, e As EventArgs) Handles btnApplyMessageSettings.Click
306
        Try
307
            btnApplyMessageSettings.Enabled = False
308
            Dim result As Boolean = False
309
            If chkEnableMessageIndication.Checked Then
310
                If cboMessageIndicationOption.Text.Equals("Trigger") Then
311
                    ' Incoming SMS and status report messages will be using trigger
312
                    result = mobileGateway.EnableNewMessageNotification(MessageNotification.ReceivedMessage Or MessageNotification.StatusReport)
313

                    
314
                    ' Set to false to disable polling
315
                    mobileGateway.PollNewMessages = False
316
                Else
317
                    ' If you fail to receive status report indication, then try to comment this line,
318
                    ' and uncomment out DisableMessageNotifications
319
                    result = mobileGateway.EnableNewMessageNotification(MessageNotification.StatusReport)
320

                    
321
                    ' Disable incoming notifications since we want to use polling
322
                    'result = mobileGateway.DisableMessageNotifications();
323

                    
324
                    ' Incoming SMS will be polled periodically
325

                    
326
                    mobileGateway.PollNewMessages = True
327
                End If
328
            Else
329
                ' Disable all incoming notifications
330
                result = mobileGateway.DisableMessageNotifications()
331

                    
332
                ' No polling will be performed
333
                mobileGateway.PollNewMessages = False
334
            End If
335
            mobileGateway.Configuration.DeleteReceivedMessage = chkDeleteAfterReceive.Checked
336
            If result Then
337
                MessageBox.Show("Message settings are applied", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
338
            Else
339
                MessageBox.Show("Error applying settings", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
340
            End If
341
        Finally
342
            btnApplyMessageSettings.Enabled = True
343
        End Try
344
    End Sub
345
    Private Sub OnMessageReceived(sender As Object, e As MessageReceivedEventArgs)
346
        txtMessageLog.BeginInvoke(_displayMessageLog, e)
347
    End Sub
348
    Private Sub OnMessageSent(sender As Object, e As MessageEventArgs)
349
        Dim sms As Sms = DirectCast(e.Message, Sms)
350
        MessageBox.Show("Message is sent successfully to " & sms.DestinationAddress & ". Message index is  " & String.Join(",", (sms.Indexes.ConvertAll(Of String)(Function(i As Integer) i.ToString())).ToArray()) & ". Message identifier is " & sms.Identifier, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
351
    End Sub
352
    Private Sub OnMessageFailed(sender As Object, e As MessageErrorEventArgs)
353
        Dim sms As Sms = DirectCast(e.Message, Sms)
354
        MessageBox.Show("Failed to send message to " & sms.DestinationAddress, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
355
        MessageBox.Show(e.[Error].Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
356

                    
357
    End Sub
358
    Private Sub ShowMessageLog(e As MessageReceivedEventArgs)
359
        If e.Message.MessageType = MessageTypeIndicator.MtiSmsDeliver Then
360
            txtMessageLog.AppendText("Received message from " & e.Message.PhoneNumber & vbLf)
361
            txtMessageLog.AppendText("Received date: " & e.Message.ReceivedDate & vbLf)
362
            txtMessageLog.AppendText("Message type: " & Convert.ToString(e.Message.MessageType) & vbLf)
363
            txtMessageLog.AppendText("Received content: " & e.Message.Content & vbLf)
364
            txtMessageLog.AppendText(vbLf)
365
        Else
366
            If e.Message.DeliveryStatus = MessageStatusReportStatus.Success Then
367
                txtMessageLog.AppendText("Message is delivered to " & e.Message.PhoneNumber & vbLf)
368
                txtMessageLog.AppendText("Delivered date: " & e.Message.ReceivedDate & vbLf)
369
                txtMessageLog.AppendText("Message type: " & Convert.ToString(e.Message.MessageType) & vbLf)
370
                txtMessageLog.AppendText("Content: " & e.Message.Content & vbLf)
371
                txtMessageLog.AppendText(vbLf)
372
            Else
373
                txtMessageLog.AppendText("Message is not delivered to " & e.Message.PhoneNumber & vbLf)
374
                txtMessageLog.AppendText("Message type: " & Convert.ToString(e.Message.MessageType) & vbLf)
375
                txtMessageLog.AppendText("Delivery status: " & Convert.ToString(e.Message.DeliveryStatus) & vbLf)
376
                txtMessageLog.AppendText("Content: " & e.Message.Content & vbLf)
377
                txtMessageLog.AppendText(vbLf)
378
            End If
379
        End If
380
    End Sub
381
    Private Sub ShowCallLog(e As IncomingCallEventArgs)
382
        txtIncomingCallIndication.AppendText("Call received from " & e.CallInformation.Number)
383
        txtIncomingCallIndication.AppendText(vbLf)
384
        txtIncomingCallIndication.AppendText("Number type - " & Convert.ToString(e.CallInformation.NumberType))
385
        txtIncomingCallIndication.AppendText(vbLf & vbLf)
386
    End Sub
387
    Private Sub frmSMS_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
388
        If mobileGateway IsNot Nothing Then
389
            mobileGateway.Disconnect()
390
            mobileGateway.Dispose()
391
            mobileGateway = Nothing
392
        End If
393
    End Sub
394
   
395
   
396
    Private Sub btnMakeCall_Click(sender As Object, e As EventArgs) Handles btnMakeCall.Click
397
        Try
398

                    
399
            If Not String.IsNullOrEmpty(txtCallingNo.Text) Then
400
                btnMakeCall.Enabled = False
401
                mobileGateway.Dial(txtCallingNo.Text)
402
            Else
403
                MessageBox.Show("Calling number cannot be empty", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
404
            End If
405
        Finally
406
            btnMakeCall.Enabled = True
407
        End Try
408
    End Sub
409
    Private Sub btnHangUp_Click(sender As Object, e As EventArgs) Handles btnHangUp.Click
410
        Try
411
            btnHangUp.Enabled = False
412
            mobileGateway.HangUp()
413
        Finally
414
            btnHangUp.Enabled = True
415
        End Try
416
    End Sub
417
    Private Sub btnAnswerCall_Click(sender As Object, e As EventArgs) Handles btnAnswerCall.Click
418
        Try
419
            btnAnswerCall.Enabled = False
420
            mobileGateway.Answer()
421
        Finally
422
            btnAnswerCall.Enabled = True
423
        End Try
424
    End Sub
425
    Private Sub OnCallReceived(sender As Object, e As IncomingCallEventArgs)
426
        txtCallingNo.BeginInvoke(_displayCallLog, e)
427
    End Sub
428
    Private Sub OnGatewayConnect(sender As Object, e As ConnectionEventArgs)
429
        ' Called when gateway is connected
430
        'MessageBox.Show("Connect");
431
        Console.WriteLine(e.GatewayId)
432
    End Sub
433
    Private Sub OnGatewayDisconnect(sender As Object, e As ConnectionEventArgs)
434
        ' Called when gateway is disconnected
435
        'MessageBox.Show("Disconnect");
436
        Console.WriteLine(e.GatewayId)
437
    End Sub
438
    Private Sub OnWatchDogFailed(sender As Object, e As WatchDogEventArgs)
439
        ' Called when gateway is disconnected
440
        Console.WriteLine(e.GatewayId)
441
        If e.[Error] IsNot Nothing Then
442
            Console.WriteLine(e.ToString())
443
        End If
444
    End Sub
445
    Private Shared Function GetDataCodingScheme(content As String) As MessageDataCodingScheme
446
        Dim i As Integer = 0
447
        For i = 1 To content.Length
448
            Dim code As Integer = Convert.ToInt32(Convert.ToChar(content.Substring(i - 1, 1)))
449
            If code < 0 OrElse code > 255 Then
450
                Return MessageDataCodingScheme.Ucs2
451
            End If
452
        Next
453
        Return MessageDataCodingScheme.DefaultAlphabet
454
    End Function
455
    Private Sub btnViewLogFile_Click(sender As Object, e As EventArgs) Handles btnViewLogFile.Click
456
        If Not String.IsNullOrEmpty(txtLogFile.Text) AndAlso File.Exists(txtLogFile.Text) Then
457
            System.Diagnostics.Process.Start(txtLogFile.Text)
458
        End If
459
    End Sub
460
    Private Sub btnClearLogFile_Click(sender As Object, e As EventArgs) Handles btnClearLogFile.Click
461
        If Not String.IsNullOrEmpty(txtLogFile.Text) AndAlso File.Exists(txtLogFile.Text) Then
462
            mobileGateway.ClearLog()
463
        End If
464
    End Sub
465

                    
466
    Private Sub OnCallDialled(sender As Object, e As OutgoingCallEventArgs)
467
        txtOutgoingCallEvent.BeginInvoke(_displayCallEventLog, e)
468
    End Sub
469
    Private Sub ShowCallEventLog(e As OutgoingCallEventArgs)
470
        txtOutgoingCallEvent.AppendText("Dialled " & e.CallInformation.Number)
471
        txtOutgoingCallEvent.AppendText(vbCr & vbLf)
472
        txtOutgoingCallEvent.AppendText("Number type - " & Convert.ToString(e.CallInformation.NumberType))
473
        txtOutgoingCallEvent.AppendText(vbCr & vbLf & vbCr & vbLf)
474
    End Sub
475
    Private Sub btnStatus_Click(sender As Object, e As EventArgs) Handles btnStatus.Click
476
        If mobileGateway.ValidateConnection() Then
477
            MessageBox.Show("Gateway is connected", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
478
        Else
479
            MessageBox.Show("Gateway is disconnected", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
480
        End If
481
    End Sub
482
 
483

                    
484

                    
485
End Class