Exemplo n.º 1
0
        /// <summary>
        /// Creates an new Manual measurement.
        /// Returns new MeasurementNumber for a Manaul Measurement.
        /// </summary>
        /// <param name="site_code"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public int NewMeasurement(string siteID, DateTime date, double flow = 0.0,
                                  double stage = 0.0, string quality = "", string party = "", string notes = "")
        {
            var sc = m_db.GetSeriesCatalog();

            var dt = new HydrographyDataSet.measurementDataTable();
            var mr = dt.NewmeasurementRow();

            mr.id            = m_db.Server.NextID("measurement", "id");
            mr.siteid        = siteID;
            mr.date_measured = date;
            mr.discharge     = flow;
            mr.stage         = stage;
            mr.quality       = quality;
            mr.party         = party;
            mr.notes         = notes;
            dt.Rows.Add(mr);
            m_db.Server.SaveTable(dt);


            sc.AddMeasurement(mr);

            sc.Save();

            return(mr.id);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads Yakima Excel sheets that contain flow measurements
        /// </summary>
        public static void FillMeasurementTable(string filename, HydrographyDataSet.measurementDataTable table)
        {
            var xls = new NpoiExcel(filename);

            var cbtt = GetCbtt(filename);


            var sheetName = GetSheetName(xls);

            if (sheetName == "")
            {
                Console.WriteLine("Did not find a sheet to read from " + Path.GetFileNameWithoutExtension(filename));
                return;
            }
            else
            {
                Logger.WriteLine("Reading from sheet " + sheetName);
            }

            var tbl = xls.ReadDataTable(sheetName, false, true);

            Logger.WriteLine(filename + " contains " + tbl.Rows.Count + " rows ");



            tbl.TableName = Path.GetFileNameWithoutExtension(filename);

            if (tbl.TableName == "")
            {
                tbl.TableName = cbtt;
            }

            FixColumnNames(tbl);

            // load data into measurement table
            if (tbl.Columns.Contains("stage") && tbl.Columns.Contains("discharge"))
            {
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    var newRow = table.NewmeasurementRow();

                    string   siteid        = cbtt;
                    DateTime?date_measured = TryGetDateTime(tbl.Rows[i], "date_measured");
                    double?  stage         = TryGetDouble(tbl.Rows[i], "stage");
                    double?  discharge     = TryGetDouble(tbl.Rows[i], "discharge");
                    string   quality       = TryGetString(tbl.Rows[i], "quality");
                    string   party         = TryGetString(tbl.Rows[i], "party");
                    string   notes         = TryGetString(tbl.Rows[i], "notes");

                    if (stage.HasValue && discharge.HasValue)
                    {
                        table.AddmeasurementRow(table.NextID(), siteid, date_measured.GetValueOrDefault(), stage.Value,
                                                discharge.GetValueOrDefault(), quality, party, notes);
                    }
                }
            }
        }
Exemplo n.º 3
0
 internal HydrographyDataSet.measurementDataTable GetMeasurements()
 {
     if (s_measurememnt == null)
     {
         s_measurememnt = new HydrographyDataSet.measurementDataTable();
         if (m_db.Server.TableExists("measurement"))
         {
             m_db.Server.FillTable(s_measurememnt, "select * from measurement order by siteid, date_measured");
         }
     }
     return(s_measurememnt);
 }