Exemplo n.º 1
0
        public void NotifyFiltersChanged()
        {
            try
            {
                if (_subCategoryDisplayItem.AllProducts != null)
                {
                    // Check if any filters have been enabled
                    var hasFilters = FilterGroups.Any(fg => fg.IsGroupFiltered);

                    if (hasFilters)
                    {
                        //Filter the list of Product Items from our Filter Groups
                        List <ProductListFilterItem> selectedFilterItems;
                        var filteredProducts = GetFilteredProducts(_subCategoryDisplayItem.AllProducts, FilterGroups.ToList(), out selectedFilterItems);

                        // Update the parent SubCategory with new filtered product list + enabled filters.
                        _subCategoryDisplayItem.SetFilteredProducts(filteredProducts, selectedFilterItems);
                    }
                    else
                    {
                        // Notify the parent Subcategory to reset products back to full unfiltered list
                        _subCategoryDisplayItem.ResetFilteredProducts();
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Validates this object.
        /// </summary>
        /// <returns>A List containing an <see cref="Error"/> item for each validation error.</returns>
        public override List <Error> GetValidationErrors()
        {
            var consolidatedList = new List <Error>();

            if (SearchGroupId == 0)
            {
                consolidatedList.Add(new Error {
                    Message = "A folder must be selected for this Analytic."
                });
            }

            var entityErrors = Identity.GetAllValidationErrors();

            consolidatedList.AddRange(entityErrors);


            entityErrors = FilterGroups.GetAllValidationErrors();
            consolidatedList.AddRange(entityErrors);

            entityErrors = PriceListGroups.GetAllValidationErrors();
            consolidatedList.AddRange(entityErrors);

            entityErrors = ValueDrivers.GetAllValidationErrors();
            consolidatedList.AddRange(entityErrors);

            return(consolidatedList);
        }
Exemplo n.º 3
0
        public async Task <ListResponse <Resource> > Query(string query, IEnumerable <string> requested, IEnumerable <string> excluded)
        {
            IEnumerable <Core2Group> groups;

            if (!string.IsNullOrWhiteSpace(query))
            {
                groups = new FilterGroups(this._context).FilterGen(query);
            }
            else
            {
                groups = await this._context.CompleteGroups().ToListAsync().ConfigureAwait(false);
            }

            NameValueCollection  keyedValues = HttpUtility.ParseQueryString(query);
            IEnumerable <string> keys        = keyedValues.AllKeys;
            string countString = keyedValues[QueryKeys.Count];
            string startIndex  = keyedValues[QueryKeys.StartIndex];

            if (startIndex == null)
            {
                startIndex = ControllerConstants.DefaultStartIndexString;
            }

            int start = int.Parse(startIndex, CultureInfo.InvariantCulture);

            if (start < this._defaultStartIndex)
            {
                start = this._defaultStartIndex;
            }

            int?count = null;
            int total = groups.Count();

            groups = groups.OrderBy(d => d.DisplayName).Skip(start - 1);

            if (countString != null)
            {
                count  = int.Parse(countString, CultureInfo.InvariantCulture);
                groups = groups.Take(count.Value);
            }

            groups = groups.Select(u =>
                                   ColumnsUtility.FilterAttributes(requested, excluded, u, this._alwaysReturnedAttributes)).ToList();



            ListResponse <Resource> list = new ListResponse <Resource>()
            {
                TotalResults = total,
                StartIndex   = groups.Any() ? start : (int?)null,
                Resources    = groups,
            };

            if (count.HasValue)
            {
                list.ItemsPerPage = count.Value;
            }
            return(list);
        }
Exemplo n.º 4
0
        public FilterGroup AddFilterGroup(string caption, FilterProperty property,
                                          ExpressionType expressionType = ExpressionType.In, string description = default)
        {
            var group = new FilterGroup(caption, property, expressionType, description);

            FilterGroups.Add(group);
            return(group);
        }
Exemplo n.º 5
0
        public FilterGroup AddForeignFilterGroup(string caption, string fieldName, Type foreignEntity,
                                                 ExpressionType expressionType = ExpressionType.In,
                                                 string description            = default)
        {
            var group = new FilterGroup(caption, new FilterProperty(fieldName, foreignEntity), expressionType, description);

            FilterGroups.Add(group);
            return(group);
        }
Exemplo n.º 6
0
        public FilterGroup AddHiddenFilterGroup(FilterProperty property, ExpressionType expressionType = ExpressionType.In)
        {
            var group = new FilterGroup(property, expressionType)
            {
                Hidden = true
            };

            FilterGroups.Add(group);
            return(group);
        }
Exemplo n.º 7
0
        public FilterGroup AddHiddenFilterGroup <TForeignEntity>(string fieldName, ExpressionType expressionType = ExpressionType.In)
        {
            var group = new FilterGroup(new FilterProperty(fieldName, typeof(TForeignEntity)), expressionType)
            {
                Hidden = true
            };

            FilterGroups.Add(group);
            return(group);
        }
Exemplo n.º 8
0
        static ReportFilterHelper()
        {
            LazyFilterGroups = new Lazy <IEnumerable <ReportFilter> >(() =>
            {
                var vals = new List <ReportFilter>();
                foreach (var val in Enum.GetValues(typeof(ReportFilter)).OfType <ReportFilter>().Where(val => val != ReportFilter.None))
                {
                    var temp = ExtractGroup(val);
                    if (temp == val && !vals.Contains(val))
                    {
                        vals.Add(val);
                    }
                }
                return(vals);
            }, true);

            LazyFilterCaptions = new Lazy <IDictionary <ReportFilter, string> >(() =>
            {
                var values           = Enum.GetValues(typeof(ReportFilter)).OfType <ReportFilter>();
                ReportFilter filters = default(ReportFilter);
                values.ToList().ForEach(filter => filters |= filter);
                var descriptions = filters.GetAttributeValues <System.ComponentModel.DescriptionAttribute, string>(x => x.Description);
                return(descriptions.ToDictionary(tuple => (ReportFilter)tuple.Item1, value => value.Item2));
            }, true);

            LazyFilterGroupValues = new Lazy <IDictionary <ReportFilter, IList <ReportFilter> > >(() =>
            {
                var result = FilterGroups.ToDictionary(k => k, v => new List <ReportFilter>() as IList <ReportFilter>);
                var values = Enum.GetValues(typeof(ReportFilter)) as ReportFilter[];
                result.Keys.ToList().ForEach(group =>
                {
                    var toAdd = values.Where(
                        (filter) =>
                    {
                        var isGroup = filter.IsGroup();
                        if (!isGroup)
                        {
                            var isGroupValue = (group & filter) == group;
                            return(isGroupValue);
                        }
                        return(false);
                    });
                    (result[group] as List <ReportFilter>).AddRange(toAdd);
                });
                return(result);
            }, true);

            LazyFilterGroupFlag = new Lazy <ReportFilter>(() =>
            {
                var temp = default(ReportFilter);
                LazyFilterGroups.Value.ToList()
                .ForEach(group => temp |= group);
                return(temp);
            }, true);
        }
        private async Task OnAddCommandExecuteAsync()
        {
            var logFilterGroup = new LogFilterGroup();

            if (await _uiVisualizerService.ShowDialogAsync <LogFilterGroupEditorViewModel>(logFilterGroup) ?? false)
            {
                FilterGroups.Add(logFilterGroup);
                await SaveFilterGroupsAsync();

                Updated.SafeInvoke(this);
            }
        }
        private async Task OnRemoveCommandExecuteAsync()
        {
            var result = await _messageService.ShowAsync("Are you sure?", button : MessageButton.YesNo, icon : MessageImage.Warning);

            if (result == MessageResult.Yes)
            {
                FilterGroups.Remove(SelectedFilterGroup);
                await SaveFilterGroupsAsync();

                SelectedFilterGroup = null;

                Updated.SafeInvoke(this);
            }
        }
Exemplo n.º 11
0
 private void FilterGroupPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "SelectedTrack")
     {
         if (Object.ReferenceEquals(sender, _selectedFilterGroup))
         {
             RaisePropertyChanged("SelectedTrack");
         }
         else if ((sender is FilterGroupViewModel) && FilterGroups.Contains(sender))
         {
             SelectedFilterGroup = (FilterGroupViewModel)sender;
         }
     }
 }
Exemplo n.º 12
0
        private async Task OnRemoveCommandExecuteAsync()
        {
            var result = await _messageService.ShowAsync(LanguageHelper.GetString("Controls_LogViewer_AreYouSure"),
                                                         button : MessageButton.YesNo, icon : MessageImage.Warning);

            if (result == MessageResult.Yes)
            {
                FilterGroups.Remove(SelectedFilterGroup);
                await SaveFilterGroupsAsync();

                SelectedFilterGroup = null;

                Updated?.Invoke(this, EventArgs.Empty);
            }
        }
Exemplo n.º 13
0
        public IActionResult Filter(FilterGroups model)
        {
            var groups = db.Groups.AsNoTracking();

            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                groups = groups.Where(s => EF.Functions.Like(s.Name, $"%{model.Name}%"));
            }

            var viewModels = groups.Select(g => new ViewModels.FilterGroupsViewModel()
            {
                Id            = g.Id,
                Name          = g.Name,
                StudentsCount = g.StudentGroups.Count
            }).ToList();

            return(Ok(viewModels));
        }
Exemplo n.º 14
0
 public FilterGroup GetFilterGroup(string name) => FilterGroups.FirstOrDefault(g => g.GroupID.Equals(name.ToLower()));
 protected override void CreateFilterGroups()
 {
     FilterGroups.Clear();
     FilterGroups.Add(CreateWorkPeriodFilterGroup());
 }
Exemplo n.º 16
0
        private async Task LoadFilterGroupsAsync()
        {
            var filterGroups = await _applicationLogFilterGroupService.LoadAsync();

            FilterGroups.ReplaceRange(filterGroups /*.Where(x => !x.IsRuntime)*/.OrderBy(x => x.Name));
        }
 private async Task LoadFilterGroupsAsync()
 {
     FilterGroups.ReplaceRange(await _applicationLogFilterGroupService.LoadAsync());
 }
Exemplo n.º 18
0
        public virtual Condition BuildCondition(Type type, VariableResolver variableResolver = null, IEnumerable <string> validProperties = null, IDictionary <string, string> propertyMapping = null)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            var arg = new BuildArgument
            {
                ValidProperties  = validProperties,
                VariableResolver = variableResolver,
                EvaluationType   = type,
                PropertyMapping  = propertyMapping
            };

            var           error         = new ConditionBase.ErrorInfo();
            var           result        = new Condition();
            var           predicates    = new List <LambdaExpression>();
            var           exceptions    = new List <Exception>();
            OrderByClause orderByClause = null;

            if (Filters != null && Filters.Any())
            {
                var filtersResult = Filters.TryBuildPredicate(type, arg);
                if (filtersResult.Succeeded)
                {
                    predicates.Add(filtersResult.Result);
                }
                else
                {
                    if (filtersResult.Exception != null)
                    {
                        exceptions.Add(filtersResult.Exception);
                    }
                }
            }

            if (FilterGroups != null && FilterGroups.Any())
            {
                var filterGroupsResult = FilterGroups.TryBuildPredicate(type, arg);
                if (filterGroupsResult.Succeeded)
                {
                    predicates.Add(filterGroupsResult.Result);
                }
                else
                {
                    if (filterGroupsResult.Exception != null)
                    {
                        exceptions.Add(filterGroupsResult.Exception);
                    }
                }
            }

            if (!string.IsNullOrEmpty(Where))
            {
                var whereResult = ExpressionParser.Parse(Where, type, arg);
                if (whereResult.Succeeded)
                {
                    predicates.Add(whereResult.Result);
                }
                else
                {
                    if (whereResult.Exception != null)
                    {
                        exceptions.Add(whereResult.Exception);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(OrderBy))
            {
                var orderByResult = OrderByParser.Parse(OrderBy, arg);
                if (orderByResult.Succeeded)
                {
                    orderByClause = orderByResult.Result;
                }
                else
                {
                    if (orderByResult.Exception != null)
                    {
                        exceptions.Add(orderByResult.Exception);
                    }
                }
            }
            else if (OrderBys != null && OrderBys.Any())
            {
                var orderBysResult = OrderByParser.Parse(OrderBys.ToArray(), arg);
                if (orderBysResult.Succeeded)
                {
                    orderByClause = orderBysResult.Result;
                }
                else
                {
                    if (orderBysResult.Exception != null)
                    {
                        exceptions.Add(orderBysResult.Exception);
                    }
                }
            }

            var isInvalid = arg.InvalidProperties.Any() || arg.InvalidOperators.Any() || arg.InvalidVariables.Any() || exceptions.Any();

            result.IsValid = !isInvalid;
            if (isInvalid)
            {
                error.EvaluationResult = new EvaluationResultBase
                {
                    InvalidProperties        = arg.InvalidProperties,
                    InvalidValues            = arg.InvalidValues,
                    InvalidOperators         = arg.InvalidOperators,
                    InvalidVariables         = arg.InvalidVariables,
                    InvalidOrderByDirections = arg.InvalidOrderByDirections
                };
                error.Exceptions = exceptions;
                result.Error     = error;
            }
            else
            {
                result.Predicates    = predicates;
                result.OrderByClause = orderByClause;
            }

            return(result);
        }