/// <summary> /// /// </summary> public bool StartSearchResultProcess() { if (this._SearchItem == null || this._SearchItem.searchResult == null) { throw new InvalidOperationException("No search item to process."); } Advertisement.Advertisements _results = null; Stopwatch _stopwatch = new Stopwatch(); _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.ProcessStarting; bool _cancel = false; this.InvokeEventProcessStarting(new Handlers.EventHandlers.ProcessStartingEventArgs(_cancel)); if (!_cancel) { _stopwatch.Reset(); _stopwatch.Start(); _results = this.StartSearchResultProcessCallback(); _stopwatch.Stop(); } _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.ProcessFinished; this.InvokeEventProcessFinished(new Handlers.EventHandlers.ProcessFinishedEventArgs(_results, _stopwatch.Elapsed)); if (_results != null) { this._Advertisements = _results; return(_results.Count > 0); } return(false); }
/// <summary> /// /// </summary> /// <param name="searchItem"></param> /// <param name="seachLocation"></param> /// <returns></returns> public void AnalyzeSearch(string searchItem, string seachLocation) { Handlers.EventHandlers.SearchAnalysisStartingEventArgs _ea = new Handlers.EventHandlers.SearchAnalysisStartingEventArgs(); InvokeEventSearchAnalysisStarting(_ea); if (!_ea.cancel) { _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.SearchAnalysisStarting; new Thread(() => { this.ForceStopSearchAnalysis = false; this._IsBusy = true; string _htmlDoc = string.Empty; bool _resultIsError = false; if (this._SearchItem == null) { this._SearchItem = new SearchItem(); } if (!string.IsNullOrEmpty(searchItem) && !string.IsNullOrEmpty(seachLocation)) { this._SearchItem.searchItem = searchItem; this._SearchItem.searchLocation = seachLocation; } _htmlDoc = this.GenerateSearchResultPageCallback(ref _resultIsError); if (_resultIsError) { throw new Exception(string.Format("The search page generated contains error: {0}", _htmlDoc)); } if (this.ForceStopSearchAnalysis) { return; } if (!string.IsNullOrEmpty(_htmlDoc)) { AnalyzeSearch(_htmlDoc); } }) { IsBackground = true } .Start(); } }
/// <summary> /// /// </summary> /// <param name="htmlDocument"></param> public void AnalyzeSearch(string htmlDocument) { this.ForceStopSearchAnalysis = false; this._IsBusy = true; Stopwatch _stopWatch = new Stopwatch(); _stopWatch.Reset(); _stopWatch.Start(); Models.SearchItem _searchItem = this.AnalyzeSearchCallback(htmlDocument, this.SearchItem); _stopWatch.Stop(); this.SearchItem = _searchItem; _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.SearchAnalysisFinished; this._IsBusy = false; InvokeEventSearchAnalysisFinished(new Handlers.EventHandlers.SearchAnalysisFinishedEventArgs(_searchItem, _stopWatch.Elapsed)); }
/// <summary> /// /// </summary> public bool StartSearchResultProcess() { if(this._SearchItem == null || this._SearchItem.searchResult == null) throw new InvalidOperationException("No search item to process."); Advertisement.Advertisements _results = null; Stopwatch _stopwatch = new Stopwatch(); _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.ProcessStarting; bool _cancel = false; this.InvokeEventProcessStarting(new Handlers.EventHandlers.ProcessStartingEventArgs(_cancel)); if(!_cancel) { _stopwatch.Reset(); _stopwatch.Start(); _results = this.StartSearchResultProcessCallback(); _stopwatch.Stop(); } _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.ProcessFinished; this.InvokeEventProcessFinished(new Handlers.EventHandlers.ProcessFinishedEventArgs(_results, _stopwatch.Elapsed)); if(_results != null) { this._Advertisements = _results; return _results.Count > 0; } return false; }
/// <summary> /// /// </summary> /// <param name="searchItem"></param> /// <param name="seachLocation"></param> /// <returns></returns> public void AnalyzeSearch(string searchItem, string seachLocation) { Handlers.EventHandlers.SearchAnalysisStartingEventArgs _ea = new Handlers.EventHandlers.SearchAnalysisStartingEventArgs(); InvokeEventSearchAnalysisStarting(_ea); if(!_ea.cancel) { _DirectoryProviderRoutineStage = DirectoryProviderRoutineStageEnum.SearchAnalysisStarting; new Thread(() => { this.ForceStopSearchAnalysis = false; this._IsBusy = true; string _htmlDoc = string.Empty; bool _resultIsError = false; if(this._SearchItem == null) this._SearchItem = new SearchItem(); if(!string.IsNullOrEmpty(searchItem) && !string.IsNullOrEmpty(seachLocation)) { this._SearchItem.searchItem = searchItem; this._SearchItem.searchLocation = seachLocation; } _htmlDoc = this.GenerateSearchResultPageCallback(ref _resultIsError); if(_resultIsError) throw new Exception(string.Format("The search page generated contains error: {0}", _htmlDoc)); if(this.ForceStopSearchAnalysis) return; if(!string.IsNullOrEmpty(_htmlDoc)) AnalyzeSearch(_htmlDoc); }) { IsBackground = true } .Start(); } }