Esempio n. 1
0
        /// <summary>
        /// using the daily_calculation table preload hydrmet data referenced in the equations
        /// </summary>
        /// <param name="groupNames"></param>
        public void PreloadDailyHydrometData(string[] groupNames, DateTime t1, DateTime t2)
        {
            string sql = "select * from daily_calculation where group_name in ( '"
                         + System.String.Join("','", groupNames) + "' )";

            daily_calculationDataTable tbl = new daily_calculationDataTable();

            GetServer().FillTable(tbl, sql);

            var cbttPcodeList = new List <string>();

            // check for calculations (where cbtt_pcode) format is used.
            // example  JCK_AF
            foreach (var row in tbl)
            {
                string pattern = "(?<cbttPcode>[A-Z]{2,8}_[A-Z]{2,8})";
                var    mc      = Regex.Matches(row.equation, pattern);
                if (mc.Count > 0)
                {
                    foreach (Match item in mc)
                    {
                        cbttPcodeList.Add(item.Groups["cbttPcode"].Value.Replace("_", " "));
                    }
                }
            }

            cbttPcodeList = cbttPcodeList.Distinct().ToList();

            var cache = new HydrometDataCache();

            cache.Add(cbttPcodeList.ToArray(), t1, t2, HydrometHost.PN, TimeInterval.Daily);

            HydrometDailySeries.Cache = cache;
        }
Esempio n. 2
0
        private static void SetupCacheForShef(CsvFile csv, DateTime t1, DateTime t2)
        {
            Cache = new HydrometDataCache();

            // get list of pcodes and cbtts
            var query = from row in csv.AsEnumerable()
                        select row.Field <string>("cbtt")
                        + " " + row.Field <string>("pcode");

            Cache.Add(query.ToArray(), t1, t2, HydrometHost.PNLinux, TimeInterval.Daily);
        }
Esempio n. 3
0
        public static void PreloadInstantHydrometData(AlarmDataSet.alarm_definitionDataTable alarmdef)
        {
            // find all instant data, and largest hours_back, to make a single cache of data
            var cbttPcodes = (from row in alarmdef.AsEnumerable()
                         where row.database.ToLower() == "i"  // instant hydromet data
                         select row.cbtt.ToLower() + " " + row.pcode.ToLower()).Distinct().ToArray();

            if (cbttPcodes.Length == 0)
                return;

            // TO DO.  throw error if mixing quality and 'regular' data.
            //if (MixedQualityData(cbttPcodes))
            //{
            //    throw new ArgumentException("Error: quality and Mixing qual");
            //}

            var hours_back = (from row in alarmdef.AsEnumerable()
                              where row.database.ToLower() == "i"
                              select row.hours_back).Max();

            DateTime t1 = DateTime.Now.AddHours(-hours_back);
            DateTime t2 = DateTime.Now;
               // HydrometInstantSeries.KeepFlaggedData = true;

            var cache = new HydrometDataCache();
            cache.Add(String.Join(",", cbttPcodes).Split(','), t1, t2,
                HydrometHost.PN, Reclamation.TimeSeries.TimeInterval.Irregular, hours_back);

            HydrometInstantSeries.Cache = cache;
            Console.WriteLine(cbttPcodes);
        }
Esempio n. 4
0
        /// <summary>
        /// using the daily_calculation table preload hydrmet data referenced in the equations
        /// </summary>
        /// <param name="groupNames"></param>
        public void PreloadDailyHydrometData(string[] groupNames,DateTime t1,DateTime t2)
        {
            string sql = "select * from daily_calculation where group_name in ( '"
                          + System.String.Join("','",groupNames)+"' )";

            daily_calculationDataTable tbl = new daily_calculationDataTable();

            GetServer().FillTable(tbl, sql);

            var cbttPcodeList = new List<string>();

            // check for calculations (where cbtt_pcode) format is used.
            // example  JCK_AF
            foreach (var row in tbl)
            {
                string pattern = "(?<cbttPcode>[A-Z]{2,8}_[A-Z]{2,8})";
                var mc = Regex.Matches(row.equation, pattern);
                if (mc.Count > 0)
                {
                    foreach (Match item in mc)
                    {
                        cbttPcodeList.Add(item.Groups["cbttPcode"].Value.Replace("_", " "));
                    }
                }
            }

            cbttPcodeList = cbttPcodeList.Distinct().ToList();

            var cache = new HydrometDataCache();

            cache.Add(cbttPcodeList.ToArray(),t1,t2, HydrometHost.PN, TimeInterval.Daily);

            HydrometDailySeries.Cache = cache;
        }