| | |
| | | </assemblyBinding> |
| | | </runtime> |
| | | <appSettings> |
| | | <add key="WebApiUrl" value="http://localhost:5263/" /> |
| | | <!--<add key="WebApiUrl" value="http://192.168.1.145:81/" />--> |
| | | <!--<add key="WebApiUrl" value="http://localhost:5263/" />--> |
| | | <add key="WebApiUrl" value="http://192.168.1.145:81/" /> |
| | | <add key="LogPath" value="logs" /> |
| | | <add key="ProductName" value="G-MES V2.0" /> |
| | | <add key="PageSize" value="50" /> |
| | |
| | | using DevExpress.Utils.MVVM.Services; |
| | | using DevExpress.XtraGrid.Columns; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Dynamic; |
| | | using System.IO; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames; |
| | | |
| | | namespace Gs.DevApp.DevFrm.Work |
| | | { |
| | | public partial class Frm_Work01 : DevExpress.XtraEditors.XtraForm |
| | | { |
| | | string _webServiceName = "WorkCollect/"; |
| | | string fGx = ""; |
| | | string fBc = ""; |
| | | string dianJianPath = "";//电检取值路径 |
| | | string goodTag = "√"; |
| | | string badTag = "×"; |
| | | string fGxTouRu = "G001:投入"; |
| | | string fGxDianJian = "G002:电检"; |
| | | string fGxShouJian = "G003:水检"; |
| | | string fGxZhongJian = "G004:终检"; |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="_fGx">工序</param> |
| | | /// <param name="_fBc">班次</param> |
| | | public Frm_Work01(string _fGx, string _fBc) |
| | | { |
| | | InitializeComponent(); |
| | | this.fGx = _fGx; |
| | | this.fBc = _fBc; |
| | | this.Text = "工序采集 - " + fGx + " - " + fBc; |
| | | txt_gx.Text = fGx; |
| | | txt_bc.Text = fBc; |
| | | txt_gx.Text = _fGx; |
| | | txt_bc.Text = _fBc; |
| | | this.Text = "工序采集 - " + _fGx + " - " + _fBc; |
| | | if (!getConfig()) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("读取配置文件失败,请联系管理员!"); |
| | | } |
| | | addColumn(); |
| | | txt_barCode.KeyDown += (s, e) => |
| | | { |
| | | if (e.KeyCode == Keys.Enter) { getModel("", goodTag); }; |
| | | if (e.KeyCode == Keys.Enter) { addModel(goodTag); }; |
| | | }; |
| | | btnGood.Click += (s, e) => |
| | | { |
| | | getModel("", goodTag); |
| | | addModel(goodTag); |
| | | }; |
| | | btnBad.Click += (s, e) => |
| | | { |
| | |
| | | vm.Show(); |
| | | } |
| | | else |
| | | getModel("", badTag, _txt); |
| | | addModel(badTag, _txt); |
| | | }; |
| | | frm.ShowDialog(); |
| | | }; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 先读取配置 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool getConfig() |
| | | { |
| | | string _where = " and 1=1 and defect_code='7001'"; |
| | | var pgq = new PageQueryModel(1, 999999, "a.defect_code", "asc", "", _where); |
| | | var json = JsonConvert.SerializeObject(pgq); |
| | | try |
| | | { |
| | | var strReturn = UtilityHelper.HttpPost("", "MesDefectCodeManager/GetListPage", json); |
| | | var dd = UtilityHelper.ReturnToTablePage(strReturn); |
| | | var dt = dd.rtnData.list; |
| | | if (dt != null && dt.Rows.Count > 0) |
| | | { |
| | | dianJianPath = dt.Rows[0]["defectName"].ToString(); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 读取实体 |
| | | /// </summary> |
| | | /// <param name="_checkVal">检测值</param> |
| | | /// <param name="_checkResult">检测结果</param> |
| | | /// <param name="_badReson">不良原因</param> |
| | | /// <param name="_inBz">备注</param> |
| | | private void getModel(string _checkVal, string _checkResult, string _badReson = "", string _inBz = "") |
| | | /// <param name="_barCode"></param> |
| | | /// <param name="_checkResult"></param> |
| | | /// <param name="_badReson"></param> |
| | | /// <returns></returns> |
| | | private dynamic getObj(string _barCode, string _checkResult, string _badReson = "") |
| | | { |
| | | dynamic _obj = new ExpandoObject(); |
| | | _obj.barCode = _barCode; |
| | | _obj.checkResult = _checkResult;//检测结果 |
| | | _obj.processNo = txt_gx.Text.Trim();//工序 |
| | | _obj.banCi = txt_bc.Text.Trim();//班次 |
| | | _obj.gongWei = txt_gw.Text.Trim();//工位 |
| | | _obj.badReson = _badReson.Trim();//不良原因 |
| | | if (txt_gx.Text.Trim() == fGxTouRu) |
| | | { |
| | | return _obj; |
| | | } |
| | | if (txt_gx.Text.Trim() == fGxDianJian) |
| | | { |
| | | string TM = ""; |
| | | string JD = ""; |
| | | string JY = ""; |
| | | string JN = ""; |
| | | string XL = ""; |
| | | string GV = ""; |
| | | string JDV = ""; |
| | | string JYV = ""; |
| | | string JNV = ""; |
| | | string XLV = ""; |
| | | string GVV = ""; |
| | | string myStr = File.ReadAllText(dianJianPath, Encoding.Default); |
| | | if (myStr == "") |
| | | { |
| | | return null; |
| | | } |
| | | File.WriteAllText(dianJianPath, ""); |
| | | JArray dsTemp = JArray.Parse(myStr); |
| | | foreach (var ss in dsTemp) //查找某个字段与值 |
| | | { |
| | | TM = (((JObject)ss)["TiaoMa"] == null) ? "" : ((JObject)ss)["TiaoMa"].ToString(); |
| | | JD = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["state"].ToString(); |
| | | JY = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["state"].ToString(); |
| | | JN = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["state"].ToString(); |
| | | XL = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["state"].ToString(); |
| | | GV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["state"].ToString(); |
| | | JDV = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["value"].ToString().Replace(" ", ", "); |
| | | JYV = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["value"].ToString().Replace(" ", ", "); |
| | | JNV = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["value"].ToString().Replace(" ", ", "); |
| | | XLV = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["value"].ToString().Replace(" ", ", "); |
| | | GVV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["value"].ToString().Replace(" ", ", "); |
| | | } |
| | | _obj.t001 = TM; |
| | | _obj.t002 = JD; |
| | | _obj.t003 = JY; |
| | | _obj.t004 = JN; |
| | | _obj.t005 = XL; |
| | | _obj.t006 = GV; |
| | | _obj.t007 = JDV; |
| | | _obj.t008 = JYV; |
| | | _obj.t009 = JNV; |
| | | _obj.t010 = XLV; |
| | | _obj.t011 = GVV; |
| | | return _obj; |
| | | } |
| | | |
| | | if (txt_gx.Text.Trim() == fGxShouJian) |
| | | { |
| | | string strCsl1 = "strCsl1"; |
| | | string strSw1 = "strSw1"; |
| | | string strCsl2 = "strCsl2"; |
| | | string strSw2 = "strSw2"; |
| | | string strCsl3 = "strCsl3"; |
| | | string strSw3 = "strSw3"; |
| | | string strCsl4 = "strCsl4"; |
| | | string strSw4 = "strSw4"; |
| | | string strCsl5 = "strCsl5"; |
| | | string strSw5 = "strSw5"; |
| | | _obj.t002 = strCsl1; |
| | | _obj.t003 = strSw1; |
| | | _obj.t004 = strCsl2; |
| | | _obj.t005 = strSw2; |
| | | _obj.t006 = strCsl3; |
| | | _obj.t007 = strSw3; |
| | | _obj.t008 = strCsl4; |
| | | _obj.t009 = strSw4; |
| | | _obj.t010 = strCsl5; |
| | | _obj.t011 = strSw5; |
| | | return _obj; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 上报实体 |
| | | /// </summary> |
| | | /// <param name="_checkResult">判定结果</param> |
| | | /// <param name="_badReson">不良原因,可空</param> |
| | | private void addModel(string _checkResult, string _badReson = "") |
| | | { |
| | | string _barCode = txt_barCode.Text.Trim(); |
| | | if (string.IsNullOrEmpty(_barCode)) |
| | |
| | | vm.Show(); |
| | | return; |
| | | } |
| | | var _obj = new |
| | | dynamic _obj = getObj(_barCode, _checkResult, _badReson); |
| | | if (_obj == null) |
| | | { |
| | | barCode = _barCode, |
| | | inBz = _inBz.Trim(), |
| | | checkVal = _checkVal, |
| | | checkResult = _checkResult, |
| | | processNo = txt_gx.Text.Trim(),//工序 |
| | | banCi = txt_bc.Text.Trim(),//班次 |
| | | gongWei = txt_gw.Text.Trim(),//工位 |
| | | badReson = _badReson.Trim() |
| | | }; |
| | | Toast vm = new Toast(-1, "~读取数据失败,请检查设备~"); |
| | | vm.Show(); |
| | | return; |
| | | } |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); |
| | |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | dynamic dy = _rtn.rtnData; |
| | | //头表和汇总 |
| | | //表头和汇总 |
| | | UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, false); |
| | | lbSum1.Text = dy.lbSum1; |
| | | lbSum2.Text = dy.lbSum2; |
| | | lbSum3.Text = dy.lbSum3; |
| | | lbSum4.Text = dy.lbSum4; |
| | | prog1.Position = dy.jd; |
| | | //良品 |
| | | //良品列表 |
| | | txt_barCode.ReadOnly = false; |
| | | JObject _job = JObject.Parse(strJson); |
| | | JArray array = new JArray(); |
| | |
| | | { |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); |
| | | } |
| | | //不良品 |
| | | //不良品列表 |
| | | JArray array2 = new JArray(); |
| | | foreach (var a in _job["rtnData"]["list2"]) |
| | | { |
| | |
| | | string _msg = _rtn.rtnMsg; |
| | | if (!string.IsNullOrEmpty(_msg)) |
| | | { |
| | | |
| | | Toast vm = new Toast((goodTag == "√" ? 1 : -1), _msg); |
| | | vm.Show(); |
| | | }; |
| | |
| | | vm.Show(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 增加电检取数的列 |
| | | /// </summary> |
| | | public void addColumn() |
| | | { |
| | | List<dynamic> _lst = new List<dynamic>(); |
| | | if (txt_gx.Text.Trim() == fGxDianJian) |
| | | { |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t002", |
| | | wenben = "接地", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t004", |
| | | wenben = "交耐", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t005", |
| | | wenben = "泄漏", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t006", |
| | | wenben = "功率", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t007", |
| | | wenben = "接地结果", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t009", |
| | | wenben = "交耐结果", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t010", |
| | | wenben = "泄漏结果", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t011", |
| | | wenben = "功率结果", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | } |
| | | if (txt_gx.Text.Trim() == fGxShouJian) |
| | | { |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t002", |
| | | wenben = "出水量1", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t003", |
| | | wenben = "水温1", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t004", |
| | | wenben = "出水量2", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t005", |
| | | wenben = "水温2", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t006", |
| | | wenben = "出水量3", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t007", |
| | | wenben = "水温3", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t008", |
| | | wenben = "出水量4", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t009", |
| | | wenben = "水温4", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t010", |
| | | wenben = "出水量5", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | _lst.Add(new |
| | | { |
| | | ziduan = "t011", |
| | | wenben = "水温5", |
| | | kejian = true, |
| | | visibleIndex = 1, |
| | | }); |
| | | } |
| | | foreach (var item in _lst) |
| | | { |
| | | GridColumn newColumn = new GridColumn(); |
| | | newColumn.FieldName = item.ziduan; // 设置与数据源对应的字段名 |
| | | newColumn.Caption = item.wenben; // 设置列的标题 |
| | | //newColumn.Visible = item.visibleIndex; // 设置列是否可见 |
| | | newColumn.VisibleIndex = item.visibleIndex; // 设置列的显示顺序 |
| | | gvMx1.Columns.Add(newColumn); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
| | | <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="NModbus, Version=3.0.81.0, Culture=neutral, processorArchitecture=MSIL"> |
| | | <HintPath>..\packages\NModbus.3.0.81\lib\net46\NModbus.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="Oracle.ManagedDataAccess, Version=4.122.23.1, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL"> |
| | | <HintPath>..\packages\Oracle.ManagedDataAccess.23.6.0\lib\net472\Oracle.ManagedDataAccess.dll</HintPath> |
| | | </Reference> |
| | |
| | | /// </summary> |
| | | private static void _startLogin() |
| | | { |
| | | //Application.Run(new XtraForm1()); |
| | | //return; |
| | | Application.Run(new XtraForm1()); |
| | | return; |
| | | CefSettings settings = new CefSettings(); |
| | | settings.Locale = "zh-CN"; |
| | | Cef.Initialize(settings); |
| | |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel1)).BeginInit(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel2)).BeginInit(); |
| | | this.splitContainerControl1.SuspendLayout(); |
| | | this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); |
| | | this.simpleButton2 = new DevExpress.XtraEditors.SimpleButton(); |
| | | this.SuspendLayout(); |
| | | // |
| | | // splitContainerControl1 |
| | | // simpleButton1 |
| | | // |
| | | this.splitContainerControl1.Location = new System.Drawing.Point(192, 205); |
| | | this.splitContainerControl1.Name = "splitContainerControl1"; |
| | | this.simpleButton1.Location = new System.Drawing.Point(146, 51); |
| | | this.simpleButton1.Name = "simpleButton1"; |
| | | this.simpleButton1.Size = new System.Drawing.Size(94, 29); |
| | | this.simpleButton1.TabIndex = 0; |
| | | this.simpleButton1.Text = "simpleButton1"; |
| | | this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click_1); |
| | | // |
| | | // splitContainerControl1.Panel1 |
| | | // simpleButton2 |
| | | // |
| | | this.splitContainerControl1.Panel1.Text = "Panel1"; |
| | | // |
| | | // splitContainerControl1.Panel2 |
| | | // |
| | | this.splitContainerControl1.Panel2.Text = "Panel2"; |
| | | this.splitContainerControl1.Size = new System.Drawing.Size(200, 100); |
| | | this.splitContainerControl1.TabIndex = 0; |
| | | this.simpleButton2.Location = new System.Drawing.Point(146, 234); |
| | | this.simpleButton2.Name = "simpleButton2"; |
| | | this.simpleButton2.Size = new System.Drawing.Size(94, 29); |
| | | this.simpleButton2.TabIndex = 1; |
| | | this.simpleButton2.Text = "水检按钮"; |
| | | this.simpleButton2.Click += new System.EventHandler(this.simpleButton2_Click); |
| | | // |
| | | // XtraForm1 |
| | | // |
| | | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F); |
| | | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
| | | this.ClientSize = new System.Drawing.Size(887, 659); |
| | | this.Controls.Add(this.splitContainerControl1); |
| | | this.Controls.Add(this.simpleButton2); |
| | | this.Controls.Add(this.simpleButton1); |
| | | this.Name = "XtraForm1"; |
| | | this.Text = "XtraForm1"; |
| | | ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel1)).EndInit(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel2)).EndInit(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit(); |
| | | this.splitContainerControl1.ResumeLayout(false); |
| | | this.ResumeLayout(false); |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1; |
| | | private DevExpress.XtraEditors.SimpleButton simpleButton1; |
| | | private DevExpress.XtraEditors.SimpleButton simpleButton2; |
| | | } |
| | | } |
| | |
| | | using DevExpress.Utils; |
| | | using Newtonsoft.Json.Linq; |
| | | using NModbus; |
| | | using System; |
| | | using System.Data; |
| | | using System.IO; |
| | | using System.Net.Sockets; |
| | | using System.Text; |
| | | |
| | | namespace Gs.DevApp |
| | | { |
| | |
| | | InitializeComponent(); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 是否第一次投入,0为第一次投入,1为维修过来要报废的2为已经报废过了的,3返工过来重投的4清尾工单的报废 |
| | | /// </summary> |
| | | private string flagFirst = "0"; //是否第一次投入 |
| | | |
| | | private void simpleButton1_Click(object sender, EventArgs e) |
| | | |
| | | private void simpleButton1_Click_1(object sender, EventArgs e) |
| | | { |
| | | //toastNotificationsManager1 = new ToastNotificationsManager(); |
| | | //VanishingMessage vm = new VanishingMessage(System.Drawing.Color.OrangeRed, "操作成春树暮云顶戴槈"); |
| | | //vm.Show(); |
| | | ToolTipControllerShowEventArgs aa = new ToolTipControllerShowEventArgs(); |
| | | aa.AllowHtmlText = DefaultBoolean.True; |
| | | aa.Title = "详情"; //HTML, 粗体 |
| | | aa.ToolTip = "你好爱你的克格勃"; //断行 |
| | | aa.ShowBeak = true; |
| | | aa.Rounded = true; ////圆角 |
| | | aa.RoundRadius = 7; //圆角率 |
| | | aa.ToolTipType = ToolTipType.SuperTip; //超级样式,可多行或显示图标 |
| | | aa.ToolTipType = ToolTipType.Standard;//标准样式,可显示鸟嘴。 |
| | | aa.IconType = ToolTipIconType.Information; //消息图标 |
| | | aa.IconSize = ToolTipIconSize.Small; //大图标 |
| | | AddDianJian(); |
| | | } |
| | | |
| | | //添加电检数据 |
| | | private string AddDianJian() |
| | | { |
| | | string TM = ""; |
| | | string JD = ""; |
| | | string JY = ""; |
| | | string JN = ""; |
| | | string XL = ""; |
| | | string GV = ""; |
| | | string JDV = ""; |
| | | string JYV = ""; |
| | | string JNV = ""; |
| | | string XLV = ""; |
| | | string GVV = ""; |
| | | //if (imaQAB009.EditValue.ToString() != VSLoginInfo.SystemParam["DianJianNo"].ToString()) |
| | | //{ |
| | | // return ""; |
| | | //} |
| | | //string sql = string.Format(@" select MIG006 from BASMIG(nolock) where MIG001='DianJianQuShu' and MIG003='{0}' and MIG005='Y'", txtDAA042.EditValue.ToString()); |
| | | //DataTable dt = manager.GetDataTable(sql, "tmpBASMIG"); |
| | | //if (dt == null || dt.Rows.Count <= 0) |
| | | //{ |
| | | // return ""; |
| | | //} |
| | | try |
| | | { |
| | | //FileStream fs = new FileStream(dt.Rows[0][0].ToString(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); |
| | | //int fsLen = (int)fs.Length; |
| | | //byte[] heByte = new byte[fsLen]; |
| | | //fs.Read(heByte, 0, heByte.Length); |
| | | //string myStr = System.Text.Encoding.Default.GetString(heByte); |
| | | //fs.Close(); |
| | | string strPath = @"D:\uploadData.txt"; |
| | | string myStr = File.ReadAllText(strPath, Encoding.Default); |
| | | if (myStr == "") |
| | | { |
| | | return "NULL"; |
| | | } |
| | | File.WriteAllText(strPath, ""); |
| | | JArray dsTemp = JArray.Parse(myStr); |
| | | |
| | | foreach (var ss in dsTemp) //查找某个字段与值 |
| | | { |
| | | TM = (((JObject)ss)["TiaoMa"] == null) ? "" : ((JObject)ss)["TiaoMa"].ToString(); |
| | | JD = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["state"].ToString(); |
| | | JY = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["state"].ToString(); |
| | | JN = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["state"].ToString(); |
| | | XL = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["state"].ToString(); |
| | | GV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["state"].ToString(); |
| | | JDV = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["value"].ToString().Replace(" ", ", "); |
| | | JYV = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["value"].ToString().Replace(" ", ", "); |
| | | JNV = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["value"].ToString().Replace(" ", ", "); |
| | | XLV = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["value"].ToString().Replace(" ", ", "); |
| | | GVV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["value"].ToString().Replace(" ", ", "); |
| | | |
| | | Gs.DevApp.ToolBox.LogHelper.Debug("TM", TM); |
| | | Gs.DevApp.ToolBox.LogHelper.Debug("JD", JD); |
| | | Gs.DevApp.ToolBox.LogHelper.Debug("JY", JY); |
| | | Gs.DevApp.ToolBox.LogHelper.Debug("XL", XL); |
| | | Gs.DevApp.ToolBox.LogHelper.Debug("XLV", XLV); |
| | | Gs.DevApp.ToolBox.LogHelper.Debug("GVV", GVV); |
| | | } |
| | | return "已采集"; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return "文件打开失败," + e.Message; |
| | | } |
| | | } |
| | | |
| | | private void simpleButton2_Click(object sender, EventArgs e) |
| | | { |
| | | string strCsl1 = ""; |
| | | string strSw1 = ""; |
| | | string strCsl2 = ""; |
| | | string strSw2 = ""; |
| | | string strCsl3 = ""; |
| | | string strSw3 = ""; |
| | | string strCsl4 = ""; |
| | | string strSw4 = ""; |
| | | string strCsl5 = ""; |
| | | string strSw5 = ""; |
| | | string SJJG = ""; |
| | | try//水检取数,后面补充 |
| | | { |
| | | string hostname = "192.168.1.5"; |
| | | ModbusFactory modbusFactory = new ModbusFactory(); |
| | | IModbusMaster master = modbusFactory.CreateMaster(new TcpClient(hostname, 26)); |
| | | master.Transport.ReadTimeout = 10000; |
| | | master.Transport.Retries = 10000; |
| | | DataTable dt = new DataTable(); |
| | | //参数(分别为从站地址,起始地址,长度) |
| | | byte slaveAddress = byte.Parse(dt.Rows[0][0].ToString()); |
| | | ushort numberOfPoints = ushort.Parse("1"); |
| | | float fsw = 0; |
| | | DataTable dt1 = new DataTable(); |
| | | ushort[] csl1 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[0]["MIG003"].ToString()), numberOfPoints); |
| | | strCsl1 = csl1[0].ToString(); |
| | | |
| | | ushort[] sw1 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[1]["MIG003"].ToString()), numberOfPoints); |
| | | strSw1 = (float.Parse(sw1[0].ToString()) / 10).ToString(); |
| | | |
| | | ushort[] csl2 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[2]["MIG003"].ToString()), numberOfPoints); |
| | | strCsl2 = csl2[0].ToString(); |
| | | |
| | | ushort[] sw2 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[3]["MIG003"].ToString()), numberOfPoints); |
| | | strSw2 = (float.Parse(sw2[0].ToString()) / 10).ToString(); |
| | | |
| | | ushort[] csl3 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[4]["MIG003"].ToString()), numberOfPoints); |
| | | strCsl3 = csl3[0].ToString(); |
| | | |
| | | ushort[] sw3 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[5]["MIG003"].ToString()), numberOfPoints); |
| | | strSw3 = (float.Parse(sw3[0].ToString()) / 10).ToString(); |
| | | |
| | | ushort[] csl4 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[6]["MIG003"].ToString()), numberOfPoints); |
| | | strCsl4 = csl4[0].ToString(); |
| | | |
| | | ushort[] sw4 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[7]["MIG003"].ToString()), numberOfPoints); |
| | | strSw4 = (float.Parse(sw4[0].ToString()) / 10).ToString(); |
| | | |
| | | ushort[] csl5 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[8]["MIG003"].ToString()), numberOfPoints); |
| | | strCsl5 = csl5[0].ToString(); |
| | | |
| | | ushort[] sw5 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[9]["MIG003"].ToString()), numberOfPoints); |
| | | strSw5 = (float.Parse(sw5[0].ToString()) / 10).ToString(); |
| | | |
| | | bool[] sjjg = master.ReadCoils(slaveAddress, ushort.Parse(dt1.Rows[10]["MIG003"].ToString()), numberOfPoints); |
| | | SJJG = sjjg[0].ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //VisiblePanel(txtDQBarCode.EditValue.ToString(), ex.Message, "NG", Color.Yellow); |
| | | //txtGWM.EditValue = ""; |
| | | return; |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" /> |
| | | <package id="Microsoft.Web.WebView2" version="1.0.2592.51" targetFramework="net48" /> |
| | | <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" /> |
| | | <package id="NModbus" version="3.0.81" targetFramework="net48" /> |
| | | <package id="Oracle.ManagedDataAccess" version="23.6.0" targetFramework="net48" /> |
| | | <package id="System.Buffers" version="4.5.1" targetFramework="net48" /> |
| | | <package id="System.Configuration.ConfigurationManager" version="8.0.0" targetFramework="net48" /> |