本文整理汇总了C#中ITicketService.ListTickets方法的典型用法代码示例。如果您正苦于以下问题:C# ITicketService.ListTickets方法的具体用法?C# ITicketService.ListTickets怎么用?C# ITicketService.ListTickets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITicketService
的用法示例。
在下文中一共展示了ITicketService.ListTickets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchIndex
public IEnumerable<Ticket> SearchIndex(ITicketService ticketService, string searchText, out string queryTerm)
{
string[] fields = new[] { "title", "details", "tags", "comments" };
MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, fields, TdIndexAnalyzer);
Query query = parser.Parse(searchText);
queryTerm = query.ToString();
TopScoreDocCollector collector = TopScoreDocCollector.create(20, true);
TdIndexSearcher.Search(query, collector);
ScoreDoc[] hits = collector.TopDocs().scoreDocs;
SortedList<int, int> ticketIDs = new SortedList<int, int>();
var o = 0;
foreach (ScoreDoc scoreDoc in hits)
{
//Get the document that represents the search result.
Document document = TdIndexSearcher.Doc(scoreDoc.doc);
int ticketID = int.Parse(document.Get("ticketid"));
//The same document can be returned multiple times within the search results.
if (!ticketIDs.Values.Contains(ticketID))
{
ticketIDs.Add(o, ticketID);
o++;
}
}
return ticketService.ListTickets(ticketIDs, false);
}
示例2: BuildIndex
private void BuildIndex(ITicketService ticketService)
{
lock (buildLock)
{
//index writer will open existing index and merge changes with it
IndexWriter writer = new IndexWriter(TdSearchDirectory, TdIndexAnalyzer, IndexWriter.MaxFieldLength.UNLIMITED);
writer.SetMergeFactor(25);
writer.DeleteAll();
//process tickets in batches of 25
IPagination<Ticket> tickets = null;
var p = 1;
do
{
tickets = ticketService.ListTickets(p, 25, true);
foreach (var ticket in tickets)
{
var doc = CreateIndexDocuementForTicket(ticket);//make the doc
//writer.DeleteDocuments(new Term("ticketid", ticket.TicketId.ToString()));//delete any existing references in the index
//write the document to (or back to) the index
writer.AddDocument(doc);
}
p++;
tickets = (tickets.HasNextPage) ? ticketService.ListTickets(p, 25, true) : null;
} while (tickets != null);
//optimize and close the writer
writer.Commit();
writer.Optimize();
writer.Close();
//close the shared instacnes of the directory and searcher so new searches grab new instances.
ResetTdSearchDirectory();
ResetTdIndexSearcher();
}
}