Exemplo n.º 1
0
        public static TimeSeriesDatabaseDataSet.RatingTableDataTable GetRatingTable(string cbtt, string pcode, string ratingName)
        {
            string url = "";


            if (HydrometInfoUtility.HydrometServerFromPreferences() == HydrometHost.GreatPlains)
            {
                //url = "http://www.usbr.gov/gp-bin/expandrtf.pl?site=adatunco&pcode=q&form=col";
                url = "http://www.usbr.gov/gp-bin/expandrtf.pl?site=pali&pcode=q&form=col";
                url = url.Replace("site=pali", "site=" + cbtt.Trim());
                url = url.Replace("pcode=q", "pcode=" + pcode.Trim());
            }
            else
            {
                //url = "http://www.usbr.gov/pn-bin/expandrtf.pl?site=pali&pcode=q&form=col";
                url = "http://lrgs1.pn.usbr.gov/rating_tables/" + ratingName + ".csv";
                if (!NetworkUtility.Intranet)
                {
                    url = "http://www.usbr.gov/pn/hydromet/configurationdata/rating_tables/" + ratingName + ".csv";
                }

                var tmp = FileUtility.GetTempFileName(".csv");
                Web.GetFile(url, tmp);

                var rt = new TimeSeriesDatabaseDataSet.RatingTableDataTable();
                rt.ReadFile(tmp);
                return(rt);
            }
            // yakima ?
            //http://www.usbr.gov/pn-bin/yak/expandrtf.pl?site=kee&pcode=af&form=col


            return(ReadFromWeb(cbtt, pcode, url));
        }
Exemplo n.º 2
0
        private static void DownloadRatingsFromPnhyd0()
        {
            TextFile tf = new TextFile(@"c:\temp\rtf_list.dat");

            for (int i = 0; i < tf.Length; i++)
            {
                if (tf[i].Length < 14)
                {
                    continue;
                }
                var cbtt  = tf[i].Substring(6, 8).ToLower().Trim();
                var pcode = tf[i].Substring(14, 7).ToLower().Trim();

                if (pcode.Trim() == "")
                {
                    continue;
                }


                string path = @"C:\temp\rating_tables";

                var fn  = Path.Combine(path, cbtt + "_" + pcode + ".csv");
                var fn2 = Path.Combine(path, cbtt + ".csv");

                if (File.Exists(fn) || File.Exists(fn2))
                {
                    System.Console.WriteLine("File exists <skipping> :" + cbtt + " " + pcode);
                    continue;
                }

                //var rt = HydrometInfoUtility.GetRatingTable(cbtt, pcode);
                string url = "http://www.usbr.gov/pn-bin/expandrtf.pl?site=pali&pcode=q&form=csv";
                url = "http://hydromet.pn.usbr.gov/~dataaccess/expandrtf.exe?site=pali&pcode=q&shift&form=csv";

                url = url.Replace("site=pali", "site=" + cbtt.Trim());
                url = url.Replace("pcode=q", "pcode=" + pcode.Trim());

                string[] data = Web.GetPage(url);


                TextFile tf2 = new TextFile(data);

                if (pcode == "q")
                {
                    fn = fn2; // short filename
                }

                System.Console.WriteLine("Saving: " + fn);
                tf2.SaveAs(Path.Combine(path, fn));

                // test

                var rt = new TimeSeriesDatabaseDataSet.RatingTableDataTable();
                rt.ReadFile(fn);
            }
        }
Exemplo n.º 3
0
        public static TimeSeriesDatabaseDataSet.RatingTableDataTable GetRatingTable(string cbtt, string pcode, string ratingName)
        {
            string url = "";

            var server = HydrometInfoUtility.HydrometServerFromPreferences();

            if (server == HydrometHost.GreatPlains)
            {
                url = "https://www.usbr.gov/gp-bin/expandrtf.pl?site=pali&pcode=q&form=col";
                url = url.Replace("site=pali", "site=" + cbtt.Trim());
                url = url.Replace("pcode=q", "pcode=" + pcode.Trim());
            }
            else if (server == HydrometHost.PN || server == HydrometHost.PNLinux)
            {
                url = ConfigurationManager.AppSettings["RatingTablePath"] + ratingName + ".csv";

                if (!NetworkUtility.Intranet)
                {
                    url = "https://www.usbr.gov/pn/hydromet/configurationdata/rating_tables/" + ratingName + ".csv";
                }

                var tmp = FileUtility.GetTempFileName(".csv");
                Web.GetFile(url, tmp);

                var rt = new TimeSeriesDatabaseDataSet.RatingTableDataTable();
                rt.ReadFile(tmp);
                return(rt);
            }
            else if (server == HydrometHost.Yakima)
            {            // yakima ?
                url = "https://www.usbr.gov/pn-bin/yak/expandrtf.pl?site=kee&pcode=af&form=col";
                url = url.Replace("site=kee", "site=" + cbtt.Trim());
                url = url.Replace("pcode=af", "pcode=" + pcode.Trim());
            }

            string[] data = Web.GetPage(url);
            TextFile tf   = new TextFile(data);

            return(ParseRatingTableData(tf, cbtt, pcode));
        }
Exemplo n.º 4
0
        public static TimeSeriesDatabaseDataSet.RatingTableDataTable GetRatingTable(string cbtt, string pcode,string ratingName)
        {
            string url = "";

            if (HydrometInfoUtility.HydrometServerFromPreferences() == HydrometHost.GreatPlains)
            {
                url = "https://www.usbr.gov/gp-bin/expandrtf.pl?site=pali&pcode=q&form=col";
                url = url.Replace("site=pali", "site=" + cbtt.Trim());
                url = url.Replace("pcode=q", "pcode=" + pcode.Trim());
            }
            else if( HydrometInfoUtility.HydrometServerFromPreferences() == HydrometHost.PN)
            {
                url = "http://lrgs1.pn.usbr.gov/rating_tables/"+ratingName+".csv";
                if( !NetworkUtility.Intranet)
                    url = "https://www.usbr.gov/pn/hydromet/configurationdata/rating_tables/" + ratingName + ".csv";

                var tmp = FileUtility.GetTempFileName(".csv");
                Web.GetFile(url, tmp);

                var rt = new TimeSeriesDatabaseDataSet.RatingTableDataTable();
                rt.ReadFile(tmp);
                return rt;
            }
            else if (HydrometInfoUtility.HydrometServerFromPreferences() == HydrometHost.Yakima)
            {            // yakima ?
                url = "https://www.usbr.gov/pn-bin/yak/expandrtf.pl?site=kee&pcode=af&form=col";
                url = url.Replace("site=kee", "site=" + cbtt.Trim());
                url = url.Replace("pcode=af", "pcode=" + pcode.Trim());
            }

            string[] data = Web.GetPage(url);
            TextFile tf = new TextFile(data);
            return ParseRatingTableData(tf, cbtt, pcode);
        }