Beispiel #1
0
        public static List <CustomReportFilterViewModel> GetUsedFiltersForReport(IUnitOfWork db, long reportId)
        {
            var query = from filter in db.CustomReportFilters.GetAllAsDto()

                        join predefinedField in db.CustomReportPredefinedFields.GetAllAsDto()
                        on filter.CustomReportPredefinedFieldId equals predefinedField.Id
                        where filter.CustomReportId == reportId
                        select new
            {
                Id = filter.Id,
                PredefinedField = predefinedField,
                Filter          = filter,
                //Field = field
            };

            var res = query.ToList().Select(x => new CustomReportFilterViewModel()
            {
                Id    = x.Filter.Id,
                Field = new CustomReportFieldViewModel(x.PredefinedField),
                AvailableOperations = CustomReportService.GetOperations(x.PredefinedField.DataType).Select(y => new FilterOperationViewModel(y)).ToList(),
                Operation           = (FilterOperation)Enum.Parse(typeof(FilterOperation), x.Filter.Operation),
                Value             = GetObjectFromString(x.PredefinedField.DataType, x.Filter.Value),
                PredefinedFieldId = x.PredefinedField.Id,
                OperationString   = EnumHelper <FilterOperation> .GetEnumDescription(x.Filter.Operation.ToString()),
                Items             = x.PredefinedField.DataType == "feature" ? FeatureViewModel.GetFeatureValuesByName(db, x.PredefinedField.Name) : new List <SelectListItemEx>(),
                ValueTitle        = x.PredefinedField.DataType == "feature" ? db.FeatureValues.Get((int)GetObjectFromString(x.PredefinedField.DataType, x.Filter.Value)).Value : null
            });

            return(res.ToList());
        }
Beispiel #2
0
        public static List <CustomReportFilterViewModel> GetAllPredefinedFilters(IUnitOfWork db)
        {
            var predefinedList = db.CustomReportPredefinedFields.GetAllAsDto().ToList();
            var res            = from a in predefinedList
                                 select new CustomReportFilterViewModel()
            {
                PredefinedFieldId   = a.Id,
                Field               = new CustomReportFieldViewModel(a),
                AvailableOperations = CustomReportService.GetOperations(a.DataType).Select(x => new FilterOperationViewModel(x)).ToList(),
                OperationString     = new FilterOperationViewModel(CustomReportService.GetOperations(a.DataType).First()).OperationString,
                Items               = a.DataType == "feature" ? FeatureViewModel.GetFeatureValuesByName(db, a.Name) : new List <SelectListItemEx>()
            };

            return(res.ToList());
        }
Beispiel #3
0
        private static List <FilterOperationViewModel> GetOperations(CustomReportFieldAttribute atr)
        {
            var operations = CustomReportService.GetOperations(atr.DataType);

            return(operations.Select(x => new FilterOperationViewModel(x)).ToList());
        }