private void button5_Click(object sender, RoutedEventArgs e) { if ((sender as Button).IsEnabled) { if (this.pivotGrid1.GroupingBar != null && this.pivotGrid1.GroupingBar.AllowMultiFunctionalSortFilter) { FilterConverter filterconv = new FilterConverter(); for (int i = 0; i < this.pivotGrid1.Filters.Count; i++) { filterconv.UpdateDictionary(this.pivotGrid1.Filters[i].DimensionName); } } else { ImageConverter imgconv = new ImageConverter(); for (int i = 0; i < this.pivotGrid1.Filters.Count; i++) { imgconv.UpdateDictionary(this.pivotGrid1.Filters[i].DimensionName); } } this.pivotGrid1.Filters.Clear(); this.pivotGrid1.InternalGrid.Refresh(true); } this.pivotGrid1.InvalidateCells(); }
public IHttpActionResult TISPaginatedList([FromBody] IList <FilterModel> filters, FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <NatisExport>(filter, (FilterJoin)filterJoin); var query = dbContext .NatisExports .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <NatisExportModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <NatisExportModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <NatisExport>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <NatisExportModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; var totalPages = Math.Ceiling(totalCount / (float)pageSize); paginationList.Models = entities.Select(f => new Models.TISCapture.NatisExportModel { //ID = f.ID, VehicleRegistration = f.VehicleRegistration, InfringementDate = f.InfringementDate, ReferenceNumber = f.ReferenceNumber, ExportDate = f.ExportDate, DistrictID = f.DistrictID, LockedByCredentialID = f.LockedByCredentialID, LockedByName = f.LockedByCredentialID.HasValue ? string.Format("{0}, {1}", f.User.LastName, f.User.FirstName) : string.Empty, DistrictName = f.District.BranchName, }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public QueryResult <Product> Search(Query query) { var options = new QueryOptions(); AbstractSolrQuery q = new SolrQuery(!string.IsNullOrEmpty(query.SearchText) ? query.SearchText : "*"); options.ExtraParams = new[] { new KeyValuePair <string, string>("df", "description") }; options.Rows = query.NumToReturn ?? DefaultSettings.DefaultNumToReturn; options.StartOrCursor = OffsetConverter.GetOffsetFromCurrentPage(query.Page); options.OrderBy = SortOrderConverter.GetSortOrder(query); string facetToExclude; options.FilterQueries = FilterConverter.GetSolrNetFilters(query, out facetToExclude); options.Facet = FacetConverter.GetSolrNetFacetParameters(query, facetToExclude); options.Highlight = HighlightConverter.GetSolrNetHighlightingParameters(query.SearchText); var results = SolrOperations.Query(q, options); var convertedResults = ResultConverter.GetQueryResult(results); if (convertedResults == null) { convertedResults.ErrorMessages = new[] { "An error occured communicating with the solr instance" }; } return(convertedResults); }
public IHttpActionResult GetCameraPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.Camera>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .Cameras .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <CameraModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <CameraModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <Camera>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <CameraModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new CameraModel { ID = f.ID, AdapterType = (Models.Enums.CameraAdapterType)f.CameraAdapterType, ConfigJson = f.ConfigJson, CreatedTimeStamp = f.CreatedTimeStamp, ConnectToHost = f.ConnectToHost == "1", DeviceConnectionType = (Models.Enums.CameraConnectionType)f.CameraConnectionType, DeviceStatus = (Models.Enums.CameraStatusType)f.CameraStatusType, FriendlyName = f.FriendlyName, GpsLatitude = f.GpsLatitude, GpsLongitude = f.GpsLongitude, IsEnabled = f.IsEnabled == "1", ModifiedTimeStamp = f.ModifiedTimeStamp }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public void WhenOneStatement_ThenReturnString() { var filter = Filter.When("Name", QueryComparison.Equal, "John").Build(); var result = FilterConverter.ToTableQueryFilter(filter); Assert.That(result, Is.EqualTo("Name eq 'John'")); }
/// <summary> /// new search on facility click /// </summary> protected void onFacilitySearchClick(object sender, CommandEventArgs e) { // create facility search filter from activity search criteria FacilitySearchFilter filter = FilterConverter.ConvertToFacilitySearchFilter(SearchFilter); // create new activity filter filter.ActivityFilter = getActivityFilter(e); LinkSearchRedirecter.ToFacilitySearch(Response, filter); }
/// <summary> /// getPollutantReleasesLambda /// </summary> private static Expression <Func <POLLUTANTRELEASE, bool> > getPollutantReleasesLambda(DataClassesPollutantReleaseDataContext db, IndustrialActivitySearchFilter filter) { ParameterExpression param = Expression.Parameter(typeof(POLLUTANTRELEASE), "s"); PollutantReleaseSearchFilter filterReleases = FilterConverter.ConvertToPollutantReleaseSearchFilter(filter); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantReleases(filterReleases, param); Expression <Func <POLLUTANTRELEASE, bool> > lambda = Expression.Lambda <Func <POLLUTANTRELEASE, bool> >(exp, param); return(lambda); }
/// <summary> /// get lambda for confidential pollutant transfers /// </summary> private static Expression <Func <POLLUTANTTRANSFER, bool> > getPollutantTransfersConfidentialLambda(DataClassesPollutantTransferDataContext db, IndustrialActivitySearchFilter filter, bool includePollutant) { ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s"); PollutantTransfersSearchFilter filterTransfers = FilterConverter.ConvertToPollutantTransfersSearchFilter(filter); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filterTransfers, param, includePollutant); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param); return(lambda); }
public IHttpActionResult GetInfringementLocationPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.InfringementLocation>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .InfringementLocations .Include(f => f.Court) .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <InfringementLocationModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <InfringementLocationModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <InfringementLocation>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <InfringementLocationModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new InfringementLocationModel { ID = f.ID, Code = f.Code, Description = f.Description, CourtID = f.CourtID, CourtName = f.Court == null ? string.Empty : f.Court.CourtName, GpsLatitude = f.GpsLatitude, GpsLongitude = f.GpsLongitude, InfringementLocationType = (Models.Enums.InfringementLocationType)f.InfringementLocationType }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
// ---------------------------------------------------------------------------------- // WasteTransfers // ---------------------------------------------------------------------------------- #region WasteTransfers /// <summary> /// get waste transfers /// </summary> public static IEnumerable <Summary.WasteSummaryTreeListRow> GetWasteTransfers(IndustrialActivitySearchFilter filter) { // Result is the same as for wastetransfer, without the filtering on wastetype WasteTransferSearchFilter filterWaste = FilterConverter.ConvertToWasteTransferSearchFilter(filter); IEnumerable <Summary.WasteSummaryTreeListRow> wastes = WasteTransfers.GetWasteTransfers(filterWaste); filter.Count = filterWaste.Count; return(wastes); }
/// <summary> /// invoke activity search /// </summary> protected void onActivitySearchClick(object sender, CommandEventArgs e) { // create activity filter IndustrialActivitySearchFilter filter = FilterConverter.ConvertToIndustrialActivitySearchFilter(SearchFilter); // Change activity filter filter.ActivityFilter = getActivityFilter(e); LinkSearchRedirecter.ToIndustrialActivity(Response, filter, Sheets.IndustrialActivity.PollutantTransfers); }
public IHttpActionResult GetPaginatedList([FromBody] IList <FilterModel> filters, FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.MobileDevice>(filter, (FilterJoin)filterJoin); var query = dbContext .MobileDevices .Include(f => f.District) .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <MobileDeviceModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <MobileDeviceModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <MobileDevice>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var totalPages = Math.Ceiling(totalCount / (float)pageSize); var paginationList = new PaginationListModel <MobileDeviceModel>(); paginationList.Models = entities.Select(f => new MobileDeviceModel { ID = f.ID, DeviceID = f.DeviceID, CreatedTimestamp = f.CreatedTimestamp, DistrictID = f.District == null ? default(long?) : f.District.ID, DistrictName = f.District == null ? string.Empty : f.District.BranchName, SerialNumber = f.SerialNumber, Status = (Models.Enums.MobileDeviceStatus)f.Status }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public IHttpActionResult GetCountryPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { if (string.IsNullOrWhiteSpace(orderPropertyName)) { orderPropertyName = "Description"; } using (var dbContext = new DataContext()) { var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.Country>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .Countries .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <CountryModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <CountryModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <Country>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = pageResults.ToList(); } var paginationList = new PaginationListModel <CountryModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new CountryModel { ID = f.ID, Description = f.Description, ModifiedTimestamp = f.ModifiedTimestamp }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
/// <summary> /// new search on facility click /// </summary> protected void onFacilitySearchClick(object sender, CommandEventArgs e) { string code = e.CommandArgument.ToString().ToUpper(); // create facility search filter from activity search criteria FacilitySearchFilter filter = FilterConverter.ConvertToFacilitySearchFilter(SearchFilter); // Change activity filter filter.ActivityFilter = getActivityFilter(e); LinkSearchRedirecter.ToFacilitySearch(Response, filter); }
/// <summary> /// invoke pollutant search search for this row /// </summary> protected void onPollutantSearchClick(object sender, CommandEventArgs e) { // create pollutant search filter PollutantTransfersSearchFilter filter = FilterConverter.ConvertToPollutantTransfersSearchFilter(SearchFilter); // create pollutant filter filter.PollutantFilter = getPollutantFilter(e); // go to pollutant release LinkSearchRedirecter.ToPollutantTransfers(Response, filter); }
protected override IQueryable <Role> ApplyFilter(IQueryable <Role> query, RoleFilter filter) { if (filter == null) { return(query); } var exp = FilterConverter.Convert <IRole, Role>(filter.Expression); return(query.Where(exp)); }
/// <summary> /// Query the table using a filter. /// </summary> /// <param name="filter">Filter to apply in the query.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation. Result will contain list of matching entities.</returns> /// <exception cref="T:System.ArgumentNullException"><paramref name="filter" /> is null.</exception> public Task <IList <TEntity> > QueryAsync(Filter filter, CancellationToken cancellationToken = default) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } var filterString = FilterConverter.ToTableQueryFilter(filter); return(_table.QueryAsync <TEntity>(filterString, cancellationToken)); }
/// <summary> /// new search on facility click /// </summary> protected void onNewSearchClick(object sender, CommandEventArgs e) { // create facility search filter from activity search criteria FacilitySearchFilter filter = FilterConverter.ConvertToFacilitySearchFilter(SearchFilter); // Search for country according to code filter.AreaFilter = getAreaFilter(e); // go to facility levels page LinkSearchRedirecter.ToFacilitySearch(Response, filter); }
public void WhenTwoStatementsWithOrOp_ThenReturnString() { var filter = Filter .When("Name", QueryComparison.Equal, "John") .Or() .When("Age", QueryComparison.Equal, "50") .Build(); var result = FilterConverter.ToTableQueryFilter(filter); Assert.That(result, Is.EqualTo("(Name eq 'John') or (Age eq '50')")); }
public IHttpActionResult GetSystemFunctionPaginatedList([FromBody] IList <FilterModel> filters, Kapsch.Gateway.Models.Shared.Enums.FilterJoin filterJoin, bool asc, string orderPropertyName, int pageIndex, int pageSize) { using (var dbContext = new DataContext()) { //dbContext.Database.Log = (s) => Debug.WriteLine(s); var totalCount = 0; var filter = filters.Select(f => FilterConverter.Convert(f)).ToList(); var func = ExpressionBuilder.GetExpression <Data.SystemFunction>(filter, (Kapsch.Core.Filters.FilterJoin)filterJoin); var query = dbContext .SystemFunctions .AsNoTracking(); if (func != null) { query = query.Where(func); } var orderedQuery = asc ? query.OrderByMember(PropertyHelper.GetSortingValue <SystemFunctionModel>(orderPropertyName)) : query.OrderByMemberDescending(PropertyHelper.GetSortingValue <SystemFunctionModel>(orderPropertyName)); var resultsToSkip = (pageIndex - 1) * pageSize; var pageResults = orderedQuery .Skip(resultsToSkip) .Take(pageSize) .OrderByMember(PropertyHelper.GetSortingValue <SystemFunctionModel>(orderPropertyName)) .GroupBy(f => new { Total = query.Count() }) .FirstOrDefault(); var entities = new List <SystemFunction>(); if (pageResults != null) { totalCount = pageResults.Key.Total; entities = (asc ? pageResults.OrderBy(orderPropertyName) : pageResults.OrderByDescending(orderPropertyName)).ToList(); } var paginationList = new PaginationListModel <SystemFunctionModel>(); paginationList.PageIndex = pageIndex; paginationList.PageSize = pageSize; paginationList.Models = entities.Select(f => new SystemFunctionModel { ID = f.ID, Name = f.Name, Description = f.Description }) .ToList(); paginationList.TotalCount = totalCount; return(Ok(paginationList)); } }
public string GetCondition(string TableName, params Packet[] packets) { string Condition = ""; packets[packets.Length - 1].Couple = Couple.None; foreach (Packet packet in packets) { IFilter filter = new Filter(TableName, packet.Left, packet.Right.ToString(), packet.Sign, packet.Couple); Condition += $"{FilterConverter.Convert(filter)} "; } return(Condition); }
public void Convert_ValidSourceFilter_ReturnConvertedFilter() { // Arrange var filterClause = MakeFilter("[Name] IN ('john')", "[Surname] IN ('doe', 'smith')", "[AGE] IN (18, 65)"); // Act var filter = FilterConverter.Convert(filterClause.Clause); // Assert filter.Should().Be( "(Name != null && (Name = \"john\")) AND (Surname != null && (Surname = \"doe\" OR Surname = \"smith\")) AND (AGE != null && (AGE = 18 OR AGE = 65))"); }
public void Convert_StringFieldWithNumberValues_ReturnEscapedNumbers() { // Arrange var filterClause = MakeFilter("[Name] IN ('john', '1')", "[AGE] IN (18, 65)"); // Act var filter = FilterConverter.Convert(filterClause.Clause); // Assert filter.Should().Be( "(Name != null && (Name = \"john\" OR Name = \"1\")) AND (AGE != null && (AGE = 18 OR AGE = 65))"); }
static void Main(string[] args) { var spec1 = new ShortbookSpecification(); var spec2 = new AuthorSpecification("Author1"); using (var ctx = new BookContext()) { var repository = new AudioBookRepository(ctx); var spec2Converted = FilterConverter.ConvertSpecification <Book, AudioBook>(spec2); var results = repository.List(spec2Converted); } }
/// <summary> /// new search on facility click /// </summary> protected void onFacilitySearchClick(object sender, CommandEventArgs e) { // create facility search filter from activity search criteria FacilitySearchFilter filter = FilterConverter.ConvertToFacilitySearchFilter(SearchFilter); // create pollutant filter filter.PollutantFilter = getPollutantFilter(e); // set medium filter filter.MediumFilter = LinkSearchBuilder.GetMediumFilter(false, false, false, true); // go to facility levels page LinkSearchRedirecter.ToFacilitySearch(Response, filter); }
/// <summary> /// invoke pollutant search search for this row /// </summary> protected void onWasteSearchClick(object sender, CommandEventArgs e) { string code = e.CommandArgument.ToString(); // create pollutant search filter WasteTransferSearchFilter filter = FilterConverter.ConvertToWasteTransferSearchFilter(SearchFilter); // create waste type filter according to command argument filter.WasteTypeFilter = LinkSearchBuilder.GetWasteTypeFilter(code); // go to waste search LinkSearchRedirecter.ToWasteTransfers(Response, filter); }
/// <summary> /// new search on facility click /// </summary> protected void onFacilitySearchClick(object sender, CommandEventArgs e) { string code = e.CommandArgument.ToString(); // create facility search filter from activity search criteria FacilitySearchFilter filter = FilterConverter.ConvertToFacilitySearchFilter(SearchFilter); // create waste type filter according to command argument filter.WasteTypeFilter = LinkSearchBuilder.GetWasteTypeFilter(code); // go to facility levels page LinkSearchRedirecter.ToFacilitySearch(Response, filter); }
private void populateMediumSelector() { MediumFilter mf = new MediumFilter(); mf.ReleasesToAir = true; mf.ReleasesToSoil = true; mf.ReleasesToWater = true; var filter = FilterConverter.ConvertToPollutantReleaseSearchFilter(SearchFilter); var counts = PollutantReleases.GetFacilityCounts(filter); this.ucMediumSelector.PopulateMediumRadioButtonList(mf, counts); }
/// <summary> /// new search on facility click /// alternative Server.Transfer("FacilityLevels.aspx"); /// </summary> protected void onNewSearchClick(object sender, CommandEventArgs e) { string code = e.CommandArgument.ToString().ToUpper(); // create facility search filter from activity search criteria FacilitySearchFilter filter = FilterConverter.ConvertToFacilitySearchFilter(SearchFilter); // create new area filter filter.AreaFilter = getAreaFilter(e); // go to facility search page with new filter LinkSearchRedirecter.ToFacilitySearch(Response, filter); }
protected override IQueryable <StarredThread> ApplyFilter(IQueryable <StarredThread> query, StarredThreadFilter filter) { if (filter == null) { return(query); } var exp = FilterConverter.Convert <IStarredTread, StarredThread>(filter.Expression, new Dictionary <Type, Type> { [typeof(IUserReference)] = typeof(UserReference), }); return(query.Where(exp)); }