From: <sa...@us...> - 2007-04-30 18:53:14
|
Revision: 359 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=359&view=rev Author: saamand Date: 2007-04-30 11:53:08 -0700 (Mon, 30 Apr 2007) Log Message: ----------- Removed Paths: ------------- trunk/plugins/MyLyrics/LyricsEngine/GetGoogleSearchResult.cs Deleted: trunk/plugins/MyLyrics/LyricsEngine/GetGoogleSearchResult.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/GetGoogleSearchResult.cs 2007-04-30 12:39:13 UTC (rev 358) +++ trunk/plugins/MyLyrics/LyricsEngine/GetGoogleSearchResult.cs 2007-04-30 18:53:08 UTC (rev 359) @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.Remoting.Messaging; -using System.Threading; -using System.Diagnostics; - -namespace LyricsEngine -{ - class GetGoogleSearchResult : IDisposable - { - private LyricSearch_GoogleSites m_LyricSearh; - GetGoogleSearchResultsDelegate delSearch; - IAsyncResult ar; - public static bool Abort = false; - - // Constructor - public GetGoogleSearchResult(LyricSiteInfo siteInfo, LyricSearch_GoogleSites lyricSearch2) - { - Thread.Sleep(1000); - - this.m_LyricSearh = lyricSearch2; - - Google.GoogleSearchService s = new Google.GoogleSearchService(); - Google.GoogleSearchResult searchResult = new Google.GoogleSearchResult(); - - delSearch = new GetGoogleSearchResultsDelegate(GetGoogleSearchResults); - - string[] artistWords = siteInfo.artist.Split(' '); - - string m_lastUsedLicenseKey = m_LyricSearh.GoogleLicenseKey; - - ar = delSearch.BeginInvoke(m_lastUsedLicenseKey, ((!m_LyricSearh.TestedAll) ? "intitle:" + siteInfo.artistWithDoubleQuotes : "intitle:" + artistWords[artistWords.Length - 1]) + " " + "intitle:" + siteInfo.trackWithDoubleQuotes + " " + "intitle:" + siteInfo.extra + " " + siteInfo.siteNameToSearch + " " + "site:" + siteInfo.siteWWW, - 0, siteInfo.noOfHitsUsed, false, "", false, "", "", "", new AsyncCallback(getGoogleSearchResultsCallBack), siteInfo); - - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "GetGoogleSearchResult(" + siteInfo.artist + ", " + siteInfo.track + ", " + siteInfo.siteName + ")"); - } - - public delegate Google.GoogleSearchResult GetGoogleSearchResultsDelegate(string key, string q, int start, int maxResults, bool filter, string restrict, bool safe, string lr, string ie, string oe); - - private Google.GoogleSearchResult GetGoogleSearchResults(string key, string q, int start, int maxResults, bool filter, string restrict, bool safe, string lr, string ie, string oe) - { - - //Thread.CurrentThread.Name = q; - try - { - Google.GoogleSearchService s = new Google.GoogleSearchService(); - return s.doGoogleSearch(key, q, start, maxResults, filter, restrict, safe, lr, ie, oe); - } - catch (System.Net.WebException) - { - return null; - } - catch (System.Web.Services.Protocols.SoapException soapException) - { - //System.Windows.Forms.MessageBox.Show(soapException.ToString()); - m_LyricSearh.stopThreadAndContinue(soapException); - return null; - } - } - - public void Dispose() - { - try - { - ar = null; - //Google.GoogleSearchResult searchResult = delSearch.EndInvoke - delSearch = null; - } - catch (Exception) - { - } - System.Console.WriteLine("*****************************"); - } - - private void getGoogleSearchResultsCallBack(IAsyncResult ar) - { - if (!Abort) - { - AsyncResult result = (AsyncResult)ar; - - // grab the delegate - GetGoogleSearchResultsDelegate del = - (GetGoogleSearchResultsDelegate)result.AsyncDelegate; - - LyricSiteInfo siteInfo = (LyricSiteInfo)ar.AsyncState; - - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "getGoogleSearchResultsCallBack(" + siteInfo.artist + ", " + siteInfo.track + ", " + siteInfo.siteName + ")"); - - Google.GoogleSearchResult searchResult = null; - - // call EndInvoke on the delegate to get all the information about our method call - try - { - searchResult = del.EndInvoke(ar); - - if (searchResult != null) - { - m_LyricSearh.validateSearchResult(searchResult.resultElements, siteInfo); - } - else - { - m_LyricSearh.validateSearchResult(null, siteInfo); - } - } - catch (Exception) - { - } - } - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |