Data processing and forwarding
As the data receiver class is potentially connected directly to the Internet, isolating it from processes deeper in the systems is a smart idea. In order the get the checked and verified data into the database another (data) class that utilizes data base stored procedures is implemented. This prevents any direct access to the database from Internet facing processes. This is the call to
DataService.PutLoggerData(objMeas.mac, objMeas.ip, objMeas.temp)
Public Shared Function PutLoggerData(mac As String, ip As String, value As String) As Boolean
Dim ok As Boolean = False
Try
Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("YOUR_DB_CONNECTIONSTRING").ConnectionString
Using Connection As SqlConnection = New SqlConnection(ConnectionString)
Using Command As SqlCommand = New SqlCommand("put_logger", Connection)
Command.CommandTimeout = 2
Command.Parameters.AddWithValue("@mac", mac)
Command.Parameters.AddWithValue("@ip", ip)
Command.Parameters.AddWithValue("@value", value)
Command.CommandType = CommandType.StoredProcedure
If Connection.State = ConnectionState.Closed Then
Connection.Open()
End If
Command.ExecuteNonQuery()
ok = True
End Using
End Using
Catch ex As Exception
Errorhandler.ErrorHandler(0, ex.ToString)
End Try
Return ok
End Function