2
我已經與稱重機進行交互的Windows服務,並獲得結果到txt文件。而不是我想要將這些數據接收到我的Web應用程序中。我的服務代碼如下。如何從Windows服務中獲取數據到WEB應用程序?
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
lg.WriteToLog("------------Service Started!-----------------")
Try
myPort.PortName = "COM2"
myPort.BaudRate = 9600
myPort.Parity = Parity.None
myPort.StopBits = System.IO.Ports.StopBits.One
myPort.DataBits = 8
AddHandler myPort.DataReceived, AddressOf DataReceived
myPort.Open()
Catch ex As Exception
lg.WriteToLog("Error Occurred while Initializing Serial Port !")
lg.WriteToLog(ex.ToString)
End Try
End Sub
Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Try
If myPort.IsOpen Then
ReceivedText(myPort.ReadExisting())
lg.WriteToLog("Port is open and getting the data!")
End If
Catch ex As Exception
lg.WriteToLog("Error Occurred while reading data!")
lg.WriteToLog(ex.ToString)
End Try
End Sub Private Sub ReceivedText(ByVal [text] As String)
lg.WriteToLog(output([text]))
End Sub`
任何人都可以建議我如何獲得相同的數據發送回WebApplication的,因爲我與Web應用程序很新鮮,我試着用搜索引擎,但沒有發現任何有用的答案。這裏的輸出只是一個簡單的功能,可以以正確的格式執行重量轉換,因此您可以忽略這一點!
感謝您的答覆先生,這將是巨大的,如果你能方式如何做到這一點給我。 –
我已添加一個鏈接,請按照它。 – Eklavya