private Dictionary <int, uint> GetMeterValues(SpatialRecord spatialRecord, List <WorkingData> meters, Dictionary <WorkingData, int> metersByIsoIds) { var dlvsToWrite = new Dictionary <int, uint>(); var metersWithValues = meters.Where(x => spatialRecord.GetMeterValue(x) != null); var dlvOrders = metersWithValues.Select(m => metersByIsoIds[m]).Distinct(); foreach (var order in dlvOrders) { var dlvMeters = meters.Where(m => metersByIsoIds[m] == order).ToList(); var numericMeter = dlvMeters[0] as NumericWorkingData; UInt32?value = null; if (numericMeter != null && spatialRecord.GetMeterValue(numericMeter) != null) { value = _numericValueMapper.Map(numericMeter, spatialRecord); } var isoEnumerateMeter = dlvMeters[0] as ISOEnumeratedMeter; if (isoEnumerateMeter != null && spatialRecord.GetMeterValue(isoEnumerateMeter) != null) { value = _enumeratedValueMapper.Map(isoEnumerateMeter, dlvMeters, spatialRecord); } if (value == null) { continue; } if (_previousDlvs.ContainsKey(order) && _previousDlvs[order] != value) { _previousDlvs[order] = value.Value; dlvsToWrite.Add(order, value.Value); } else if (!_previousDlvs.ContainsKey(order)) { _previousDlvs.Add(order, value.Value); dlvsToWrite.Add(order, value.Value); } } return(dlvsToWrite); }
private Dictionary <int, uint> GetMeterValues(SpatialRecord spatialRecord, List <WorkingData> workingDatas) { var dlvsToWrite = new Dictionary <int, uint>(); var workingDatasWithValues = workingDatas.Where(x => spatialRecord.GetMeterValue(x) != null); foreach (WorkingData workingData in workingDatasWithValues) { int order = _dlvOrdersByWorkingDataID[workingData.Id.ReferenceId]; UInt32?value = null; if (workingData is NumericWorkingData) { NumericWorkingData numericMeter = workingData as NumericWorkingData; if (numericMeter != null && spatialRecord.GetMeterValue(numericMeter) != null) { value = _numericValueMapper.Map(numericMeter, spatialRecord); } } else if (workingData is EnumeratedWorkingData) { EnumeratedWorkingData enumeratedMeter = workingData as EnumeratedWorkingData; if (enumeratedMeter != null && spatialRecord.GetMeterValue(enumeratedMeter) != null) { value = _enumeratedValueMapper.Map(enumeratedMeter, new List <WorkingData>() { workingData }, spatialRecord); } } if (value == null) { continue; } if (_previousDlvs.ContainsKey(order) && _previousDlvs[order] != value) { _previousDlvs[order] = value.Value; dlvsToWrite.Add(order, value.Value); } else if (!_previousDlvs.ContainsKey(order)) { _previousDlvs.Add(order, value.Value); dlvsToWrite.Add(order, value.Value); } } return(dlvsToWrite); }