Exemple #1
0
        public void SearchKeyword(SearchTransaction searchTransaction)
        {
            queueKeywords = new System.Collections.Queue();

            try
            {
                //pour chaque keyword on lance le search dans un thread séparé
                foreach (Keyword k in searchTransaction.Keywords)
                {
                    KeywordCollection keyword     = null;
                    SearchTransaction searchTrans = null;
                    keyword = new KeywordCollection();
                    keyword.Add(k);
                    searchTrans = new SearchTransaction(searchTransaction.IdTransaction, keyword, searchTransaction.MinFileFromPeerFilter, searchTransaction.IpAcceptRangeCollection);
                    queueKeywords.Enqueue(searchTrans);
                }

                // regrouping of results for this transaction
                // will raise the CompletResultHandler event when we received one results for each keyword
                G2SearchResultRegrouping searchRegrouping = new G2SearchResultRegrouping(searchTransaction, searchTransaction.Keywords.Count, false);
                searchRegrouping.CompletResult += new CompletResultHandler(searchRegrouping_CompletResult);
                searchResultRegroupingKeyword_.Add(searchRegrouping);



                while (queueKeywords.Count > 0)
                {
                    SearchTransaction srchTrans = (SearchTransaction)queueKeywords.Dequeue();

                    G2Log.Write("Starting Transaction - Keyword :" + srchTrans.Keywords[0].KeywordName.ToString());
                    searchManager.NewSearch(srchTrans);

                    // on attends 30sec ?????????????????????????
                    //System.Threading.Thread.Sleep(30000);
                }
            }
            catch
            {
                G2Log.Write("Erreur niveau manager.....");
            }
        }
Exemple #2
0
        /**
         * When results arrive, they are stacked  and regrouped
         * */
        public void SearchKeywordResult(SearchResult searchResult)
        {
            G2SearchResultRegrouping search = null;

            try
            {
                string id = searchResult.SearchTransaction.IdTransaction;
                search = (G2SearchResultRegrouping)searchResultRegroupingKeyword_.Find(searchResult.SearchTransaction.IdTransaction);
                search.AddGlobalResult(searchResult); // Rajoute ces résultats aux résultats globaux
                string word = searchResult.SearchTransaction.Keywords[0].KeywordName;
                G2Log.Write("G2MANAGER : Received results for " + word + " => " + searchResult.PeerCollection.Count
                            + " Peers & " + searchResult.FileCollection.Count + " Files ...");
            }
            catch (Exception ex)
            {
                G2Log.Write("Error AddGlobalResult" + ex.Message, G2Log.ERROR_FILE);
                G2Log.Write("Erreur server_NewResult = " + ex.Message
                            + "\n" + "Erreur server_NewResult, source= " + ex.Source
                            + "\n" + "Erreur server_NewResult, stack= " + ex.StackTrace, G2Log.ERROR_FILE);
            }
        }