Option Explicit On Option Strict On Imports System.Data Imports Extensiones Imports System.Data.SqlClient Imports Microsoft.AspNet.SignalR Imports System.IO Partial Class PortalGPS_ServiciosGPS Inherits System.Web.UI.Page Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then If Request("Correr") IsNot Nothing AndAlso Request("Correr").ToString = "1" Then 'Dim Tipo As String = RdlTipo.SelectedValue EjecutarComandos() End If End If End Sub Private Sub EjecutarComandos(Optional Tipo As String = "GPRS") Dim ObjGPS As New ClsGPS Dim ObjHerra As New ClsGPSHerramientas If ObjGPS.DispositivosGet(-1, 1, -1, -1) Then Try Dim DtDispositivos = ObjGPS.DtResultados.FiltraParametros("Modelo IN ('ST300K','ST300KE','ST300C')") For Each Dr As DataRow In DtDispositivos.Rows Dim DevID As String = Dr("DevID").ToString If Not String.IsNullOrEmpty(DevID) Then Dim Comando As String = $"ST300GED;{DevID};02" Dim Telefono As String = Dr("NumeroTelefono").ToString Dim CveDispositivo As Integer = Dr("CveDispositivo").ToString.ToEntero Select Case Tipo Case "GPRS" If ObjHerra.EjecutarComandoManualGPRS(Comando, Telefono, CveDispositivo, -1) Then LblFecha.Text = Now.ToString("dd/MM/yyyy") GuardaLog($"Se ejecuto el comando correctamente vía GPRS. ") End If Case "SMS" If ObjHerra.EjecutarComandoManualSMS(Comando, Telefono, CveDispositivo, -1) Then LblFecha.Text = Now.ToString("dd/MM/yyyy") GuardaLog($"Se ejecuto el comando correctamente vía SMS Fecha. ") End If End Select End If Next Catch ex As Exception GuardaLog($"Ocurrió un error al ejecutar el comando. {ex.ToString}") End Try End If ObjGPS.Dispose() ObjHerra.Dispose() End Sub Protected Sub BtnPrueba_Click(sender As Object, e As EventArgs) Dim Tipo As String = RdlTipo.SelectedValue EjecutarComandos(Tipo) End Sub Public Sub GuardaLog(Str As String) Dim ArchivoW As StreamWriter Dim strLineaTMP As String strLineaTMP = String.Format("{0}{1}Log: {2}{3}:{4}", Chr(13), Chr(10), Str, DateTime.Now.ToShortDateString, DateTime.Now.ToShortTimeString) Try ArchivoW = New StreamWriter(String.Format("{0}\log\LogCanBus.txt", AppDomain.CurrentDomain.BaseDirectory), True, System.Text.Encoding.UTF8) Catch ex As Exception Exit Sub End Try Try ArchivoW.WriteLine(strLineaTMP) Catch End Try ArchivoW.Close() ArchivoW.Dispose() End Sub End Class