示例#1
0
        public void TestParseXmlSeries(String fileName)
        {
            WaterOneFlow10Parser parser = new WaterOneFlow10Parser();
            string basePath             = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles");
            string xmlFileName          = Path.Combine(basePath, fileName);

            IList <Series> seriesList = parser.ParseGetValues(xmlFileName);
        }
示例#2
0
        public void TestParseDataSeries(String samplesPath)
        {
            IWaterOneFlowParser parser = new WaterOneFlow10Parser();
            string xmlDirectory        = GetXmlTempDirectory();

            // we want a clean set of test cases
            CleanAndCopySamplesFiles(xmlDirectory, samplesPath);

            string[] fileNames = Directory.GetFiles(xmlDirectory);

            foreach (string fileName in fileNames)
            {
                IList <Series> seriesList = parser.ParseGetValues(fileName);
                Assert.Greater(seriesList.Count, 0);
                Assert.Greater(seriesList[0].ValueCount, 0,
                               "Error in filename '" + fileName + "' the number of values in the seriesList must be greater than zero.");
            }
        }
示例#3
0
        public void TestSaveMultipleSeries()
        {
            string tempDir = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "hydrodesktop");

            string[] files = System.IO.Directory.GetFiles(tempDir);
            Array.Sort(files);

            IWaterOneFlowParser parser = new WaterOneFlow10Parser();

            Theme theme1 = new Theme("SaveValuesTest1", "Test on Save Values");

            ActualDataManager manager = HydroDesktop.Database.Config.ActualDataManager();

            foreach (string fileName in files)
            {
                IList <Series> seriesList = parser.ParseGetValues(fileName);
                Series         series1    = seriesList[0];

                manager.SaveSeries(series1, theme1, OverwriteOptions.Copy);
            }
        }
示例#4
0
        /// <summary>
        /// Converts the xml file to a list of data series objects.
        /// In most cases the list will only contain one object.
        /// </summary>
        /// <param name="xmlFile">The name of the xml file</param>
        /// <returns>the data series list or null in case of error</returns>
        public IList <Series> DataSeriesFromXml(string xmlFile)
        {
            IList <Series> seriesList = null;

            try
            {
                WaterOneFlow10Parser parser = new WaterOneFlow10Parser();
                seriesList = parser.ParseGetValues(xmlFile);
                if (seriesList == null)
                {
                    MessageBox.Show("There was an error parsing the WaterML document. " +
                                    "Please check if the document is in correct WaterML 1.0 format.");
                    return(null);
                }
            }
            catch
            {
                //in case of error - return an empty list
            }
            return(seriesList);
        }