public MainForm() { InitializeComponent(); FormLog = new LogForm(); CurrentFilter = new DocumentFilter(); AddDocumentToGridDelegate = new AddDocumentGridDelegate(AddDocumentGrid); delShowStatusDelegate = new ShowStatusDelegate(ShowStatusMessage); if (File.Exists("config.xml")) { LoadFromConfig("config.xml"); //UpdateDocList(); } StopSearch = true; }
private void FilterDocList(object _df) { AddDocumentGridDelegate deleg = new AddDocumentGridDelegate(AddDocumentGrid); DocumentFilter df = (DocumentFilter)_df; if (df.Count > 0) { DBDocumentStorage ds = new DBDocumentStorage(DBstorage.DB.ConnectionString); List<Guid> docids = ds.GetDocumentsIDs(); docs.Clear(); int i = 0; int scancount = 0; foreach (Guid docid in docids) { if (StopSearch) break; bool flag = false; DBDocument d = ds.GetDocumentByID(docid); try { string ct = d.LastVersion.HeadersCollection[HttpResponseHeader.ContentType]; if (ct.StartsWith("text")) { string src = HTMLUtils.GetPlainText(d.LastVersion.DataAsText); /*foreach (string word in df) { if (src.IndexOf(word) > -1) { flag = true; if (foundword != "") foundword = foundword + ", "; foundword += word; //break; } }*/ List<FoundText> matches = HTMLUtils.GetMatches(src, df.ToArray()); if (matches.Count >0 ) { docs.Add(d.ID, d.URL); string FoundWords = ""; foreach(FoundText m in matches) { if (FoundWords != "") FoundWords = FoundWords+ ", " ; FoundWords = FoundWords + string.Format("({0},{1}) {2}", m.Index, m.Length, src.Substring(m.Index, m.Length)); } dgv.Invoke(deleg, i++, d.ID, d.URL, FoundWords); } } } catch (Exception ex) { Log(ex); } finally { scancount++; string message = string.Format("Scanned {0}/{1} documents. Found {2} documents.", scancount, docids.Count, i); Log(message); d.Dispose(); } } } }