Beispiel #1
0
        private void ConnectAction()
        {
            if (MeasurementTasks.Count < 1)
            {
                FormMessageBox.SetShow(null, "测试错误", "请至少选择一个产品测试", 4);
                while (!IsStop && FormMessageBox.MessageBoxResult == 0)
                {
                    System.Threading.Thread.Sleep(500);
                }

                IsStop = true;
                return;
            }

            if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.DuplicationCheckType > 0)
            {
                var c = new ModifyTestInfo();
                foreach (var task in MeasurementTasks)
                {
                    var temp = c.GetLastTestInfo(MeasurementJob.ProductInfo.ProductID, MeasurementJob.StationInfo.StationID, task.TestSN, true);
                    if (temp.Status)
                    {
                        if (temp.Data != null && temp.Data != Guid.Empty)
                        {
                            tipCallback?.Invoke(task.TestOrderID, 2, $"{task.TestSN}重复测试", 0);
                            FormMessageBox.SetShow(null, "重复测试", $"系统检查到 {task.TestSN} 已经测试\r\n请确认SN号码是否重号或者产品多次测试。", 3);
                            while (!IsStop && FormMessageBox.MessageBoxResult == 0)
                            {
                                System.Threading.Thread.Sleep(500);
                            }
                            if (FormMessageBox.MessageBoxResult != 1)
                            {
                                IsStop = true;
                                return;
                            }
                        }
                    }
                }
            }

            if (!MeasurementController.Connect())
            {
                FormMessageBox.SetShow(null, "仪器错误", $"连接仪器失败\r\n{MeasurementController.ErrorString}", 4);
                while (!IsStop && FormMessageBox.MessageBoxResult == 0)
                {
                    System.Threading.Thread.Sleep(500);
                }

                IsStop = true;
                return;
            }
        }
Beispiel #2
0
        private void Print(string sn, bool mandatory)
        {
            if (!template.Open(tempFile))
            {
                printResultCallback?.Invoke("", 0, "打开Excel模板失败");
                errorCallback?.Invoke(template.ErrorString);
                return;
            }

            var controller = new ModifyTestInfo();

            printResultCallback?.Invoke(sn, 0, $"正在获取{sn}数据");
            var last = controller.GetLastTestInfo(_productID, _stationID, sn, _printPass);

            if (!last.Status)
            {
                printResultCallback?.Invoke(sn, 2, $"获取{sn}数据失败:{last.Message}");
                return;
            }
            var info = controller.GetTestInfo(last.Data);

            if (!info.Status)
            {
                printResultCallback?.Invoke(sn, 2, $"获取{sn}数据失败:{info.Message}");
                return;
            }
            if (!string.IsNullOrEmpty(_workID))
            {
                if (!_workID.Equals(info.Data.WorkInfo.WorkOrderID, StringComparison.OrdinalIgnoreCase))
                {
                    printResultCallback?.Invoke(sn, 2, $"核对{sn}数据失败:当前工单为{info.Data.WorkInfo.WorkOrderID}");
                    return;
                }
            }

            try
            {
                var tempData = new TemplateData();
                tempData.SetData(info.Data, exData);

                printResultCallback?.Invoke(sn, 0, $"正在制作{sn}模板");
                if (!template.Compile(tempData))
                {
                    printResultCallback?.Invoke(sn, 2, $"{sn}模板制作失败:{template.ErrorString}");
                    return;
                }
                if (!_onlySave)
                {
                    printResultCallback?.Invoke(sn, 0, $"正在打印{sn}模板");
                    if (!template.Print(mandatory))
                    {
                        printResultCallback?.Invoke(sn, 2, $"{sn}打印失败:{template.ErrorString}");
                        return;
                    }
                }


                var savePath = $"{_savePath}/{sn}.xls";
                if (System.IO.File.Exists(savePath))
                {
                    AppFramework.Context.Execute(new Action(() =>
                    {
                        AppFramework.Context.ShowError($"{sn}重复打印,将覆盖原来的模板。");
                    }));
                }

                if (!template.SaveAs($"{_savePath}/{sn}.xls"))
                {
                    printResultCallback?.Invoke(sn, 2, $"{sn}保存:{template.ErrorString}");
                    return;
                }
                if (listTemp != null)
                {
                    listTemp.Compile(tempData);
                    if (!_onlySave)
                    {
                        listTemp.Print(mandatory);
                    }
                    listTemp.SaveAs($"{_savePath}/{prodcutCode}.xls");
                }
            }
            catch (Exception ex)
            {
                printResultCallback?.Invoke(sn, 2, $"打印{sn}失败:{ex.Message}");
                return;
            }

            printResultCallback?.Invoke(sn, 1, $"打印{sn}成功");
        }