public List <Geo> InformaGeoDAO() { try { List <Geo> List = new List <Geo>(); SqlDataReader Dr = null; using (SqlConnection Con = new Conexao().ConexaoDB()) { SqlCommand Cmd = new SqlCommand(@" SELECT L1.*, L3.nome FROM Geolocalizacao As L1 INNER JOIN ( SELECT idUsuario, MAX(dataRegistro) As UltimaData FROM Geolocalizacao WHERE LATITUDE <> '0.0' AND LONGITUDE <> '0.0' and idEmpresa = @Empresa GROUP BY idUsuario) As L2 ON (L1.idUsuario = L2.idUsuario AND L1.dataRegistro = L2.UltimaData) INNER JOIN Usuario As L3 on (L1.idUsuario = L3.idUsuario) ORDER BY L1.idUsuario;", Con); Cmd.Parameters.AddWithValue("@Empresa", InfoGlobal.GlobalIdEmpresa); Dr = Cmd.ExecuteReader(); while (Dr.Read()) { Geo GeoLoc = FactoryGeo.GetNew(); GeoLoc.Id = Dr.GetInt32(0); GeoLoc.Latitude = Dr.GetString(1); GeoLoc.Longitude = Dr.GetString(2); GeoLoc.IdUsr = Dr.GetInt32(3); GeoLoc.Data = Dr.GetDateTime(5); GeoLoc.NomeUsuario = Dr.GetString(6); List.Add(GeoLoc); } return(List); } } catch (SqlException) { throw; } }
public GeoController() { ObjGeo = FactoryGeo.GetNew(); }