Exemple #1
0
        private void DeviceStartTest(DeviceShortMessageLine line)
        {
            //有正在测试的器件,则需要等待
            if (NowTestDevice != null)
            {
                MessageDialog dialog = new MessageDialog("有器件正在测试,请等待......");
                dialog.ShowDialog();
            }
            //如果没有,则可以使用这个器件开始测试
            else
            {
                if (BottomPart.Unity.IsConnect())
                {
                    MessageDialog dialog = new MessageDialog(String.Format("喷油泵型号 : {0}\n是否开始测试?", line.GetEquType()), true);

                    //同意开始测试
                    if (dialog.ShowDialog().Value)
                    {
                        line.SetTesting(true);
                        NowTestDevice = line;
                        StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(line.GetID());
                        model.Id = line.GetID();

                        //注册接受事件代理
                        ITrans.UnityIns.Add_GetMeeageDel(this.RecieveData);


                        ITrans.UnityIns.SendMeesageAsync(model.ToString(), ITrans.CommandEnum.REQUIRE, (result, data, commmand) =>
                        {
                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                if (result)
                                {
                                    BottomPart.Log("发送喷油泵标准测试数据成功", LogMessage.LevelEnum.Important);
                                }
                                else
                                {
                                    BottomPart.Log("发送喷油泵标准测试数据失败", LogMessage.LevelEnum.Important);
                                }
                            }));
                        });
                    }
                }
                //还未连接,则提示
                else
                {
                    MessageDialog dialog = new MessageDialog("测试台未连接,请先连接测试台");
                    dialog.ShowDialog();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 添加器件信息(显示部分,不包含数据库操作)
        /// </summary>
        /// <param name="id">信息Id</param>
        private void AddDSMessage(int id, String equType, String equCode)
        {
            DeviceShortMessageLine line = new DeviceShortMessageLine(id, equType, equCode, DeviceStartTest, (DeviceShortMessageLine which) =>
            {
                //之前的器件取消选择状态
                if (NowSelectDevice != null)
                {
                    NowSelectDevice.Selected_Cancel();
                }

                NowSelectDevice = which;
            });

            DeviceSMesageContainer.Children.Add(line);
        }
Exemple #3
0
        /// <summary>
        /// 接受数据代理
        /// </summary>
        /// <param name="result"></param>
        /// <param name="data"></param>
        /// <param name="command"></param>
        private void RecieveData(bool result, String data, ITrans.CommandEnum command)
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                //接受到了数据
                if (command == ITrans.CommandEnum.RESULT)
                {
                    HistoryModel model = new HistoryModel(data);

                    if (model.Id == NowTestDevice.GetID())
                    {
                        int index = -1;
                        StandardDeviceDesModel sdd = DBControler.UnityIns.GetSSDesTotalRecord(NowTestDevice.GetID());

                        //测试状态取消
                        NowTestDevice.SetTesting(false);
                        NowTestDevice = null;

                        CombinaPara(sdd, model);

                        BottomPart.Log("接受结果数据成功", LogMessage.LevelEnum.Important);

                        index    = DBControler.UnityIns.AddHistoryRecord(model);
                        model.Id = index;

                        if (index > 0)
                        {
                            BottomPart.Log("保存测试数据成功", LogMessage.LevelEnum.Important);
                            MainWindow.MWindow.AddAHistoryLine(model);
                        }
                        else
                        {
                            BottomPart.Log("保存测试数据失败", LogMessage.LevelEnum.Error);
                        }
                    }
                    else
                    {
                        BottomPart.Log("接受结果数据与当前测试数据ID不匹配", LogMessage.LevelEnum.Error);
                    }
                }
            }));
        }
Exemple #4
0
        private void AddNewDeviceDispose(StandardDeviceDesModel result)
        {
            int repetitionId = 0;

            //查重,如果出现了型号和编号重复
            if (DBControler.UnityIns.CheckSSDesRepetition(result.EquCode, result.EquType, out repetitionId))
            {
                //询问是否覆盖数据
                MessageDialog mDialog = new MessageDialog("数据库中已存在该器件\n器件型号 : " + result.EquType + "\n是否覆盖数据?", true);

                //无需覆盖,直接返回
                if (!mDialog.ShowDialog().Value)
                {
                    return;
                }
                //覆盖数据
                else
                {
                    result.Id = repetitionId;

                    //寻找相同数据
                    foreach (DeviceShortMessageLine line in DeviceSMesageContainer.Children)
                    {
                        //出现了重复,则是覆盖了之前的内容
                        if (line.GetID() == result.Id)
                        {
                            //在这里需要检查该器件是否正在被使用,如果是,则无法修改
                            if (!line.IsTesting())
                            {
                                //可以修改数据
                                //修改成功
                                if (DBControler.UnityIns.ModifySSDesRecord(result))
                                {
                                    BottomPart.Log(String.Format("覆盖数据成功(<编号:{0}><型号:{1}>)", result.EquCode, result.EquType), LogMessage.LevelEnum.Normal);
                                }
                                //修改失败
                                else
                                {
                                    BottomPart.Log(String.Format("覆盖数据失败(<编号:{0}><型号:{1}>)", result.EquCode, result.EquType), LogMessage.LevelEnum.Error);
                                    return;
                                }

                                line.ModifyEquType(result.EquType, result.EquCode);
                                return;
                            }
                            //器件正在被使用,故而无法修改数据
                            else
                            {
                                MessageDialog errorDialog = new MessageDialog("该器件信息正在被使用,无法修改!");
                                if (errorDialog.ShowDialog().Value)
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            //没有重复的编号和型号
            else
            {
                int newId = DBControler.UnityIns.AddSSDesRecord(result);
                //插入失败
                if (newId < 0)
                {
                    BottomPart.Log(String.Format("添加新器件信息失败"), LogMessage.LevelEnum.Error);
                    return;
                }
                else
                {
                    //保存获得的id
                    result.Id = newId;
                    BottomPart.Log(String.Format("添加新器件信息成功(<编号:{0}><型号:{1}>)", result.EquCode, result.EquType), LogMessage.LevelEnum.Normal);

                    //新添加的器件信息
                    DeviceShortMessageLine newLine = new DeviceShortMessageLine(result.Id, result.EquType, result.EquCode, DeviceStartTest, (DeviceShortMessageLine which) =>
                    {
                        //之前的器件取消选择状态
                        if (NowSelectDevice != null)
                        {
                            NowSelectDevice.Selected_Cancel();
                        }

                        NowSelectDevice = which;
                    });
                    DeviceSMesageContainer.Children.Add(newLine);
                }
            }
        }