private void btnSave__Click(object sender, EventArgs e) { Button btn = sender as Button; Control txtTemp = this.Controls.Find("txt_" + _keyName, true)[0]; YunTextBox yTextbox = txtTemp as YunTextBox; switch (btn.Text.Trim()) { case "设置": btn.Image = Properties.Resources.btnSave; btn.Text = " 保存"; yTextbox.ReadOnly = false; break; case "保存": btn.Image = Properties.Resources.btnSet; btn.Text = " 设置"; yTextbox.ReadOnly = true; //测试 META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='{_keyName}'"); info.Value = yTextbox.Text.Trim(); BLLFactory <META_Parameter> .Instance.Update(info, info.ID); break; } }
public override void ExecuteCommand(MesSession session, MesRequestInfo requestInfo) { log = new LogInfo(session, LogLevel.Info, "开始读配置文件【OP010_STP01】值。"); META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='WebPassword'"); string equ = info.Value; log = new LogInfo(session, LogLevel.Info, $"读取完成【OP010】值为:{equ},下一步写配置文件。"); string temp = StringHelper.GetFirstToChart(equ, ".".ToCharArray()); if (temp == "E") { equ = equ.Replace($"{temp}.", "P3."); } else { equ = equ.Replace($"{temp}.", "E."); } info.Value = equ; BLLFactory <META_Parameter> .Instance.Update(info, info.ID); log = new LogInfo(session, LogLevel.Info, $"写完成【OP010】值为:{equ}。"); requestInfo.TData.Status = CheckResult.OK.ToString(); string msg = GlobalData.ToTranString(requestInfo.TData); session.Send(msg); log = new LogInfo(session, LogLevel.Info, GlobalData.Pre_Send + msg); }
/// <summary> /// 执行获取工单余量 (成功返回制令单号) /// </summary> /// <returns></returns> private bool ExecuteResidueByWO(MesSession _session, TransData _transData) { // 判断API是否执行超时 --------------------------------- DataTable dtR; if (!GlobalData.IsDebug) { bool bRet = GlobalData.RunTaskWithTimeoutDT <DataTable>(delegate { return(DBHelper.GetWorkOrderRemain()); }, out dtR, GlobalData.ApiTimeout, _session, _transData, "空", EmployeeName); if (!bRet) { new LogInfo(_session, LogLevel.Error, $"工单剩余数量为0,请重新开工单。"); return(false); } } else { dtR = GetResidueByWO_Debug(); } //首次获取工单 string workOrder = DataTableHelper.GetCellValueinDT(dtR, 0, "ReturnMsg"); _transData.ProcessData = $"{DataTableHelper.GetCellValueinDT(dtR, 0, "CheckStatus")}---{workOrder}"; META_ParameterInfo info2 = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='WorkOrder'"); info2.Value = workOrder; BLLFactory <META_Parameter> .Instance.Update(info2, info2.ID); LogInfo log = new LogInfo(_session, LogLevel.Info, $"工单:{workOrder}【已缓存】。"); return(true); }
private void btnRefresh__Click(object sender, EventArgs e) { Button btn = sender as Button; string comm = StringUtil.RemovePrefix(btn.Name, "btnRefresh_"); Control txtTemp = this.Controls.Find("txt_" + comm, true)[0]; META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='{comm}'"); txtTemp.Text = info.Value; }
/// <summary> /// 获取产品条码 /// </summary> /// <param name="_session"></param> /// <param name="_transData"></param> /// <param name="equipmentID"></param> /// <returns></returns> private bool GetSN(MesSession _session, TransData _transData, string workOrder) { LogInfo log; string actionParam = $"{workOrder}"; string mEmployeeName = $"{EmployeeName}-获取条码"; DataTable dtR = null; if (!GlobalData.IsDebug) { bool bRet = GlobalData.RunTaskWithTimeoutDT <DataTable>(delegate { return(Dm_Interface.SFC_DM__ProvideBlockID_ByWO(workOrder)); }, out dtR, GlobalData.ApiTimeout, _session, _transData, actionParam, mEmployeeName); if (!bRet) { return(false); } } else { dtR = GetResidueByWO(workOrder); } // 判断API是否执行成功 --------------------------------- string checkStatusR = DataTableHelper.GetCellValueinDT(dtR, 0, 0); _transData.SN = checkStatusR.Substring(4); // 1---DFM201982.93748 #region 校验明码 List <string> lstCode = StringHelper.GetStrArray(_transData.SN, '-', false); if (lstCode.Count < 2) { log = new LogInfo(_session, LogLevel.Error, $"[{_transData.SN}]执行条码拆分失败1。"); return(false); } try { string disCode = lstCode[1].Substring(3, 10); } catch (Exception e) { log = new LogInfo(_session, LogLevel.Error, $"[{_transData.SN}]执行条码拆分失败2。"); return(false); } #endregion META_ParameterInfo info2 = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='OP010_SN_CHECK'"); info2.Value = _transData.SN; BLLFactory <META_Parameter> .Instance.Update(info2, info2.ID);// 缓存当前条码留作下一步校验。 log = new LogInfo(_session, LogLevel.Info, $"[{_transData.SN}]执行【{mEmployeeName}】接口成功>> SN:[{_transData.SN}]【已缓存】,执行参数:{actionParam}。"); return(true); }
/// <summary> /// 校验Status并返回 /// </summary> /// <param name="_session"></param> /// <param name="_transData"></param> /// <param name="status"></param> /// <param name="caller"></param> /// <returns></returns> public static bool CheckApiStatus(MesSession _session, TransData _transData, out string apiStatus, string caller) { META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='{_transData.Status}'"); apiStatus = "ERROR"; if (info == null || string.IsNullOrEmpty(info.Value)) { LogInfo log = new SocketService.LogInfo(_session, LogLevel.Error, $"[{_transData.SN}]执行【{caller}】接口失败>> 参数错误,请检查SQLLite中是否配置WorkOrder参数,执行参数:{_transData.Status}。"); EmployeeComm.SendMsg(_session, _transData, CheckResult.NG); return(false); } apiStatus = info.Value; return(true); }
/// <summary> /// 校验WorkOrder并返回 /// </summary> /// <param name="_session"></param> /// <param name="_transData"></param> /// <param name="workOrder"></param> /// <param name="caller"></param> /// <returns></returns> public static bool CheckNormalParam(MesSession _session, TransData _transData, string paramKey, out string paramValue, string paramDisplay, string caller) { META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='{paramKey}'"); if (info == null && string.IsNullOrEmpty(info.Value)) { paramValue = "ERROR"; LogInfo log = new SocketService.LogInfo(_session, LogLevel.Error, $"[{_transData.SN}]执行【{caller}】接口失败>> 参数错误,获取{paramDisplay}失败,请检查SQLLite中是否缓存{paramDisplay},(请求参数:{paramKey})。"); _transData.ProcessData = $"Failed to get the cache barcode by [{paramKey}],Check SQLite DB."; EmployeeComm.SendMsg(_session, _transData, CheckResult.NG); return(false); } paramValue = info.Value; return(true); }
private void FrmSet() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景. SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 在缓冲区重绘 SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 DelegateState.ServerStateInfo = ServerShowStateInfo; DelegateState.NewSessionConnected = NewSessionConnected; DelegateState.SessionClosed = SessionClosed; #region wgvList Dictionary <string, string> columnNameAlias = new Dictionary <string, string>(); columnNameAlias.Add("SessionID", "会话ID"); columnNameAlias.Add("RemoteDeviceName", "远端地址"); columnNameAlias.Add("Time", "操作时间"); columnNameAlias.Add("Mode", "动作"); columnNameAlias.Add("Reason", "原因"); wgvList.ShowLineNumber = false; wgvList.BestFitColumnWith = false;//是否设置为自动调整宽度,false为不设置 wgvList.dataGridView1.DataSourceChanged += new EventHandler(wgvList_DataSourceChanged); wgvList.dataGridView1.RowPostPaint += new DataGridViewRowPostPaintEventHandler(wgvList_RowPostPaint); wgvList.DisplayColumns = "SessionID,RemoteDeviceName,Time,Mode,Reason"; wgvList.ColumnNameAlias = columnNameAlias; #endregion queueServer.IsBackground = true; queueServer.ProcessItem += QueueServer_ProcessItem; sessionClosedQueueServer.IsBackground = true; sessionClosedQueueServer.ProcessItem += SessionClosedQueueServer_ProcessItem; MainTabIndex = 0; TabControl1.SelectedIndex = 0; tPanelSet.DataBindings.Add(new Binding("Enabled", btnTCPStart, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged)); lblPSetWarm.DataBindings.Add(new Binding("Visible", btnTCPStop, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged)); META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle("Key='ServiceDescription'"); if (info != null) { Text = info.Value; } }
private void Init() { Control txtTemp = this.Controls.Find("txt_" + KeyName, true)[0]; try { YunTextBox yTextbox = txtTemp as YunTextBox; META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='{KeyName}'"); yTextbox.Text = info.Value; yTextbox.ReadOnly = true; } catch (Exception ex) { txtTemp.Text = $"{ DateTime.Now.ToString("yyyy.MM.dd HH: mm:ss.fff")} >> 刷新异常:{ex.Message}."; } }
/// <summary> /// 读取配置参数 /// </summary> public static void LoadConfig() { try { List <META_ParameterInfo> lstParameter = BLLFactory <META_Parameter> .Instance.GetAll(); META_ParameterInfo info = lstParameter.Find(li => li.Key == "RefreshSecond"); if (info != null) { RefreshSecond = ConvertHelper.ToInt32(info.Value, 1000); } info = lstParameter.Find(li => li.Key == "ApiTimeout"); if (info != null) { ApiTimeout = ConvertHelper.ToInt32(info.Value, 1000); } info = lstParameter.Find(li => li.Key == "WebUserID"); if (info != null) { WebUserID = info.Value; } info = lstParameter.Find(li => li.Key == "WebPassword"); if (info != null) { WebUserID = info.Value; } info = lstParameter.Find(li => li.Key == "IsDebug"); if (info != null) { IsDebug = info.Value.Equals("是") ? true : false; } queueServerNDQ.IsBackground = true; queueServerNDQ.ProcessItem += QueueServer_ProcessItem; } catch (Exception e) { } }
/// <summary> /// 校验WorkOrder并返回(配置文件获取) /// </summary> /// <param name="_session"></param> /// <param name="_transData"></param> /// <param name="workOrder"></param> /// <param name="caller"></param> /// <returns></returns> public static bool CheckWorkOrder(MesSession _session, TransData _transData, out string workOrder, string caller, DataFrom getFrom) { workOrder = string.Empty; caller += "-获取工单编码"; META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='WorkOrder'"); if (info == null && string.IsNullOrEmpty(info.Value)) { LogInfo log = new SocketService.LogInfo(_session, LogLevel.Error, $"[{_transData.SN}]执行【{caller}】接口失败>> 参数错误,请检查SQLLite中是否配置WorkOrder参数。"); EmployeeComm.SendMsg(_session, _transData, CheckResult.NG); return(false); } switch (getFrom) { case DataFrom.SQLite: workOrder = info.Value; break; case DataFrom.SQLServer: DataTable dtR; DM_API.DM_SFCInterface Dm_Interface = new DM_API.DM_SFCInterface(); bool bRet = GlobalData.RunTaskWithTimeoutDT <DataTable>(delegate { return(DBHelper.GetWorkOrderRemain()); }, out dtR, GlobalData.ApiTimeout, _session, _transData, "空", caller); if (!bRet) { return(false); } workOrder = DataTableHelper.GetCellValueinDT(dtR, 0, "ReturnMsg"); info.Value = workOrder; BLLFactory <META_Parameter> .Instance.Update(info, info.ID); LogInfo log = new SocketService.LogInfo(_session, LogLevel.Info, $"[{_transData.SN}]执行【{caller}】接口成功,数据缓存本地成功,当前工单号:{workOrder}。"); break; } return(true); }
private void lnkClient_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { META_DevLinkInfo info = BLLFactory <META_DevLink> .Instance.FindSingle($"DevCode='OP010'"); //测试 META_ParameterInfo info2 = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='WorkOrder'"); info2.Value = "TEST002"; BLLFactory <META_Parameter> .Instance.Update(info2, info2.ID); info2 = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='OK_RE'"); try { if (mesServer == null) { MessageUtilSkin.ShowTips("请启动数据服务器."); return; } TabControl1.SelectedIndex = 1; IPEndPoint EndPoint = mesServer.Listeners[0].EndPoint; Frm_Msg frm = new Frm_Msg(); frm.Text = $"{ EndPoint.Address}"; frm.txtMsg.Text = string.Empty; frm.EndPoint = EndPoint; if (frm.ShowDialog() != DialogResult.OK) { return; } } catch (Exception ex) { MessageUtilSkin.ShowTips(ex.Message); } }
public DataTable PrintBarCode(MesSession _session, string _sn, string processData) { META_ParameterInfo info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='LablePath'"); string lablePath = info.Value; info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='TracePrinterName'"); string tracePrinterName = info.Value; info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='ConFormPrinterName'"); string conFormPrinterName = info.Value; info = BLLFactory <META_Parameter> .Instance.FindSingle($"Key='CustomerCode'"); string customerCode = info.Value; META_DevLinkInfo devInfo = BLLFactory <META_DevLink> .Instance.FindSingle($"DevCode='OP320'"); string productType = devInfo.ProcessType; new LogInfo(_session, LogLevel.Info, $"打印基础数据准备完成{System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}"); List <string> lstMsg = StringHelper.GetStrArray(processData, '/', false); string supplierCode = lstMsg[0]; string traceLabel = lstMsg[1]; string conFormLabel = lstMsg[2]; string traceability = lstMsg[3]; string imsafeCode = lstMsg[3]; if (productType == "ECMP" && (supplierCode == "A009D3 01" || supplierCode == "M107190000")) { imsafeCode = customerCode + supplierCode + lstMsg[3].ToString().Substring(7, 6) + "A"; } else { imsafeCode = lstMsg[3]; } string sn = lstMsg[4]; string hw = lstMsg[5]; string sw = lstMsg[6]; ApplicationClass lbl_1 = null, lbl_2 = null; Document doc_1 = null, doc_2 = null; DataTable dt = DataTableHelper.CreateTable("CheckStatus,ReturnMsg"); dt.TableName = "PrintCheck"; try { lbl_1 = new ApplicationClass(); lbl_1.Documents.Open(lablePath + conFormLabel); doc_1 = lbl_1.ActiveDocument; doc_1.Printer.SwitchTo(conFormPrinterName); string[] arrProduct = _sn.Trim().Split('-'); doc_1.Variables.FormVariables.Item("Product").Value = arrProduct[0].ToUpper(); doc_1.Variables.FormVariables.Item("SullperCode").Value = supplierCode.ToUpper(); doc_1.Variables.FormVariables.Item("Date").Value = System.DateTime.Now.ToString("dd-MM-yy"); doc_1.Variables.FormVariables.Item("Barcode").Value = sn.ToUpper(); doc_1.Variables.FormVariables.Item("HW").Value = hw.ToUpper(); doc_1.Variables.FormVariables.Item("SW").Value = sw.ToUpper(); new LogInfo(_session, LogLevel.Info, $"产品条码打印:DocName:{lablePath + conFormLabel},Printer:{conFormPrinterName},{doc_1.Printer.FullName}"); doc_1.PrintDocument(1); lbl_2 = new ApplicationClass(); lbl_2.Documents.Open(lablePath + traceLabel); doc_2 = lbl_2.ActiveDocument; doc_2.Printer.SwitchTo(tracePrinterName); doc_2.Variables.FormVariables.Item("Date").Value = System.DateTime.Now.ToString("dd-MM-yy"); doc_2.Variables.FormVariables.Item("TraceabilityNumber").Value = traceability.Substring(6, 7).ToUpper(); if (productType == "ECMP") { doc_2.Variables.FormVariables.Item("SerialNumber").Value = customerCode.ToUpper(); } else { doc_2.Variables.FormVariables.Item("SerialNumber").Value = arrProduct[1].Substring(0, 13).ToUpper(); } doc_2.Variables.FormVariables.Item("SullperCode").Value = supplierCode.ToUpper(); doc_2.Variables.FormVariables.Item("Barcode").Value = imsafeCode.ToUpper(); if (supplierCode == "A009D3 01") { doc_2.Variables.FormVariables.Item("NO.").Value = "01"; } else { doc_2.Variables.FormVariables.Item("NO.").Value = ""; } doc_2.PrintDocument(1); new LogInfo(_session, LogLevel.Info, $"客户追溯条码打印:DocName:{lablePath + traceLabel},Printer:{tracePrinterName},{doc_2.Printer.FullName}"); dt.Rows.Add("1", "Print Success."); } catch (Exception e) { if (lbl_1 != null) { lbl_1.Quit(); } if (lbl_2 != null) { lbl_2.Quit(); } LogInfo log = new LogInfo(_session, LogLevel.Error, $"打印异常:{e.ToString()}"); dt.Rows.Add("-1", e.Message); } finally { LogInfo log = new LogInfo(_session, LogLevel.Info, $"退出打印:TracePrinterName:{tracePrinterName},ConFormPrinterName:{conFormPrinterName}"); if (lbl_1 != null) { lbl_1.Documents.CloseAll(true); lbl_1.Quit();//退出 lbl_1 = null; doc_1 = null; } if (lbl_2 != null) { lbl_2.Documents.CloseAll(true); lbl_2.Quit();//退出 lbl_2 = null; doc_2 = null; } GC.Collect(0); } ProcessHelper.KillProcess("lppa"); return(dt); }