Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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();
                }
            }
        }
Beispiel #4
0
        private void ProcessFile(RouteOptions routing, FileSystemInfo fi)
        {
            var    fn  = fi.FullName;
            string dir = System.IO.Path.GetDirectoryName(fn);

            if (fi.CreationTime.AddSeconds(2) > DateTime.Now)
            {
                Console.WriteLine(" skipping file newer than 2 seconds ago " + fn + " " + fi.CreationTime);
                return;
            }
            string importTag = "import"; // used to make friendly export filename

            try
            {
                TextFile   tf = new TextFile(fi.FullName);
                SeriesList sl = new SeriesList();

                if (HydrometInstantSeries.IsValidDMS3(tf))
                {
                    importTag = "decodes";
                    sl        = Reclamation.TimeSeries.Hydromet.HydrometInstantSeries.HydrometDMS3DataToSeriesList(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
                {
                    Console.WriteLine("skipped Unknown File Format: " + fn);
                    return;
                }

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

                if (sl.Count > 0)
                {
                    m_importer.Import(sl, m_computeDependencies, m_computeDailyOnMidnight, importTag);
                    FileUtility.MoveToSubDirectory(Path.GetDirectoryName(fn), "attic", fn);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Error:" + ex.Message);
                Console.WriteLine("Error:  skipping file, will move to error subdirectory " + fn);
                FileUtility.MoveToSubDirectory(Path.GetDirectoryName(fn), "error", fn);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
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();
                }
            }
        }
Beispiel #7
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);

            }
        }
Beispiel #8
0
        private void ProcessFile(string fileName)
        {
            Logger.WriteLine("ProcessFile('" + 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 (CsvScadaFile.IsValidFile(tf))
                {
                    importTag = "scada";
                    m_db.GetSiteCatalog();
                    var scada = new CsvScadaFile(fileName);
                    sl = scada.ToSeries();
                }
                else if (XConnectTextFile.IsValidFile(tf))
                {
                    importTag = "xc";
                    var xc = new XConnectTextFile(tf);
                    sl = xc.ToSeries();
                }
                else if (HydrometMonthlySeries.IsValidFile(tf))
                {
                    sl = HydrometMonthlySeries.FileToSeriesList(tf);
                }
                else
                {
                    Logger.WriteLine("skipped Unknown File Format: " + fileName);
                    return;
                }

                if (m_importer == null)
                {
                    m_importer = new TimeSeriesImporter(m_db, 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);
            }
        }