private List <NTPI> getNTPI(HtmlNode row) { List <NTPI> nTPIs = new List <NTPI>(); if (row != null) { HtmlNodeCollection transportNodes = row.SelectNodes(".//div[contains(@class, \"transportationDetail\")]"); if (transportNodes != null) { foreach (HtmlNode transportNode in transportNodes) { string transportCategory = ""; HtmlNode categoryNode = transportNode.SelectSingleNode(".//thead/tr/th[1]"); if (categoryNode != null) { transportCategory = categoryNode.ChildNodes[1].InnerHtml.Trim(); } foreach (HtmlNode trNode in transportNode.SelectNodes(".//tbody/tr")) { NTPI ntpi = new NTPI(); ntpi.property = myUrl.property; ntpi.category = transportCategory; HtmlNode tdDrive = trNode.SelectSingleNode(".//td[2]"); if (tdDrive != null) { ntpi.drivetime = Util.parseDouble(tdDrive.InnerHtml.Trim().Split(" ")[0], 0); } HtmlNode tdDistance = trNode.SelectSingleNode(".//td[3]"); if (tdDistance != null) { ntpi.distance = Util.parseDouble(tdDistance.InnerHtml.Trim().Split(" ")[0], 0); } HtmlNode transportationNameNode = trNode.SelectSingleNode(".//div[contains(@class, \"transportationName\")]"); if (transportationNameNode != null) { HtmlNode transportationNameNodeA = transportationNameNode.SelectSingleNode(".//a"); if (transportationNameNodeA != null) { ntpi.name = transportationNameNodeA.InnerHtml.Trim(); } else { ntpi.name = transportationNameNode.InnerHtml.Trim(); } } nTPIs.Add(ntpi); } } } } return(nTPIs); }
private static int getNtpiIdDb(NTPI x) { if (x != null) { using (IDbConnection db = DBConnectionHelper.getConnection()){ NTPI y = db.QueryFirstOrDefault <NTPI>( "Select * from NearestTransitPointInterest where " + "name like @name and " + "drive like @drive" ); } } return(0); }
private List <NTPICategory> getNTPI(HtmlNode row) { List <NTPICategory> ntpiCategoryList = new List <NTPICategory>(); if (row != null) { HtmlNodeCollection transportNodes = row.SelectNodes(".//div[contains(@class, \"transportationDetail\")]"); if (transportNodes != null) { foreach (HtmlNode transportNode in transportNodes) { string transportCategory = ""; NTPICategory ntpiCategory = new NTPICategory(); ntpiCategory.NtpiList = new List <NTPI>(); HtmlNode categoryNode = transportNode.SelectSingleNode(".//thead/tr/th[1]"); if (categoryNode != null) { transportCategory = categoryNode.ChildNodes[1].InnerHtml.Trim(); } ntpiCategory.Name = transportCategory; ntpiCategory.NtpiList = new List <NTPI>(); foreach (HtmlNode trNode in transportNode.SelectNodes(".//tbody/tr")) { NTPI ntpi = new NTPI(); ntpi.PropNTPIMapping = new List <PropertyNTPIMapping>(); PropertyNTPIMapping propNTPIMap = new PropertyNTPIMapping(); propNTPIMap.Property = myUrl.property; //ntpi.category = transportCategory; HtmlNode tdDrive = trNode.SelectSingleNode(".//td[2]"); if (tdDrive != null) { ntpi.Drive = Util.parseDouble(tdDrive.InnerHtml.Trim().Split(" ")[0], 0); } HtmlNode tdDistance = trNode.SelectSingleNode(".//td[3]"); if (tdDistance != null) { ntpi.distance = Util.parseDouble(tdDistance.InnerHtml.Trim().Split(" ")[0], 0); } HtmlNode transportationNameNode = trNode.SelectSingleNode(".//div[contains(@class, \"transportationName\")]"); if (transportationNameNode != null) { HtmlNode transportationNameNodeA = transportationNameNode.SelectSingleNode(".//a"); if (transportationNameNodeA != null) { ntpi.name = transportationNameNodeA.InnerHtml.Trim(); } else { ntpi.name = transportationNameNode.InnerHtml.Trim(); } } ntpi.PropNTPIMapping.Add(propNTPIMap); ntpiCategory.NtpiList.Add(ntpi); } ntpiCategoryList.Add(ntpiCategory); } } } return(ntpiCategoryList); }