| | |
| | | /// <param name="action"></param> |
| | | public void ThreadSettingInit(Tag tag) |
| | | { |
| | | List<Task> tasks = new List<Task>(); |
| | | tasks.Add(GetTask(wmsPrint, tag, 3000)); |
| | | |
| | | |
| | | //GZ.Modular.Redis.WriteGroupEntity group = new GZ.Modular.Redis.WriteGroupEntity(); |
| | | //group.groupName = "PLC1.ssx2Xplc"; |
| | | //group.queueStatus = 1; |
| | | //group.queueTime = DateTime.Now; |
| | | |
| | | //group.writeList = new List<GZ.Modular.Redis.ParamData>(); |
| | | //GZ.Modular.Redis.ParamData barcodeData = new GZ.Modular.Redis.ParamData(); |
| | | //barcodeData.paramName = "PLC1.Param4"; |
| | | //barcodeData.paramValue = Tag.PLC1.Param4 + 1 + ""; |
| | | |
| | | //GZ.Modular.Redis.ParamData sendData = new GZ.Modular.Redis.ParamData(); |
| | | //sendData.paramName = "PLC1.Param5"; |
| | | //sendData.paramValue = Tag.PLC1.Param5 + 2 + ""; |
| | | |
| | | //group.writeList.Add(barcodeData); |
| | | //group.writeList.Add(sendData); |
| | | //Conn.é»è®¤Redis.SetQueue(group, "PLC1Queue", "PLC1.Param1_LAST", "1") ? "--æå" : "--失败"; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | Task.WaitAll(tasks.ToArray()); |
| | | } |
| | | |
| | | private void wmsPrint(Tag tag) |
| | | { |
| | | HttpServer.apiHelper.WebGet($"http://{"test1.wmsdev.net:18980"}/expcenter/WebSocketPrintAction?sysType=OT01&QS01=YANGYZ&QS02={"æ¶é´æ³"}&QS04=P4EL67LRIWWDCMP7C&clsid=export_header&method=printByWebSocket&origin=http%3A%2F%2Ftest1.wmsdev.net%3A18980&organizationId=FLUX&warehouseId=FLUXWH01&printServer=YYZ&printerName=LocalPrinter&copies=1&functionId=A2002&tableId=BAS_LOCATION&exportCode=YYZ_CN&itemObj=%0A%7B%0A++++%22bizOrgId%22%3A+%22FLUX%22%2C%0A++++%22CHECK.locationId%22%3A+%22001-001-01-01%22%2C%0A++++%22bizWarehouseId%22%3A+%22FLUXWH01%22%0A%7D%0A%0A"); |
| | | } |
| | | |
| | | private Task GetTask(Action<Tag> action, Tag tag, int i = 2500) |
| | | { |
| | | var task = Task.Run(() => |
| | | { |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | action(tag); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Error(ex.Message, ex); |
| | | } |
| | | Thread.Sleep(i); |
| | | } |
| | | }); |
| | | return task; |
| | | } |
| | | |
| | | public async void ThreadwebSoc() |
| | |
| | | public class HttpServer |
| | | { |
| | | public static readonly HttpHelper apiHelper = new HttpHelper(); |
| | | System.Net.HttpListener HttpSvcHost = null; |
| | | public static System.Net.HttpListener HttpSvcHost = null; |
| | | |
| | | public static string _listenerPrefix = ""; |
| | | public HttpServer(string ip) |
| | |
| | | |
| | | public async Task<bool> SendAsync(string message) |
| | | { |
| | | if (_webSocket?.State != WebSocketState.Open) |
| | | try |
| | | { |
| | | throw new InvalidOperationException("WebSocket is not connected"); |
| | | } |
| | | if (_webSocket?.State != WebSocketState.Open) |
| | | { |
| | | throw new InvalidOperationException("WebSocket is not connected"); |
| | | } |
| | | |
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(message); |
| | | await _webSocket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, _cts.Token); |
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(message); |
| | | await _webSocket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, _cts.Token); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Error(ex.Message, ex); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | if (stream != null) stream.Close(); |
| | | if (rsp != null) rsp.Close(); |
| | | } |
| | | |
| | | } |
| | | public string WebGet(string url) |
| | | { |
| | | //using (var client = new HttpClient()) { |
| | | // //请æ±ç»æ |
| | | // string result = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result; |
| | | |
| | | // Console.WriteLine(result); |
| | | // return result; |
| | | |
| | | //} |
| | | //Console.WriteLine(url); |
| | | WebRequest request = WebRequest.Create(url); |
| | | request.Timeout = 6000; |
| | | request.Method = "GET"; |
| | | |
| | | try |
| | | { |
| | | WebResponse response = request.GetResponse(); |
| | | Stream dataStream = response.GetResponseStream(); |
| | | StreamReader reader = new StreamReader(dataStream); |
| | | string responseFromServer = reader.ReadToEnd(); |
| | | |
| | | reader.Close(); |
| | | dataStream.Close(); |
| | | response.Close(); |
| | | Console.WriteLine(responseFromServer); |
| | | return responseFromServer; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Error($"WebGet Error:{ex.Message}", ex); |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | #endregion [èªå®ä¹ç±»][20250325095622918][HttpHelper] |
| | | } |
| | | public class Clloc |