private async Task <List <MOND> > createMOND(ge_log_file log_file, int page_size, int page, string round_ref, DateTime?fromDT, DateTime?toDT, string ge_source = "ge_flow", Boolean addWLEV = true) { // Find borehole in point table of gint database string holeId = log_file.getBoreHoleId(); if (holeId == "") { return(null); // BadRequest ($"Borehole ref not provided"); } POINT pt = await GetPointByHoleId(holeId); if (pt == null) { return(null);// return BadRequest ($"Borehole ref {holeId} not found in {project.name}"); } List <MONG> mgs = await GetParentsByHoleId(holeId); // Find monitoring point in mong table of gint database float probe_depth = log_file.getProbeDepth(); if (probe_depth == 0) { return(null); // return BadRequest ($"No probe depth provided for borehole ref {holeId} not found in {project.name}"); } MONG mg = null; string formatMATCH = "{0:00.0}"; if (mgs.Count == 1) { mg = mgs.FirstOrDefault(); } else { foreach (MONG m in mgs) { if (m.MONG_DIS != null) { if (String.Format(formatMATCH, m.MONG_DIS.Value) == String.Format(formatMATCH, probe_depth)) { mg = m; break; } } } } if (mg == null) { return(null); // return BadRequest ($"No installations in borehole ref {holeId} have a probe depth of {probe_depth} in {project.name}"); } // Add all readings to new items in List<MOND> List <MOND> MOND = new List <MOND>(); string device_name = log_file.getDeviceName(); float?gl = null; if (pt.Elevation != null) { gl = Convert.ToSingle(pt.Elevation.Value); } if (gl == null && pt.LOCA_GL != null) { gl = Convert.ToSingle(pt.LOCA_GL.Value); } // int round_no = getInt32(round_ref); string mond_rem_suffix = ""; string mond_ref = ""; if (ge_source == "ge_flow") { mond_rem_suffix = " flow meter reading"; } if (ge_source == "ge_logger") { mond_rem_suffix = " datalogger reading"; } List <ge_log_reading> readings2 = log_file.getIncludeReadingsPage(fromDT, toDT, page_size, page); foreach (ge_log_reading reading in readings2) { foreach (value_header vh in log_file.field_headers) { if (ge_source == "ge_flow") { mond_ref = String.Format("Round {0} Seconds {1:00}", round_ref, reading.Duration); } if (vh.id == "WDEPTH" && vh.units == "m") { // Add MOND WDEP record MOND md = NewMOND(mg, reading, device_name, round_ref, "WDEP", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Water Depth", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } if (gl != null && addWLEV == true) { // Add MOND WLEV record MOND md2 = NewMOND(mg, reading, device_name, round_ref, "WLEV", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Water Level", vh.units, vh.format, gl, ge_source); if (md2 != null) { MOND.Add(md2); } } } if (vh.id == "PH") { // Add MOND Potential Hydrogen MOND md = NewMOND(mg, reading, device_name, round_ref, "PH", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } if (vh.id == "DO" && vh.units == "mg/l") { // Add MOND Disolved Oxygen MOND md = NewMOND(mg, reading, device_name, round_ref, "DO", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Dissolved Oxygen", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } // if ((vh.id == "AEC" && vh.units == "μS/cm") | // (vh.id == "AEC" & vh.units == "mS/cm")) { // // Add MOND Electrical Conductivity // MOND md = NewMOND (mg, reading, device_name, round_ref, "AEC", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Actual Electrical Conductivity", vh.units, vh.format, null, ge_source); // if (md!=null) MOND.Add (md); // } //if (vh.id == "AEC" && (vh.units == "μS/cm" || vh.units == "mS/cm")) { if (vh.id == "AEC") { // Add MOND Electrical Conductivity MOND md = NewMOND(mg, reading, device_name, round_ref, "AEC", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Actual Electrical Conductivity", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } // if ((vh.id == "EC" && vh.units == "μS/cm")) { if ((vh.id == "EC")) { // Add MOND Electrical Conductivity MOND md = NewMOND(mg, reading, device_name, round_ref, "EC", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Electrical Conductivity", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } if (vh.id == "SAL" && vh.units == "g/cm3") { // Add MOND Salinity record MOND md = NewMOND(mg, reading, device_name, round_ref, "SAL", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Salinity", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } if (vh.id == "TEMP" && vh.units == "Deg C") { // Add MOND Temp record MOND md = NewMOND(mg, reading, device_name, round_ref, "DOWNTEMP", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Downhole Temperature", vh.units, vh.format, null, ge_source); MOND.Add(md); } if (vh.id == "RDX" && vh.units == "mV") { // Add MOND Redox Salinity record MOND md = NewMOND(mg, reading, device_name, round_ref, "RDX", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Redox Potential", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } if (vh.id == "TURB" && vh.units == "NTU") { // Add MOND Salinity record MOND md = NewMOND(mg, reading, device_name, round_ref, "TURB", mg.MONG_TYPE + mond_rem_suffix, mond_ref, vh.db_name, "Turbity", vh.units, vh.format, null, ge_source); if (md != null) { MOND.Add(md); } } } } return(MOND); }