| | |
| | | using NModbus; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Dynamic; |
| | |
| | | //如果是水检,可以提交了 |
| | | if (txt_gx.Text.Trim() == fGxShouJian) |
| | | { |
| | | if (txt_gongWei.Text.Trim().Length <= 0) |
| | | { |
| | | Toast vm = new Toast(-1, "~请扫工位码~"); |
| | | vm.Show(); |
| | | this.ActiveControl = this.txt_gongWei; |
| | | txt_gongWei.Focus(); |
| | | return; |
| | | } |
| | | addModel(goodTag); |
| | | } |
| | | } |
| | |
| | | { |
| | | Toast vm = new Toast(-1, "~请先扫追溯码~"); |
| | | vm.Show(); |
| | | this.ActiveControl = this.txt_barCode; |
| | | txt_barCode.Focus(); |
| | | return; |
| | | } |
| | | dynamic _obj = getObj(_barCode, _checkResult, _badDescription); |
| | |
| | | string SJJG = "";//水检查结果ok、ng |
| | | string GWZT = "";//工位状态 |
| | | string SJJGZ = "";//水检查结果1 |
| | | bool blIp = true; |
| | | blIp = CheckPort(hostName, hostNamePoint); |
| | | if (blIp) |
| | | { |
| | | System.Text.StringBuilder sbSql1 = new StringBuilder(); |
| | | sbSql1.Append($"select MIG004,MIG005 from BASMIG(nolock) where MIG001='ShuiJianZhanWei01' and MIG003='{((BaseEdit)this.txt_gongWei).EditValue.ToString()}'"); |
| | | DataTable dataTable1 = this.GetDataTable(sbSql1.ToString(), "tmpBASMIG2"); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return (strCsl1, strSw1, SJJG, GWZT, SJJGZ); |
| | | } |
| | | private DataTable GetDataTable(string SQLString, string tmpBASMIG2) |
| | |
| | | return ds.Tables[0]; |
| | | } |
| | | } |
| | | |
| | | private bool CheckPort(string host, int port) |
| | | { |
| | | int vanishingSeconds = 3; |
| | | string _vanishingSeconds = ConfigurationManager.AppSettings["AsyncSeconds"]; |
| | | if (!string.IsNullOrEmpty(_vanishingSeconds)) |
| | | vanishingSeconds = int.Parse(_vanishingSeconds); |
| | | bool isOpen = false; |
| | | try |
| | | { |
| | | using (var client = new TcpClient()) |
| | | { |
| | | var result = client.BeginConnect(host, port, null, null); |
| | | var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(vanishingSeconds)); // 等待5秒 |
| | | if (success) |
| | | { |
| | | isOpen = true; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(this.ToString(), "CheckPort:" + ex.Message); |
| | | } |
| | | return isOpen; |
| | | } |
| | | #endregion |
| | | |
| | | } |