protected override void DoEndOfFile() { foreach (KeyValuePair <RecordIndex, int> item in _numberOfRecords) { _testResults.Add(new TestResult(ResultType.Success, AddmlLocation.FromRecordIndex(item.Key), string.Format(Messages.AnalyseCountRecordDefinitionOccurencesMessage, item.Value))); } _numberOfRecords.Clear(); }
protected override void DoEndOfFile() { foreach (KeyValuePair <RecordIndex, HashSet <PrimaryKeyValue> > entry in _nonUniqueprimaryKeyValuesPerRecord) { string text = string.Join(" ", entry.Value); _testResults.Add(new TestResult(ResultType.Error, AddmlLocation.FromRecordIndex(entry.Key), string.Format(Messages.ControlKeyMessage, text))); } _nonUniqueprimaryKeyValuesPerRecord.Clear(); _primaryKeyValuesPerRecord.Clear(); }
public FixedFormatReader(StreamReader streamReader, FixedFormatConfig fixedFormatConfig) { _streamReader = streamReader; _recordLength = fixedFormatConfig.RecordLength; _recordSeparator = fixedFormatConfig.RecordSparator; if (fixedFormatConfig.RecordDefinitions.Count < 1) { throw new ArgumentException( "fixedFormatDefinition.RecordDefinitions must contain at least 1 FixedFormatRecordDefinition"); } // If only one recordDefinition and recordIdentifier is not set, set it to empty string if (fixedFormatConfig.RecordDefinitions.Count == 1 && fixedFormatConfig.RecordDefinitions[0].RecordIdentifier == null) { fixedFormatConfig.RecordDefinitions[0].RecordIdentifier = ""; } _fieldLengthsPerRecordDefinition = new Dictionary <string, List <int> >(); foreach (FixedFormatRecordConfig f in fixedFormatConfig.RecordDefinitions) { List <int> fieldLengths = f.FieldLengths; _fieldLengthsPerRecordDefinition.Add(f.RecordIdentifier, fieldLengths); int sumOfFieldLengths = fieldLengths.Sum(); if (sumOfFieldLengths != _recordLength) { var message = string.Format(Resources.Messages.ExceptionFixedLengthSumIsNotCorrect, AddmlLocation.FromRecordIndex(f.RecordIndex), _recordLength, sumOfFieldLengths); throw new ArkadeException(message); } } _identifierStartPosition = fixedFormatConfig.IdentifierStartPosition; _identifierLength = fixedFormatConfig.IdentifierLength; if ((_identifierStartPosition.HasValue && !_identifierLength.HasValue) || (!_identifierStartPosition.HasValue && _identifierLength.HasValue)) { throw new ArgumentException("Both IdentifierStartPosition and IdentifierLength must be set"); } if ((fixedFormatConfig.RecordDefinitions.Count <= 1) && _identifierStartPosition.HasValue && _identifierLength.HasValue) { throw new ArgumentException( "fixedFormatDefinition.RecordDefinitions must contain more than 1 FixedFormatRecordDefinition if identifier values are set"); } }
protected override void DoEndOfFile() { foreach (KeyValuePair <RecordIndex, MinAndMax> entry in _minAndMaxRecordLength) { RecordIndex index = entry.Key; MinAndMax minAndMaxValue = entry.Value; string minLengthString = minAndMaxValue.GetMin()?.ToString() ?? "<no value>"; string maxLengthString = minAndMaxValue.GetMax()?.ToString() ?? "<no value>"; _testResults.Add(new TestResult(ResultType.Success, AddmlLocation.FromRecordIndex(index), string.Format(Messages.AnalyseFindExtremeRecordsMessage, maxLengthString, minLengthString))); } _minAndMaxRecordLength.Clear(); }
protected override void DoEndOfFile() { foreach (KeyValuePair <RecordIndex, bool> entry in _recordDefinitionsInUse) { RecordIndex index = entry.Key; bool isInUse = entry.Value; if (!isInUse) { _testResults.Add(new TestResult(ResultType.Error, AddmlLocation.FromRecordIndex(entry.Key), Messages.ControlNotUsedRecordDefMessage)); } } _recordDefinitionsInUse.Clear(); }
protected override void DoRun(Record record) { int?specifiedLength = record.Definition.RecordLength; if (!specifiedLength.HasValue) { return; } var actualLength = record.Value.Length; if (actualLength == specifiedLength) { return; } // actual record length is different than specified RecordIndex index = record.Definition.GetIndex(); _testResults.Add(new TestResult(ResultType.Error, AddmlLocation.FromRecordIndex(index), string.Format(Messages.ControlFixedLengthMessage, specifiedLength, actualLength))); }