SetFilterTokens() public static method

public static SetFilterTokens ( IEnumerable filters, QueryDescription qd, bool canAggregate = false ) : void
filters IEnumerable
qd Signum.Entities.DynamicQuery.QueryDescription
canAggregate bool
return void
Beispiel #1
0
        private void RefreshSimpleFilters()
        {
            if (SimpleFilterBuilder != null)
            {
                FilterOptions.Clear();
                var newFilters = SimpleFilterBuilder.GenerateFilterOptions();

                FilterOption.SetFilterTokens(newFilters, Description);
                FilterOptions.AddRange(newFilters);
            }
        }
Beispiel #2
0
        public static QueryValueRequest ToRequest(this QueryCountOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            FilterOption.SetFilterTokens(options.FilterOptions, qd);

            var request = new QueryValueRequest
            {
                QueryName = options.QueryName,
                Filters   = options.FilterOptions.Select(f => f.ToFilter()).ToList()
            };

            return(request);
        }
Beispiel #3
0
        public static UniqueEntityRequest ToRequest(this UniqueOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            FilterOption.SetFilterTokens(options.FilterOptions, qd);
            OrderOption.SetOrderTokens(options.OrderOptions, qd);

            var request = new UniqueEntityRequest
            {
                QueryName  = options.QueryName,
                Filters    = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders     = options.OrderOptions.Select(f => f.ToOrder()).ToList(),
                UniqueType = options.UniqueType,
            };

            return(request);
        }
Beispiel #4
0
        public static QueryGroupRequest ToRequest(this QueryGroupOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            ColumnOption.SetColumnTokens(options.ColumnOptions, qd, canAggregate: true);
            FilterOption.SetFilterTokens(options.FilterOptions, qd, canAggregate: true);
            OrderOption.SetOrderTokens(options.OrderOptions, qd, canAggregate: true);

            var request = new QueryGroupRequest
            {
                QueryName = options.QueryName,
                Filters   = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders    = options.OrderOptions.Select(f => f.ToOrder()).ToList(),
                Columns   = options.ColumnOptions.Select(f => f.ToColumn()).ToList(),
            };

            return(request);
        }
Beispiel #5
0
        public static QueryRequest ToRequest(this QueryOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            ColumnOption.SetColumnTokens(options.ColumnOptions, qd);
            FilterOption.SetFilterTokens(options.FilterOptions, qd);
            OrderOption.SetOrderTokens(options.OrderOptions, qd);

            var request = new QueryRequest
            {
                QueryName  = options.QueryName,
                Filters    = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders     = options.OrderOptions.Select(f => f.ToOrder()).ToList(),
                Columns    = ColumnOption.MergeColumns(options.ColumnOptions, options.ColumnOptionsMode, qd),
                Pagination = options.Pagination ?? QueryOptions.DefaultPagination,
            };

            return(request);
        }
Beispiel #6
0
        public void Reinitialize(IEnumerable <FilterOption> filters, List <ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List <OrderOption> orders)
        {
            if (qd == null)
            {
                qd = DynamicQueryServer.GetQueryDescription(QueryName);
            }

            ColumnOptions.Clear();
            ColumnOptions.AddRange(columns);
            ColumnOptionsMode = columnOptionsMode;

            FilterOptions.Clear();
            FilterOptions.AddRange(filters);
            FilterOption.SetFilterTokens(FilterOptions, qd);

            OrderOptions.Clear();
            OrderOptions.AddRange(orders);
            OrderOption.SetOrderTokens(OrderOptions, qd);
        }
Beispiel #7
0
        void SearchControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= SearchControl_Loaded;

            if (DesignerProperties.GetIsInDesignMode(this) || QueryName == null)
            {
                return;
            }

            if (qd == null)
            {
                qd = DynamicQueryServer.GetQueryDescription(QueryName);
            }

            if (FilterColumn.HasText())
            {
                FilterOptions.Add(new FilterOption
                {
                    ColumnName = FilterColumn,
                    Operation  = FilterOperation.EqualTo,
                    Frozen     = true,
                }.Bind(FilterOption.ValueProperty, new Binding("DataContext" + (FilterRoute.HasText() ? "." + FilterRoute : null))
                {
                    Source = this
                }));
                ColumnOptions.Add(new ColumnOption(FilterColumn));
                ColumnOptionsMode = ColumnOptionsMode.Remove;
            }

            FilterOption.SetFilterTokens(FilterOptions, qd);

            AutomationProperties.SetName(this, QueryUtils.GetQueryUniqueKey(QueryName));

            Search();

            foreach (var item in FilterOptions)
            {
                item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged);
            }
        }
