public FishboneNodeActionPlansVM(FishboneNodeVM defection, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentFishboneNode = defection; FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork); FishboneNodeDataService.ActionPlanAdded += OnActionPlanAdded; FishboneNodeDataService.ActionPlanRemoved += OnActionPlanRemoved; ActionPlanDataService = new ActionPlanDataService(UnitOfWork); var selectedVms = new ObservableCollection<ActionPlanFishboneVM>(); foreach (var productFishboneNode in FishboneNodeDataService.GetActionPlans(defection.Id)) { selectedVms.Add(new ActionPlanFishboneVM(productFishboneNode, Access, RelationDirection.Reverse)); } SelectedItems = new ListCollectionView(selectedVms); var allVms = new ObservableCollection<ActionPlanVM>(); foreach (var actionPlan in ActionPlanDataService.GetActives()) { allVms.Add(new ActionPlanVM(actionPlan, Access, ActionPlanDataService)); } AllItems = new ListCollectionView(allVms); IncludeCommand = new Command(Include, CanInclude); ExcludeCommand = new Command(Exclude, CanExclude); }
private void OnFishboneNodeRemoved(object sender, ModelRemovedEventArgs e) { foreach (ActionPlanFishboneVM item in SelectedItems) { if (item.Id == e.Id) { var model = FishboneNodeDataService.GetSingle(item.FishboneNodeId); var returnedVm = new FishboneNodeVM(model, Access, FishboneNodeDataService); AllItems.AddNewItem(returnedVm); AllItems.CommitNew(); SelectedItems.Remove(item); break; } } }
private void OnFishboneNodeAdded(object sender, ModelAddedEventArgs<FishboneNode> e) { var fishboneRootVm = new FishboneNodeVM(e.NewModel, Access, FishboneNodeDataService); CurrentNode.ChildNodes.Add(fishboneRootVm); if (CurrentNode == RootNode) { CurrentNode = fishboneRootVm; } }
private FishboneNodeType FindRootType(FishboneNodeVM node) { if (node.NodeType!= FishboneNodeType.None) { return node.NodeType; } while (node.Id != RootNode.Id) { node = (FishboneNodeVM) FindNode(RootNode, node.ParentId); if (node.NodeType != FishboneNodeType.None) { return node.NodeType; } } return FishboneNodeType.None; }
public RootFishbonesVM(RootVM root, ProductDefectionVM productDefection, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentRoot = root; RootDataService = new RootDataService(UnitOfWork); RootDataService.FishboneAdded += OnFishboneNodeAdded; RootDataService.FishboneRemoved += OnFishboneNodeRemoved; ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork); ProductDataService = new ProductDataService(UnitOfWork); DefectionDataService = new DefectionDataService(UnitOfWork); SwitchItemsCommand = new Command(SetProductDefections); ViewProductDefectionsCommand = new Command(ViewProductDefections); InitializeFishboneCommand = new Command(InitializeFishbone); FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork); RootNode = new FishboneNodeVM(Access, FishboneNodeDataService) { Title = string.Empty, Id = -1, ParentId = -2 }; var selectedVms = new ObservableCollection<FishboneNodeVM>(); foreach (var rootFishboneNode in RootDataService.GetFishboneNodes(root.Id)) { selectedVms.Add(new FishboneNodeVM(rootFishboneNode, Access, FishboneNodeDataService)); } SetProductDefections(); IncludeCommand = new Command(Include, CanInclude); ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree); foreach (FishboneNodeVM item in selectedVms) { if (item.ParentId == RootNode.Id) { RootNode.ChildNodes.Add(item); break; } } CurrentNode = RootNode; if (productDefection != null) { foreach (IInfoViewModel item in DefectionList) { if (item.Id == productDefection.DefectionId) { CurrentDefection = item; ViewProductDefections(null); break; } } if(AllItems!=null) foreach (ProductDefectionVM item in AllItems) { if (item.Id == productDefection.Id) { CurrentProductDefection = item; IsEnabled = false; break; } } } }