public static string ToHtml(OfficeData item) { StringBuilder sb = new StringBuilder(); sb.Append("<b>File Name: </b>"); sb.Append("<a id='0' href='"); sb.Append(item.FileName); sb.Append("'>"); sb.Append(item.FileName); sb.Append("</a><br>"); sb.Append("<b>Folder: </b>"); sb.Append(" <a id='1' href='"); sb.Append(item.FileName); sb.Append("'>"); sb.Append(System.IO.Path.GetDirectoryName(item.FileName)); sb.Append("</a><br>"); sb.Append("<b>LastWriteTime: </b>"); sb.Append(item.DLastWriteTime.ToString("yyyy-MM-dd hh:ss")); sb.Append("<br><b>Body: </b>"); sb.Append(item.Body); return(sb.ToString()); }
public static string ToShortHtml(List <OfficeData> lst) { if (lst.Count == 0) { return("Found nothing"); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < lst.Count; i++) { OfficeData item = lst[i]; sb.Append("<b><a id='-1' href='"); sb.Append(item.FileName); sb.Append("'>"); sb.Append(item.FileName); sb.Append("</a></b><br>"); sb.Append(TruncateAtWord(item.Body)); sb.Append(" <a id="); sb.Append(i.ToString()); sb.Append(" href='0'>"); sb.Append("read more"); sb.Append("</a><br>"); } return(sb.ToString()); }
public bool CheckDocExist(OfficeData officeData) { Lucene.Net.Search.Query query1 = new Lucene.Net.Search.TermQuery(new Lucene.Net.Index.Term("FileName", officeData.FileName)); Lucene.Net.Search.Query query2 = new Lucene.Net.Search.TermQuery(new Lucene.Net.Index.Term("LastWriteTime", officeData.LastWriteTime)); Lucene.Net.Search.BooleanQuery query3 = new Lucene.Net.Search.BooleanQuery(); query3.Add(query1, Lucene.Net.Search.Occur.MUST); query3.Add(query2, Lucene.Net.Search.Occur.MUST); Lucene.Net.Search.TopDocs topDocs = searcher.Search(query3, 2); if (topDocs.TotalHits == 0) { return(false); } return(true); }
public List <OfficeData> Search(Lucene.Net.Search.Query query, int maxResult) { List <OfficeData> results = new List <OfficeData>(); Lucene.Net.Search.ScoreDoc[] hitsFound = searcher.Search(query, maxResult).ScoreDocs; OfficeData data = null; foreach (var hit in hitsFound) { data = new OfficeData(); Document doc = searcher.Doc(hit.Doc); data.Body = doc.Get("Body"); data.LastWriteTime = doc.Get("LastWriteTime"); data.FileName = doc.Get("FileName"); float score = hit.Score; data.Score = score; data.ScoreDocDoc = hit.Doc; //vi tri co the xoa document (IndexReader) results.Add(data); } return(results); }
public TabView(OfficeData officeData) { InitializeComponent(); webBrowser1.DocumentText = MyExt.ToHtml(officeData); }