public IDataImporter Build()
        {
            var parserFactory = new DefaultCSVParserFactory();

            var testImporter = new SimpleCSVDataImporter(ResultLevel.ERROR, 4);

            var extensionValidationRule = new CSVFileNameExtensionMatchValidationRule(".dat", false);
            testImporter.AddValidationRule(extensionValidationRule);

            var stationNameMatchRule = new CellValueMatchCriteriaValidationRule(new CSVDataSourceLocation(0, 0), new DefaultCSVParserFactory(), typeof(string), new RegexCriteria("^TOA5$"));
            testImporter.AddValidationRule(stationNameMatchRule);


            var dateTimeFieldExtractConfiguration = new SimpleCSVExtractConfiguration(0,
                                                                                      "DateTime", 
                                                                                      parserFactory.GetCellParser(typeof(DateTime)), 
                                                                                      new SimpleValueAssigner(), 
                                                                                      typeof(DateTime));

            var waterLevelExtractConfiguration = new SimpleCSVExtractConfiguration(2,
                                                                                   "WaterLevel",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   new SimpleValueAssigner(),
                                                                                   typeof(double?));

            var waterTemperatureExtractConfiguration = new SimpleCSVExtractConfiguration(3,
                                                                                         "WaterTemperature",
                                                                                         parserFactory.GetCellParser(typeof(double?)),
                                                                                         new SimpleValueAssigner(),
                                                                                         typeof(double?));


            testImporter.AddExtractConfiguration(dateTimeFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(waterLevelExtractConfiguration);
            testImporter.AddExtractConfiguration(waterTemperatureExtractConfiguration);

            return testImporter;
        }
Beispiel #2
0
        public IDataImporter Build()
        {
            var parserFactory = new DefaultCSVParserFactory();

            var testImporter = new SimpleCSVDataImporter(ResultLevel.ERROR, 4);

            var extensionValidationRule = new CSVFileNameExtensionMatchValidationRule(".dat", false);

            testImporter.AddValidationRule(extensionValidationRule);

            var stationNameMatchRule = new CellValueMatchCriteriaValidationRule(new CSVDataSourceLocation(0, 0), new DefaultCSVParserFactory(), typeof(string), new RegexCriteria("^TOA5$"));

            testImporter.AddValidationRule(stationNameMatchRule);


            var dateTimeFieldExtractConfiguration = new SimpleCSVExtractConfiguration(0,
                                                                                      "DateTime",
                                                                                      parserFactory.GetCellParser(typeof(DateTime)),
                                                                                      new SimpleValueAssigner(),
                                                                                      typeof(DateTime));

            var waterLevelExtractConfiguration = new SimpleCSVExtractConfiguration(2,
                                                                                   "WaterLevel",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   new SimpleValueAssigner(),
                                                                                   typeof(double?));

            var waterTemperatureExtractConfiguration = new SimpleCSVExtractConfiguration(3,
                                                                                         "WaterTemperature",
                                                                                         parserFactory.GetCellParser(typeof(double?)),
                                                                                         new SimpleValueAssigner(),
                                                                                         typeof(double?));


            testImporter.AddExtractConfiguration(dateTimeFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(waterLevelExtractConfiguration);
            testImporter.AddExtractConfiguration(waterTemperatureExtractConfiguration);

            return(testImporter);
        }
Beispiel #3
0
        private IDataImporter BuildChemistryFileImporter()
        {
            var simpleValueAssigner = new SimpleValueAssigner();

            var parserFactory = new DefaultCSVParserFactory();

            var testImporter = new SimpleCSVDataImporter(ResultLevel.ERROR, 1);

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(0,
                                                                                   "SampleCode",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(1,
                                                                                   "ChemCode",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(2,
                                                                                   "OriginalChemName",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(3,
                                                                                   "Prefix",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(4,
                                                                                   "Result",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(double?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(5,
                                                                                   "ResultUnit",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(6,
                                                                                   "TotalOrFiltered",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(7,
                                                                                   "ResultType",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(8,
                                                                                   "MethodType",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(9,
                                                                                   "MethodName",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(10,
                                                                                   "ExtractionDate",
                                                                                   parserFactory.GetCellParser(typeof(DateTime?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(DateTime?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(11,
                                                                                   "AnalysedDate",
                                                                                   parserFactory.GetCellParser(typeof(DateTime?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(DateTime?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(12,
                                                                                   "EQL",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(double?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(13,
                                                                                   "EQLUnits",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(14,
                                                                                   "Comments",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(16,
                                                                                   "UCL",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(double?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(17,
                                                                                   "LCL",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(double?)));
            return(testImporter);
        }
        public static IDataImporter BuildSampleDataFileImporter()
        {
            var simpleValueAssigner = new SimpleValueAssigner();

            var parserFactory = new DefaultCSVParserFactory();

            var testImporter = new SimpleCSVDataImporter(ResultLevel.ERROR, 1);

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(0,
                                                                                   "SampleCode",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(1,
                                                                                   "SampledDateTime",
                                                                                   parserFactory.GetCellParser(typeof(DateTime?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(DateTime?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(2,
                                                                                   "FieldID",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(4,
                                                                                   "SampleDepth",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(double?)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(6,
                                                                                   "MatrixType",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(7,
                                                                                   "SampleType",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(8,
                                                                                   "ParentSample",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(10,
                                                                                   "SDG",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(11,
                                                                                   "LabName",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(12,
                                                                                   "LabSampleID",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(13,
                                                                                   "Comments",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));

            testImporter.AddExtractConfiguration(new SimpleCSVExtractConfiguration(14,
                                                                                   "LabReportNumber",
                                                                                   parserFactory.GetCellParser(typeof(string)),
                                                                                   simpleValueAssigner,
                                                                                   typeof(string)));
            return(testImporter);
        }