public ItemInFilterData(IFilterData fD)
 {
     this.Text     = fD.Text;
     this.Value    = fD.Value;
     this.Icon     = fD.Icon;
     this.Selected = fD.Selected;
 }
        internal static LambdaExpression LessPredicate(IFilterData data, object value)
        {
            CreateConvertedParameters(data, value, out var parameterExp, out var constExp, out var propertyConvertedExp);

            var equalExp = Expression.LessThan(propertyConvertedExp, constExp);

            return(Expression.Lambda(equalExp, parameterExp));
        }
        internal static LambdaExpression AllPredicate(IFilterData data, LambdaExpression lambdaExpression)
        {
            CreateConvertedParameters(data, null, out var parameterExp, out var _, out var propertyConvertedExp);

            var all = CreateAll(propertyConvertedExp, lambdaExpression);

            return(Expression.Lambda(all, parameterExp));
        }
        private static void GetSelection(IFilterData data, out ParameterExpression parameterExp, out Expression propertyExp)
        {
            var childTree  = FilterDataHelper.CreateChildTree(data);
            var parentData = GetParent(childTree);

            parameterExp = Expression.Variable(parentData.PropertyType);
            propertyExp  = CreatePropertyOrSelect(childTree, parameterExp, data);
        }
Example #5
0
        /// <summary>
        /// TODO
        /// </summary>
        public FilterDefaultValue(IFilterData filterData)
        {
            MaxDate = filterData.MaxDate;

            DateTime minDate = filterData.MaxDate.AddDays(-((filterData.MaxDate - filterData.MinDate).Days * 0.1));

            MinDate = minDate > filterData.MinDate ? minDate : filterData.MinDate;
        }
Example #6
0
        public string GetCampNameByCampaignId(IFilterData filterData)
        {
            string name    = "";
            var    service = new ServiceCampaign(filterData.Config, filterData.Log);

            name = service.GetCampNameByCampaignId(filterData.EntityGuidId);
            return(name);
        }
        public static IFilterData CreateFilterData(IFilterData parent, string valueMember)
        {
            var parentType   = TypeHelper.GetTypeOfData(parent);
            var propertyInfo = TypeDescriptor.GetProperties(parentType).Cast <PropertyDescriptor>().FirstOrDefault(p => p.Name == valueMember);
            var propertyType = propertyInfo.PropertyType;

            return(CreateFilterData(parent, propertyType, valueMember));
        }
Example #8
0
 internal static IFilterData GetGrandFather(this IFilterData data)
 {
     while (data.Parent is IFilterData parent)
     {
         data = parent;
     }
     return(data);
 }
        internal static LambdaExpression AnyPredicate(IFilterData data)
        {
            CreateConvertedParameters(data, null, out var parameterExp, out var _, out var propertyConvertedExp);

            var any = CreateAny(propertyConvertedExp);

            return(Expression.Lambda(any, parameterExp));
        }
        private static void CreateParameters(IFilterData data, object value, out ParameterExpression parameterExp, out ConstantExpression constExp, out Expression propertyExp)
        {
            var childTree  = FilterDataHelper.CreateChildTree(data);
            var parentData = GetParent(childTree);

            parameterExp = Expression.Variable(parentData.PropertyType);
            constExp     = Expression.Constant(value);
            propertyExp  = CreatePropertyExp(childTree, parameterExp);
        }
        public static IEnumerable <IFilterData> CreateChildren(this IFilterData parent)
        {
            var type       = parent.PropertyType;
            var properties = TypeDescriptor.GetProperties(type);

            foreach (PropertyDescriptor property in properties)
            {
                yield return(new FilterData(parent, property.PropertyType, property.Name, property.DisplayName));
            }
        }
        private static Expression CreateSelect(Expression parentExp, IFilterData propertyInfo, IFilterData data)
        {
            var newData        = data.Copy();
            var inner          = FilterDataHelper.ChangeInnerParent(propertyInfo.Parent, newData);
            var innerLambda    = PropertySelector(newData);
            var collectionType = parentExp.Type.GetInterface(nameof(IQueryable)) != null? typeof(Queryable) : parentExp.Type.GetInterface(nameof(IEnumerable)) != null ? typeof(Enumerable) : throw new ArgumentException(parentExp.Type.Name);
            var select         = collectionType.GetMethods(BindingFlags.Static | BindingFlags.Public).First(m => m.Name == "Select" && m.GetParameters().Length == 2).MakeGenericMethod(new[] { inner.PropertyType, innerLambda.ReturnType });

            return(Expression.Call(select, parentExp, innerLambda));
        }
        internal static IFilterData ChangeInnerParent(IFilterData oldParent, IFilterData data)
        {
            while (!data.Parent.Equals(oldParent))
            {
                data = data.Parent;
            }

            data.Parent      = data.Parent.AsRoot();
            data.IsSelection = false;
            return(data.Parent);
        }
        internal static LambdaExpression LikePredicate(IFilterData data, object value)
        {
            CreateConvertedParameters(data, value, out var parameterExp, out var constExp, out var propertyConvertedExp);
            //var containsInfo = typeof(String).GetMethod(nameof(String.Contains));
            //var equalExp = Expression.Call(propertyConvertedExp, containsInfo, constExp);

            var containsInfo = typeof(DbFunctions).GetMethod(nameof(DbFunctions.Like), new[] { typeof(string), typeof(string), typeof(string) });
            var equalExp     = Expression.Call(null, containsInfo, propertyConvertedExp, ToLikeExp(value?.ToString() ?? ""), Expression.Constant(FilterDataHelper.LikeScreening.ToString()));

            return(Expression.Lambda(equalExp, parameterExp));
        }
