/// <summary>
        /// 添加仪器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void NewBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            //创建创建仪器对话框
            var dialog3 = new InputDialog3();

            dialog3.Model().Label1           = "Instrument Name";
            dialog3.Model().Label3           = "Communication Type";
            dialog3.Model().ItemsSource      = new ObservableCollection <ComboBoxItemModel>(SystemSettings.Comm1);
            dialog3.Model().Input1           = "";
            dialog3.Model().WarningMsg1      = "Input not available!";
            dialog3.Model().Input1Validation = (
                s =>
            {
                return(!SystemSettings.InstrumentsList.Any(t => t.Name.ToUpper() == s.ToUpper()));
            });
Input:
            var result = await DialogHost.Show(dialog3, "RootDialog", new DialogClosingEventHandler((s, t) => { }));

            if ((bool)result)
            {
                var typeStr = ((ComboBoxItemModel)dialog3.Model().Input3).Name;
                var type    = (CommunicationType)Enum.Parse(typeof(CommunicationType), typeStr);

                //仪器通讯类型错误则返回重新选择类型
                if (type == CommunicationType.None)
                {
                    await this.MsgBox("Please select the correct communication type.");

                    goto Input;
                }

                var instr = new InstrumentModel()
                {
                    Name               = dialog3.Model().Input1,
                    Description        = dialog3.Model().Input1,
                    CommnunicationType = type,
                    Config             = CommunicationBase.CreateCfg(type),
                    CommReference      = CommunicationBase.CreateCommunication(type)
                };
                //添加仪器至全局变量
                SystemSettings.InstrumentsList.Add(instr);
                //选中当前添加的仪器
                Instruments.SelectedItem = instr;
            }
        }
        private async void ItemCreate(object obj)
        {
            var dialog3 = new InputDialog3();

            dialog3.Model().WarningMsg1      = "Input not available!";
            dialog3.Model().Label3           = "Product Type";
            dialog3.Model().ItemsSource      = new ObservableCollection <ProductModel>(SystemSettings.ProductModels);
            dialog3.Model().Input1Validation = (
                s =>
            {
                return(!this.Model().Items.Any(t => t.Name.ToUpper() == s.ToUpper()));
            });
            var result = await DialogHost.Show(dialog3, "RootDialog", new DialogClosingEventHandler((s, t) => { }));

            //判断输入是否确认,并添加新增项至列表
            if ((bool)result)
            {
                var item = new ProcessListModel()
                {
                    GUID        = Guid.NewGuid().ToString("N").ToUpper(),
                    Creator     = SystemSettings.Operator.Name,
                    CreateTime  = DateTime.Now.ToString(),
                    Name        = dialog3.Model().Input1,
                    Description = dialog3.Model().Input2,
                    ProductGuid = ((ProductModel)dialog3.Model().Input3).Guid
                };
                var res = this.SaveData(item, null);
                if (res.Status)
                {
                    this.Model().AddProcessItem(item);
                }
                else
                {
                    await this.MsgBox(res.Message);
                }
            }
            this.LoadTableDefine(((ProductModel)dialog3.Model().Input3).Guid);
        }
        private async void ItemModify(object obj)
        {
            var dialog3 = new InputDialog3();

            dialog3.Model().WarningMsg1      = "Input not available!";
            dialog3.Model().Input1           = this.Model().SelectedItem.Name;
            dialog3.Model().Input2           = this.Model().SelectedItem.Description;
            dialog3.Model().Input3           = SystemSettings.ProductModels.First(t => t.Guid == this.Model().SelectedItem.ProductGuid);
            dialog3.Model().Label3           = "Product Type";
            dialog3.Model().ItemsSource      = new ObservableCollection <ProductModel>(SystemSettings.ProductModels);
            dialog3.Model().Input1Validation = (
                s =>
            {
                if (s == this.Model().SelectedItem.Name)
                {
                    return(true);
                }
                return(!this.Model().Items.Any(t => t.Name.ToUpper() == s.ToUpper()));
            });

            var result = await DialogHost.Show(dialog3, "RootDialog", new DialogClosingEventHandler((s, t) => { }));

            if ((bool)result)
            {
                var name        = dialog3.Model().Input1;
                var description = dialog3.Model().Input2;
                this.Model().SelectedItem.Name        = dialog3.Model().Input1;
                this.Model().SelectedItem.Description = dialog3.Model().Input2;
                this.Model().SelectedItem.ProductGuid = ((ProductModel)dialog3.Model().Input3).Guid;
                var res = this.UpdateData <ProcessListModel>(new[] { 1, 2, 5 }, new[] { name, description },
                                                             new[] { new ConditionExperssion <ProcessListModel>().Eq(0, this.Model().SelectedItem.GUID) });
                if (res.Status)
                {
                    this.Model().UpdateSelectedItem(name, description);
                    this.LoadTableDefine(this.Model().SelectedItem.ProductGuid);
                }
                else
                {
                    await this.MsgBox(res.Message);
                }
            }
        }