当前位置: 首页>>代码示例>>C#>>正文


C# ITicketService.ListTickets方法代码示例

本文整理汇总了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);

        }
开发者ID:robkobobko,项目名称:TicketDesk,代码行数:35,代码来源:TicketSearchService.cs

示例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();
            }
        }
开发者ID:robkobobko,项目名称:TicketDesk,代码行数:38,代码来源:TicketSearchService.cs


注:本文中的ITicketService.ListTickets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。