Example #15
0
 public static Type GetTypeOfParent(this IFilterData f)
 {
     if (f == null)
     {
         throw new ArgumentNullException(nameof(f));
     }
     else
     {
         return(GetTypeOfData(f.Parent));
     }
 }
        internal static List <IFilterData> CreateChildTree(IFilterData data)
        {
            var current   = data ?? throw new ArgumentNullException(nameof(data));
            var childTree = new List <IFilterData>();

            while (current != null)
            {
                childTree.Add(current);
                current = current.Parent;
            }
            return(childTree);
        }
Example #17
0
        public List <CampaignConflitView> GetDataDemo(IFilterData filterData)
        {
            var service   = new ServiceCampaign(filterData.Config, filterData.Log);
            var startDate = DateTime.ParseExact(filterData.StartDate,
                                                ConstVars.DATE_FORMAT,
                                                new CultureInfo(Culture));

            var endDate = DateTime.ParseExact(filterData.EndDate,
                                              ConstVars.DATE_FORMAT,
                                              new CultureInfo(Culture));

            return(service.GetDataDemo().ToList());
        }
Example #18
0
        public GridFilter(IEnumerable <IFilterData> fD, IFilterData defaultFilterItem, string name)
        {
            var items = new List <ItemInFilter>();

            foreach (IFilterData f in fD)
            {
                if (f.Equals(defaultFilterItem))
                {
                    f.Selected = true;
                }
                items.Add(new ItemInFilter(f));
            }
            this.items       = items;
            this.name        = name;
            this.defaultItem = new ItemInFilter(defaultFilterItem);
            CSSId            = "js_filter_" + name;
        }
Example #19
0
        public static Type GetTypeOfData(IFilterData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var t = data.PropertyType;

            if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                return(t.GetGenericArguments().Single());
            }
            else
            {
                return(t);
            }
        }
Example #20
0
        private GeneralDisplayViewModel CreateGeneralDisplayViewModel(StandardFilter standardFilter)
        {
            // load the data
            IEnumerable <IEntry> entries = EntryContext.LoadEntries(standardFilter);

            // register parsers
            EntryParsing.Register(GraphProcessor);
            EntryParsing.Register(StatisticsProcessor);

            // parse data
            EntryParsing.Parse(entries);

            // create EntryListViewModel
            EntryListViewModel entryListViewModel = new EntryListViewModel(entries);


            // create EntriesGraphViewModel
            EntriesGraphViewModel entriesGraphViewModel = new EntriesGraphViewModel(GraphProcessor.Result);

            // create EntriesStatisticsViewModel
            EntriesStatisticsViewModel entriesStatisticsViewModel = new EntriesStatisticsViewModel(StatisticsProcessor.Result);

            //TODO: move filter to another action and create sepparate call for it or something
            // get filter data
            IFilterData filterData = EntryContext.GetFilterData();

            // create FilterViewModel
            FilterViewModel filterViewModel = new FilterViewModel(filterData);


            // create generalDisplayViewModel
            GeneralDisplayViewModel generalDisplayViewModel = new GeneralDisplayViewModel(entryListViewModel, entriesGraphViewModel, entriesStatisticsViewModel, filterViewModel);

            // return ...
            return(generalDisplayViewModel);
        }
 private void SetDefaultFilter(IFilterData defaultFilter)
 {
     this.defaultFilter = defaultFilter;
 }
 private void SetDefaultFilter()
 {
     this.defaultFilter = emptyFilter;
 }
 public GridFilter GetGridFilter(List <IFilterData> filterDataset, string emptyFilterName, string gridFilterName, IFilterData defaultFilter)
 {
     setEmptyFilter(emptyFilterName);
     SetDefaultFilter(defaultFilter);
     SetEmptyFilterNotSelected();
     SetUpGridFilter(filterDataset, gridFilterName);
     return(gridFilter);
 }
Example #24
0
 public static (Type SrcTypem, string PropertyName, string DisplayProperty) ToDisplay(this IFilterData data) => (data.GetTypeOfParent(), data.PropertyName, data.DisplayName);
 public static ISortDataOperand SortOperand(IFilterData data, SortingDirection direction) => new SortOperand(direction, data);
Example #26
0
 public LessFilter(IFilterData data)
 {
     Data = data;
 }
 public MoreFilter(IFilterData data)
 {
     Data = data;
 }
 public static LessFilter LessFilter(IFilterData data, object value) => new LessFilter(data)
 {
     Value = value
 };
Example #29
0
 public abstract List <T> GetData(IFilterData filterData);
 public static LessFilter LessFilter(IFilterData data) => new LessFilter(data);