Esempio n. 1
0
 public SysDicItemSelectViewModel(IEnumerable <SysDicItemViewModel> sysDicItemVms, SysDicItemViewModel selected, Action <SysDicItemViewModel> onOk)
 {
     _sysDicItemVms    = sysDicItemVms;
     _selectedResult   = selected;
     OnOk              = onOk;
     this.ClearKeyword = new DelegateCommand(() => {
         this.Keyword = string.Empty;
     });
 }
Esempio n. 2
0
 private void Init()
 {
     VirtualRoot.On <SysDicItemAddedEvent>("添加了系统字典项后调整VM内存", LogEnum.DevConsole,
                                           action: (message) => {
         if (!_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Add(message.Source.GetId(), new SysDicItemViewModel(message.Source));
             OnPropertyChanged(nameof(List));
             OnPropertyChanged(nameof(Count));
             OnPropertyChanged(nameof(KernelBrandItems));
             SysDicViewModel sysDicVm;
             if (SysDicViewModels.Current.TryGetSysDicVm(message.Source.DicId, out sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     VirtualRoot.On <SysDicItemUpdatedEvent>("更新了系统字典项后调整VM内存", LogEnum.DevConsole,
                                             action: (message) => {
         if (_dicById.ContainsKey(message.Source.GetId()))
         {
             SysDicItemViewModel entity = _dicById[message.Source.GetId()];
             int sortNumber             = entity.SortNumber;
             entity.Update(message.Source);
             if (sortNumber != entity.SortNumber)
             {
                 SysDicViewModel sysDicVm;
                 if (SysDicViewModels.Current.TryGetSysDicVm(entity.DicId, out sysDicVm))
                 {
                     sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                     sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
                 }
             }
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     VirtualRoot.On <SysDicItemRemovedEvent>("删除了系统字典项后调整VM内存", LogEnum.DevConsole,
                                             action: (message) => {
         _dicById.Remove(message.Source.GetId());
         OnPropertyChanged(nameof(List));
         OnPropertyChanged(nameof(Count));
         OnPropertyChanged(nameof(KernelBrandItems));
         SysDicViewModel sysDicVm;
         if (SysDicViewModels.Current.TryGetSysDicVm(message.Source.DicId, out sysDicVm))
         {
             sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
             sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     foreach (var item in NTMinerRoot.Current.SysDicItemSet)
     {
         _dicById.Add(item.GetId(), new SysDicItemViewModel(item));
     }
 }
Esempio n. 3
0
 public SysDicItemViewModel(Guid id)
 {
     _id       = id;
     this.Edit = new DelegateCommand(() => {
         SysDicItemEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Code}系统字典项吗?", title: "确认", onYes: () => {
             Global.Execute(new RemoveSysDicItemCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         SysDicItemViewModel upOne = SysDicItemViewModels.Current.List.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdateSysDicItemCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateSysDicItemCommand(this));
             SysDicViewModel sysDicVm;
             if (SysDicViewModels.Current.TryGetSysDicVm(this.DicId, out sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         SysDicItemViewModel nextOne = SysDicItemViewModels.Current.List.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             Global.Execute(new UpdateSysDicItemCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateSysDicItemCommand(this));
             SysDicViewModel sysDicVm;
             if (SysDicViewModels.Current.TryGetSysDicVm(this.DicId, out sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
 }
Esempio n. 4
0
 public SysDicItemViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (NTMinerRoot.Instance.SysDicItemSet.ContainsKey(this.Id))
         {
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
         }
         else
         {
             VirtualRoot.Execute(new AddSysDicItemCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         VirtualRoot.Execute(new SysDicItemEditCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowDialog(message: $"您确定删除{this.Code}系统字典项吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveSysDicItemCommand(this.Id));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         SysDicItemViewModel upOne = AppContext.Instance.SysDicItemVms.List.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
             if (AppContext.Instance.SysDicVms.TryGetSysDicVm(this.DicId, out SysDicViewModel sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         SysDicItemViewModel nextOne = AppContext.Instance.SysDicItemVms.List.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
             if (AppContext.Instance.SysDicVms.TryGetSysDicVm(this.DicId, out SysDicViewModel sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
 }
 public SysDicItemViewModels()
 {
     foreach (var item in NTMinerRoot.Current.SysDicItemSet)
     {
         _dicById.Add(item.GetId(), new SysDicItemViewModel(item));
     }
     Global.Access <SysDicItemAddedEvent>(
         Guid.Parse("3527e754-9b63-4931-8b14-5b5cada26165"),
         "添加了系统字典项后调整VM内存",
         LogEnum.Log,
         action: (message) => {
         if (!_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Add(message.Source.GetId(), new SysDicItemViewModel(message.Source));
             OnPropertyChanged(nameof(List));
             OnPropertyChanged(nameof(Count));
             SysDicViewModel sysDicVm;
             if (SysDicViewModels.Current.TryGetSysDicVm(message.Source.DicId, out sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
     Global.Access <SysDicItemUpdatedEvent>(
         Guid.Parse("9146e461-dc8f-4aba-9254-6b81fe79389e"),
         "更新了系统字典项后调整VM内存",
         LogEnum.Log,
         action: (message) => {
         if (_dicById.ContainsKey(message.Source.GetId()))
         {
             SysDicItemViewModel entity = _dicById[message.Source.GetId()];
             int sortNumber             = entity.SortNumber;
             entity.Update(message.Source);
             if (sortNumber != entity.SortNumber)
             {
                 SysDicViewModel sysDicVm;
                 if (SysDicViewModels.Current.TryGetSysDicVm(entity.DicId, out sysDicVm))
                 {
                     sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                     sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
                 }
             }
         }
     });
     Global.Access <SysDicItemRemovedEvent>(
         Guid.Parse("767cf0bd-f645-43f6-984d-0bde96786837"),
         "删除了系统字典项后调整VM内存",
         LogEnum.Log,
         action: (message) => {
         _dicById.Remove(message.Source.GetId());
         OnPropertyChanged(nameof(List));
         OnPropertyChanged(nameof(Count));
         SysDicViewModel sysDicVm;
         if (SysDicViewModels.Current.TryGetSysDicVm(message.Source.DicId, out sysDicVm))
         {
             sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
             sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
         }
     });
 }
Esempio n. 6
0
 public SysDicItemViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (NTMinerContext.Instance.ServerContext.SysDicItemSet.ContainsKey(this.Id))
         {
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
         }
         else
         {
             VirtualRoot.Execute(new AddSysDicItemCommand(this));
         }
         VirtualRoot.Execute(new CloseWindowCommand(this.Id));
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         VirtualRoot.Execute(new EditSysDicItemCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowSoftDialog(new DialogWindowViewModel(message: $"您确定删除{this.Code}系统字典项吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveSysDicItemCommand(this.Id));
         }));
     });
     this.SortUp = new DelegateCommand(() => {
         SysDicItemViewModel upOne = AppRoot.SysDicItemVms.GetSysDicItemVmsByDicId(this.DicId).GetUpOne(this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
             if (AppRoot.SysDicVms.TryGetSysDicVm(this.DicId, out SysDicViewModel sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         SysDicItemViewModel nextOne = AppRoot.SysDicItemVms.GetSysDicItemVmsByDicId(this.DicId).GetNextOne(this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateSysDicItemCommand(this));
             if (AppRoot.SysDicVms.TryGetSysDicVm(this.DicId, out SysDicViewModel sysDicVm))
             {
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItems));
                 sysDicVm.OnPropertyChanged(nameof(sysDicVm.SysDicItemsSelect));
             }
         }
     });
 }
Esempio n. 7
0
 public bool TryGetValue(Guid id, out SysDicItemViewModel vm)
 {
     return(_dicById.TryGetValue(id, out vm));
 }