private static IEnumerable <PackageTracking> ParseTrackingInfo(CQ dom) { var tracking = new List <PackageTracking>(); PackageTracking status = null; var tableRows = dom.Select("table tr"); if (tableRows.Length == 0) { throw new ParseException(dom.Select("p").Text().RemoveLineEndings()); } try { foreach (var columns in tableRows.Skip(1).Select(tableRow => tableRow.ChildElements.ToList())) { if (columns.Count == 3) { status = new PackageTracking(); if (columns[0].HasAttribute("rowspan")) { status.Date = DateTime.Parse(columns[0].InnerText.RemoveLineEndings()); } status.Location = columns[1].InnerText.RemoveLineEndings(); status.Status = columns[2].InnerText.RemoveLineEndings(); tracking.Add(status); } else { if (status != null) { status.Details = columns[0].InnerText.RemoveLineEndings(); } } } } catch (Exception ex) { throw new ParseException("Não foi possível converter o pacote/encomenda.", ex); } if (tracking.Count() == 0) { throw new ParseException("Rastreamento não encontrado."); } return(tracking); }
public void AddTrackingInfo(PackageTracking tracking) { TrackingHistory.Add(tracking); }
private void AddTrackingInfo(PackageTracking tracking) { TrackingHistory.Add(tracking); }