/// <summary> /// 删除 HTML 文件处理 /// </summary> private void onDeleteHtml() { Searcher.SearchTaskQueue.Add(new Queue.Delete(new DataKey { Type = DataType.HtmlTitle, Id = Id }, Title)); Searcher.SearchTaskQueue.Add(new Queue.Delete(new DataKey { Type = DataType.HtmlBodyText, Id = Id }, Text)); HtmlImage.Free(ref Images); }
/// <summary> /// 删除 HTML 文件处理 /// </summary> private void onDeleteHtml() { Searcher.Default.Remove(new DataKey { Type = DataType.HtmlTitle, Id = Id }, Title); Searcher.Default.Remove(new DataKey { Type = DataType.HtmlBodyText, Id = Id }, Text); HtmlImage.Free(ref Images); }
/// <summary> /// 新建 HTML 文件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void onCreatedHtml(object sender, FileSystemEventArgs e) { try { FileInfo htmlFile = new FileInfo(e.FullPath); Html newHtml = getHtml(htmlFile); if (newHtml != null) { Html html; string url = htmlFile.FullName.Substring(AutoCSer.Web.Config.Search.HtmlPath.Length).Replace('\\', '/'), lowerUrl = url.FileNameToLower(); Monitor.Enter(htmlLock); if (urls.TryGetValue(lowerUrl, out html) && html != Null) { Monitor.Exit(htmlLock); if (html.Title != newHtml.Title) { Searcher.SearchTaskQueue.Add(new Queue.Update(new DataKey { Type = DataType.HtmlTitle, Id = html.Id }, newHtml.Title, html.Title)); html.Title = newHtml.Title; } if (html.Text != newHtml.Text) { Searcher.SearchTaskQueue.Add(new Queue.Update(new DataKey { Type = DataType.HtmlBodyText, Id = html.Id }, newHtml.Text, html.Text)); html.Text = newHtml.Text; } HtmlImage.Free(ref html.Images); html.Images = newHtml.Images; } else { try { urls[lowerUrl] = newHtml; } finally { Monitor.Exit(htmlLock); } newHtml.Url = url; newHtml.Id = Cache.GetIndex(newHtml); Searcher.SearchTaskQueue.Add(new Queue.Append(new DataKey { Id = newHtml.Id, Type = DataType.HtmlTitle }, newHtml.Title)); Searcher.SearchTaskQueue.Add(new Queue.Append(new DataKey { Id = newHtml.Id, Type = DataType.HtmlBodyText }, newHtml.Text)); html = newHtml; } foreach (HtmlImage image in html.Images) { image.GetIndex(html.Id); Searcher.SearchTaskQueue.Add(new Queue.Append(new DataKey { Id = image.Id, Type = DataType.HtmlImage }, image.Title)); } } } catch (Exception error) { AutoCSer.Log.Pub.Log.Add(AutoCSer.Log.LogType.Error, error); } }