private void SearchGroup() { string fields = "[g_id],[g_name],[g_description],[g_tags]"; string where = "[g_name] like '%" + key.Replace("'", "''") + "%'"; string sql = "select top {0} {1} from [group] where {2}"; sql = String.Format(sql, pageSize, fields, where); DataTable dt = DB.GetTable(sql); int cnt = dt != null ? dt.Rows.Count : 0; if (cnt == 0) { Response.Write("<p class='resulttitle'>没有找到 <b>" + key + "</b> 的相关内容</p>"); return; } Response.Write("<p class='resulttitle'>找到有关 <b>" + key + "</b> 的 <b>" + cnt + "</b> 个结果</p>"); foreach (DataRow row in dt.Rows) { Response.Write("<div class='item'>"); Response.Write("<div class='itemleft'>"); Response.Write(String.Format("<a href='/{0}{1}' target=_blank><img src='/upload/group/{0}-s.jpg' {2} /></a>", row["g_id"], Settings.Ext, Strings.GroupSmallImageError)); Response.Write("</div><div class='itemright'>"); Response.Write(String.Format("<a class='bold' href='/{0}{1}' target=_blank>{2}</a>", row["g_id"], Settings.Ext, SetRed(row["g_name"].ToString()))); Response.Write("<p>" + Tools.HtmlEncode(row["g_description"].ToString()) + "</p>"); Response.Write("<span class='em'>标签: " + TagTools.ToLinks(row["g_tags"].ToString(), true) + "</span>"); Response.Write("</div>"); Response.Write("<div class='clear'></div></div>"); } }
private int pageNumber = 9;//显示页数 protected void Page_Load(object sender, EventArgs e) { tag = ""; if (Request.QueryString["q"] != null) { string[] qs = Request.QueryString["q"].Split('/'); tag = TagTools.Filter(qs[0]).Replace(",", ""); if (qs.Length > 1) { if (int.TryParse(qs[1], out pageIndex)) { pageIndex -= 1; } else { pageIndex = 0; } } } if (tag == "") { Server.Transfer("~/note.aspx?q=Notfound"); } BindBlogs(); lblLogin.Text = Print.LoginBox(); lblHotTags.Text = Data.GetHotTags(); Page.Title = "Tag:" + tag + " - cnOpenBlog"; }
private static HashSet <string> BuildLibraryTagList(Library library, bool add_autotags, bool add_tags) { HashSet <string> tags = new HashSet <string>(); if (add_autotags) { // Check that the AutoTags are not getting too old if (null == library.AITagManager.AITags || library.AITagManager.AITags.IsGettingOld || library.AITagManager.AITags.HaveNoTags) { library.AITagManager.Regenerate(); } // Add in the auto tags if (null != library.AITagManager.AITags) { tags.UnionWith(library.AITagManager.AITags.GetAllTags()); } } // Add in the manually generated tags if (add_tags) { foreach (PDFDocument pdf_document in library.PDFDocuments) { HashSet <string> document_tags = TagTools.ConvertTagBundleToTags(pdf_document.Tags); tags.UnionWith(document_tags); } } return(tags); }
private static void Export_Directories_Tags(Library library, string base_path, Dictionary <string, PDFDocumentExportItem> pdf_document_export_items) { WshShell shell = new WshShell(); string tags_base_path = base_path + @"tags\"; Directory.CreateDirectory(tags_base_path); foreach (var item in pdf_document_export_items.Values) { try { foreach (string tag in TagTools.ConvertTagBundleToTags(item.pdf_document.Tags)) { string tag_base_path = tags_base_path + FileTools.MakeSafeFilename(tag) + @"\"; Directory.CreateDirectory(tag_base_path); string filename = tag_base_path + FileTools.MakeSafeFilename(item.pdf_document.TitleCombined) + ".lnk"; CreateShortcut(shell, item.filename, filename); } } catch (Exception ex) { Logging.Error(ex, "Error creating shortcut for " + item.filename); } } }
private void BindTags() { string sql = "select [tags] from [blog] where [user_name]='" + username + "'"; DataTable dt = DB.GetTable(sql); if (dt == null || dt.Rows.Count == 0) { return; } List <string> list = new List <string>(); foreach (DataRow row in dt.Rows) { list.AddRange(row[0].ToString().Split(',')); } List <Tag> tags = TagTools.Format(list); StringBuilder sb = new StringBuilder(); foreach (Tag t in tags) { sb.AppendFormat("<a href='/search.aspx?q=tag:{0}&blogger={1}' style='font-size:{3}px'>{2}</a> ", Tools.UrlEncode(t.Name), username, t.Name, Math.Min(t.Count + 11, 24)); } lblTags.Text = sb.ToString(); }
private void SearchBlog() { Documents h = SearchEngine.Simple.Search(key, Request["onlytitle"] != null); int cnt = h != null ? h.Count : 0; if (cnt == 0) { Response.Write("<p class='resulttitle'>没有找到 <b>" + key + "</b> 的相关内容</p>"); return; } Response.Write("<p class='resulttitle'>找到有关 <b>" + key + "</b> 的 <b>" + cnt + "</b> 个结果</p>"); for (int i = 0; i < cnt && i < 10; i++) { Document doc = h[i]; Response.Write("<div class='item'>"); Response.Write("<div class='itemleft'>"); Response.Write(String.Format("<a href='/{0}{1}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a>", doc.Author, Settings.Ext, Strings.UserSmallImageError)); Response.Write("</div><div class='itemright'>"); Response.Write(String.Format("<a class='bold' href='{0}' target=_blank>{1}</a>", doc.Path, SetRed(doc.Title))); Response.Write("<p>" + SetRed(doc.Body) + "</p>"); Response.Write("<span class='em'>标签: " + TagTools.ToLinks(doc.Tag) + "</span>"); Response.Write("</div>"); Response.Write("<div class='clear'></div></div>"); } }
public static List <TagCloudEntry> BuildTagCloud(Library library, PDFDocument pdf_document) { int MAX_PAGE_LIMIT = 20; AITags ai_tags = pdf_document.Library.AITagManager.AITags; HashSet <string> autotags = ai_tags.GetTagsWithDocument(pdf_document.Fingerprint); foreach (var tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags)) { autotags.Add(tag); } CountingDictionary <string> word_counts = new CountingDictionary <string>(); { Logging.Info("+Counting the autotags"); int total_tags = 0; for (int page = 1; page <= pdf_document.PDFRenderer.PageCount && page < MAX_PAGE_LIMIT; ++page) { string page_text = pdf_document.PDFRenderer.GetFullOCRText(page); foreach (string autotag in autotags) { int word_count = StringTools.CountStringOccurence(page_text, autotag); if (0 < word_count) { ++total_tags; word_counts.TallyOne(autotag); } } } Logging.Info("-Counting the autotags: total_occurences={0} unique_tags={1}", total_tags, word_counts.Count); } Logging.Info("+Building the ratios"); List <TagCloudEntry> entries = new List <TagCloudEntry>(); foreach (var pair in word_counts) { int document_count = ai_tags.GetTagCount(pair.Key) + 1; // Limit the wordcount to cull the hyperfrequent words int word_count = pair.Value; TagCloudEntry entry = new TagCloudEntry(); entry.word = pair.Key; entry.word_count = word_count; entry.document_count = document_count; entry.importance = word_count / (double)document_count; entries.Add(entry); } Logging.Info("-Building the ratios"); entries.Sort(delegate(TagCloudEntry a, TagCloudEntry b) { return(-Sorting.Compare(a.importance, b.importance)); }); return(entries); }
internal void ProcessAnnotation(PDFAnnotation pdf_annotation) { if (pdf_annotation.Deleted) { return; } ProcessTags(TagTools.ConvertTagBundleToTags(pdf_annotation.Tags)); }
internal void ShowTagOptions(WebLibraryDetail library_, List <PDFDocument> pdf_documents_, OnShowTagOptionsCompleteDelegate OnShowTagOptionsComplete_) { web_library_detail = library_; pdf_documents = pdf_documents_; OnShowTagOptionsComplete = OnShowTagOptionsComplete_; // Collate all the available tags HashSet <string> all_tags = new HashSet <string>(); HashSet <string> all_creators = new HashSet <string>(); foreach (var pdf_document in pdf_documents) { if (pdf_document.Deleted) { continue; } foreach (var pdf_annotation in pdf_document.GetAnnotations()) { if (pdf_annotation.Deleted) { continue; } if (null != pdf_annotation.Creator) { all_creators.Add(pdf_annotation.Creator); } string tags_bundle = pdf_annotation.Tags; HashSet <string> local_tags = TagTools.ConvertTagBundleToTags(tags_bundle); foreach (var tag in local_tags) { all_tags.Add(tag); } } } List <string> all_creators_sorted = new List <string>(all_creators); all_creators_sorted.Sort(); ObservableCollection <string> all_creators_source = new ObservableCollection <string>(all_creators_sorted); ObjFilterByCreatorCombo.ItemsSource = all_creators_source; all_tags.Add(HighlightToAnnotationGenerator.HIGHLIGHTS_TAG); all_tags.Add(InkToAnnotationGenerator.INKS_TAG); List <string> all_tags_sorted = new List <string>(all_tags); all_tags_sorted.Sort(); ObservableCollection <string> bindable_tags = new ObservableCollection <string>(all_tags_sorted); ListTags.Items.Clear(); ListTags.ItemsSource = bindable_tags; Show(); }
internal void ShowTagOptions(Library library, List <PDFDocument> pdf_documents, OnShowTagOptionsCompleteDelegate OnShowTagOptionsComplete) { this.library = library; this.pdf_documents = pdf_documents; this.OnShowTagOptionsComplete = OnShowTagOptionsComplete; // Collate all the availalbe tags HashSet <string> all_tags = new HashSet <string>(); HashSet <string> all_creators = new HashSet <string>(); foreach (var pdf_document in pdf_documents) { if (pdf_document.Deleted) { continue; } foreach (var pdf_annotation in pdf_document.Annotations) { if (pdf_annotation.Deleted) { continue; } if (null != pdf_annotation.Creator) { all_creators.Add(pdf_annotation.Creator); } string tags_bundle = pdf_annotation.Tags; HashSet <string> local_tags = TagTools.ConvertTagBundleToTags(tags_bundle); foreach (var tag in local_tags) { all_tags.Add(tag); } } } List <string> all_creators_sorted = new List <string>(all_creators); all_creators_sorted.Sort(); ObjFilterByCreatorCombo.ItemsSource = all_creators_sorted; List <string> bindable_tags = new List <string>(all_tags); bindable_tags.Add(HighlightToAnnotationGenerator.HIGHLIGHTS_TAG); bindable_tags.Add(InkToAnnotationGenerator.INKS_TAG); bindable_tags.Sort(); ListTags.Items.Clear(); ListTags.ItemsSource = bindable_tags; this.Show(); }
// ----------------------------- internal static MultiMapSet <string, string> GetNodeItems(Library library, HashSet <string> parent_fingerprints) { Logging.Info("+Getting node items for " + "Tags"); List <PDFDocument> pdf_documents = null; if (null == parent_fingerprints) { pdf_documents = library.PDFDocuments; } else { pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints); } // Load all the annotations upfront so we dont have to go to the database for each PDF Dictionary <string, byte[]> library_items_annotations_cache = library.LibraryDB.GetLibraryItemsAsCache(PDFDocumentFileLocations.ANNOTATIONS); // Build up the map of PDFs associated with each tag MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>(); foreach (PDFDocument pdf_document in pdf_documents) { bool has_tag = false; foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags)) { tags_with_fingerprints.Add(tag, pdf_document.Fingerprint); has_tag = true; } // And check the annotations foreach (var pdf_annotation in pdf_document.GetAnnotations(library_items_annotations_cache)) { if (!pdf_annotation.Deleted) { foreach (string annotation_tag in TagTools.ConvertTagBundleToTags(pdf_annotation.Tags)) { tags_with_fingerprints.Add(annotation_tag, pdf_document.Fingerprint); has_tag = true; } } } if (!has_tag) { tags_with_fingerprints.Add(NO_TAG_KEY, pdf_document.Fingerprint); } } Logging.Info("-Getting node items"); return(tags_with_fingerprints); }
private void ExpandTags() { FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Tags); PDFDocument pdf_document = pdf_document_node_content.PDFDocument; foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags)) { PDFTagNodeContent pdf_tag = new PDFTagNodeContent(pdf_document.Library.WebLibraryDetail.Id, tag); NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_tag, false); } }
void CmdGenerate_Click(object sender, RoutedEventArgs e) { string new_tag = TextNewTagName.Text; if (String.IsNullOrEmpty(new_tag)) { if (!MessageBoxes.AskQuestion("You have specified an EMPTY new tag name. This will effectively delete tag '{0}' from your library. Are you sure you want to do this?", tag)) { return; } } // Rename all the tags in the documents foreach (PDFDocument pdf_document in library.PDFDocuments) { // Rename the tags in the annotations foreach (PDFAnnotation pdf_annotation in pdf_document.Annotations) { // This fast search will flag is the tag appears in the substring if (null != pdf_annotation.Tags && pdf_annotation.Tags.Contains(tag)) { HashSet <string> tags = TagTools.ConvertTagBundleToTags(pdf_annotation.Tags); // Now do a proper check for the appearance of the tag if (tags.Contains(tag)) { tags.Remove(tag); if (!String.IsNullOrEmpty(new_tag)) { tags.Add(new_tag); } pdf_annotation.Tags = TagTools.ConvertTagListToTagBundle(tags); pdf_annotation.Bindable.NotifyPropertyChanged(() => pdf_annotation.Tags); } } } // Rename the document tags if (pdf_document.Tags.Contains(tag)) { pdf_document.RemoveTag(tag); if (!String.IsNullOrEmpty(new_tag)) { pdf_document.AddTag(new_tag); } } } this.DialogResult = true; this.Close(); }
// public Object source; void OnGUI() { EditorGUILayout.BeginVertical(); //source = EditorGUILayout.ObjectField(source, typeof(Object), true); //if (GUILayout.Button( "AddObject")) //{ // if (source != null) // { // tagGameObject.Add(source); // } //} for (int i = 0; i < TagTools.tags.Length; i++) { GUILayout.Label(TagTools.tags[i]); tagGameObject[i] = EditorGUILayout.ObjectField(tagGameObject[i], typeof(Object), true); if (GUILayout.Button("Save!")) { if (tagGameObject[i] != null) { PlayerPrefs.SetString(TagTools.tags[i], tagGameObject[i].name); TagTools.AddTags(); ((GameObject)tagGameObject[i]).tag = TagTools.tags[i]; } else if (Help.HasHelpForObject(tagGameObject[i])) { Help.ShowHelpForObject(tagGameObject[i]); } else { Help.BrowseURL("http://forum.unity3d.com/search.php"); } } } EditorGUILayout.EndVertical(); }
private static void Export_HTML_Tags(StringBuilder html, Library library, string base_path, Dictionary <string, PDFDocumentExportItem> pdf_document_export_items) { MultiMap <string, PDFDocumentExportItem> items_sliced = new MultiMap <string, PDFDocumentExportItem>(false); foreach (var item in pdf_document_export_items.Values) { foreach (string tag in TagTools.ConvertTagBundleToTags(item.pdf_document.Tags)) { items_sliced.Add(tag, item); } } Export_HTML_XXX(html, "Tags", items_sliced); }
internal void ProcessDocument(PDFDocument pdf_document) { if (pdf_document.Deleted) { return; } ProcessTags(TagTools.ConvertTagBundleToTags(pdf_document.Tags)); foreach (var pdf_annotation in pdf_document.GetAnnotations()) { ProcessAnnotation(pdf_annotation); } }
static int CountDocumentsWithTag(Library library, string search_tag) { int count = 0; foreach (PDFDocument pdf_document in library.PDFDocuments) { foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags)) { if (0 == String.Compare(tag, search_tag)) { ++count; break; } } } return(count); }
public void AddTag(string new_tag_bundle) { HashSet <string> new_tags = TagTools.ConvertTagBundleToTags(new_tag_bundle); HashSet <string> tags = TagTools.ConvertTagBundleToTags(Tags); int tag_count_old = tags.Count; tags.UnionWith(new_tags); int tag_count_new = tags.Count; // Update listeners if we changed anything if (tag_count_old != tag_count_new) { Tags = TagTools.ConvertTagListToTagBundle(tags); Bindable.NotifyPropertyChanged(() => Tags); TagManager.Instance.ProcessDocument(this); } }
internal List <PDFDocument> GetDocumentsByTag(string target_tag) { List <PDFDocument> pdf_documents_list = new List <PDFDocument>(); foreach (var pdf_document in this.PDFDocuments) { foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags)) { if (0 == tag.CompareTo(target_tag)) { pdf_documents_list.Add(pdf_document); break; } } } return(pdf_documents_list); }
private int pageNumber = 9;//显示页数 protected void Page_Load(object sender, EventArgs e) { tag = ""; if (Request.QueryString["q"] != null) { tag = TagTools.Filter(Request.QueryString["q"]).Replace(",", ""); } if (tag == "") { Server.Transfer("~/note.aspx?q=Notfound"); } BindGroups(); BindHotGroups(); lblLogin.Text = Print.LoginBox(); Page.Title = "群组Tag:" + tag + " - cnOpenBlog"; }
public FolderWatcher(FolderWatcherManager folder_watcher_manager, Library library, string folder_to_watch, string tags) { this.folder_watcher_manager = folder_watcher_manager; this.library = library; this.folder_to_watch = folder_to_watch; this.tags = TagTools.ConvertTagBundleToTags(tags); this.previous_folder_to_watch = null; file_system_watcher = new FileSystemWatcher(); file_system_watcher.IncludeSubdirectories = true; file_system_watcher.Filter = "*.pdf"; file_system_watcher.Changed += file_system_watcher_Changed; file_system_watcher.Created += file_system_watcher_Created; previous_folder_to_watch = null; folder_contents_has_changed = false; file_system_watcher.Path = null; file_system_watcher.EnableRaisingEvents = false; }
private void BindBlogs() { Documents docs = SearchEngine.Simple.SearchTag(tag); int cnt = docs.Count; pageCount = cnt / pageSize; if (cnt % pageSize > 0) { pageCount++; } pageIndex = Math.Max(0, pageIndex); pageIndex = Math.Min(pageCount - 1, pageIndex); StringBuilder sb = new StringBuilder(); int ind; for (int i = 0; i < pageSize; i++) { ind = pageIndex * pageSize + i; if (ind == cnt) { break; } Document doc = docs[ind]; sb.Append("<div style='margin-top:16px;margin-left:14px;'>"); sb.AppendFormat("<div class='ileft'><a href='/{0}{1}' title='{0}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a></div>", doc.Author, Settings.Ext, Strings.UserSmallImageError); sb.AppendFormat("<div class='iright'><a class='bold' href='{0}' target=_blank>{1}</a>", doc.Path, Tools.HtmlEncode(doc.Title)); sb.AppendFormat("<p>{0}</p>", Tools.HtmlEncode(doc.Body)); sb.AppendFormat("<span class='em'>标签:{0}</span></div>", TagTools.ToLinks(doc.Tag)); sb.Append("<div class='clear'></div></div>"); } lblBlogList.Text = sb.ToString(); if (pageCount > 1) { string url = String.Format("/tag/{0}/{1}{2}", tag, "{0}", Settings.Ext); lblPageList.Text = Tools.GetPager(pageIndex, pageCount, pageNumber, url); } }
public void RemoveTag(string dead_tag_bundle) { HashSet <string> dead_tags = TagTools.ConvertTagBundleToTags(dead_tag_bundle); HashSet <string> tags = TagTools.ConvertTagBundleToTags(Tags); int tag_count_old = tags.Count; foreach (string dead_tag in dead_tags) { tags.Remove(dead_tag); } int tag_count_new = tags.Count; if (tag_count_old != tag_count_new) { Tags = TagTools.ConvertTagListToTagBundle(tags); Bindable.NotifyPropertyChanged(() => Tags); TagManager.Instance.ProcessDocument(this); } }
public FolderWatcher(FolderWatcherManager _folder_watcher_manager, WebLibraryDetail _library, string folder_to_watch, string _tags) { folder_watcher_manager = new TypedWeakReference <FolderWatcherManager>(_folder_watcher_manager); web_library_detail = new TypedWeakReference <WebLibraryDetail>(_library); aspiring_folder_to_watch = folder_to_watch; tags = TagTools.ConvertTagBundleToTags(_tags); configured_folder_to_watch = null; watch_stats = new WatchStatistics(); file_system_watcher = new FileSystemWatcher(); file_system_watcher.IncludeSubdirectories = true; file_system_watcher.Filter = "*.pdf"; file_system_watcher.Changed += file_system_watcher_Changed; file_system_watcher.Created += file_system_watcher_Created; configured_folder_to_watch = null; FolderContentsHaveChanged = false; file_system_watcher.Path = null; file_system_watcher.EnableRaisingEvents = false; }
private void BindGroups() { string sql = "select * from [group] where [g_tags] like '%" + tag + "%'"; DataTable dt = DB.GetTable(sql); int cnt = dt != null ? dt.Rows.Count : 0; if (cnt == 0) { return; } pageCount = cnt / pageSize; if (cnt % pageSize > 0) { pageCount++; } pageIndex = Math.Max(0, pageIndex); pageIndex = Math.Min(pageCount - 1, pageIndex); StringBuilder sb = new StringBuilder(); foreach (DataRow row in dt.Rows) { sb.Append("<div style='margin-top:16px;margin-left:14px;'>"); sb.AppendFormat("<div class='ileft'><a href='/{0}{1}' title='{0}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a></div>", row["g_id"], Settings.Ext, Strings.GroupSmallImageError); sb.AppendFormat("<div class='iright'><a class='bold' href='/group/{0}{1}' target=_blank>{2}</a>", row["g_id"], Settings.Ext, Tools.HtmlEncode(row["g_name"].ToString())); sb.AppendFormat("<p>{0}</p>", Tools.HtmlEncode(row["g_description"].ToString())); sb.AppendFormat("<span class='em'>标签:{0}</span></div>", TagTools.ToLinks(row["g_tags"].ToString(), true)); sb.Append("<div class='clear'></div></div>"); } lblGroupList.Text = sb.ToString(); if (pageCount > 1) { string url = String.Format("/group/tag/{0}/{1}{2}", tag, "{0}", Settings.Ext); lblPageList.Text = Tools.GetPager(pageIndex, pageCount, pageNumber, url); } }
private static void ExpandTags(PDFDocument doc, NodeControl node_control) { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); ASSERT.Test(doc != null); FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Tags); if (doc != null) { var tags = TagTools.ConvertTagBundleToTags(doc.Tags); WPFDoEvents.InvokeInUIThread(() => { WPFDoEvents.AssertThisCodeIsRunningInTheUIThread(); foreach (string tag in tags) { PDFTagNodeContent pdf_tag = new PDFTagNodeContent(doc.LibraryRef.Id, tag); NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_tag, false); } }); } }
private void ButtonApplyTagsAdd_Click(object sender, RoutedEventArgs e) { List <PDFDocument> selected_pdf_documents = SelectedPDFDocuments; if (null == selected_pdf_documents) { return; } HashSet <string> new_tags = TagTools.ConvertTagBundleToTags(tags_add_stub.Tags); if (!MessageBoxes.AskQuestion("Are you sure you want to add {0} tags to {1} documents?" , new_tags.Count , selected_pdf_documents.Count)) { return; } foreach (var pdf_document in selected_pdf_documents) { pdf_document.AddTag(tags_add_stub.Tags); } }
internal List <PDFDocument> GetDocumentsByTag(string target_tag) { List <PDFDocument> pdf_documents_list = new List <PDFDocument>(); Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start(); lock (pdf_documents_lock) { l1_clk.LockPerfTimerStop(); foreach (var pdf_document in pdf_documents.Values) { foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags)) { if (0 == tag.CompareTo(target_tag)) { pdf_documents_list.Add(pdf_document); break; } } } } return(pdf_documents_list); }
private void BindTag() { string sql = "select top " + size.ToString() + " [_id],[user_name],[title],[cat_id],[zhaiyao],[uptime],[filepath] from [blog]"; sql += " where [tags] like '%" + TagTools.Filter(q).Replace(",", "") + "%'"; sql += " order by [_id] desc"; DataTable dt = DB.GetTable(sql); StringBuilder sb = new StringBuilder(); sb.Append(RSSHead); sb.Append("<channel>"); sb.AppendFormat("<title>标签:{0} 博客订阅 - cnOpenBlog.com</title>", q); sb.AppendFormat("<link>{0}tag/{1}/feed{2}</link>", Settings.BaseURL, q, Settings.Ext); sb.Append("<description></description>"); sb.AppendFormat("<pubDate>{0}</pubDate>", DateTime.Now.ToLongTimeString()); sb.AppendFormat("<generator>{0}tag/{1}{2}</generator>", Settings.BaseURL, q, Settings.Ext); Response.Write(sb.ToString()); foreach (DataRow row in dt.Rows) { sb = new StringBuilder(); sb.Append("<item>"); sb.AppendFormat("<title><![CDATA[{0}]]></title>", row["title"]); sb.AppendFormat("<link>{0}{1}</link>", Settings.BaseURL.TrimEnd('/'), row["filepath"]); sb.AppendFormat("<description><![CDATA[{0}]]></description>", row["zhaiyao"]); sb.AppendFormat("<author>{0}</author>", row["user_name"]); sb.AppendFormat("<category>{0}</category>", Category.GetNameById((int)row["cat_id"])); sb.AppendFormat("<pubDate>{0}</pubDate>", row["uptime"]); sb.AppendFormat("<guid>{0}{1}</guid>", Settings.BaseURL.TrimEnd('/'), row["filepath"]); sb.Append("</item>"); Response.Write(sb.ToString()); } Response.Write("</channel>"); Response.Write("</rss>"); }
public static List <AnnotationWork> GenerateAnnotationWorks(Library library, List <PDFDocument> pdf_documents, AnnotationReportOptionsWindow.AnnotationReportOptions annotation_report_options) { List <AnnotationWork> annotation_works = new List <AnnotationWork>(); // The caches we will need... Dictionary <string, byte[]> library_items_highlights_cache = library.LibraryDB.GetLibraryItemsAsCache(PDFDocumentFileLocations.HIGHLIGHTS); Dictionary <string, byte[]> library_items_inks_cache = library.LibraryDB.GetLibraryItemsAsCache(PDFDocumentFileLocations.INKS); for (int j = 0; j < pdf_documents.Count; ++j) { if (j % 10 == 0) { StatusManager.Instance.UpdateStatus("AnnotationReport", "Initialising annotation report", j, pdf_documents.Count); } PDFDocument pdf_document = pdf_documents[j]; // Add the comments token if this document has some comments or abstract (and the user wants them) if (annotation_report_options.IncludeAllPapers) { if (!String.IsNullOrEmpty(pdf_document.Comments) || !String.IsNullOrEmpty(pdf_document.Abstract)) { annotation_works.Add(new AnnotationWork { library = library, pdf_document = pdf_document, pdf_annotation = null }); } } List <PDFAnnotation> pdf_annotations = new List <PDFAnnotation>(); pdf_annotations.AddRange(pdf_document.Annotations); if (library_items_highlights_cache.ContainsKey(pdf_document.Fingerprint)) { pdf_annotations.AddRange(HighlightToAnnotationGenerator.GenerateAnnotations(pdf_document, library_items_highlights_cache)); } if (library_items_inks_cache.ContainsKey(pdf_document.Fingerprint)) { pdf_annotations.AddRange(InkToAnnotationGenerator.GenerateAnnotations(pdf_document, library_items_inks_cache)); } pdf_annotations.Sort(AnnotationSorter); foreach (PDFAnnotation pdf_annotation in pdf_annotations) { if (pdf_annotation.Deleted) { continue; } // Filter by annotations if (null != annotation_report_options.filter_tags && annotation_report_options.filter_tags.Count > 0) { HashSet <string> annotation_tags = new HashSet <string>(TagTools.ConvertTagBundleToTags(pdf_annotation.Tags)); annotation_tags.IntersectWith(annotation_report_options.filter_tags); if (0 == annotation_tags.Count) { continue; } } // Filter by date ranges and creators { if (annotation_report_options.FilterByCreationDate && pdf_annotation.DateCreated.HasValue) { DateTime date_to = annotation_report_options.FilterByCreationDate_To; if (date_to != DateTime.MaxValue) { date_to = date_to.AddDays(1); } if (pdf_annotation.DateCreated.Value < annotation_report_options.FilterByCreationDate_From) { continue; } if (pdf_annotation.DateCreated.Value >= date_to) { continue; } } if (annotation_report_options.FilterByFollowUpDate) { DateTime date_to = annotation_report_options.FilterByFollowUpDate_To; if (date_to != DateTime.MaxValue) { date_to = date_to.AddDays(1); } if (!pdf_annotation.FollowUpDate.HasValue) { continue; } if (pdf_annotation.FollowUpDate.Value < annotation_report_options.FilterByFollowUpDate_From) { continue; } if (pdf_annotation.FollowUpDate.Value >= date_to) { continue; } } if (annotation_report_options.FilterByCreator) { if (pdf_annotation.Creator != annotation_report_options.FilterByCreator_Name) { continue; } } } annotation_works.Add(new AnnotationWork { library = library, pdf_document = pdf_document, pdf_annotation = pdf_annotation }); } } return(annotation_works); }