private void ProcessFileContent(ContentRecord record, byte[] contentBytes) { if (AddUrlsFound) { _parser.ProcessFile(record, contentBytes); } }
private void UpdateTemplate(bool forced) { string tempPath = new Uri(_baseUri, _config.Searching.TemplateUri).NormalizedPathAndQuery(); ContentRecord record; ContentRecord.Builder update; if (_data.TryGetValue(TemplatePath, out record)) { update = record.ToBuilder(); } else { update = _data.New(TemplatePath, DateTime.Now); } ContentRecord template; if (_data.TryGetValue(tempPath, out template)) { if (template.HasContentStoreId && (forced || template.HashOriginal != update.HashOriginal)) { update.SetContentType(template.ContentType); update.SetHashOriginal(template.HashOriginal); update.SetLastCrawled(template.LastCrawled); update.SetLastValid(template.LastValid); update.SetDateModified(DateTime.Now); update.SetHttpStatus(template.HttpStatus); update.ClearContentRedirect(); if (template.HasContentRedirect) { update.SetContentRedirect(update.ContentRedirect); } ContentParser parser = new ContentParser(_data, _baseUri); parser.RelativeUri = true; parser.RewriteUri += uri => new Uri(uri.OriginalString); Uri templateUri = new Uri(_baseUri, SearchTemplate.SearchPath); parser.MakeRelativeUri = (s, d) => templateUri.MakeRelativeUri(d); byte[] mapped = parser.ProcessFile(template, _data.ReadContent(template, true)); string templateHtml = CreateTemplate(Encoding.UTF8.GetString(mapped)); using (ITransactable trans = _data.WriteContent(update, Encoding.UTF8.GetBytes(templateHtml))) { _data.AddOrUpdate(TemplatePath, update.Build()); trans.Commit(); } } } if (!_data.TryGetValue(SearchCssPath, out record)) { ContentRecord cssRecord = _data.New(SearchCssPath, DateTime.Now) .SetContentType("text/css") .SetHttpStatus(200) .Build(); _data.Add(cssRecord.ContentUri, cssRecord); _data.WriteContent(cssRecord, Encoding.UTF8.GetBytes(Properties.Resources.search_css)); } }