public async Task Search() { if (string.IsNullOrWhiteSpace(SearchText)) { IsBrowseVisible = true; SearchResultsVisible = false; return; } var request = new Model.Requests.SearchRequest { SearchString = SearchText }; var list = await _serviceSearch.Get <List <Model.SearchResult> >(request); SearchResultList.Clear(); SearchResultsVisible = true; IsBrowseVisible = false; if (list.Count != 0) { foreach (var item in list) { SearchResultList.Add(item); } } else { SearchResultList.Add(new Model.SearchResult { ResultText = "No results found." }); } }
/// <summary> /// 検索結果を更新する /// </summary> /// <param name="playlists"></param> public void Update(IEnumerable <Channel> channels) { SearchResultList.Clear(); foreach (var channel in channels) { SearchResultList.Add(new ChannelViewModel(channel, m_WebClientService)); } }
/// <summary> /// 検索結果を更新する /// </summary> /// <param name="playlists"></param> public void Update(IEnumerable <Playlist> playlists) { SearchResultList.Clear(); foreach (var playlist in playlists) { SearchResultList.Add(new PlaylistViewModel(playlist, m_WebClientService)); } }
/// <summary> /// 検索結果を更新する /// </summary> /// <param name="videos"></param> public void Update(IEnumerable <Video> videos) { SearchResultList.Clear(); foreach (var video in videos) { SearchResultList.Add(new VideoViewModel(video, m_WebClientService)); } }
private void Search() { if (IsSearching) { return; } IsSearching = true; SynchronizationContext UIContext = SynchronizationContext.Current; SearchResultList.Clear(); new Thread(() => { string FFUURL = null; string[] EmergencyURLs = null; try { string TempProductType = ProductType.ToUpper(); if ((TempProductType != null) && TempProductType.StartsWith("RM") && !TempProductType.StartsWith("RM-")) { TempProductType = "RM-" + TempProductType.Substring(2); } ProductType = TempProductType; FFUURL = LumiaDownloadModel.SearchFFU(ProductType, ProductCode, OperatorCode, out TempProductType); if (TempProductType != null) { ProductType = TempProductType; } if (ProductType != null) { EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType); } } catch { } UIContext.Post(s => { if (FFUURL != null) { SearchResultList.Add(new SearchResult(FFUURL, ProductType, FFUDownloaded, null)); } if (EmergencyURLs != null) { SearchResultList.Add(new SearchResult(ProductType + " emergency-files", EmergencyURLs, ProductType, EmergencyDownloaded, ProductType)); } }, null); IsSearching = false; }).Start(); }
/// <summary> /// 過去トラ観たか情報検索(所有) /// </summary> public void searchMitakaDataMine() { // 管理番号リスト取得(所有) DataTable manageNoList = _DbMitakaData.getManageNoFromRelationUser(); // 管理番号でループ for (int i = 0; i < manageNoList.Rows.Count; i++) { // 過去トラ観たか情報インスタンス定義(引数に管理番号、ユーザーIDをセット) MitakaData mitakaData = new MitakaData((string)manageNoList.Rows[i]["MITAKA_NO"], _Owner); // 検索結果フィールドに過去トラ観たか情報インスタンスを追加 SearchResultList.Add(mitakaData); } }
/// <summary> /// 過去トラ観たか情報検索(検索条件指定) /// </summary> public void searchMitakaDataCondition() { // 管理番号取得(過去トラ観たか検索) DataTable manageNoList = _DbMitakaData.getManageNoFromMitakaSearchData(this); // 管理番号でループ for (int i = 0; i < manageNoList.Rows.Count; i++) { // 過去トラ観たか情報インスタンス定義(引数に管理番号、ユーザーIDをセット) MitakaData mitakaData = new MitakaData((string)manageNoList.Rows[i]["MITAKA_NO"], _Owner); // 検索結果フィールドに過去トラ観たか情報インスタンスを追加 SearchResultList.Add(mitakaData); } }
public ItemDimensionAdjustmentSearchViewModel() { WarehouseClient.GetItemDimensionsQuantitiesByDateCompleted += (s, e) => { if (e.Result.Count <= 0) { MessageBox.Show(strings.NoDataFound); } foreach (var iR in e.Result) { if (iR.ColorFrom == null) { iR.ColorFrom = new TblColor() { Iserial = iR.ColorFromId, Code = iR.ColorFromCode }; } // هشوف لو موجود مش هحطه if (!SearchResultList.Any(sr => sr.ItemDimFromIserial == iR.ItemDimFromIserial)) { var qtemp = iR.AvailableQuantity; iR.AvailableQuantity = 0; iR.CountedQuantity = 0; iR.AvailableQuantity = qtemp; SearchResultList.Add(iR); } } Loading = false; FullCount = e.fullCount; }; WarehouseClient.GetItemDimensionsOrCreateCompleted += (s, e) => { SelectedSearchResultList.Clear(); foreach (var item in e.Result) { SelectedSearchResultList.Add(item); } IsWorking = false; }; WarehouseClient.GetAccWarehouseRowsCompleted += (s, e) => { //اخر حاجة راجع بيند الكميات وبحث التسوية مش بيحسب الكميات غالبا بيند if (e.Result.Count <= 0) { MessageBox.Show(strings.NoDataFound); } foreach (var iR in e.Result) { // هشوف لو موجود مش هحطه if (!SearchResultList.Any(sr => sr.ItemDimFromIserial == iR.ItemDimFromIserial)) { var qtemp = iR.AvailableQuantity; iR.AvailableQuantity = 0; iR.CountedQuantity = 0; iR.AvailableQuantity = qtemp; SearchResultList.Add(iR); } } Loading = false; }; ApplyCommand = new RelayCommand((o) => { var view = (o as ItemDimensionAdjustmentSearchChildWindow); if (view != null) { //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية ApplySelectedItem(view); } }); OkCommand = new RelayCommand((o) => { var view = (o as ItemDimensionAdjustmentSearchChildWindow); if (view != null) { //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية لو مكانش راح //وهقفل الشاشة فى الاخر ApplySelectedItem(view); view.DialogResult = true; view.Close(); } }); }
public ItemDimensionSearchViewModel() { Client.AccWithConfigAndSizeCompleted += (s, sv) => { bool isSearchItem = false; var itemSearchModel = SearchResultList.FirstOrDefault(i => i.ItemId == sv.Result.Iserial && i.ItemType == sv.Result.ItemGroup); CRUDManagerService.ItemsDto item; if (itemSearchModel != null) { item = itemSearchModel.ItemPerRow ?? (itemSearchModel.ItemPerRow = new CRUDManagerService.ItemsDto()); isSearchItem = true; } else { item = ItemPerRow; } item.AccConfigList = sv.Result.AccConfigList; item.SizesList = new ObservableCollection <string>(); item.CombinationList = sv.Result.CombinationList; var tblAccessoryAttributesDetails = sv.Result.CombinationList.FirstOrDefault(); if (tblAccessoryAttributesDetails != null) { item.SizesList.Add(tblAccessoryAttributesDetails.Size); } if (item.CombinationList != null) { item.SizesList = new ObservableCollection <string>(); } if (isSearchItem) { if (item.AccConfigList == null) { item.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>(); } itemSearchModel.ColorPerRow = item.AccConfigList.FirstOrDefault(c => c.Iserial == itemSearchModel.ColorToId); } }; Client.InspectionRouteCompleted += (o, e) => { foreach (var batchNo in e.Result.Select(x => x.RollBatch)) { if (!BatchNoList.Contains(batchNo)) { BatchNoList.Add(batchNo); } } }; // Client.SearchF WarehouseClient.GetAccWarehouseRowsCompleted += (s, e) => { if (e.Result.Count <= 0) { MessageBox.Show(strings.NoDataFound); } foreach (var iR in e.Result) { // هشوف لو موجود مش هحطه if (!SearchResultList.Any(sr => sr.ItemDimFromIserial == iR.ItemDimFromIserial)) { var qtemp = iR.AvailableQuantity; iR.AvailableQuantity = 0; // iR.CountedQuantity = 0; iR.AvailableQuantity = qtemp; if (iR.PendingQuantity > 0) { iR.TransferredQuantity = iR.AvailableQuantity; } else { iR.TransferredQuantity = iR.AvailableQuantity + iR.PendingQuantity; } ItemDimensionSearchModel item = new ItemDimensionSearchModel(); item.InjectFrom(iR); if (item.ItemPerRow == null) { item.ItemPerRow = new CRUDManagerService.ItemsDto(); } if (ItemPerRow.Iserial > 0) { item.ItemPerRow.InjectFrom(ItemPerRow); } //else // Client.AccWithConfigAndSizeAsync(new CRUDManagerService.ItemsDto() // { // Iserial = item.ItemId, // ItemGroup = item.ItemType, // Code=item.ItemCode, // }); if (item.ItemPerRow.AccConfigList == null) { item.ItemPerRow.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>(); } var colorRow = item.ItemPerRow.AccConfigList.FirstOrDefault(c => c.Iserial == iR.ColorPerRow.Iserial); if (colorRow == null) { colorRow = new CRUDManagerService.TblColor() { Iserial = item.ColorFromId, Code = item.ColorFromCode }; } item.ColorPerRow = colorRow; SearchResultList.Add(item); } } Loading = false; }; WarehouseClient.GetItemDimensionsOrCreteForTransferCompleted += (s, e) => { SelectedSearchResultList.Clear(); foreach (var item in e.Result) { ItemDimensionSearchModel temp = new ItemDimensionSearchModel(); temp.InjectFrom(item); temp.ItemPerRow = ItemPerRow; temp.ColorPerRow.InjectFrom(item.ColorPerRow); SelectedSearchResultList.Add(temp); } IsWorking = false; }; CancelCommand = new RelayCommand((o) => // هقفل وارجع فولس يعرف انه كنسل { var view = (o as ChildWindowsOverride); if (view != null) { view.DialogResult = false; view.Close(); } }); ApplyCommand = new RelayCommand((o) => { var view = (o as ItemDimensionSearchChildWindow); if (view != null) { //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية ApplySelectedItem(view); } }); OkCommand = new RelayCommand((o) => { var view = (o as ItemDimensionSearchChildWindow); if (view != null) { //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية لو مكانش راح //وهقفل الشاشة فى الاخر ApplySelectedItem(view); view.DialogResult = true; view.Close(); } }); LoadingRow = new GalaSoft.MvvmLight.Command.RelayCommand <object>((o) => { var e = o as System.Windows.Controls.DataGridRowEventArgs; if (SearchResultList.Count < PageSize) { return; } if (SearchResultList.Count - 2 < e.Row.GetIndex() && !Loading) { GetInspectionWarehouseRows(); } }); DetailSelectionChanged = new GalaSoft.MvvmLight.Command.RelayCommand <object>( (o) => { var e = o as System.Windows.Controls.SelectionChangedEventArgs; var temp = new Web.DataLayer.ItemDimensionSearchModel(); if (e.AddedItems != null && e.AddedItems.Count > 0) { temp.InjectFrom(e.AddedItems[0]); WarehouseClient.GetItemToQuantitiesAsync(temp, WarehouseToCode); } }); WarehouseClient.GetItemToQuantitiesCompleted += (s, e) => { var item = SearchResultList.FirstOrDefault(rl => rl.ItemId == e.Result.ItemId && rl.ItemType == e.Result.ItemType && rl.ItemDimFromIserial == e.Result.ItemDimFromIserial && rl.ColorFromId == e.Result.ColorFromId && rl.SizeFrom == e.Result.SizeFrom && rl.BatchNoFrom == e.Result.BatchNoFrom && rl.ColorToId == e.Result.ColorToId && rl.SizeTo == e.Result.SizeTo && rl.BatchNoTo == e.Result.BatchNoTo); if (item != null) { item.ItemDimToIserial = e.Result.ItemDimToIserial; item.AvailableToQuantity = e.Result.AvailableToQuantity; item.PendingToQuantity = e.Result.PendingToQuantity; } else { //item.AvailableToQuantity = 0; //item.PendingToQuantity = 0; } }; WarehouseClient.GetItemGroupCompleted += (s, e) => { foreach (var item in e.Result) { ItemTypes.Add(item); } }; WarehouseClient.GetItemGroupAsync(); }
private async void SearchBox_OnTextChanged(object sender, TextChangedEventArgs e) { var textboxSender = (TextBox)sender; string searchText = textboxSender.Text.Trim(); if (string.IsNullOrWhiteSpace(searchText)) { ClearAndHideSearchResultListBox(); return; } IsLoading = true; try { var graphService = MicrosoftGraphService.Instance; await graphService.TryLoginAsync(); GraphServiceClient graphClient = graphService.GraphProvider; if (graphClient != null) { var options = new List <QueryOption> { new QueryOption("$search", $"\"{searchText}\""), new QueryOption("$filter", "personType/class eq 'Person' and personType/subclass eq 'OrganizationUser'") }; IUserPeopleCollectionPage peopleList = await graphClient.Me.People.Request(options).GetAsync(); if (peopleList.Any()) { List <Person> searchResult = peopleList.ToList(); // Remove all selected items foreach (Person selectedItem in Selections) { searchResult.RemoveAll(u => u.UserPrincipalName == selectedItem.UserPrincipalName); } SearchResultList.Clear(); var result = SearchResultLimit > 0 ? searchResult.Take(SearchResultLimit).ToList() : searchResult; foreach (var item in result) { SearchResultList.Add(item); } _searchResultListBox.Visibility = Visibility.Visible; } else { ClearAndHideSearchResultListBox(); } } } catch (Exception) { } finally { IsLoading = false; } }
public SearchResultList Search(SearchQuery query) { if (query == null) { throw new ArgumentNullException(nameof(query)); } List <NpgsqlParameter> parameters = new List <NpgsqlParameter>(); string sql = @"SELECT id,url,snippet,timestamp, COUNT(*) OVER() AS ___total_count___ FROM system_search "; if (query.ResultType == SearchResultType.Full) { sql = @"SELECT *, COUNT(*) OVER() AS ___total_count___ FROM system_search "; } string textQuerySql = string.Empty; if (!string.IsNullOrWhiteSpace(query.Text)) { if (query.SearchType == SearchType.Contains) { var words = query.Text.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); foreach (var word in words) { string parameterName = "@par_" + Guid.NewGuid().ToString().Replace("-", ""); NpgsqlParameter parameter = new NpgsqlParameter(parameterName, $"%{word}%"); parameters.Add(parameter); textQuerySql = textQuerySql + $"OR content ILIKE {parameterName} "; } if (textQuerySql.StartsWith("OR")) { textQuerySql = textQuerySql.Substring(2); //remove initial OR textQuerySql = $"({textQuerySql})"; //add brackets } } else if (query.SearchType == SearchType.Fts) { string parameterName = "@par_" + Guid.NewGuid().ToString().Replace("-", ""); string analizedText = ftsAnalyzer.ProcessText(query.Text.ToLowerInvariant()); bool singleWord = analizedText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Count() == 1; if (singleWord) { //search for all lexemes starting with this word parameters.Add(new NpgsqlParameter(parameterName, analizedText + ":*")); textQuerySql = textQuerySql + " to_tsvector( 'simple', stem_content ) @@ to_tsquery( 'simple', " + parameterName + ") "; } else { parameters.Add(new NpgsqlParameter(parameterName, analizedText)); textQuerySql = textQuerySql + " to_tsvector( 'simple', stem_content) @@ plainto_tsquery( 'simple', " + parameterName + ") "; } } } string entityQuerySql = string.Empty; if (query.Entities.Any()) { foreach (var id in query.Entities) { string parameterName = "@par_" + Guid.NewGuid().ToString().Replace("-", ""); NpgsqlParameter parameter = new NpgsqlParameter(parameterName, $"%{id}%"); parameters.Add(parameter); entityQuerySql = entityQuerySql + $"OR entities ILIKE {parameterName} "; } if (entityQuerySql.StartsWith("OR")) { entityQuerySql = entityQuerySql.Substring(2); //remove initial OR entityQuerySql = $"({entityQuerySql})"; //add brackets } } string appsQuerySql = string.Empty; if (query.Apps.Any()) { foreach (var id in query.Apps) { string parameterName = "@par_" + Guid.NewGuid().ToString().Replace("-", ""); NpgsqlParameter parameter = new NpgsqlParameter(parameterName, $"%{id}%"); parameters.Add(parameter); appsQuerySql = appsQuerySql + $"OR entities ILIKE {parameterName} "; } if (appsQuerySql.StartsWith("OR")) { appsQuerySql = entityQuerySql.Substring(2); //remove initial OR appsQuerySql = $"({appsQuerySql})"; //add brackets } } string recordsQuerySql = string.Empty; if (query.Records.Any()) { foreach (var id in query.Records) { string parameterName = "@par_" + Guid.NewGuid().ToString().Replace("-", ""); NpgsqlParameter parameter = new NpgsqlParameter(parameterName, $"%{id}%"); parameters.Add(parameter); recordsQuerySql = recordsQuerySql + $"OR entities ILIKE {parameterName} "; } if (recordsQuerySql.StartsWith("OR")) { recordsQuerySql = entityQuerySql.Substring(2); //remove initial OR recordsQuerySql = $"({recordsQuerySql})"; //add brackets } } string whereSql = string.Empty; if (!string.IsNullOrWhiteSpace(textQuerySql)) { whereSql = $"WHERE {textQuerySql} "; } if (!string.IsNullOrWhiteSpace(entityQuerySql)) { if (whereSql == string.Empty) { whereSql = $"WHERE {entityQuerySql} "; } else { whereSql = $"AND {entityQuerySql} "; } } if (!string.IsNullOrWhiteSpace(appsQuerySql)) { if (whereSql == string.Empty) { whereSql = $"WHERE {appsQuerySql} "; } else { whereSql = $"AND {appsQuerySql} "; } } if (!string.IsNullOrWhiteSpace(recordsQuerySql)) { if (whereSql == string.Empty) { whereSql = $"WHERE {recordsQuerySql} "; } else { whereSql = $"AND {recordsQuerySql} "; } } sql = sql + whereSql; if (query.SearchType != SearchType.Fts) { sql = sql + " ORDER BY timestamp DESC "; } string pagingSql = string.Empty; if (query.Limit != null || query.Skip != null) { pagingSql = "LIMIT "; if (query.Limit.HasValue && query.Limit != 0) { pagingSql = pagingSql + query.Limit + " "; } else { pagingSql = pagingSql + "ALL "; } if (query.Skip.HasValue) { pagingSql = pagingSql + " OFFSET " + query.Skip; } sql = sql + pagingSql; } DataTable dt = new DataTable(); using (var connection = DbContext.Current.CreateConnection()) { var command = connection.CreateCommand(sql, parameters: parameters); command.CommandTimeout = 60; new NpgsqlDataAdapter(command).Fill(dt); SearchResultList resultList = new SearchResultList(); foreach (DataRow dr in dt.Rows) { resultList.Add(dr.MapTo <SearchResult>()); if (resultList.TotalCount == 0) { resultList.TotalCount = (int)((long)dr["___total_count___"]); } } return(resultList); } }
void WebSearchCompleted(object sender, SearchCompletedEventArgs e) { progressBing.IsIndeterminate = false; progressBing.Visibility = Visibility.Collapsed; searchPivot.SelectedIndex = 1; SearchResponse response = e.Result; ImageResponse imageResponse = e.Result.Image; SearchResultList searchResult = new SearchResultList(); if (response.Web.Results.Count() > 0) { foreach (WebResult result in response.Web.Results) { searchResult.Add(new SearchResult { Title = result.Title, URL = result.Url, Description = result.Description }); } } webSearchResult.ItemsSource = searchResult; imagesSearchResult.Items.Clear(); foreach (ImageResult bingImage in response.Image.Results) { Image image = new Image(); image.Source = new BitmapImage(new Uri(bingImage.Thumbnail.Url)); image.Width = bingImage.Thumbnail.Width; image.Height = bingImage.Thumbnail.Height; imagesSearchResult.Items.Add(image); } }