コード例 #1
0
        /// <summary>
        /// 校验EquipmentID并返回
        /// </summary>
        /// <param name="_session"></param>
        /// <param name="_transData"></param>
        /// <param name="equipmentID"></param>
        /// <returns></returns>
        public static bool CheckEquipmentID(MesSession _session, TransData _transData, out string equipmentID, string caller)
        {
            caller     += "-获取设备编码";
            equipmentID = string.Empty;
            META_DevLinkInfo info = BLLFactory <META_DevLink> .Instance.FindSingle($"DevCode='{_transData.DeviceCode}'");

            if (info == null)
            {
                LogInfo log = new SocketService.LogInfo(_session, LogLevel.Error, $"[{_transData.SN}]执行【{caller}】接口失败>> 参数错误,根据机台编码[{_transData.DeviceCode}] 获取设备编码失败,请检查SQLLite中是否配置机台映射关系。");
                _transData.ProcessData = $"Failed to get the equipmentID by {_transData.DeviceCode},Check SQLite DB.";
                EmployeeComm.SendMsg(_session, _transData, CheckResult.NG);
                return(false);
            }

            //前工序校验是获取产品工艺类型
            if (!GlobalData.IsDebug && _transData.FuncCode == "PRC")
            {
                DataTable dtR;
                DM_API.DM_SFCInterface Dm_Interface = new DM_API.DM_SFCInterface();
                caller += "-获取工艺类型<用于识别设备编码>";
                string[] arrSN = _transData.SN.Trim().Split('-');
                bool     bRet  = GlobalData.RunTaskWithTimeoutDT <DataTable>(delegate { return(Dm_Interface.SFC_DM_SelectProductionProcess(arrSN[0])); }, out dtR, GlobalData.ApiTimeout, _session, _transData, arrSN[0], caller);
                if (!bRet)
                {
                    return(false);
                }

                string type = DataTableHelper.GetCellValueinDT(dtR, 0, 1);
                info.ProcessType = type;
                BLLFactory <META_DevLink> .Instance.Update(info, info.ID);

                LogInfo log = new SocketService.LogInfo(_session, LogLevel.Info, $"[{_transData.SN}]获取当前机台工艺类型成功,工艺类型[{info.ProcessType}]【已缓存】 ");
            }

            switch (info.ProcessType)
            {
            case "PHEV-3.3KW":
                equipmentID = info.EquipmentID2;
                break;

            case "PHEV-6.6KW":
                equipmentID = info.EquipmentID3;
                break;

            default:
                equipmentID = info.EquipmentID1;
                break;
            }
            return(true);
        }
コード例 #2
0
ファイル: Frm_Main.cs プロジェクト: wuyunhai/EasyCareAuto
        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);
            }
        }
コード例 #3
0
ファイル: PTR.cs プロジェクト: wuyunhai/EasyCareAuto
        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);
        }