/// <summary> /// 删除选择项 /// </summary> /// <param name="p"></param> private void ExecuteDeleteCmd(int p) { CheckWorkerState(); Debug.WriteLine("get abnornal id :" + p); Messenger.Default.Send("disEnableDeleteBtn", "BTVM2BTV"); bool isAbnormal = true; //修改列表显示 for (int i = 0; i < AbnormalVMs.Count; i++) { if (AbnormalVMs[i].AbnormalId == p) { Debug.WriteLine("get item in AbnormalVMs :" + p); if (AbnormalVMs[i].Abnormal.Type == 0 || AbnormalVMs[i].Abnormal.Type == 6) { isAbnormal = false; } DispatcherHelper.CheckBeginInvokeOnUI(() => { AbnormalVMs.RemoveAt(i); }); } } //修改右下角展示区显示 //重新计算现有的总异常 if (isAbnormal) { ErrorNum--; } //总数由abnormalVMs.Count直接生成切无需更改 //删除数据库 AbnormalService.GetService().DeleteItem(p); }
public void ExecuteAddCmd(int p) { CheckWorkerState(); Debug.WriteLine("get abnornal id :" + p); //修改数据库 int newId = AbnormalService.GetService().AddItem(p); bool isAbnormal = true; //修改列表显示 for (int i = 0; i < AbnormalVMs.Count; i++) { if (AbnormalVMs[i].AbnormalId == p) { Debug.WriteLine("get item in AbnormalVMs :" + p); if (AbnormalVMs[i].Abnormal.Type == 0 || AbnormalVMs[i].Abnormal.Type == 6) { isAbnormal = false; } AbnormalViewModel abnormalViewModel = AbnormalVMs[i]; MetaModel mm = new MetaModel(); AbnormalModel am = new AbnormalModel(); AbnormalViewModel avm = new AbnormalViewModel(); mm.Addr = abnormalViewModel.Meta.Addr; mm.PipeCode = abnormalViewModel.Meta.PipeCode; mm.PipeType = (int)abnormalViewModel.Meta.PipeType; mm.FramePath = abnormalViewModel.Meta.FramePath; if (!string.IsNullOrEmpty(abnormalViewModel.Meta.StartTime)) { mm.StartTime = abnormalViewModel.Meta.StartTime; } else { mm.StartTime = "未填写"; } am.VideoId = (int)abnormalViewModel.Abnormal.VideoId; am.Type = (int)abnormalViewModel.Abnormal.Type; am.Position = abnormalViewModel.Abnormal.Position; //新加的状态和任务编号 am.State = 1000; am.TaskId = (int)abnormalViewModel.Abnormal.TaskId; avm.AbnormalId = newId; avm.Meta = mm; avm.Abnormal = am; DispatcherHelper.CheckBeginInvokeOnUI(() => { AbnormalVMs.Insert(i, avm); }); break; } } //修改右下角展示区显示 //重新计算现有的总异常 if (isAbnormal) { ErrorNum++; } }