/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/handlers/alcohol.ashx
78 строк
3 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
<%@ WebHandler Language="VB" Class="Alcohol" %> Imports sharedClasses.dbFunctions Imports System.Net Imports System.IO Imports Newtonsoft.Json Public Class Alcohol : Implements IHttpHandler Public Class Json_request Public Property Gen As String Public Property EmployeeName As String Public Property CardNO As String Public Property FactoryName As String Public Property DeptCode As String Public Property DeptName As String Public Function Query() As String Dim q As String q = JsonConvert.SerializeObject(Me, Formatting.None) Return q End Function End Class Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim sqlf As New SqlFunctions Dim com As New Data.SqlClient.SqlCommand Dim cardNo = context.Request.QueryString("cardNo") Dim result As Integer = 0 Dim js_r As New Json_request If Not (cardNo Is Nothing) Then Dim dt As Data.DataTable = sqlf.GetData("SELECT top 1 [EventLogSeq], isnull([EmployeeNO],'') as EmployeeNO, [EmployeeName], [CardNO], [FactoryName], isnull([DeptCode],'') as DeptCode, [DepartmentName] FROM [hr].[dbo].[CHECK_CARD_LOG] where CardNO = '" & cardNo & "' order by [EventLogSeq] desc ") If Not (dt Is Nothing) Then result = dt.Rows.Count For Each dr As Data.DataRow In dt.Rows js_r.Gen = (dr("EmployeeNO")) js_r.EmployeeName = (dr("EmployeeName")) js_r.CardNO = (dr("CardNO")) js_r.FactoryName = (dr("FactoryName")) js_r.DeptCode = (dr("DeptCode")) js_r.DeptName = (dr("DepartmentName")) Next socket_test(js_r) End If End If context.Response.ContentType = "content/text" If result > 0 Then context.Response.Write("Ok") Else context.Response.Write("Ng") End If End Sub Public Sub socket_test(js As Json_request) Dim httpWebRequest = WebRequest.Create("http://realtime.serk.lan:8081/dashboard") httpWebRequest.ContentType = "application/x-www-form-urlencoded" httpWebRequest.Method = "POST" 'js.Gen = "1234567890" Dim post_data = "CHANNEL=u_alcohol&DATA=" + Uri.EscapeDataString(js.Query) Dim data = Encoding.ASCII.GetBytes(post_data) httpWebRequest.ContentLength = data.Length ' Get the request stream. Dim dataStream As Stream = httpWebRequest.GetRequestStream() ' Write the data to the request stream. dataStream.Write(data, 0, data.Length) ' Close the Stream object. dataStream.Close() ' Get the response. Dim response As WebResponse = httpWebRequest.GetResponse() End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class