//string sortNum = "0"; public void OnDataChange(int group, int[] clientId, object[] values) { if (group == 5)//完成信号 { for (int i = 0; i < clientId.Length; i++) { string tempvalue = values[i].ToString(); if (decimal.Parse(tempvalue) >= 1)//分拣完成 { try { if (decimal.Parse(tempvalue) != 0) { WriteLog.GetLog().Write("从电控读取特异型烟任务号:" + tempvalue); //UnPokeClass.UpdateunTask(tempvalue, 20); //sortNum = tempvalue; UnPokeClass.UpdateunTask1(decimal.Parse(tempvalue), 20); try { sortnum = RelenishimentClass.GetMinSortNum(); } catch { } lblSortnum.Text = "当前任务:" + sortnum; //SpecialClass.UpdateSpecialState(decimal.Parse(tempvalue),2); WriteLog.GetLog().Write("特异型烟任务号" + tempvalue + "号任务已完成,数据库更新完成"); GetData(); } } catch (Exception ex) { WriteLog.GetLog().Write("服务器连接失败" + ex.Message.ToString()); return; } } opcServer.FinishOnlyGroup.Write(0, clientId[i] - 1); } } else if (group == 9)//接收标志 { for (int i = 0; i < clientId.Length; i++) { if (clientId[i] == 1)//一线任务 { try { if (values[i] != null && int.Parse(values[i].ToString()) == 0) { while (!opcServer.ConnectState) { Thread.Sleep(100); } int receivePackage = int.Parse(opcServer.OnlyTaskGroup.ReadD(i).ToString()); if (receivePackage != 0) { WriteLog.GetLog().Write("特异型烟任务号:" + receivePackage + "已接收"); UnPokeClass.UpdateTask(receivePackage, 15); //UnPokeClass.UpdateHunhe(receivePackage); } if (opcServer.IsSendOn)//如果任务已经在发送中则返回 { return; } StringBuilder outStr = new StringBuilder(); object[] data = RelenishimentClass.GetSendTasks(10, out outStr); DelSendTask task = new DelSendTask(opcServer.SendOnlyTask); IAsyncResult result = task.BeginInvoke(data, outStr, null, task); StringBuilder re = task.EndInvoke(result); if (re.ToString() == "特异型烟道暂无任务") { databaselinkcheck("特异型烟道暂无任务"); return; } WriteLog.GetLog().Write(re.ToString()); GetData(); } else { if (values[i] != null && int.Parse(values[i].ToString()) != 0) { WriteLog.GetLog().Write("补货读到标志位:" + values[i]); } } } catch (Exception ex) { WriteLog.GetLog().Write("补货异常信息" + ex.Message); } } } } }
private void BtnUpdate_Click(object sender, EventArgs e) { DialogResult MsgBoxResult = MessageBox.Show("确定要更新任务?", //对话框的显示内容 "操作提示", //对话框的标题 MessageBoxButtons.YesNo, //定义对话框的按钮,这里定义了YSE和NO两个按钮 MessageBoxIcon.Question, //定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号 MessageBoxDefaultButton.Button2); //定义对话框的按钮式样 if (MsgBoxResult == DialogResult.Yes) { string txtStart = TxtStartNum.Text; string txtEnd = TxtEndNum.Text; int status = 10; if (string.IsNullOrWhiteSpace(TxtEndNum.Text))//如果只输入第一个任号务 则其修改 { txtEnd = txtStart; } else if (string.IsNullOrWhiteSpace(TxtStartNum.Text))//如果只输入第一个任号务 则其修改 { txtStart = txtEnd; } else if (Convert.ToDecimal(TxtStartNum.Text) > Convert.ToDecimal(TxtEndNum.Text)) //防止任务号输反 { string tmp = txtStart; txtStart = txtEnd; txtEnd = tmp; } switch (CmbState.SelectedIndex) { case 0: status = 10; //新增 break; case 1: status = 15; //已发送 break; case 2: status = 20; //已完成 break; } decimal start = 0; decimal end = 0; if (decimal.TryParse(txtStart, out start) && decimal.TryParse(txtEnd, out end)) { UnPokeClass.UpdateTask(start, end, status); WriteLog.GetLog().Write("任务号从:" + txtStart + "任务号到:" + txtEnd + ",修改状态为:" + status + ",修改包装机为" + ",任务更新完成!"); int sortNum = 0; bool a = int.TryParse(TxtSortNum.Text, out sortNum); list = UnPokeClass.GetDataAll(pageNum, out count, sortNum, TxtRegionCode.Text, TxtCusID.Text); lblCount.Text = "共" + count + "条记录"; pageCount = (int)Math.Floor(count / 50.0); lblPageCount.Text = "共" + pageCount + "页"; Bind(list); } else { MessageBox.Show("输入错误!!!"); } } }