private void ExecuteDeleteModelCmd(ModelViewModel p)
        {
            if (p == null)
            {
                MessageBox.Show("还未选择要删除的对象");
                return;
            }
            int result = ModelService.GetService().DeleteModel(p);

            if (result > 0)
            {
                foreach (var item in Models)
                {
                    if (item.Id == p.Id)
                    {
                        models.Remove(item);
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("删除失败,该数据可能已被更改");
            }
        }
        private void ExecuteUpdateModelCmd(DataGridCellEditEndingEventArgs p)
        {
            ModelViewModel mvm     = p.Row.DataContext as ModelViewModel;
            string         oldName = mvm.ModelModel.Location + "\\" + mvm.ModelModel.ModelName;

            mvm.ModelModel.ModelName = (p.EditingElement as TextBox).Text;
            string newName = (p.EditingElement as TextBox).Text;
            string args    = "\"" + oldName + " " + newName + "\"";

            //调用PYTHON修改文件夹
            var t = new Task(() =>
            {
                Process process = CmdHelper.RunProcess(@"Util/changeModelName.exe", args);
                process.Start();
                Console.WriteLine(args);
                Console.WriteLine("wait for exit");
                process.WaitForExit();
                Console.WriteLine("exited");
                process.Close();
                Console.WriteLine("closed");
            });

            t.Start();
            t.ContinueWith((task) =>
            {
                if (task.IsCompleted)
                {
                    mvm.ModelModel.UpdateTime = DateTime.Now.ToString();
                    int result = ModelService.GetService().UpdateModel(mvm);
                }
                else if (task.IsCanceled)
                {
                    MessageBox.Show("已取消");
                }
                else if (task.IsFaulted)
                {
                    MessageBox.Show("任务失败");
                }
            });
        }
 private bool CanExecuteDeleteModelCmd(ModelViewModel arg)
 {
     return(arg != null);
 }