private void RaiseEventStartParsingFile() { _statusEventHandler.RaiseEventFileProcessingStarted( new FileProcessingStatusEventArgs(ArkadeConstants.ArkivstrukturXmlFileName, ArkadeConstants.ArkivstrukturXmlFileName)); }
public TestSuite RunTestsOnArchive(TestSession testSession) { AddmlDefinition addmlDefinition = testSession.AddmlDefinition; _addmlProcessRunner.Init(addmlDefinition); List <FlatFile> flatFiles = addmlDefinition.GetFlatFiles(); foreach (FlatFile file in flatFiles) { string testName = string.Format(Messages.RunningAddmlProcessesOnFile, file.GetName()); var recordIdx = 1; _statusEventHandler.RaiseEventFileProcessingStarted( new FileProcessingStatusEventArgs(testName, file.GetName()) ); _addmlProcessRunner.RunProcesses(file); IRecordEnumerator recordEnumerator = _flatFileReaderFactory.GetRecordEnumerator(testSession.Archive, file); int numberOfRecordsWithFieldDelimiterError = 0; while (recordEnumerator != null && recordEnumerator.MoveNext()) { try { _statusEventHandler.RaiseEventRecordProcessingStart(); Record record = recordEnumerator.Current; _addmlProcessRunner.RunProcesses(file, record); foreach (Field field in record.Fields) { _addmlProcessRunner.RunProcesses(file, field); } } catch (ArkadeAddmlDelimiterException exception) { numberOfRecordsWithFieldDelimiterError++; if (numberOfRecordsWithFieldDelimiterError <= MaxNumberOfSingleReportedFieldDelimiterErrors) { _testResultsFailedRecordsList.Add(new TestResult(ResultType.Error, new AddmlLocation(file.GetName(), exception.RecordName, ""), exception.Message + " Felttekst: " + exception.RecordData) ); _statusEventHandler.RaiseEventOperationMessage( $"{AddmlMessages.RecordLengthErrorTestName} i fil {file.GetName()}, post nummer {recordIdx}, feil nummer {numberOfRecordsWithFieldDelimiterError}", exception.Message + " Felttekst: " + exception.RecordData, OperationMessageStatus.Error ); } else { _statusEventHandler.RaiseEventOperationMessage( $"ADDML-poster med feil antall felt i filen {file.GetName()}", $"Totalt antall: {numberOfRecordsWithFieldDelimiterError}", OperationMessageStatus.Error ); } } finally { _statusEventHandler.RaiseEventRecordProcessingStopped(); } recordIdx++; } if (numberOfRecordsWithFieldDelimiterError > 0) { _testResultsFailedRecordsList.Add(new TestResult(ResultType.ErrorGroup, new Location(file.GetName()), $"Filens totale antall poster med feil antall felt: {numberOfRecordsWithFieldDelimiterError}", numberOfRecordsWithFieldDelimiterError) ); } _addmlProcessRunner.EndOfFile(file); _statusEventHandler.RaiseEventFileProcessingFinished( new FileProcessingStatusEventArgs(testName, file.GetName(), true) ); } TestSuite testSuite = _addmlProcessRunner.GetTestSuite(); testSuite.AddTestRun(new AH_02_ControlExtraOrMissingFiles(addmlDefinition, testSession.Archive).GetTestRun()); testSuite.AddTestRun(new AH_03_ControlRecordAndFieldDelimiters(_testResultsFailedRecordsList).GetTestRun()); return(testSuite); }