Esempio n. 1
0
        private DischargeActivity CreateDischargeActivity(FieldVisitInfo visit)
        {
            var dischargeActivityFactory = new DischargeActivityFactory(UnitSystem)
            {
                DefaultParty = DataFile.Properties.Operator
            };

            var dischargeActivity = dischargeActivityFactory.CreateDischargeActivity(
                new DateTimeInterval(visit.StartDate, visit.EndDate), UnitConverter.ConvertDischarge(DataFile.Calculations.Discharge));

            dischargeActivity.Comments = DataFile.Properties.Comment;
            dischargeActivity.ActiveUncertaintyType = UncertaintyType.Quantitative;

            _resultsAppender.GetPluginConfigurations().TryGetValue("IsoUncertaintyScalar", out var scalarText);

            if (!double.TryParse(scalarText, out var scalar))
            {
                scalar = 1.0;
            }

            dischargeActivity.QuantitativeUncertainty = scalar * DataFile.Calculations.UncertaintyIso.Overall * 100;

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (scalar != 1.0)
            {
                dischargeActivity.QualityAssuranceComments = $"Scaled ISO uncertainty by {scalar}";
            }

            return(dischargeActivity);
        }
        public ParseFileResult ParseFile(Stream fileStream, LocationInfo targetLocation,
                                         IFieldDataResultsAppender appender, ILog logger)
        {
            var parser = new AquaCalcCsvParser(fileStream)
            {
                Settings = appender.GetPluginConfigurations()
            };

            if (!parser.CanParse())
            {
                return(ParseFileResult.CannotParse());
            }

            var parsedData = parser.Parse();

            if (targetLocation == null)
            {
                targetLocation = appender.GetLocationByIdentifier(parsedData.GageId);
            }

            var visitDetails = new VisitMapper(parsedData).GetVisitDetails(targetLocation.UtcOffset);

            logger.Info($"Got visit details: '{visitDetails.StartDate:s}@{targetLocation.LocationIdentifier}'");

            var visitInfo = appender.AddFieldVisit(targetLocation, visitDetails);

            AppendActivity(appender, parsedData, visitInfo, logger);

            return(ParseFileResult.SuccessfullyParsedAndDataValid());
        }
Esempio n. 3
0
        private Config LoadConfig()
        {
            var settings = _appender.GetPluginConfigurations();

            if (settings == null || !settings.TryGetValue(nameof(Config), out var jsonText) || string.IsNullOrWhiteSpace(jsonText))
            {
                jsonText = GetDefaultConfiguration();
            }

            return(jsonText.FromJson <Config>());
        }
 public ConfigLoader(IFieldDataResultsAppender appender)
 {
     Settings = appender.GetPluginConfigurations();
 }
 public Dictionary <string, string> GetPluginConfigurations()
 {
     return(ActualAppender.GetPluginConfigurations());
 }