/// <summary> /// Add a requirement rows /// </summary> /// <param name="req">The <see cref="Requirement"/> to add</param> private void AddRequirementRow(Requirement req) { var row = new RequirementRowViewModel(req, this.Session, this); this.requirementCache[req] = row; this.requirementContainerGroupCache[req] = req.Group; if (req.Group == null) { this.ContainedRows.SortedInsert(row, ChildRowComparer); } else { IRowViewModelBase <Thing> groupRow; if (this.GroupCache.TryGetValue(req.Group, out groupRow)) { groupRow.ContainedRows.SortedInsert(row, ChildRowComparer); } else { logger.Error("The requirement group with iid {0} could not be found", req.Group.Iid); this.ContainedRows.SortedInsert(row, ChildRowComparer); } } var updateListener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(req) .Where(objectChange => objectChange.EventKind == EventKind.Updated && objectChange.ChangedThing.RevisionNumber > this.RevisionNumber) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => this.UpdateRequirementRow((Requirement)x.ChangedThing)); this.listenerCache[req] = updateListener; }
/// <summary> /// Add a requirement rows /// </summary> /// <param name="req">The <see cref="Requirement"/> to add</param> private void AddRequirementRow(Requirement req) { var row = new RequirementRowViewModel(req, this.Session, this); this.requirementCache[req] = row; this.requirementContainerGroupCache[req] = req.Group; if (req.Group == null) { this.ContainedRows.SortedInsert(row, ChildRowComparer); } else { IRowViewModelBase <Thing> groupRow; if (this.GroupCache.TryGetValue(req.Group, out groupRow)) { groupRow.ContainedRows.SortedInsert(row, ChildRowComparer); } else { logger.Error("The requirement group with iid {0} could not be found", req.Group.Iid); this.ContainedRows.SortedInsert(row, ChildRowComparer); } } var updateListener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(req) .Where(objectChange => objectChange.EventKind == EventKind.Updated && objectChange.ChangedThing.RevisionNumber > this.RevisionNumber) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => this.UpdateRequirementRow((Requirement)x.ChangedThing, false)); var orderPt = OrderHandlerService.GetOrderParameterType((EngineeringModel)this.Thing.TopContainer); if (orderPt != null) { var orderListener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(typeof(SimpleParameterValue)) .Where(objectChange => ((SimpleParameterValue)objectChange.ChangedThing).ParameterType == orderPt && this.Thing.Requirement.Any(r => r.ParameterValue.Contains(objectChange.ChangedThing))) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => this.UpdateRequirementRow((Requirement)x.ChangedThing.Container, true)); this.Disposables.Add(orderListener); } this.Disposables.Add(updateListener); this.listenerCache[req] = updateListener; }