private bool ReceiveFaxFinishJob(IDevice device) { bool done = true; List <FaxReport> faxReports = null; FaxReport faxData = null; UpdateStatus(string.Format("Retrieving Fax report")); string FaxReportHtml = _faxApp.RetrieveFaxReport(); if (!string.IsNullOrEmpty(FaxReportHtml)) { UpdateStatus(string.Format("Consolidating Fax report")); faxReports = ConsolidateFaxReport(FaxReportHtml); } if (faxReports != null) { faxData = faxReports.Where(p => p.Identification == _data.FaxNumber) .OrderByDescending(p => p.DateTime) .FirstOrDefault(); } if (faxData == null || faxData.Result != "Success") { done = false; } return(done); }
/// <summary> /// Consolidating the Fax Report from HTml to list format /// </summary> /// <param name="HtmlString"></param> /// <returns></returns> private List <FaxReport> ConsolidateFaxReport(string HtmlString) { List <FaxReport> Report = new List <FaxReport>(); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(HtmlString); var metaTags = htmlDoc.DocumentNode.SelectNodes("//tr"); if (metaTags != null) { foreach (var tag in metaTags) { FaxReport reportnode = new FaxReport(); HtmlNode Job = tag.FirstChild; reportnode.JobID = Job.InnerHtml; HtmlNode DateTime = Job.NextSibling; reportnode.DateTime = DateTime.InnerHtml; HtmlNode User = DateTime.NextSibling; reportnode.User = User.InnerHtml; HtmlNode Type = User.NextSibling; reportnode.Type = Type.InnerHtml; HtmlNode Identification = Type.NextSibling; reportnode.Identification = Identification.InnerHtml; HtmlNode Duration = Identification.NextSibling; reportnode.Duration = Duration.InnerHtml; HtmlNode Pages = Duration.NextSibling; reportnode.Pages = Pages.InnerHtml; HtmlNode Result = Pages.NextSibling; reportnode.Result = Result.InnerHtml; Report.Add(reportnode); } } return(Report); }