CopyDetector(int ID, bool increaseChannel) //still need to add this detector to the collection of its associated Approach { var detectorRepository = DetectorRepositoryFactory.Create(); var detectorToCopy = detectorRepository.GetDetectorByID(ID); var newGD = new Detector(); var dtr = DetectionTypeRepositoryFactory.Create(); newGD.AllDetectionTypes = dtr.GetAllDetectionTypesNoBasic(); newGD.DateAdded = DateTime.Now; newGD.DetectionTypeIDs = new List <int>(); newGD.DetectionTypes = new List <DetectionType>(); foreach (var dt in detectorToCopy.DetectionTypes) { newGD.DetectionTypeIDs.Add(dt.DetectionTypeID); } newGD.DistanceFromStopBar = detectorToCopy.DistanceFromStopBar; newGD.LaneNumber = detectorToCopy.LaneNumber; newGD.MinSpeedFilter = detectorToCopy.MinSpeedFilter; newGD.MovementTypeID = detectorToCopy.MovementTypeID; newGD.LaneTypeID = detectorToCopy.LaneTypeID; newGD.DecisionPoint = detectorToCopy.DecisionPoint; newGD.MovementDelay = detectorToCopy.MovementDelay; newGD.DetectionHardwareID = detectorToCopy.DetectionHardwareID; newGD.MovementDelay = detectorToCopy.MovementDelay; newGD.DetectorComments = new List <DetectorComment>(); if (increaseChannel) { newGD.DetChannel = detectorRepository.GetMaximumDetectorChannel(detectorToCopy.Approach.VersionID) + 1; } else //when copying signals, signalID changes, and DetChannel should be kept the same. { newGD.DetChannel = detectorToCopy.DetChannel; } if (newGD.DetChannel < 10) { newGD.DetectorID = detectorToCopy.Approach.SignalID + "0" + newGD.DetChannel; } else { newGD.DetectorID = detectorToCopy.Approach.SignalID + newGD.DetChannel; } return(newGD); }
public ApproachVolume(List <Models.Approach> primaryDirectionApproaches, List <Models.Approach> opposingDirectionApproaches, ApproachVolumeOptions approachVolumeOptions, DirectionType primaryDirection, DirectionType opposingDirection, int detectionTypeId) { var detectionTypeRepository = DetectionTypeRepositoryFactory.Create(); DetectionType = detectionTypeRepository.GetDetectionTypeByDetectionTypeID(detectionTypeId); PrimaryDirection = primaryDirection; MetricInfo.Direction1 = primaryDirection.Description; OpposingDirection = opposingDirection; MetricInfo.Direction2 = opposingDirection.Description; _approachVolumeOptions = approachVolumeOptions; _primaryDirectionApproaches = primaryDirectionApproaches; _opposingDirectionApproaches = opposingDirectionApproaches; SetVolume(); SetVolumeMetrics(); }