Exemple #1
0
        public ParseFileResult ParseFile(Stream fileStream, IFieldDataResultsAppender appender, ILog logger)
        {
            var xmlRoot = SectionBySectionSerializer.DeserializeNoThrow(fileStream, logger);

            if (xmlRoot == null)
            {
                return(ParseFileResult.CannotParse());
            }

            var stationNo = xmlRoot.Summary?.WinRiver_II_Section_by_Section_Summary?.Station_No;

            if (string.IsNullOrWhiteSpace(stationNo))
            {
                logger.Error("File can be parsed but there is no Station_No specified.");
                return(ParseFileResult.SuccessfullyParsedButDataInvalid("Missing Station_No."));
            }
            try
            {
                var trimmedLocationIdentifier = stationNo.Trim();
                var location = appender.GetLocationByIdentifier(trimmedLocationIdentifier);

                return(ParseXmlRootNoThrow(location, xmlRoot, appender, logger));
            }
            catch (Exception exception)
            {
                logger.Error($"Cannot find location with identifier {stationNo}.");
                return(ParseFileResult.CannotParse(exception));
            }
        }
Exemple #2
0
        public ParseFileResult ParseFile(Stream fileStream, LocationInfo targetLocation,
                                         IFieldDataResultsAppender appender, ILog logger)
        {
            var xmlRoot = SectionBySectionSerializer.DeserializeNoThrow(fileStream, logger);

            return(xmlRoot == null
                ? ParseFileResult.CannotParse()
                : ParseXmlRootNoThrow(targetLocation, xmlRoot, appender, logger));
        }