Example #1
0
        public void MALI_DailyAverageMidnight()
        {
            string fn = Path.Combine(TestData.DataPath, "MALI_2016_08_16_2315.dat");
            LoggerNetFile lf = new LoggerNetFile(fn);

            SeriesList list = lf.ToSeries();
            TimeRange tr;
            bool valid = TimeSeriesImporter.TryGetDailyTimeRange(list, out tr, new DateTime(2016,8,17,0,10,0));

            Assert.IsTrue(valid);
            Assert.AreEqual( DateTime.Parse("2016-08-16"),tr.StartDate);
            Assert.AreEqual( DateTime.Parse("2016-08-16").EndOfDay(),tr.EndDate);
        }
Example #2
0
        public void MALI_TodayFilesNoCalc()
        {
            string fn = CreateFutureFile();
            var contents = File.ReadAllText(fn);
            contents = contents.Replace("2016-08-16", DateTime.Now.ToString("yyyy-MM-dd"));

            File.WriteAllText(fn, contents);

            LoggerNetFile lf = new LoggerNetFile(fn);

            SeriesList list = lf.ToSeries();
            TimeRange tr;
            bool valid = TimeSeriesImporter.TryGetDailyTimeRange(list, out tr,DateTime.Now);

            Assert.IsFalse(valid);
        }
Example #3
0
        private void AddCampbellDataLogger(object sender, EventArgs e)
        {
            if (openFileDialogCr10x.ShowDialog() == DialogResult.OK)
            {
                TextFile tf = new TextFile(openFileDialogCr10x.FileName);
                if (LoggerNetFile.IsValidFile(tf))
                {
                    // import all columns in LoggerNet file.
                    LoggerNetFile ln = new LoggerNetFile(tf);

                    foreach (var item in ln.ToSeries())
                    {
                        DB.AddSeries(item);
                    }
                    //ln.ToSeries()
                }
                else
                {
                    ImportCr10x();
                }
            }
        }
Example #4
0
        private void ProcessFile(RouteOptions routing, string fileName)
        {
            string importTag = "import"; // used to make friendly export filename
            try
            {
                TextFile tf = new TextFile(fileName);
                SeriesList sl = new SeriesList();

                if (HydrometInstantSeries.IsValidDMS3(tf))
                {
                    importTag = "decodes";
                    sl = HydrometInstantSeries.HydrometDMS3DataToSeriesList(tf);
                }
                else if( HydrometDailySeries.IsValidArchiveFile(tf))
                {
                    importTag = "htools";
                    sl = HydrometDailySeries.HydrometDailyDataToSeriesList(tf);
                }
                else if (LoggerNetFile.IsValidFile(tf))
                {
                    LoggerNetFile lf = new LoggerNetFile(tf);

                    if (lf.IsValid && Array.IndexOf(validSites, lf.SiteName) >= 0)
                    {
                        importTag = lf.SiteName;
                        sl = lf.ToSeries(validPcodes);
                    }
                }
                //else if (DecodesRawFile.IsValidFile(tf))
                //{
                //    DecodesRawFile df = new DecodesRawFile(tf);
                //    importTag = "raw";
                //    sl = df.ToSeries();
                //}
                else
                {
                    Logger.WriteLine("skipped Unknown File Format: " + fileName);
                    return;
                }

                m_importer = new TimeSeriesImporter(m_db, routing,m_saveOption);
                Console.WriteLine("Found " + sl.Count + " series in " + fileName);
                foreach (var item in sl)
                {
                    Logger.WriteLine(item.Table.TableName);
                }

                if (sl.Count > 0)
                {
                    m_importer.Import(sl, m_computeDependencies, m_computeDailyDependencies,importTag);
                    FileUtility.MoveToSubDirectory(Path.GetDirectoryName(fileName), "attic", fileName);
                }

            }
            catch (Exception ex)
            {
                Logger.WriteLine("Error:" + ex.Message);
                Console.WriteLine("Error:  skipping file, will move to error subdirectory " + fileName);
                FileUtility.MoveToSubDirectory(Path.GetDirectoryName(fileName), "error", fileName);

            }
        }