public static List<Location> GetGeoDataForJobs(string[] sourceIDs) { List<Location> colLocations = new List<Location>(); DataTable dtResults = null; DataAccess objADO = new DataAccess(); DataAccess.ArrayListParameter objParameter = null; string strStoredProcedure = "selGeoDataForJobs"; objADO = Domain.GetADOInstance(); objParameter = new DataAccess.ArrayListParameter("WMSourceIDs", sourceIDs); dtResults = objADO.GetDataSet(strStoredProcedure, objParameter, null).Tables[0]; objADO = null; Location location = null; foreach (DataRow locationRow in dtResults.Rows) { location = new Location(); location.ID = int.Parse(locationRow["WMSourceID"].ToString()); location.PostCode = locationRow["PostCode"].ToString(); if (!locationRow["Latitude"].Equals(DBNull.Value)) { location.Latitude = double.Parse(locationRow["Latitude"].ToString()); } if (!locationRow["Longitude"].Equals(DBNull.Value)) { location.Longitude = double.Parse(locationRow["Longitude"].ToString()); } if (!locationRow["Town"].Equals(DBNull.Value)) { location.Town = locationRow["Town"].ToString(); } if (!locationRow["Street"].Equals(DBNull.Value)) { location.Street = locationRow["Street"].ToString(); } if (!locationRow["HouseNo"].Equals(DBNull.Value)) { int parseResult = 0; if (int.TryParse(locationRow["HouseNo"].ToString(), out parseResult)) { location.HouseNo = parseResult; } } colLocations.Add(location); } return colLocations; }
public Location Populate(DataRow locationRow) { Location objProperty = new Location(); objProperty.ID = (int)locationRow["LocationID"]; objProperty.PropertyReference = objProperty.ID; objProperty.XCoord = (int)decimal.Parse(locationRow["XCoord"].ToString()); objProperty.YCoord = (int)decimal.Parse(locationRow["YCoord"].ToString()); objProperty.PostCode = locationRow["PostCode"].ToString(); if (!locationRow["HouseName"].Equals(DBNull.Value)) { objProperty.HouseName = locationRow["HouseName"].ToString(); } if (!locationRow["HouseNo"].Equals(DBNull.Value)) { int parseResult = 0; if (int.TryParse(locationRow["HouseNo"].ToString(), out parseResult)) { objProperty.HouseNo = parseResult; } else { objProperty.HouseName += locationRow["HouseNo"].ToString(); } } objProperty.Street = locationRow["Street"].ToString(); objProperty.Town = locationRow["Town"].ToString(); if (!locationRow["District"].Equals(DBNull.Value)) { objProperty.District = locationRow["District"].ToString(); } if (!locationRow["SubBuilding"].Equals(DBNull.Value)) { objProperty.SubBuilding = locationRow["SubBuilding"].ToString(); } //------------------------------------------------------------------ if (!locationRow["Directions"].Equals(DBNull.Value)) { objProperty.Directions = locationRow["Directions"].ToString(); } return objProperty; }