示例#1
0
        private void ExportAllButton_Click()
        {
            DialogBox.SaveFileDialog dialog = new DialogBox.SaveFileDialog();
            string     filePath;
            List <int> indexs = new List <int>();

            foreach (DeviceShortMessageLine line in DeviceSMesageContainer.Children)
            {
                indexs.Add(line.GetID());
            }

            dialog.Title      = "选择导出文件保存路径";
            dialog.Filter     = "xml File(*.xml)|*.xml";
            dialog.DefaultExt = "xml";
            //如果用户没有添加则自动添加扩展
            dialog.AddExtension = true;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //文件路径
                filePath = dialog.FileName;
                List <StandardDeviceDesModel> list = new List <StandardDeviceDesModel>();

                for (int counter = 0; counter < indexs.Count; counter++)
                {
                    list.Add(DBControler.UnityIns.GetSSDesTotalRecord(indexs[counter]));
                }


                SDDAndXml.SaveToXml(filePath, list);
                BottomPart.Log("导出所有器件信息成功", LogMessage.LevelEnum.Important);
            }
        }
示例#2
0
        private void DeleteButton_Click()
        {
            //正在测试,无法删除该器件
            if (Testing)
            {
                MessageDialog dialogForError = new MessageDialog("该器件信息正在被使用无法删除");
                return;
            }

            MessageDialog dialog = new MessageDialog(String.Format("是否确认删除该标准器件测试信息?\n喷油泵型号 : {0}\n喷油泵编号 : {1}", EquType, EquCode), true);

            //确认删除
            if (dialog.ShowDialog().Value)
            {
                if (DBControler.UnityIns.DeleteSSDesRecord(DeviceID))
                {
                    BottomPart.Log("成功删除", LogMessage.LevelEnum.Important);
                    //移除自己的显示
                    ((StackPanel)(this.Parent)).Children.Remove(this);
                }
                else
                {
                    BottomPart.Log("删除失败", LogMessage.LevelEnum.Important);
                }
            }
        }
示例#3
0
        private void ImportAllButton_Click()
        {
            string[] filePath;
            DialogBox.OpenFileDialog dialog = new DialogBox.OpenFileDialog();
            dialog.Title       = "选择导出文件";
            dialog.Filter      = "xml File(*.xml)|*.xml";
            dialog.Multiselect = true;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //文件路径
                filePath = dialog.FileNames;

                for (int counter = 0; counter < filePath.Length; counter++)
                {
                    List <StandardDeviceDesModel> lists = null;

                    try
                    {
                        lists = SDDAndXml.GetSDDFromXml(filePath[counter]);
                    }
                    catch (Exception e)
                    {
                        BottomPart.Log("文件解析失败,文件名 : " + filePath[counter], LogMessage.LevelEnum.Error);
                        continue;
                    }

                    for (int index = 0; index < lists.Count; index++)
                    {
                        AddNewDeviceDispose(lists[index]);
                    }
                }
            }
        }
示例#4
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();
                }
            }
        }
示例#5
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);
                    }
                }
            }));
        }
示例#6
0
        private void ModifyButton_Click()
        {
            //正在测试,无法删除该器件
            if (Testing)
            {
                MessageDialog dialogForError = new MessageDialog("该器件信息正在被使用无法修改");
                return;
            }

            StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(DeviceID);

            if (model != null)
            {
                NewDeviceDialog newDDialog = new NewDeviceDialog(model, true);
                if (newDDialog.ShowDialog().Value)
                {
                    MessageDialog sureDialog = new MessageDialog(String.Format("是否确认修改该标准器件测试信息?\n喷油泵型号 : {0}\n喷油泵编号 : {1}", EquType, EquCode), true);

                    //确认修改
                    if (sureDialog.ShowDialog().Value)
                    {
                        StandardDeviceDesModel result = newDDialog.GetResult();
                        result.Id = DeviceID;

                        if (DBControler.UnityIns.ModifySSDesRecord(result))
                        {
                            BottomPart.Log("成功修改", LogMessage.LevelEnum.Important);
                        }
                        else
                        {
                            BottomPart.Log("修改失败", LogMessage.LevelEnum.Error);
                        }
                    }
                }
            }
        }
示例#7
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);
                }
            }
        }