/// <summary> /// ListBox의 이벤트 중, Select Index가 변경을 처리하기 위한 이벤트 핸들러 /// </summary> /// <param name="sender">이벤트 발생 객체</param> /// <param name="e">이벤트 아규먼트</param> private void listBoxControl1_SelectedIndexChanged(object sender, EventArgs e) { // ListBox의 선택된 아이템의 Index가 -1 보다 커야 제대로 선택된 것으로 판단한다. if (listBoxControl1.SelectedIndex > -1) { // 현재 선택된 아이템의 Index 값을 표시한다. 다만, 0부터 시작되므로 +1 한다. lblCur.Text = (listBoxControl1.SelectedIndex + 1).ToString(); // ListBox 안의 Info 객체로 꺼내서 DataSourceIndex 값을 가져온다. SearchResultInfo info = (SearchResultInfo)listBoxControl1.Items[listBoxControl1.SelectedIndex]; // 메인 Form의 Grid의 선택을 해주기 위해 DataSourceIndex 값을 담아 이벤트를 발생시킨다. OnRefocusRowRequest?.Invoke(info.DataSourceIndex); } }
private async Task <IList <ArcGISPortalItem> > GetPortalItemsInternal( ItemsRequestedType itemsRequestedType = ItemsRequestedType.Default, SearchParameters searchParameters = null) { IList <ArcGISPortalItem> results = new List <ArcGISPortalItem>(); if (CurrentPortalService.Portal == null || CurrentPortalService.Portal.ArcGISPortalInfo == null) { return(results); } SearchResultInfo <ArcGISPortalItem> items = null; try { switch (itemsRequestedType) { case ItemsRequestedType.Default: if (searchParameters != null) { items = await GetSearchResults(searchParameters); } break; case ItemsRequestedType.Featured: items = await CurrentPortalService.Portal.ArcGISPortalInfo.SearchFeaturedItemsAsync(searchParameters); break; case ItemsRequestedType.Basemaps: items = await CurrentPortalService.Portal.ArcGISPortalInfo.SearchBasemapGalleryAsync(searchParameters); break; } if (items != null) { foreach (ArcGISPortalItem item in items.Results) { results.Add(item); } } return(results); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Reperimento dei documenti per il contesto di paginazione richiesto /// </summary> /// <param name="filters"></param> /// <param name="pagingContext"></param> /// <returns></returns> public InfoDocumento[] GetDocumenti(FiltroRicerca[] filters, PagingContext pagingContext) { InfoDocumento[] documenti = null; int pageCount; int recordCount; // Array degli idProfile dei documenti restituiti dalla ricerca SearchResultInfo[] idProfilesList = new SearchResultInfo[0]; DocsPaWR.InfoUtente infoUtente = UserManager.getInfoUtente(); DocsPaWebService ws = new DocsPaWebService(); documenti = ws.DocumentoGetQueryDocumentoPaging(infoUtente.idGruppo, infoUtente.idPeople, new FiltroRicerca[1][] { filters }, false, false, pagingContext.PageNumber, true, false, out pageCount, out recordCount, out idProfilesList); if (documenti == null) { documenti = new DocsPAWA.DocsPaWR.InfoDocumento[0]; } pagingContext.PageCount = pageCount; pagingContext.RecordCount = recordCount; if (idProfilesList != null) { // Salavtaggio della lista di idProfile dei documenti individuati pagingContext.IdProfilesList = new string[idProfilesList.Length]; for (int i = 0; i < idProfilesList.Length; i++) { pagingContext.IdProfilesList[i] = idProfilesList[i].Id; } } return(documenti); }
/// <summary> /// 设置搜索 /// </summary> /// <param name="model"></param> /// <param name="result"></param> protected virtual void SetSearchView(GoodsListModel model, SearchResultInfo result) { ViewBag.SearchKey = model.SearchKey; if (result == null || result.Words == null || result.Words.Count == 0) { return; } var names = result.Words.Select(it => it.Name).ToArray(); var query = new QueryInfo(); query.SetCacheTime(DateTime.Now.AddDays(1)).SetPageIndex(0).SetPageSize(5).Query <SimilarEntity>().Where(it => names.Contains(it.Word.Name)).OrderByDescending(it => it.Count); var infos = this.GetEntities <SimilarEntity>(query); if (infos != null) { ViewBag.HotKeys = infos.Select(it => it.Name).ToList(); } }
/// <summary> /// 填充数据 /// </summary> /// <param name="model"></param> /// <param name="result"></param> protected virtual void FillSearchGoods(GoodsListModel model, SearchResultInfo result) { if (result == null || result.Documents == null) { return; } var ids = new List <long>(); var documents = result.Documents.Skip(model.PageIndex * model.PageSize).Take(model.PageSize); foreach (var document in documents) { ids.Add(document.Feilds[0].Text.Convert <long>()); } model.GoodsList = Ioc.Resolve <IGoodsApplicationService>().GetGoodsByCache(ids.ToArray()); if (model.ExistSearchProperties != null) { foreach (var esp in model.ExistSearchProperties) { if (esp.Name.Contains("价格")) { var values = esp.Value.Split('-'); if (values.Length != 2) { continue; } model.GoodsList = model.GoodsList.Where(it => it.GoodsProperties != null && it.GoodsProperties.Count(s => s.Id == esp.Id && s.Value.Convert <decimal>() >= values[0].Convert <decimal>() && s.Value.Convert <decimal>() <= values[1].Convert <decimal>()) > 0) .ToList(); } else { model.GoodsList = model.GoodsList.Where(it => it.GoodsProperties != null && it.GoodsProperties.Count(s => s.Id == esp.Id && s.Value.Contains(esp.Value)) > 0) .ToList(); } } } var dataCount = result.Documents.Count; model.DataCount = dataCount > int.MaxValue ? int.MaxValue : dataCount; OrderbySearchGoods(model); }
/// <summary> /// Fonction de mise à jour de la liste des cartes /// </summary> /// <param name="query"></param> private async void updateList(string query) { // Creation des parametres de recherche SearchParameters searchParameters = new SearchParameters(query); //searchParameters.SortField = "modified"; searchParameters.SortField = "numviews"; searchParameters.SortOrder = QuerySortOrder.Descending; // Lancement de la recherche sur le portal. SearchResultInfo <ArcGISPortalItem> resultItems = await portal.SearchItemsAsync(searchParameters); // Conversion en liste List <ArcGISPortalItem> itemList = resultItems.Results.ToList(); // On assigne les resultats à notre liste coté ihm. webmapsList.ItemsSource = itemList; }
private void SelectAndClose() { if (_resultCount > 0) { SearchResultInfo searchResult = _results[_selectedResult].Tag as SearchResultInfo; if (!searchResult.Disabled) { Destination = new GoToDestination() { AbsoluteAddress = searchResult.AbsoluteAddress, RelativeAddress = searchResult.RelativeAddress, Label = searchResult.CodeLabel, File = searchResult.File, SourceLocation = searchResult.SourceLocation }; DialogResult = DialogResult.OK; Close(); } } }
void hubConnection_Update(object sender, FlowLib.Events.FmdcEventArgs e) { Hub hub = sender as Hub; if (hub == null) { return; } switch (e.Action) { case Actions.SearchResult: if (e.Data is SearchResultInfo) { SearchResultInfo srInfo = (SearchResultInfo)e.Data; // This is if we want to enable auto adding of sources to a downloaditem. //FlowLib.Managers.DownloadManager dm = new FlowLib.Managers.DownloadManager(); //DownloadItem tmpDownloadItem = new DownloadItem(srInfo.Info); //// Do downloadItem exist? //if (dm.ContainsDownload(tmpDownloadItem)) //{ // // Add Source to the existing downloaditem. Note that we first check if it exist. // dm.AddDownload(tmpDownloadItem, srInfo.Source); //} } break; case Actions.UserOnline: bool hasMe = (hub.GetUserById(hub.Me.ID) != null); if (!sentRequest && hasMe) { // Send Search SearchInfo searchInfo = new SearchInfo(); searchInfo.Set(SearchInfo.SEARCH, "Ubuntu"); //searchInfo.Set(SearchInfo.SIZE, "1000"); //searchInfo.Set(SearchInfo.SIZETYPE, "1"); UpdateBase(this, new FlowLib.Events.FmdcEventArgs(Actions.Search, searchInfo)); sentRequest = true; } break; } }
void FixSearchResultAndList(string searchName, List <AtlasInfoForSearchSprite> atlasInfoTbl) { if (null == atlasInfoTbl) { return; } ListViewCtrl searchList = _GetControl <ListViewCtrl>(m_SearchResultListName); if (null == searchList) { return; } searchList.ClearItems(); m_SearchResultInfo = new SearchResultInfo(); m_SearchResultInfo.SearchName = searchName; m_SearchResultInfo.SearchSpriteInfo = new List <SearchSpriteInfo>(); for (int index = 0; index < atlasInfoTbl.Count; index++) { foreach (var item in atlasInfoTbl[index].SpriteInfo) { SearchSpriteInfo newInfo = new SearchSpriteInfo(); newInfo.AtlasPath = atlasInfoTbl[index].AtlasPath; newInfo.AtlasTexture = atlasInfoTbl[index].AtlasTexture; newInfo.SpriteName = item.Key; newInfo.SpriteRect = item.Value; m_SearchResultInfo.SearchSpriteInfo.Add(newInfo); ListCtrlItem newItem = new ListCtrlItem(); newItem.name = item.Key + " " + newInfo.AtlasPath; newItem.color = Color.white; newItem.onSelectColor = Color.blue; searchList.AddItem(newItem); } } }
private async Task <IEnumerable <object> > GetPortalItemsAsync(SearchParameters sp) { NoResults = false; // since GetPortalItemsAsync is called subsequently by the incremental loading collection, // always make sure the search text is valid. if (!IsSearchQueryValid(SearchQuery)) { NoResults = true; _totalHits = 0; return(null); } var ps = PortalService.CurrentPortalService; if (PortalService.CurrentPortalService == null) { return(null); } IsLoadingData = true; SearchResultInfo <ArcGISPortalItem> r = await ps.GetSearchResults(sp); IsLoadingData = false; // set NoResults each time to avoid false intermediate setting of // this depedency property if (r == null || r.TotalCount == 0) { NoResults = true; _totalHits = 0; return(null); } _totalHits = r.TotalCount; return(r.Results); }
private void SelectAndClose() { if (_resultCount > 0) { SearchResultInfo searchResult = _results[_selectedResult].Tag as SearchResultInfo; if (!searchResult.Disabled) { AddressTypeInfo addressInfo = new AddressTypeInfo() { Address = searchResult.AbsoluteAddress, Type = searchResult.MemoryType }; Destination = new GoToDestination() { AddressInfo = addressInfo, CpuAddress = addressInfo.Address >= 0 ? InteropEmu.DebugGetRelativeAddress((UInt32)addressInfo.Address, addressInfo.Type) : -1, Label = searchResult.CodeLabel, File = searchResult.Filename, Line = searchResult.FileLineNumber }; DialogResult = DialogResult.OK; Close(); } } }
private async Task <IEnumerable <ArcGISPortalItem> > GetMyMapsAsync() { var ps = PortalService.CurrentPortalService; if (PortalService.CurrentPortalService.CurrentUser == null) { return(null); } // modify query string to get the maps owned by the current user SearchParameters searchParam = SearchService.CreateSearchParameters("", PortalQuery.MyMaps, 1, 100); searchParam.QueryString = string.Format(" ({0}) AND (owner: {1}) ", searchParam.QueryString, ps.CurrentUser.UserName); IsLoadingData = true; SearchResultInfo <ArcGISPortalItem> r = await ps.GetSearchResults(searchParam); IsLoadingData = false; if (r == null) { return(null); } return(r.Results); }
// Raised when the asynchronous call to search the ArcGIS Portal has completed. private void SearchItemsCompleted(SearchResultInfo <ArcGISPortalItem> result, Exception ex) { if (ex != null) // Error occurred { IsSearching = false; // Reset busy state OnSearchFailed(ex); // Fire failed event return; } if (_cancelled) // search was cancelled { _cancelled = false; return; } if (!_pageChangeSearch) // Result of a new search { // Add and initialize results foreach (ArcGISPortalItem item in result.Results) { SearchResultViewModel viewModel = new SearchResultViewModel(item) { ProxyUrl = this.UseProxy ? this.ProxyUrl : null }; _results.Add(viewModel); viewModel.Initialize(); } // Add empty results for each of the pages not yet returned for (int i = 0; i < result.TotalCount - _pageSize; i++) { SearchResultViewModel viewModel = new SearchResultViewModel() { ProxyUrl = this.UseProxy ? this.ProxyUrl : null }; _results.Add(viewModel); } OnSearchCompleted(); // Fire completed event } else // Result of a search initiated by a page change { // index in the entire collection of the first result on the current page int i = _searchStartIndex - 1; foreach (ArcGISPortalItem item in result.Results) { // Update the empty result corresponding to the return portal item SearchResultViewModel viewModel = _results[i]; viewModel.Result = item; viewModel.Initialize(); i++; } // Execute the requested page change PagedResults.MoveToPage(_pagesRetrieved[_pagesRetrieved.Count - 1]); // Reset flag _pageChangeSearch = false; } IsSearching = false; // Reset busy state }
private int AddPartialResults(IsoFinderEntities entities, Func <IsoFolder, bool> searchExpression, SearchResultInfo <FolderSearchResult> searchResults, int skip, int pageSize) { var total = entities.IsoFolders.Count(searchExpression); var results = entities.IsoFolders.Where(searchExpression).OrderBy(f => f.Name).Skip(skip).Take(pageSize).ToList(); foreach (var isoFolder in results) { searchResults.Results.Add(new FolderSearchResult { Id = isoFolder.Id, Name = isoFolder.Name, IsoId = isoFolder.IsoId, ParentFolderId = isoFolder.ParentFolderId.Value }); } return(total); }
/// <summary> /// 重写 /// </summary> /// <param name="storeIndex"></param> /// <param name="searchQuery"></param> /// <param name="result"></param> /// <param name="documentIds"></param> protected override void AddSearchDocuments(StoreIndexInfo storeIndex, SearchQueryInfo searchQuery, SearchResultInfo result, IList <long> documentIds) { if (searchQuery.Conditions != null && searchQuery.Conditions.Count(it => _keys.Contains(it.Key)) > 0) { return; } base.AddSearchDocuments(storeIndex, searchQuery, result, documentIds); }
public SearchResultInfoEventArgs(Node node, SearchResultInfo info) : base() { Node = node; Info = info; }
private void Protocol_Update(object sender, FmdcEventArgs e) { switch (e.Action) { case Actions.MainMessage: { MainMessage zprava = e.Data as MainMessage; if (zprava.Content.StartsWith(HandlerPrikazu.PrikazPrefix) && zprava.Content.Length > 1) { ThreadPool.QueueUserWorkItem(m_ThreadPoolCallback, new ArgumentyHandleru(zprava.Content.Remove(0, 1).Trim(), zprava.From, this)); } #if DEBUG if (zprava.From == "AdminChar" || zprava.From == "VerliHub") { m_Gui.VypisRadek(zprava.Content); } #endif break; } case Actions.PrivateMessage: { PrivateMessage zprava = e.Data as PrivateMessage; if (zprava.From == m_Hub.HubSetting.DisplayName) //tohle je od novй verze 4 FlowLibu nutnй protoЮe on si posнlб jakoby vlastnн PMka { break; } string text = zprava.Content.Replace(string.Format("<{0}> ", zprava.From), ""); if (text.StartsWith(HandlerPrikazu.PrikazPrefix) && text.Length > 1) { ThreadPool.QueueUserWorkItem(m_ThreadPoolCallback, new ArgumentyHandleru(text.Remove(0, 1).Trim(), zprava.From, this)); } else if (zprava.From != "AdminChar" && zprava.From != "VerliHub") { PrivateZprava(zprava.From, string.Concat("Jsem jen tupэ bot. Pro seznam pшнkazщ napiЪ ", HandlerPrikazu.PrikazPrefix, "help")); } #if DEBUG if (zprava.From == "AdminChar" || zprava.From == "VerliHub") { m_Gui.VypisRadek(text); } #endif break; } case Actions.SearchResult: case Actions.Search: { m_Gui.VypisRadek("SEARCH"); if (e.Data is SearchInfo) { SearchInfo info = e.Data as SearchInfo; } if (e.Data is SearchResultInfo) { SearchResultInfo info = e.Data as SearchResultInfo; } break; } case Actions.TransferStarted: Transfer trans = e.Data as Transfer; if (trans != null) { //m_Gui.VypisRadek(trans.RemoteAddress.Address.ToString()); m_TransferManager.StartTransfer(trans); } break; } }
/// <summary> /// 过滤条件 /// </summary> /// <param name="documentIds"></param> /// <param name="storeIndex"></param> /// <param name="result"></param> /// <param name="searchQuery"></param> protected virtual void FilterDocuments(IList <long> documentIds, StoreIndexInfo storeIndex, SearchResultInfo result, SearchQueryInfo searchQuery) { foreach (var documentId in documentIds) { var document = Documentor.GetInfo(storeIndex, documentId); if (document == null || document.Feilds == null) { continue; } if (searchQuery.Conditions.ContainsKey("IsCustom") && document.Feilds.Count > 6 && !document.Feilds[6].Text.Convert <bool>() != searchQuery.Conditions["IsCustom"].Convert <bool>()) { continue; } if (searchQuery.Conditions.ContainsKey("StartCost") && document.Feilds.Count > 4 && document.Feilds[4].Text.Convert <decimal>() < searchQuery.Conditions["StartCost"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("EndCost") && document.Feilds.Count > 4 && document.Feilds[4].Text.Convert <decimal>() > searchQuery.Conditions["EndCost"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("StartPrice") && document.Feilds.Count > 5 && document.Feilds[5].Text.Convert <decimal>() < searchQuery.Conditions["StartPrice"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("EndPrice") && document.Feilds.Count > 5 && document.Feilds[5].Text.Convert <decimal>() > searchQuery.Conditions["EndPrice"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("Sku") && document.Feilds.Count > 3 && !string.IsNullOrEmpty(document.Feilds[3].Text)) { var texts = searchQuery.Conditions["Sku"].ToString().Split(','); var values = document.Feilds[3].Text.Split(','); var rev = texts.All(text => CheckValue(values, text)); if (rev) { continue; } } result.Documents.Add(document); } }
public SearchResultInfoEventArgs(Node node, SearchResultInfo info) { this.node = node; this.info = info; }
/// <summary> /// 排序 /// </summary> /// <param name="documentIds"></param> /// <param name="storeIndex"></param> /// <param name="result"></param> /// <param name="searchQuery"></param> protected virtual void OrderbyDocuments(IList <long> documentIds, StoreIndexInfo storeIndex, SearchResultInfo result, SearchQueryInfo searchQuery) { if (searchQuery.Conditions.ContainsKey("Seqence")) { switch (searchQuery.Conditions["Seqence"].ToString()) { case "costasc": if (searchQuery.PageSize > 0) { result.Documents = result.Documents.OrderBy(it => it.Feilds[4].Text.Convert <decimal>()) .Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } else { result.Documents = result.Documents.OrderBy(it => it.Feilds[4].Text.Convert <decimal>()).ToList(); } break; case "costdesc": if (searchQuery.PageSize > 0) { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[4].Text.Convert <decimal>()) .Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } else { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[4].Text.Convert <decimal>()).ToList(); } break; case "prasc": if (searchQuery.PageSize > 0) { result.Documents = result.Documents.OrderBy(it => it.Feilds[5].Text.Convert <decimal>()) .Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } else { result.Documents = result.Documents.OrderBy(it => it.Feilds[5].Text.Convert <decimal>()).ToList(); } break; case "prdesc": if (searchQuery.PageSize > 0) { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[5].Text.Convert <decimal>()) .Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } else { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[5].Text.Convert <decimal>()).ToList(); } break; case "ptdesc": if (searchQuery.PageSize > 0) { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[7].Text.Convert <DateTime>()) .Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } else { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[7].Text.Convert <DateTime>()).ToList(); } break; case "scasc": if (searchQuery.PageSize > 0) { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[8].Text.Convert <int>()) .Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } else { result.Documents = result.Documents.OrderByDescending(it => it.Feilds[8].Text.Convert <int>()).ToList(); } break; } } else if (searchQuery.PageSize > 0) { result.Documents = result.Documents.Skip(searchQuery.PageIndex * searchQuery.PageSize) .Take(searchQuery.PageSize) .ToList(); } }
private int AddPartialResults(GenericRepository <IsoFile> isoFileRepository, Expression <Func <IsoFile, bool> > searchExpression, SearchResultInfo <FileSearchResult> searchResults, int skip, int pageSize) { var results = isoFileRepository.SearchPaged(q => q.OrderBy(p => p.Name), skip, pageSize, searchExpression); var total = results.TotalCount; foreach (var isoFile in results.Items) { searchResults.Results.Add(new FileSearchResult { Id = isoFile.Id, FolderId = isoFile.FolderId, Name = isoFile.Name, Created = isoFile.Created, Extension = isoFile.Extension, Modified = isoFile.Modified, Path = isoFile.Path, Size = isoFile.Size, IsoVolumeLabel = isoFile.IsoFolder.IsoVolume.VolumeLabel }); } return(total); }
internal void ProcessSearchResultMessage(Node messageFrom, SearchResultInfo result) { network.RaiseReceivedSearchResult(messageFrom, result); }
// Raised when the asynchronous call to search the ArcGIS Portal has completed. private void SearchItemsCompleted(SearchResultInfo<ArcGISPortalItem> result, Exception ex) { if (ex != null) // Error occurred { IsSearching = false; // Reset busy state OnSearchFailed(ex); // Fire failed event return; } if (_cancelled) // search was cancelled { _cancelled = false; return; } if (!_pageChangeSearch) // Result of a new search { // Add and initialize results foreach (ArcGISPortalItem item in result.Results) { SearchResultViewModel viewModel = new SearchResultViewModel(item) { ProxyUrl = this.UseProxy ? this.ProxyUrl : null }; _results.Add(viewModel); viewModel.Initialize(); } // Add empty results for each of the pages not yet returned for (int i = 0; i < result.TotalCount - _pageSize; i++) { SearchResultViewModel viewModel = new SearchResultViewModel() { ProxyUrl = this.UseProxy ? this.ProxyUrl : null }; _results.Add(viewModel); } OnSearchCompleted(); // Fire completed event } else // Result of a search initiated by a page change { // index in the entire collection of the first result on the current page int i = _searchStartIndex - 1; foreach (ArcGISPortalItem item in result.Results) { // Update the empty result corresponding to the return portal item SearchResultViewModel viewModel = _results[i]; viewModel.Result = item; viewModel.Initialize(); i++; } // Execute the requested page change PagedResults.MoveToPage(_pagesRetrieved[_pagesRetrieved.Count - 1]); // Reset flag _pageChangeSearch = false; } IsSearching = false; // Reset busy state }
/// <summary> /// 得到搜索编号 /// </summary> /// <param name="storeIndex"></param> /// <param name="result"></param> /// <param name="searchQuery"></param> /// <returns></returns> protected override IList <long> GetSearchDocumentIds(StoreIndexInfo storeIndex, SearchResultInfo result, SearchQueryInfo searchQuery) { var documentIds = base.GetSearchDocumentIds(storeIndex, result, searchQuery); if (documentIds != null && searchQuery.Conditions != null && searchQuery.Conditions.Count(it => _keys.Contains(it.Key)) > 0) { FilterDocuments(documentIds, storeIndex, result, searchQuery); OrderbyDocuments(documentIds, storeIndex, result, searchQuery); if (result.Documents != null) { return(result.Documents.Select(it => it.Id).ToList()); } } return(documentIds); }
public void ActOnInMessage(IConMessage comMsg) { HubMessage message = (HubMessage)comMsg; if (message is MainChat) { MainChat main = (MainChat)message; MainMessage msg = new MainMessage(main.From, main.Content); Update(hub, new FmdcEventArgs(Actions.MainMessage, msg)); } else if (message is To) { To to = (To)message; PrivateMessage pm = new PrivateMessage(to.To, to.From, to.Content); Update(hub, new FmdcEventArgs(Actions.PrivateMessage, pm)); } else if (message is SR) { SR searchResult = (SR)message; SearchResultInfo srinfo = new SearchResultInfo(searchResult.Info, searchResult.From); Update(hub, new FmdcEventArgs(Actions.SearchResult, srinfo)); } else if (message is Search) { Search search = (Search)message; if (hub.Share == null) { return; } int maxReturns = 5; bool active = false; if (search.Address != null) { maxReturns = 10; active = true; } System.Collections.Generic.List <ContentInfo> ret = new System.Collections.Generic.List <ContentInfo>(maxReturns); // TODO : This lookup can be done nicer lock (hub.Share) { foreach (System.Collections.Generic.KeyValuePair <string, Containers.ContentInfo> var in hub.Share) { if (var.Value == null) { continue; } bool foundEnough = false; string ext = search.Info.Get(SearchInfo.EXTENTION); string sch = search.Info.Get(SearchInfo.SEARCH); if (ext != null && sch != null) { ContentInfo contentInfo = new ContentInfo(); if (search.Info.ContainsKey(SearchInfo.TYPE)) { switch (search.Info.Get(SearchInfo.TYPE)) { case "2": contentInfo.Set(ContentInfo.TTH, search.Info.Get(SearchInfo.SEARCH)); if (hub.Share.ContainsContent(ref contentInfo)) { ret.Add(contentInfo); } // We are looking through whole share here. // If no TTH matching. Ignore. foundEnough = true; break; case "1": default: if (var.Value.ContainsKey(ContentInfo.VIRTUAL) && (System.IO.Path.GetDirectoryName(var.Value.Get(ContentInfo.VIRTUAL)).IndexOf(sch, System.StringComparison.OrdinalIgnoreCase) != -1)) { ret.Add(var.Value); } break; } } if (!foundEnough) { string infoExt = System.IO.Path.GetExtension(var.Value.Get(ContentInfo.VIRTUAL)).TrimStart('.'); if ( var.Value.ContainsKey(ContentInfo.VIRTUAL) && (var.Value.Get(ContentInfo.VIRTUAL).IndexOf(sch, System.StringComparison.OrdinalIgnoreCase) != -1) && (ext.Length == 0 || ext.Contains(infoExt)) ) { ret.Add(var.Value); } } } if (foundEnough || ret.Count >= maxReturns) { break; } } } // Test against size restrictions for (int i = 0; i < ret.Count; i++) { bool send = true; long size = -1; try { size = int.Parse(search.Info.Get(SearchInfo.SIZE)); } catch { } if (search.Info.ContainsKey(SearchInfo.SIZETYPE) && size != -1) { switch (search.Info.Get(SearchInfo.SIZETYPE)) { case "1": // Min Size send = (size <= ret[i].Size); break; case "2": // Max Size send = (size >= ret[i].Size); break; case "3": // Equal Size send = (size == ret[i].Size); break; } } // Should this be sent? if (send) { SR sr = new SR(hub, ret[i], (search.Info.ContainsKey(SearchInfo.EXTENTION) ? search.Info.Get(SearchInfo.EXTENTION).Equals("$0") : false), search.From); if (active) { // Send with UDP UdpConnection.Send(sr, search.Address); } else { // Send through hub hub.Send(sr); } } } } else if (message is Lock) { hub.Send(new Supports(hub)); hub.Send(new Key(hub, ((Lock)message).Key)); hub.Send(new ValidateNick(hub)); } else if (message is HubNmdc.HubName) { HubNmdc.HubName hubname = (HubNmdc.HubName)message; Containers.HubName name = null; if (hubname.Topic != null) { name = new Containers.HubName(hubname.Name, hubname.Topic); } else { name = new Containers.HubName(hubname.Content); } Update(hub, new FmdcEventArgs(Actions.Name, name)); } else if (message is NickList) { NickList nicks = (NickList)message; foreach (string userid in nicks.List) { UserInfo userInfo = new UserInfo(); userInfo.DisplayName = userid; userInfo.Set(UserInfo.STOREID, hub.HubSetting.Address + hub.HubSetting.Port.ToString() + userid); if (hub.GetUserById(userid) == null) { Update(hub, new FmdcEventArgs(Actions.UserOnline, userInfo)); } } } else if (message is OpList) { OpList ops = (OpList)message; foreach (string userid in ops.List) { UserInfo userInfo = new UserInfo(); userInfo.DisplayName = userid; userInfo.Set(UserInfo.STOREID, hub.HubSetting.Address + hub.HubSetting.Port.ToString() + userid); userInfo.IsOperator = true; User usr = null; if ((usr = hub.GetUserById(userid)) == null) { Update(hub, new FmdcEventArgs(Actions.UserOnline, userInfo)); } else { usr.UserInfo = userInfo; Update(hub, new FmdcEventArgs(Actions.UserInfoChange, usr.UserInfo)); } } } else if (message is Quit) { Quit quit = (Quit)message; User usr = null; if ((usr = hub.GetUserById(quit.From)) != null) { Update(hub, new FmdcEventArgs(Actions.UserOffline, usr.UserInfo)); } } else if (message is LogedIn) { hub.RegMode = 2; } else if (message is ValidateDenide) { Update(hub, new FmdcEventArgs(Actions.StatusChange, new HubStatus(HubStatus.Codes.Disconnected))); } else if (message is GetPass) { hub.RegMode = 1; if (hub.HubSetting.Password.Length == 0) { Update(hub, new FmdcEventArgs(Actions.Password, null)); } else { hub.Send(new MyPass(hub)); } } else if (message is MyINFO) { MyINFO myinfo = (MyINFO)message; User usr = null; if ((usr = hub.GetUserById(message.From)) == null) { Update(hub, new FmdcEventArgs(Actions.UserOnline, myinfo.UserInfo)); } else { bool op = usr.IsOperator; usr.UserInfo = myinfo.UserInfo; usr.UserInfo.IsOperator = op; Update(hub, new FmdcEventArgs(Actions.UserInfoChange, usr.UserInfo)); } } else if (message is Hello) { if (hub.HubSetting.DisplayName.Equals(message.From)) { hub.Send(new Version(hub)); hub.Send(new GetNickList(hub)); if (hub.RegMode < 0) { hub.RegMode = 0; } UpdateMyInfo(); } } else if (message is ConnectToMe) { ConnectToMe conToMe = (ConnectToMe)message; Transfer trans = new Transfer(conToMe.Address, conToMe.Port); trans.Share = this.hub.Share; trans.Me = hub.Me; trans.Source = new Source(hub.RemoteAddress.ToString(), null); // Protocol has to be set last. trans.Protocol = new TransferNmdcProtocol(trans); #if !COMPACT_FRAMEWORK if (conToMe.TLS && hub.Me.ContainsKey(UserInfo.SECURE)) { trans.SecureProtocol = SecureProtocols.TLS; } #endif Update(hub, new FmdcEventArgs(Actions.TransferStarted, trans)); } else if (message is RevConnectToMe) { RevConnectToMe revConToMe = (RevConnectToMe)message; User usr = null; usr = hub.GetUserById(revConToMe.From); if (hub.Me.Mode == FlowLib.Enums.ConnectionTypes.Passive) { if (usr != null) { // If user are not set as passive. Set it as it and respond with a revconnect. if (usr.UserInfo.Mode != FlowLib.Enums.ConnectionTypes.Passive) { usr.UserInfo.Mode = FlowLib.Enums.ConnectionTypes.Passive; hub.Send(new RevConnectToMe(revConToMe.From, hub)); } } } else { if (usr != null) { Update(hub, new FmdcEventArgs(Actions.TransferRequest, new TransferRequest(usr.ID, hub, usr.UserInfo))); #if !COMPACT_FRAMEWORK // Security, Windows Mobile doesnt support SSLStream so we disable this feature for it. if ( usr.UserInfo.ContainsKey(UserInfo.SECURE) && hub.Me.ContainsKey(UserInfo.SECURE) && !string.IsNullOrEmpty(hub.Me.Get(UserInfo.SECURE)) ) { hub.Send(new ConnectToMe(usr.ID, hub.Share.Port, hub, SecureProtocols.TLS)); } else #endif hub.Send(new ConnectToMe(usr.ID, hub.Share.Port, hub)); } } } else if (message is ForceMove) { ForceMove forceMove = (ForceMove)message; hub.Disconnect(); Update(hub, new FmdcEventArgs(Actions.Redirect, new RedirectInfo(forceMove.Address))); } }
public List <SearchResultInfo> Search(string searchText, string searchDir, bool recursive, bool ignoreCase, bool returnMany, string zipFileExt) { try { //String strDir = txtDir.Text; string strDir = searchDir; //Check First if the Selected Directory exists if (!Directory.Exists(strDir)) { return(null); } else { //Initialize the Flags bool bRecursive = recursive; bool bIgnoreCase = ignoreCase; //File Extension String strExt = "*.txt";//txtFiles.Text; //First empty the list m_arrFiles.Clear(); //Create recursively a list with all the files complying with the criteria String[] astrExt = strExt.Split(new Char[] { ',' }); for (int i = 0; i < astrExt.Length; i++) { //Eliminate white spaces astrExt[i] = astrExt[i].Trim(); GetFiles(strDir, astrExt[i], bRecursive); } //Now all the Files are in the ArrayList, open each one //iteratively and look for the search string string[] strSearch = searchText.Split(new string[] { "\r\n" }, StringSplitOptions.None); List <SearchResultInfo> finalResults = new List <SearchResultInfo>(); //ArrayList strFinalResults = new ArrayList(); ArrayList strResults = new ArrayList(); String strLine; int iLine, iCount; bool bEmpty = true; for (int i = 0; i < strSearch.Length; i++) { // Create new searchResult object //SearchResultInfo searchResult = new SearchResultInfo(); IEnumerator enm = m_arrFiles.GetEnumerator(); while (enm.MoveNext()) { try { StreamReader sr = File.OpenText((string)enm.Current); iLine = 0; iCount = 0; bool bFirst = true; while ((strLine = sr.ReadLine()) != null) { iLine++; //Using Regular Expressions as a real Grep Match mtch; if (bIgnoreCase == true) { mtch = Regex.Match(strLine, strSearch[i], RegexOptions.IgnoreCase); } else { mtch = Regex.Match(strLine, strSearch[i]); } if (mtch.Success == true) { bEmpty = false; iCount++; if (bFirst == true) { //if (bJustFiles == true) //{ //searchResult.SearchTerm = strSearch[i]; strResults.Add((string)enm.Current); //break; //} //else // strResults.Add((string)enm.Current); bFirst = false; } } } sr.Close(); } catch (SecurityException) { //strResults += "\r\n" + (string)enm.Current + ": Security Exception\r\n\r\n"; } catch (FileNotFoundException) { //strResults += "\r\n" + (string)enm.Current + ": File Not Found Exception\r\n"; } } if (bEmpty == true) { //SetText("No matches found"); return(null); } else { //ArrayList strFinalResults = new ArrayList(); bool hasSearchItemFound = false; strResults.Reverse(); // Search to see if the backup file exists. If not, remove from the list foreach (string s in strResults) { if (hasSearchItemFound) { break; } else { string backupFileName = s.Replace(".txt", zipFileExt); if (!File.Exists(backupFileName)) { continue; } else { FileInfo zipFile = new FileInfo(backupFileName); SearchResultInfo searchResult = new SearchResultInfo(zipFile, strSearch[i]); // hasSearchItem will break the loop if an item has been found - this is only needed if we want to return 1 result // if a list of files needs to be returned for the user to see, then do not set hasSearchItemFound to true to break the loop if (!returnMany) { hasSearchItemFound = true; searchResult.Selected = true; // if we only want 1 item to be returned, then we are going to download automatically } finalResults.Add(searchResult); } } } } } //return strFinalResults; //finalResults = finalResults.OrderBy(o => o.SearchTerm).ThenBy(o => o.CreationTime).ToList(); return(finalResults.OrderBy(o => o.SearchTerm).ThenBy(o => o.CreationTime).ToList()); } } finally { //m_searchthread = null; //if (Cursor == Cursors.WaitCursor) // Cursor = Cursors.Arrow; } }