private async Task <ge_log_file> GetFile(Guid dataId, string table = "data_pressure", Boolean IncludeReadings = true) { if (dataId == null) { return(null); } var _logger = await _context.ge_data .Include(d => d.project) .AsNoTracking() .SingleOrDefaultAsync(m => m.Id == dataId); dbConnectDetails cd = await getConnectDetails(_logger.projectId, logTables.DB_DATA_TYPE); if (cd == null) { return(null); } string dbConnectStr = cd.AsConnectionString(); return(await Task.Run(() => { using (SqlConnection cnn = new SqlConnection(dbConnectStr)) { cnn.Open(); dsTable <ge_log_reading> ds_readings = new logTables().reading; dsTable <ge_log_file> ds_file = new logTables().file; ds_file.setConnection(cnn); ds_readings.setConnection(cnn); //Multichannel transducer have upto 8 tables which will all have the same dataId if (string.IsNullOrEmpty(table)) { ds_file.sqlWhere("dataId='" + dataId.ToString() + "' and (channel is null or channel='')"); } else { ds_file.sqlWhere("dataId='" + dataId.ToString() + "' and channel='" + table + "'"); } ds_file.getDataSet(); DataTable dt_file = ds_file.getDataTable(); if (dt_file == null) { return null; } if (dt_file.Rows.Count == 0) { return null; } ge_log_file file = new ge_log_file(); DataRow row = dt_file.Rows[0]; get_log_file_values(row, file); if (IncludeReadings) { ds_readings.sqlWhere("FileId='" + file.Id.ToString() + "'"); ds_readings.getDataSet(); DataTable dt_readings = ds_readings.getDataTable(); file.readings = new List <ge_log_reading>(); foreach (DataRow rrow in dt_readings.Rows) { ge_log_reading r = new ge_log_reading(); get_log_reading_values(rrow, r); file.readings.Add(r); } file.OrderReadings(); } file.unpack_exist_file(); return file; } })); }