public void UpdateNotifications(Domain.Entity.Mill.Pipe pipeSavingState) { if (isProperlyCreated) { //* What can happen at Save Pipe: (NRO - non required inspection operation) //* - pipe is new and have no previous state (to update: NROs from current size type(new)) if (initialPipeSizeTypeId == Guid.Empty) { AddPipe(pipeSavingState.PipeTestResult); ProcessOperationForPipeSizeType(pipeSavingState.Type.Id); } //* - pipe is existing and pipe size type changed (to update: NROs from previous size type(remove), NROs from current size type(new)) else if (pipeSavingState.Type == null || initialPipeSizeTypeId != pipeSavingState.Type.Id) { RemoveAndUpdatePipe(initialSelectivePipeTestResult); AddAndUpdate(pipeSavingState.PipeTestResult); } //* - pipe is existing and operations were edited (to update: NROs from current size type(track changes)) else if (initialPipeSizeTypeId == pipeSavingState.Type.Id) { HashSet <TestResultInfo> savingState = new HashSet <TestResultInfo>(GetTestResultInfoListFromPipeTestResultList(pipeSavingState.PipeTestResult)); HashSet <TestResultInfo> initialState = new HashSet <TestResultInfo>(initialSelectiveInfo); savingState.ExceptWith(initialState); foreach (TestResultInfo result in savingState.Distinct()) { manager.cache.RemovePipeAmount(result.OperationId); manager.cache.AddPipeAmount(result.OperationId); UpdateNotification(result.OperationId); } } //* - pipe deactivation (to update: NRO (remove)) else if (!pipeSavingState.IsActive) { RemoveAndUpdatePipe(pipeSavingState.PipeTestResult); } } NotificationService.Instance.NotifyInterested(); SavePipeState(pipeSavingState); }
public IPipeNotifier CreateNotifier(Domain.Entity.Mill.Pipe pipeInitialState) { return(new EmptyNotifier()); }
public void UpdateNotifications(Domain.Entity.Mill.Pipe pipeSavingState) { }
public void UpdateNotifications(Domain.Entity.Mill.Pipe pipeSavingState) { if (isProperlyCreated) { //* What can happen at Save Pipe: (NRO - non required inspection operation) //* - pipe is new and have no previous state (to update: NROs from current size type(new)) if (initialPipeSizeTypeId == Guid.Empty) { ProcessPipeTestResults(pipeSavingState.PipeTestResult); ProcessNROForPipeSizeType(pipeSavingState.Type.Id, pipeSavingState, NROWhatToDo.Add); } //* - pipe is existing and pipe size type changed (to update: NROs from previous size type(remove), NROs from current size type(new)) else if (pipeSavingState.Type == null || initialPipeSizeTypeId != pipeSavingState.Type.Id) { //update notification for old size type IList <Guid> removeId = new List <Guid>(); foreach (TestResultInfo t in initialTestResultList) { removeId.Add(t.OperationId); } removeId.Distinct(); foreach (Guid id in removeId) { manager.UpdateUnits(id); } foreach (Guid id in manager.cache.EnumerateOperationsForSizeType(initialPipeSizeTypeId)) { manager.cache.RemoveUnits(id, ChooseUnit(manager.cache.GetMeasure(id))); UpdateNotification(id); } //update notification for new size type ProcessPipeTestResults(pipeSavingState.PipeTestResult); foreach (Guid id in manager.cache.EnumerateOperationsForSizeType(pipeSavingState.Type.Id)) { manager.cache.AddUnits(id, ChooseUnit(manager.cache.GetMeasure(id), pipeSavingState)); UpdateNotification(id); } } //* - pipe is existing and operations were edited (to update: NROs from current size type(track changes)) else if (initialPipeSizeTypeId == pipeSavingState.Type.Id) { HashSet <NROInfo> initialState = new HashSet <NROInfo>(); initialState.UnionWith(initialNROList); HashSet <NROInfo> savingState = new HashSet <NROInfo>(); savingState.UnionWith(GetNROInfoListFromPipeTestResultList(pipeSavingState.PipeTestResult)); var resultList = savingState.Except(initialState); foreach (NROInfo result in resultList.Distinct()) { if (result.IsCompleted) { manager.UpdateUnits(result.OperationId); } } ProcessNROForPipeSizeType(pipeSavingState.Type.Id, pipeSavingState, NROWhatToDo.EditOperations); } //* - pipe deactivation (to update: NRO (remove)) else if (!pipeSavingState.IsActive) { ProcessPipeTestResults(pipeSavingState.PipeTestResult); ProcessNROForPipeSizeType(pipeSavingState.Type.Id, pipeSavingState, NROWhatToDo.Remove); } } NotificationService.Instance.NotifyInterested(); SavePipeState(pipeSavingState); }