using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.ServiceModel; using OPCClient; using Opc.Ua; using System.Net; using System.Linq; namespace wcfControlMonitorClient { /// /// Creator:Richard.liu and Jack.Ma /// 设备实时状态显示 /// public partial class FrmDeviceStatus : Form { #region 变量定义 Model.MDevice _device = null; int _deviceIndex; DBFactory.DBOperator dboMan = CStaticClass.dboM; DBFactory.DBOperator dbo = CStaticClass.dbo; int count = 0; /// /// 设置要显示的设备索引 /// public int DeviceIndex { set { _deviceIndex = value; } } private static FrmDeviceStatus _formInstance; public static FrmDeviceStatus FormInstance { get { if (_formInstance == null) { _formInstance = new FrmDeviceStatus(); } return _formInstance; } set { _formInstance = value; } } #endregion #region 构造函数/初始化 public FrmDeviceStatus() { InitializeComponent(); _formInstance = this; } private void FrmDeviceStatus_Load(object sender, EventArgs e) { StringBuilder sql = new StringBuilder(); sql = new StringBuilder(); sql.Append("SELECT F_DeviceIndex from T_Base_PLC_Ask where F_DeviceIndex=").Append(_deviceIndex); DataView dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; if (dvlane.Count > 0) { this.tbAddBarcode.Visible = true; this.btresendbarcode.Visible = true; } else { this.tbAddBarcode.Visible = false; this.btresendbarcode.Visible = false; } this.btLogicHaveGoods.Visible = true; this.btLogicNoneGoods.Visible = true; textBox1.Visible = true; textBox2.Visible = false; button1.Visible = false; label10.Visible = false; this.tbAddBarcode.Text = ""; if (_deviceIndex == 12014 || _deviceIndex == 12011 || _deviceIndex == 12008 || _deviceIndex == 12007) { button6.Visible = true; } else { button6.Visible = false; } if (new int[] { 22005, 22006, 29008 }.Contains(_deviceIndex)) { this.lab_AutomaticPlatform.Visible = true; this.txt_AutomaticPlatform.Visible = true; this.btn_AutomaticPlatform.Visible = true; } else { this.lab_AutomaticPlatform.Visible = false; this.txt_AutomaticPlatform.Visible = false; this.btn_AutomaticPlatform.Visible = false; } btnRefresh_Click(null, EventArgs.Empty); } #endregion #region 更新设备状态 private void btnRefresh_Click(object sender, EventArgs e) { try { _device = Model.CGetInfo.GetDeviceInfo(_deviceIndex); //20100108 if (_device == null) { MessageBox.Show("您选择的设备在数据库没有记录!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //设备索引 this.lblDeviceIndex.Value = _device.DeviceIndex; //设备名称 this.lblDeviceName.Text = _device.DeviceName; //设备指令索引 this.lblTaskIndex.Text = _device.TaskNo.ToString(); DataView dv = dbo.ExceSQL(string.Format("SELECT F_TxtParam, F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6 FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", _device.TaskNo)).Tables[0].DefaultView; if (dv.Count > 0) { //条码号 this.lblBarcode.Text = dv[0]["F_TxtParam"].ToString(); //目标位置 this.lblArrowLocation.Text = _device.ArrowLocation; if (_device.DeviceKind == 1) { this.lblArrowLocation.Text = string.Format("{0}排{1}列{2}层", dv[0]["F_NumParam4"].ToString(), dv[0]["F_NumParam5"].ToString(), dv[0]["F_NumParam6"].ToString()); } if (_device.DeviceKind == 4) { this.lblArrowLocation.Text = dv[0]["F_NumParam1"].ToString(); } if ((_device.DeviceKind == 2) || (_device.DeviceKind == 31)) { this.lblArrowLocation.Text = dv[0]["F_NumParam4"].ToString(); } } else { //20140109 if (_device.DeviceKind == 2) { if (_device.RunState == 5 && _device.SplitByte_0 == 1) { //条码号 object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", _device.DeviceIndex)); if (bcode != null) { this.lblBarcode.Text = bcode.ToString(); } else { this.lblBarcode.Text = ""; } } else { //条码号 this.lblBarcode.Text = ""; } if ((_device.DeviceIndex == 12008 || _device.DeviceIndex == 12007 || _device.DeviceIndex == 12014 || _device.DeviceIndex == 12011)) { //this.groupBox1.Visible = true; //条码号 //object bcode = dbo.GetSingle(string.Format("SELECT SN FROM ZH_pallet WHERE (Device = {0})", _device.DeviceIndex)); //if (bcode != null) //{ // this.groupBox1.Text = bcode.ToString(); //} //else //{ // this.groupBox1.Text = ""; //} } } else { //条码号 this.lblBarcode.Text = ""; if (_device.DeviceKind == 43) { //条码号 object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", 22005)); if (bcode != null) { this.lblBarcode.Text = bcode.ToString(); } else { this.lblBarcode.Text = ""; } } } //目标位置 this.lblArrowLocation.Text = ""; } if (_device.DeviceKind == 31) { this.lblTaskIndex.Text = GetMonitorTaskIndexFromBarCode(new StringBuilder(_device.Barcode)).ToString(); this.lblBarcode.Text = _device.Barcode; this.lblBarcode.Enabled = true; } else { this.lblBarcode.Enabled = false; } if (_device.DeviceKind == 1) { button2.Visible = true; } else { button2.Visible = false; } DataView dvb = dbo.ExceSQL(string.Format("select * from T_Base_PLC_Ask where F_BindingDevice = {0}", _device.DeviceIndex)).Tables[0].DefaultView; if (dvb.Count > 0 && _device.DeviceKind == 2) { //this.lblBarcode.Text = dvb[0]["F_BarCode"].ToString(); //------------------------------------------------------获取当前叠盘条码-----------------------------------------------------------------// if (Convert.ToInt32(dvb[0]["F_PalletBarcodeReservedLength"]) == 70) { textBox2.Text = ""; textBox2.Visible = true; label10.Visible = true; button1.Visible = true; StringBuilder barcode = new StringBuilder(); int dbbegin = Convert.ToInt32(dbo.GetSingle("select F_DBW2Address from t_base_device where f_deviceindex=" + dvb[0]["F_DeviceIndex"])); string s7connection = dbo.GetSingle("select F_S7Connection from t_base_device where f_deviceindex=" + dvb[0]["F_DeviceIndex"]).ToString(); CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP; CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID"); CCommonOPCClient.PlcConnectionID = s7connection;//20110216 Opc.Ua.DataValueCollection dc = new DataValueCollection(); StringBuilder[] itemnames = new StringBuilder[72]; for (int i = 0; i < 72; i++) { itemnames[i] = new StringBuilder(""); itemnames[i].Append(Model.CGeneralFunction.DBGet).Append(".").Append(Convert.ToString(dbbegin + i)).Append(",b"); } dc = CCommonOPCClient.SyncReadAllItemValue(itemnames); int PalletBarcodeLength = Convert.ToInt32(dvb[0]["F_PalletBarcodeLength"]); int BarcodeReservedLength = Convert.ToInt32(dvb[0]["F_BarcodeReservedLength"]); count = Convert.ToInt32(Convert.ToByte(dc[1].ToString())); for (int i = 0; i < 6; i++) { StringBuilder tempparam = new StringBuilder(); for (int ii = 0; ii < PalletBarcodeLength; ii++) {//周转箱叠箱时PalletBarcodeLength=0和PalletBarcodeReservedLength=0 tempparam.Append(Convert.ToChar(Convert.ToByte(dc[10 + i * BarcodeReservedLength + ii].ToString())).ToString().ToUpper());//20131106richard } //if (tempparam.ToString() == incompleteBarcode.ToString())//扫到残码,但是有货物 //{//自动生成条码“9+dvsp[0]["F_BindingDevice"]+顺序号” // //tempparam.Clear(); // //tempparam.Append(GetErrorBarcode(dcode, devidx, BarcodeLength)); //} if (tempparam.ToString().Trim().Length == PalletBarcodeLength) { barcode.Append(tempparam); } if (i < 5) { barcode.Append('|'); } textBox2.Text = barcode.ToString().Trim('\0').Trim('|'); //if ((i == 0) && (barcode.Length == 0)) //{//托盘垛或者箱垛记录最上面的条码作为记录 // barcode = tempparam; //} } } //------------------------------------------------------获取当前叠盘条码-----------------------------------------------------------------// } else { lblBarcode.Enabled = false; } if (new int[] { 22005, 22006, 29008 }.Contains(_device.DeviceIndex)) { DataView dvTemp = dbo.ExceSQL($"SELECT * FROM T_Base_Device WHERE F_DeviceIndex = {_device.DeviceIndex}").Tables[0].DefaultView; if (dvTemp.Count > 0) { this.txt_AutomaticPlatform.Text = dvTemp[0]["F_PALLETBARCODE"].ToString(); } } //设备状态 switch (_device.RunState) { case 0: lblDeviceStatus.Text = "空闲"; break; case 1: lblDeviceStatus.Text = "运行"; break; case 2: lblDeviceStatus.Text = "故障"; break; case 3: lblDeviceStatus.Text = "离线"; break; case 4: lblDeviceStatus.Text = "停用"; break; case 5://20090920 lblDeviceStatus.Text = "动作完成"; break; } if (_device.ErrorCode >= 30) { Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(_device.DeviceKind.ToString() + _device.ErrorCode.ToString())); if (err != null) { this.lblErrorName.Text = err.ErrorName + ",代码:" + _device.ErrorCode.ToString(); } else { this.lblErrorName.Text = _device.ErrorCode.ToString(); } } else { this.lblErrorName.Text = ""; } if (_device.DeviceKind == 7 || _device.DeviceKind == 42) { dv = dbo.ExceSQL(string.Format("SELECT F_BarCode ,F_ErrorBarcodeSN FROM T_Base_PLC_Ask WHERE (F_DeviceIndex = {0})", _device.DeviceIndex)).Tables[0].DefaultView; if (dv.Count > 0) { this.lblBarcode.Text = dv[0][0].ToString(); Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(_device.DeviceKind.ToString() + dv[0][1].ToString())); if (err != null) { this.lblErrorName.Text = err.ErrorName + ",代码:" + dv[0][1].ToString(); } else { this.lblErrorName.Text = ""; } } //lblErrorName.Text = ""; lblDeviceStatus.Text = ""; } if ((_device.DeviceKind == 1) || (_device.DeviceKind == 4)) { this.lblNowX.Text = _device.XCoor.ToString(); this.lblNowY.Text = _device.YCoor.ToString(); } else { this.lblNowX.Text = ""; this.lblNowY.Text = ""; } //是否逻辑有物 dv = dbo.ExceSQL("select F_DeviceIndex from T_Base_Device where F_HaveGoods >0 and F_DeviceIndex =" + this._deviceIndex).Tables[0].DefaultView; if (dv.Count > 0) { lblGoods.Text = "逻辑有物"; } else { lblGoods.Text = "逻辑无物"; } //dv = dbo.ExceSQL("select F_DeviceIndex from T_NeedLock where F_DeviceIndex =" + this._deviceIndex).Tables[0].DefaultView; //if (dv.Count > 0) //{ // button5.Visible = true; //} //else //{ // button5.Visible = false; //} //20120417被预约的调度任务 dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskKindIndex = 4 and F_MonitorIndex={0})", Convert.ToInt32(this.lblTaskIndex.Text))).Tables[0].DefaultView; if (dv.Count > 0) { lblManTask.Text = "手工任务"; } else { dv = dbo.ExceSQL(string.Format("select F_ManTaskReserve from T_Base_Device where F_ManTaskReserve>0 and F_DeviceIndex ={0}", this._deviceIndex)).Tables[0].DefaultView; if (dv.Count > 0) { int mankind = Convert.ToInt32(dv[0][0].ToString().Substring(0, 1)); int fid = Convert.ToInt32(dv[0][0].ToString().Substring(1)); lblManTask.Text = fid.ToString(); dv = dbo.ExceSQL(string.Format("SELECT F_TxtParam FROM T_Monitor_Task WHERE (F_ManageTaskKindIndex = {0} and F_ManageTaskIndex={1})", mankind, fid)).Tables[0].DefaultView; if (dv.Count > 0) { lblBarcode.Text = dv[0][0].ToString(); ; } } else { lblManTask.Text = ""; } } //dv = dbo.ExceSQL(string.Format("SELECT F_DeviceIndex,F_PalletBarcodeLength,F_BarCode FROM T_Base_PLC_Ask WHERE (F_Askkind = 4 OR F_Askkind = 14) AND (F_BindingDevice = {0})", this._deviceIndex)).Tables[0].DefaultView; //if (dv.Count > 0) //{ // gbBarcode.Visible = true; // CStaticClass.WcfControl.BeginGetReadedAndReportedBarcode(this._deviceIndex, new AsyncCallback(CallbackGetReadedAndReportedBarcode), null); //} //else //{ // gbBarcode.Visible = false; //} } catch (Exception ex) { MessageBox.Show(ex.Message); } } void CallbackGetReadedAndReportedBarcode(IAsyncResult ar) { string errortext, ReadedBarcode, ReportedBarcode; try { bool rt = CStaticClass.WcfControl.EndGetReadedAndReportedBarcode(out ReadedBarcode, out ReportedBarcode, out errortext, ar); if (rt == true) { this.BeginInvoke(new MethodInvoker(delegate () { //lblReadedBarcode.Text = ReadedBarcode; //lblReportedBarcode.Text = ReportedBarcode; })); } else { this.BeginInvoke(new MethodInvoker(delegate () { //lblReadedBarcode.Text =""; //lblReportedBarcode.Text = ""; })); if (errortext != "") { MessageBox.Show(errortext, "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch { } } #endregion #region 关闭窗体 private void btnClose_Click(object sender, EventArgs e) { this.Close(); } #endregion private void button2_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要把设备:" + this._deviceIndex + "设成逻辑无物吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } CStaticClass.WcfControl.BeginSetLogicHaveGoods(false, this._deviceIndex, new AsyncCallback(SetLogicHaveGoodsCallBack), null); btnRefresh_Click(sender, e); } private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要把设备:" + this._deviceIndex + "设成逻辑有物吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } CStaticClass.WcfControl.BeginSetLogicHaveGoods(true, this._deviceIndex, new AsyncCallback(SetLogicHaveGoodsCallBack), null); btnRefresh_Click(sender, e); } private void button3_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要向设备:" + this._deviceIndex + "发送【完成应答】吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } string errtext = string.Empty; CStaticClass.WcfControl.BeginSendDeviceReset(this._deviceIndex, 2, new AsyncCallback(SendDeviceResetCallBack), 2); } void SetLogicHaveGoodsCallBack(IAsyncResult ar) { string errtext = string.Empty; if (CStaticClass.WcfControl.EndSetLogicHaveGoods(out errtext, ar) == false) { MessageBox.Show(errtext, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } void SendDeviceResetCallBack(IAsyncResult ar) { string errtext = string.Empty; if (CStaticClass.WcfControl.EndSendDeviceReset(out errtext, ar) == false) { MessageBox.Show(errtext, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (ar.AsyncState != null) { //if ((((int)ar.AsyncState) == 4)&&(_device.DeviceKind==4)) //{ // CStaticClass.WcfControl.BeginSendDeviceReset(_deviceIndex, 2, new AsyncCallback(SendDeviceResetCallBack), null); //} if (((int)ar.AsyncState) == 2) { CStaticClass.WcfControl.BeginSendDeviceReset(_deviceIndex, 0, new AsyncCallback(SendDeviceResetCallBack), null); } } } } private void lblDeviceIndex_ValueChanged(object sender, EventArgs e) { _deviceIndex = int.Parse(lblDeviceIndex.Value.ToString()); } private void FrmDeviceStatus_FormClosing(object sender, FormClosingEventArgs e) { _formInstance = null; } private void button4_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要向设备:" + this._deviceIndex + "发送【设备复位】吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } string errtext = string.Empty; CStaticClass.WcfControl.BeginSendDeviceReset(this._deviceIndex, 4, new AsyncCallback(SendDeviceResetCallBack), 4); } int GetMonitorTaskIndexFromBarCode(StringBuilder BarCode) {//20110216 string bc = BarCode.ToString(); DataView dv = dbo.ExceSQL(string.Format("SELECT T_Monitor_Task.F_MonitorIndex FROM T_Base_Device,T_Monitor_Task WHERE T_Base_Device.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex and ((T_Base_Device.F_DeviceKindIndex = 13) OR (T_Base_Device.F_DeviceKindIndex = 31)) and (F_TxtParam = '{0}') and F_Status>0 order by F_MonitorIndex asc", bc)).Tables[0].DefaultView; if (dv.Count > 0) { return Convert.ToInt32(dv[0]["F_MonitorIndex"]); } else { return -1; } } void WriteDBDataCallback(IAsyncResult ar) { string errtext; if (CStaticClass.WcfControl.EndWriteDBData(out errtext, ar) == false) { MessageBox.Show("操作提示", errtext, MessageBoxButtons.OK, MessageBoxIcon.Error); } } void WriteBarcodeCallback(IAsyncResult ar) { if (CStaticClass.WcfControl.EndWriteBarcode(ar) == false) { MessageBox.Show("操作提示", "补码失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("操作提示", "补码成功", MessageBoxButtons.OK, MessageBoxIcon.None); } } void WriteGroupBarcodeCallback(IAsyncResult ar) { if (CStaticClass.WcfControl.EndWriteGroupBarcode(ar) == false) { MessageBox.Show("操作提示", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("操作提示", "修改成功", MessageBoxButtons.OK, MessageBoxIcon.None); } } void ClearFireAlarmCallback(IAsyncResult ar) { if (CStaticClass.WcfControl.EndClearFireAlarm(ar) == false) { MessageBox.Show("操作提示", "火警暂停解除失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("操作提示", "火警暂停解除成功", MessageBoxButtons.OK, MessageBoxIcon.None); } } void ClearPalletCallback(IAsyncResult ar) { if (CStaticClass.WcfControl.EndClearPallet(ar) == false) { MessageBox.Show("操作提示", "串盘锁定解除失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("操作提示", "串盘锁定解除成功", MessageBoxButtons.OK, MessageBoxIcon.None); } } private void lblBarcode_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { if (MessageBox.Show("您确认要修改设备【" + this._deviceIndex + "】记录的【条码】吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } CStaticClass.WcfControl.BeginWriteDBData(_deviceIndex, "DB2", lblBarcode.Text, new AsyncCallback(WriteDBDataCallback), null); } } private void btCancelDoubleFork_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要取消【" + this._deviceIndex + "】的双叉关联吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } StringBuilder sql = new StringBuilder(); sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where F_DeviceIndex=").Append(_deviceIndex); dbo.ExecuteSql(sql.ToString()); } private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) { } private void btresendbarcode_Click(object sender, EventArgs e) { int barcodelenth = Convert.ToInt32(dbo.GetSingle("select F_PalletBarcodeLength from T_Base_PLC_Ask where F_DeviceIndex=" + _deviceIndex)); //if (this.tbAddBarcode.Text.Length != barcodelenth) //{ // MessageBox.Show("操作提示", "条码位数不正确", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} //OPCClient.CSendDeviceOrder sdo = new OPCClient.CSendDeviceOrder(); //sdo.WriteBarcode(_deviceIndex, tbAddBarcode.Text); string d = Dns.GetHostEntry("localhost").HostName; if (CStaticClass.UserID != "") { d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString(); } CStaticClass.WcfControl.BeginWriteBarcode(d, _deviceIndex, string.Format("{0}", tbAddBarcode.Text), new AsyncCallback(WriteBarcodeCallback), null); MessageBox.Show("补码成功!"); } private void button1_Click_1(object sender, EventArgs e) { int barcodelenth = Convert.ToInt32(dbo.GetSingle("select F_PalletBarcodeLength from T_Base_PLC_Ask where F_BindingDevice=" + _deviceIndex)); string GroupBarcode = textBox2.Text.ToString().Trim('|'); string[] barcode = GroupBarcode.Split('|'); if (count != barcode.GetLength(0)) { MessageBox.Show("操作提示", "电气设备记录数量与补入条码数量不一致", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (barcode.GetLength(0) < 1) { MessageBox.Show("操作提示", "条码位数不正确", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } for (int i = 0; i < barcode.GetLength(0); i++) { if (barcode[i].Length != barcodelenth) { MessageBox.Show("操作提示", "条码位数不正确", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } string d = Dns.GetHostEntry("localhost").HostName; if (CStaticClass.UserID != "") { d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString(); } CStaticClass.WcfControl.BeginWriteGroupBarcode(d, _deviceIndex, GroupBarcode, new AsyncCallback(WriteGroupBarcodeCallback), null); } private void button2_Click_1(object sender, EventArgs e) { if (Convert.ToInt32(dbo.GetSingle("select F_AlarmLock from T_Base_Device where F_DeviceIndex=" + _deviceIndex)) == 0) { MessageBox.Show("操作提示", "当前设备没有被火警暂停,无需解除!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string lane = "18" + _deviceIndex.ToString().Substring(2, 3); if (Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task with(nolock) where fstartdevice=" + Convert.ToInt32(lane) + " and fenddevice like '19%'")) != 0) { MessageBox.Show("操作提示", "当前巷道仍有未完成的火警任务,不能解除锁定!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("您确认要清除【" + this._deviceIndex + "】设备的火警暂停吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } string d = Dns.GetHostEntry("localhost").HostName; if (CStaticClass.UserID != "") { string purview = dbo.GetSingle("select f_purview from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString(); if (purview.IndexOf("MIAltMonitor") < 0) { MessageBox.Show("操作提示", "该账号没有权限!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString(); } CStaticClass.WcfControl.BeginClearFireAlarm(d, _deviceIndex, new AsyncCallback(ClearFireAlarmCallback), null); } private void button5_Click(object sender, EventArgs e) { //if (Convert.ToInt32(dbo.GetSingle("select F_Lock from T_NeedLock where F_DeviceIndex=" + _deviceIndex)) == 0) //{ // MessageBox.Show("操作提示", "当前设备没有被串盘锁定,无需解除!", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} if (MessageBox.Show("您确认要清除【" + this._deviceIndex + "】设备的串盘锁定吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } string d = Dns.GetHostEntry("localhost").HostName; if (CStaticClass.UserID != "") { string purview = dbo.GetSingle("select f_purview from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString(); if (purview.IndexOf("MIAltMonitor") < 0) { MessageBox.Show("操作提示", "该账号没有权限!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString(); } CStaticClass.WcfControl.BeginClearPallet(d, _deviceIndex, new AsyncCallback(ClearPalletCallback), null); } private void button6_Click(object sender, EventArgs e) { //强制满垛 string dtime = DateTime.Now.ToString("u");//20101028 StringBuilder sql = new StringBuilder(); string strSQL = string.Format("update ZH_pallet set GOODS_COUNT=1 where Device={0}", _deviceIndex); int bl = dboMan.ExecuteSql(strSQL); if (bl == 1) { DataView dvTemp = dbo.ExceSQL($" select * from ZH_pallet where Device = {_deviceIndex} ").Tables[0].DefaultView; if (dvTemp.Count > 0) { //满垛任务申请 dtime = dtime.Substring(0, dtime.Length - 1); sql.Remove(0, sql.Length); sql.AppendLine(" INSERT INTO IO_CONTROL_APPLY ( "); sql.AppendLine(" CONTROL_APPLY_TYPE, WAREHOUSE_CODE,DEVICE_CODE");//任务类型、库房编码、位置(起始站台) sql.AppendLine(" , STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME ");//托盘条码、申请任务转态、申请时间 sql.AppendLine(" ,CONTROL_APPLY_REMARK,CONTROL_APPLY_PARAMETER ");//备注、纸箱条码信息/ASN码 sql.AppendLine(" ) VALUES ( "); sql.AppendLine($" 14 , 1 , '{_deviceIndex}'");// 14 满垛申请 sql.AppendLine($" ,'{dvTemp[0]["STOCK_BARCODE"]}',0, '{dtime}'"); sql.AppendLine($" ,'','{dvTemp[0]["SN"]}'"); sql.AppendLine(" ) "); dboMan.ExceSQL(sql.ToString()); } MessageBox.Show("操作提示", "强制满垛一下发!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("没有码垛任务!!"); } } public static implicit operator FrmDeviceStatus(FrmDeviceMS v) { throw new NotImplementedException(); } private void Btn_AutomaticPlatform_Click(object sender, EventArgs e) { string strSQL = $"update T_Base_Device set F_PALLETBARCODE = '{this.txt_AutomaticPlatform.Text}' where F_DeviceIndex = {_deviceIndex} "; dboMan.ExecuteSql(strSQL); } } }