private void linkLabelRead_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { HydrometHost svr = HydrometInfoUtility.HydrometServerFromPreferences(); int yr; if (!int.TryParse(textBoxWaterYear.Text, out yr)) { MessageBox.Show("Error parsing water year '" + textBoxWaterYear.Text + "'"); return; } if (comboBoxSiteList.SelectedIndex < 0) { return; } DateTime t1 = new DateTime(yr - 1, 10, 1); DateTime t2 = new DateTime(yr, 9, 30); int idx = this.comboBoxSiteList.SelectedIndex; string siteId = comboBoxSiteList.SelectedValue.ToString(); string query = siteId + " " + siteListTable.Rows[idx]["parameters"].ToString(); hydrometDataTable = HydrometDataUtility.ArchiveTable(svr, query, t1, t2); hydrometDataTable.AcceptChanges(); bool ctrl = (Control.ModifierKeys & Keys.Control) != 0; timeSeriesSpreadsheet1.Clear(); timeSeriesSpreadsheet1.SetDataTable(hydrometDataTable, Reclamation.TimeSeries.TimeInterval.Daily, ctrl); ReadSeries(); hydrometDataTable.RowChanged += hydrometDataTable_RowChanged; }
/// <summary> /// Imports instant data from Hydromet into TimeSeriesDatabase /// </summary> /// <param name="db"></param> private static void ImportHydrometMonthly(TimeSeriesDatabase db, DateTime t1, DateTime t2, string filter, string propertyFilter) { Console.WriteLine("ImportHydrometMonthly"); int block = 1; foreach (string query in GetBlockOfQueries(db, TimeInterval.Monthly, filter, propertyFilter)) { var table = HydrometDataUtility.MPollTable(HydrometHost.PN, query, t1, t2); Console.WriteLine("Block " + block + " has " + table.Rows.Count + " rows "); Console.WriteLine(query); SaveTableToSeries(db, table, TimeInterval.Monthly); block++; } Console.WriteLine("Finished importing monthly data"); }
/// <summary> /// Imports instant data from Hydromet into TimeSeriesDatabase /// </summary> /// <param name="db"></param> private static void ImportHydrometInstant(TimeSeriesDatabase db, DateTime t1, DateTime t2, string filter, string propertyFilter) { Console.WriteLine("ImportHydrometInstant"); int block = 1; foreach (string query in GetBlockOfQueries(db, TimeInterval.Irregular, filter, propertyFilter)) { var table = HydrometDataUtility.DayFilesTable(HydrometHost.PN, query, t1, t2, 0); Console.WriteLine("Block " + block + " has " + table.Rows.Count + " rows "); Console.WriteLine(query); SaveTableToSeries(db, table, TimeInterval.Irregular); block++; } Console.WriteLine("Finished importing 15-minute data"); }
/// <summary> /// Imports daily data from Hydromet into TimeSeriesDatabase /// </summary> /// <param name="db"></param> private static void ImportHydrometDaily(TimeSeriesDatabase db, DateTime t1, DateTime t2, string filter, string propertyFilter) { Performance perf = new Performance(); Console.WriteLine("ImportHydrometDaily"); int block = 1; foreach (string query in GetBlockOfQueries(db, TimeInterval.Daily, filter, propertyFilter)) { var table = HydrometDataUtility.ArchiveTable(HydrometHost.PN, query, t1, t2, 0); Console.WriteLine("Block " + block + " has " + table.Rows.Count + " rows "); Console.WriteLine(query); SaveTableToSeries(db, table, TimeInterval.Daily); block++; } perf.Report("Finished importing daily data"); // 15 seconds }
/// <summary> /// Imports instant data from Hydromet into TimeSeriesDatabase /// </summary> /// <param name="db"></param> private static void ImportHydrometInstant(TimeSeriesDatabase db, DateTime start, DateTime end, string filter, string propertyFilter) { // TO DO.. the outer loop of Date ranges (t,t3) could // be generated as a separate task. Console.WriteLine("ImportHydrometInstant"); TimeRange timeRange = new TimeRange(start, end); foreach (TimeRange item in timeRange.Split(30)) { int block = 1; foreach (string query in GetBlockOfQueries(db, TimeInterval.Irregular, filter, propertyFilter)) { Console.WriteLine("Reading " + item.StartDate + " to " + item.EndDate); var table = HydrometDataUtility.DayFilesTable(HydrometHost.PN, query, item.StartDate, item.EndDate, 0); Console.WriteLine("Block " + block + " has " + table.Rows.Count + " rows "); Console.WriteLine(query); SaveTableToSeries(db, table, TimeInterval.Irregular); block++; } } Console.WriteLine("Finished importing 15-minute data"); }
private void SaveToVMS(string fileName, Login login) { try { var un = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); Cursor = Cursors.WaitCursor; Application.DoEvents(); var results = HydrometEditsVMS.SaveDailyData(login.Username, login.Password, fileName, HydrometDataUtility.CreateRemoteFileName(login.Username, TimeInterval.Daily), false, false); TimeSeriesEditor.ShowVmsStatus(results); textBoxLastUpdate.Text = DateTime.Now.ToShortDateString() + " " + un; this.buttonSaveCsv_Click(this, EventArgs.Empty); } finally { Cursor = Cursors.Default; Logger.WriteLine("done.", "ui"); } }
private void buttonSave_Click(object sender, EventArgs e) { if (externalSeries == null || hmet == null) { MessageBox.Show("can not save. please try loading data"); return; } string cbtt = textBoxcbtt.Text.Trim().ToUpper(); string pcode = textBoxPcode.Text.Trim().ToUpper(); string fileName = FileUtility.GetTempFileName(".txt"); //"update" + DateTime.Now.ToString("yyyyMMMdd") + ".txt"; int counter = WriteArchivesImportFile(cbtt, pcode, fileName, GetSourceType()); labelStatus.Text = "Saved " + counter + " records to file " + fileName; Application.DoEvents(); if (counter == 0) { return; } Login login = new Login(); bool admin = Login.AdminPasswordIsValid(); if (!admin) { MessageBox.Show("You must enter the administrator password in the setup tab for this feature to work"); } if (admin && login.ShowDialog() == DialogResult.OK) { try { var un = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); Cursor = Cursors.WaitCursor; Application.DoEvents(); var results = HydrometEditsVMS.SaveDailyData(login.Username, login.Password, fileName, HydrometDataUtility.CreateRemoteFileName(login.Username, TimeInterval.Daily), false, false); TimeSeriesEditor.ShowVmsStatus(results); textBoxLastUpdate.Text = DateTime.Now.ToShortDateString() + " " + un; this.buttonSaveCsv_Click(this, EventArgs.Empty); } finally { Cursor = Cursors.Default; Logger.WriteLine("done.", "ui"); } } }