public void insertshift(string cbtt, string pcode, DateTime date_measured, double?discharge, double?gage_height, double shift, string comments, DateTime date_entered) { string sql = "select * from shifts where 2=1"; shiftsDataTable tbl = new shiftsDataTable(); GetServer().FillTable(tbl, sql); var row = tbl.NewshiftsRow(); //due to our Sequence in the Dbase the id is 0 here but will add 1 to last id in dbase row.id = 0; row.cbtt = cbtt.ToUpper(); row.pcode = pcode.ToUpper(); row.date_measured = date_measured; if (discharge.HasValue) { row["discharge"] = discharge; } if (gage_height.HasValue) { row["stage"] = gage_height; } row.shift = shift; row.comments = comments; row.username = WindowsUtility.GetShortUserName().ToLower(); row.date_entered = date_entered; tbl.AddshiftsRow(row); GetServer().SaveTable(tbl); }
public static void RouteInstant(Series s, string cbtt, string pcode, RouteOptions route = RouteOptions.Both) { if (s.Count == 0) { return; } string fileName = ""; if (route == RouteOptions.Both || route == RouteOptions.Outgoing) { fileName = GetOutgoingFileName("instant", cbtt, pcode); HydrometInstantSeries.WriteToHydrometFile(s, cbtt, pcode, WindowsUtility.GetShortUserName(), fileName); } if (route == RouteOptions.Both || route == RouteOptions.Incoming) { fileName = GetIncommingFileName("instant", cbtt, pcode); HydrometInstantSeries.WriteToHydrometFile(s, cbtt, pcode, WindowsUtility.GetShortUserName(), fileName); } }
public ServerDatabaseDialog() { var fn = Path.Combine(FileUtility.GetExecutableDirectory(), "pisces_login.txt"); if (!File.Exists(fn)) { File.Create(fn); } credentials = new TextFileCredentials(fn); InitializeComponent(); //add dashes to start and end of clear items to roughly the //length of combobox string dashes = new string('-', 30); clearItems = dashes + " clear items " + dashes; LoadDatabaseList(); this.labelUserName.Text = WindowsUtility.GetShortUserName().ToLower(); }
/// <summary> /// Routes a list of Series as a group /// hydromet cbtt is copied from list[i].SiteName /// hydromet pcode is copied from list[i].Parameter /// </summary> /// <param name="list"></param> /// <param name="route"></param> /// <param name="name">identity used as part of filename </param> public static void RouteInstant(SeriesList list, string name, RouteOptions route = RouteOptions.Both) { if (route == RouteOptions.None) { return; } if (route == RouteOptions.Both || route == RouteOptions.Outgoing) { var tmpFileName = FileUtility.GetTempFileName(".txt"); File.Delete(tmpFileName); Console.WriteLine("temp file:" + tmpFileName); foreach (var s in list) { HydrometInstantSeries.WriteToHydrometFile(s, s.SiteID, s.Parameter, WindowsUtility.GetShortUserName(), tmpFileName, true); } Console.WriteLine("Moving: " + tmpFileName); var fileName = GetOutgoingFileName("instant", name, "all"); Console.WriteLine("To: " + fileName); File.Move(tmpFileName, fileName); } else { throw new NotImplementedException("incoming not supported."); } }
// Dayfile update file public static int WriteDayfileUpdateFile(DataTable tblNew, DataTable tblOld, string outputFilename, out string[] arcCommandList, out string[] modifiedParameters, out string[] modifiedCbtt, out DateRange range) { range = new DateRange(); DateTime t1 = DateTime.MaxValue; DateTime t2 = DateTime.MinValue; var arcCommands = new List <string>(); var modParameterList = new List <string>(); var modcbtt = new List <string>(); arcCommandList = arcCommands.ToArray(); modifiedCbtt = modcbtt.ToArray(); modifiedParameters = modParameterList.ToArray(); if (tblNew.Rows.Count != tblOld.Rows.Count) { MessageBox.Show("Error: the number of rows in the data has changed. no update file will be written"); return(0); } if (tblNew.Columns.Count != tblOld.Columns.Count) { MessageBox.Show("Error: the number of columns in the data has changed. no update file will be written"); return(0); } StreamWriter output = new StreamWriter(outputFilename); int modifiedCounter = 0; // first column is date, other columns are values output.WriteLine("yyyyMMMdd hhmm cbtt PC NewValue OldValue Flag user:"******"-00"; for (int r = 0; r < tblOld.Rows.Count; r++) { double valNew = HydrometDataUtility.ReadDouble(tblNew.Rows[r][c]); double valOld = HydrometDataUtility.ReadDouble(tblOld.Rows[r][c]); string newFlag = HydrometDataUtility.ReadFlag(tblNew.Rows[r][c + 1]); string oldFlag = HydrometDataUtility.ReadFlag(tblOld.Rows[r][c + 1]); if (valNew != valOld || newFlag != oldFlag) { // something changed. write to script. DateTime date = (DateTime)tblNew.Rows[r][0]; UpdateDateRange(ref t1, ref t2, modifiedCounter, date); UpdateDayfileDependencies(modcbtt, arcCommands, modParameterList, stationName, pcode, date); flagCode = FlagCode(newFlag); System.Globalization.NumberFormatInfo nf = new System.Globalization.NumberFormatInfo(); nf.NumberDecimalDigits = 2; string str = date.ToString("yyyyMMMdd HHmm").ToUpper() + " " + stationName.Trim().PadRight(8) + " " + pcode.Trim().PadRight(9) + " " + FortranFormat(valNew) + " " + FortranFormat(valOld) + " " + flagCode.ToString().PadRight(3); output.WriteLine(str); modifiedCounter++; } } } output.Close(); range = new DateRange(t1, t2); arcCommandList = arcCommands.ToArray(); modifiedParameters = modParameterList.ToArray(); modifiedCbtt = modcbtt.ToArray(); return(modifiedCounter); }