私は計量機と相互作用し、結果をtxtファイルに変換するWindowsサービスを持っています。その代わりに、私はそのデータをWebアプリケーションに受け取りたいと思っています。私のサービスコードは以下の通りです。私は、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に送って、私はそれをグーグルで試してみたが、いずれかの有用な答えを見つけることができませんでした。ここでの出力は、正しいフォーマットでの重みの変換を実行する単純な関数ですので、無視してください!
卿、それは素晴らしいことです。 –
私はリンクを追加しました。それに従ってください。 – Eklavya