public override string GetWebPageSource(string webPageAbsoluteUriOrID, IArachnodeDAO arachnodeDAO) { if (ApplicationSettings.DownloadedWebPagesDirectory == null) { throw new Exception("_applicationSettings.DownloadedWebPagesDirectory is null. This is usually the result of failing to initialize the Application configuration from the ArachnodeDAO."); } string webPageSource = null; ArachnodeDataSet.WebPagesRow webPagesRow = arachnodeDAO.GetWebPage(webPageAbsoluteUriOrID); if (webPagesRow != null) { if (webPagesRow.Source.Length != 0) { webPageSource = Encoding.GetEncoding(webPagesRow.CodePage).GetString(webPagesRow.Source); } else { string discoveryPath = GetDiscoveryPath(ApplicationSettings.DownloadedWebPagesDirectory, webPagesRow.AbsoluteUri, webPagesRow.FullTextIndexType); if (!File.Exists(discoveryPath)) { throw new Exception("Could not find the WebPage Source in the database or on disk."); } webPageSource = File.ReadAllText(discoveryPath, Encoding.GetEncoding(webPagesRow.CodePage)); } } return(webPageSource); }
private void nudWebPageID_ValueChanged(object sender, EventArgs e) { _webPagesRow = _arachnodeDAO.GetWebPage(nudWebPageID.Value.ToString()); if (_webPagesRow != null) { _webPageDiscoveryPath = _discoveryManager.GetDiscoveryPath(_applicationSettings.DownloadedWebPagesDirectory, _webPagesRow.AbsoluteUri, _webPagesRow.FullTextIndexType); llWebPageDiscoveryPathDirectory.Visible = true; llWebPageDiscoveryPathDirectory.Text = Path.GetDirectoryName(_webPageDiscoveryPath); if (cbAutoView.Checked) { btnViewWebPage_Click(sender, e); } } else { llWebPageDiscoveryPathDirectory.Visible = false; wbMain.DocumentText = "The WebPage with the ID of " + nudWebPageID.Value + " does not exist."; } }