Beispiel #8
0
        public void Reinitialize(List <FilterOption> filters, List <ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List <OrderOption> orders, Pagination pagination)
        {
            try
            {
                avoidPaginationChange = true;

                ColumnOptions.Clear();
                ColumnOptions.AddRange(columns);
                ColumnOption.SetColumnTokens(ColumnOptions, Description);
                ColumnOptionsMode = columnOptionsMode;
                GenerateListViewColumns();

                if (!filters.SequenceEqual(FilterOptions))
                {
                    if (SimpleFilterBuilder != null)
                    {
                        SimpleFilterBuilder = null;
                    }

                    FilterOptions.Clear();
                    FilterOption.SetFilterTokens(filters, Description);
                    FilterOptions.AddRange(filters);
                }

                OrderOptions.Clear();
                OrderOptions.AddRange(orders);
                OrderOption.SetOrderTokens(OrderOptions, Description);
                SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

                UpdateMultiplyMessage(true);

                Pagination = pagination;
            }
            finally
            {
                avoidPaginationChange = false;
            }
        }
Beispiel #9
0
        public void OnLoaded()
        {
            if (loaded)
            {
                return;
            }

            loaded = true;

            if (FilterColumn.HasText())
            {
                FilterOptions.Add(new FilterOption
                {
                    ColumnName = FilterColumn,
                    Operation  = FilterOperation.EqualTo,
                    Frozen     = true,
                }.Bind(FilterOption.ValueProperty, new Binding("DataContext" + (FilterRoute.HasText() ? "." + FilterRoute : null))
                {
                    Source = this
                }));

                if (QueryUtils.IsColumnToken(FilterColumn))
                {
                    ColumnOptions.Add(new ColumnOption(FilterColumn));
                    ColumnOptionsMode = ColumnOptionsMode.Remove;
                }
                if (this.NotSet(SearchOnLoadProperty))
                {
                    SearchOnLoad = true;
                }
            }

            if (OrderOptions.IsNullOrEmpty() && !entityColumn.Implementations.Value.IsByAll)
            {
                var orderType = entityColumn.Implementations.Value.Types.All(t => EntityKindCache.GetEntityData(t) == EntityData.Master) ? OrderType.Ascending : OrderType.Descending;

                var column = Description.Columns.SingleOrDefaultEx(c => c.Name == "Id");

                if (column != null)
                {
                    OrderOptions.Add(new OrderOption(column.Name, orderType));
                }
            }

            btCreate.ToolTip = SearchMessage.CreateNew0_G.NiceToString()
                               .ForGenderAndNumber(entityColumn.Implementations.Value.Types.FirstOrDefault()?.GetGender() ?? 'm')
                               .FormatWith(entityColumn.Implementations.Value.Types.CommaOr(a => a.NiceName()));

            if (this.NotSet(SearchControl.NavigateProperty) && Navigate)
            {
                Navigate = Implementations.IsByAll ? true :
                           Implementations.Types.Any(t => Navigator.IsNavigable(t, isSearch: true));
            }

            if (this.NotSet(EntityBase.CreateProperty) && Create)
            {
                Create = Implementations.IsByAll ? false :
                         Implementations.Types.Any(t => Navigator.IsCreable(t, isSearch: true));
            }

            ColumnOption.SetColumnTokens(ColumnOptions, Description);

            if (this.CanAddFilters || this.AllowChangeColumns)
            {
                headerContextMenu = new ContextMenu();

                if (this.CanAddFilters)
                {
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = SearchMessage.AddFilter.NiceToString()
                    }.Handle(MenuItem.ClickEvent, filterHeader_Click));
                }

                if (this.CanAddFilters && this.AllowChangeColumns)
                {
                    headerContextMenu.Items.Add(new Separator());
                }

                if (this.AllowChangeColumns)
                {
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = SearchMessage.Rename.NiceToString()
                    }.Handle(MenuItem.ClickEvent, renameMenu_Click));
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = EntityControlMessage.Remove.NiceToString()
                    }.Handle(MenuItem.ClickEvent, removeMenu_Click));
                }
            }

            GenerateListViewColumns();

            FilterOption.SetFilterTokens(FilterOptions, Description);

            filterBuilder.Filters = FilterOptions;
            ((INotifyCollectionChanged)FilterOptions).CollectionChanged += FilterOptions_CollectionChanged;

            OrderOption.SetOrderTokens(OrderOptions, Description);

            SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

            if (IsVisible)
            {
                FillMenuItems();

                if (SearchOnLoad)
                {
                    Search();
                }
            }
            else
            {
                IsVisibleChanged += SearchControl_IsVisibleChanged;
            }

            UpdateVisibility();

            AutomationProperties.SetName(this, QueryUtils.GetKey(QueryName));

            foreach (var item in FilterOptions)
            {
                item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged);
            }
        }