Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new Usgs Series from the internet
        /// </summary>
        void createNewUsgsSeries_Click(object sender, System.EventArgs e)
        {
            ImportUsgs dlg = new ImportUsgs();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Series s = new Series();
                if (dlg.Daily)
                {
                    s = Usgs.UsgsDailyValueSeries.Read(dlg.SiteID, dlg.UsgsDailyParameter,
                                                       dlg.T1, dlg.T2);
                }
                if (dlg.Instantaneous)
                {
                    s = Usgs.UsgsInstantaneousSeries.Read(dlg.SiteID, dlg.T1, dlg.T2);
                }

                if (s.Count == 0)
                {
                    MessageBox.Show("Error: no USGS data pwas found");
                    return;
                }
                DB.AddSeries(s, tree1.SelectedID);
                tree1.RefreshTree();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Imports USGS data into an existing series
        /// </summary>
        private void importUSGS_Click(object sender, EventArgs e)
        {
            Series s       = DB.GetSeries(tree1.SelectedID);
            string site_no = "1350000";

            Usgs.UsgsDailyParameter par = Reclamation.TimeSeries.Usgs.UsgsDailyParameter.DailyMeanDischarge;

            if (s.Source.IndexOf("USGS") >= 0)
            {// help user by looking up previous USGS site_no
                site_no = Usgs.Utility.SiteNumberFromConnectionString(s.ConnectionString);
                par     = Usgs.Utility.DailyParameterFromString(s.Parameter);
            }
            // TODO: Daily    and instant need separate UI..
            // instant shoud not be specifing daily parameter (data type)
            DateTime t1 = new DateTime(1989, 10, 1);
            DateTime t2 = DateTime.Now.AddDays(-1);

            if (s.PeriodOfRecord.Count > 0)
            {
                t1 = s.PeriodOfRecord.T1;
                t2 = s.PeriodOfRecord.T2;
            }
            ImportUsgs dlg = new ImportUsgs(site_no, par, t1, t2);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (dlg.Daily)
                {
                    s = Usgs.UsgsDailyValueSeries.Read(dlg.SiteID, dlg.UsgsDailyParameter,
                                                       dlg.T1, dlg.T2);
                }
                if (dlg.Instantaneous)
                {
                    s = Usgs.UsgsInstantaneousSeries.Read(dlg.SiteID, dlg.T1, dlg.T2);
                }

                if (s.Count == 0)
                {
                    MessageBox.Show("Error: no USGS data pwas found");
                    return;
                }
                DB.UpdateTimeSeriesTable(tree1.SelectedID, s, true);
            }
            //Series s = dataDialog.Series;
            //if (s.Table.Rows.Count > 0)
            //{
            //    db.ImportTimeSeriesTable(s.Table, si, dataDialog.OverWrite);
            //}
        }