コード例 #1
0
        private IEnumerable <CustomReportFilterViewModel> GetFilters(CustomReportView_ViewModel model, CustomReportBaseDataViewModel it)
        {
            Regex rg = new Regex(@"\(.*?\)");

            model.ValuesListString = rg.Replace(model.ValuesListString, "").Replace(" GMT+", ".").Replace(" GMT ", ".");
            model.ValuesList       = model.ValuesListString.Split(';').ToList();
            model.IdsList          = model.IdsListString.Split(';').Select(x => long.Parse(x)).ToList();
            var filters     = model.IdsList.Zip(model.ValuesList, (i, v) => new { Id = i, Value = v }).Where(x => !String.IsNullOrEmpty(x.Value)).ToList();
            var initFilters = it.GetAllAvailableFilters(Db);
            var res         = from f in filters
                              join i in initFilters
                              on f.Id equals i.Id
                              select new CustomReportFilterViewModel()
            {
                Id = i.Id,

                Field     = i.Field,
                Operation = i.Operation,

                ValueString = f.Value,
                Value       = SystemTypeHelper.GetObjectByString(f.Value, i.Field.DataType, i.Multi)
            };

            return(res.Where(x => !String.IsNullOrEmpty(x.ValueString)));
        }
コード例 #2
0
        public static List <CustomReportFilterDTO> 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 CustomReportFilterDTO()
            {
                Id = x.Filter.Id,
                CustomReportPredefinedField = x.PredefinedField,
                //AvailableOperations = GetOperations(x.PredefinedField.DataType),
                Operation   = x.Filter.Operation,
                ValueObject = SystemTypeHelper.GetObjectByString(x.Filter.Value, x.PredefinedField.DataType),
                //OperationString = EnumHelper<FilterOperation>.GetEnumDescription(x.Filter.Operation.ToString())
            });

            return(res.ToList());
        }
コード例 #3
0
        private object GetValueObject(string val, string dataType, bool multi = false)
        {
            int days = 0;

            if (multi)
            {
                return(String.IsNullOrEmpty(val) ? new List <int>() : val.Split(',').Select(x => int.Parse(x)).ToList());
            }
            if (dataType == "datetime" && int.TryParse(val, out days))
            {
                return(DateTime.Now.AddDays(days).Date);
            }
            return(SystemTypeHelper.GetObjectByString(val, dataType));
        }