Exemplo n.º 1
0
        public ActionResult GetPartnerCollectionForPaging(string sidx, string sord, string filters, int page = 1)
        {
            using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
            {
                RelationPredicateBucket bucket = new RelationPredicateBucket();
                long firmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name);
                bucket.PredicateExpression.Add(PartnerFields.FirmaId == firmaId);

                if (filters != null)
                {
                    bucket.PredicateExpression.Add(PredicateHelper.CreatePredicateFromJqGridFilterString(filters, typeof(PartnerFields), DbGenericHelper.GetDbGenericTypeByName));
                }

                if (!string.IsNullOrWhiteSpace(filters))
                {
                    JqGridFilter     jqGridFilter = JsonConvert.DeserializeObject <JqGridFilter>(filters);
                    bool             foo;
                    JqGridFilterItem filterItem = jqGridFilter.rules.Where(r => r.field == PartnerFields.IsActive.Name && bool.TryParse(r.data, out foo)).SingleOrDefault();
                    if (filterItem != null)
                    {
                        bool isActive = bool.Parse(filterItem.data);
                        bucket.PredicateExpression.Add(PartnerFields.IsActive == isActive);
                    }
                }

                bool?isSortAscending = PagerBase.IsJqgridSortAscending(sord);

                PartnerPager partnerPager = new PartnerPager();
                partnerPager.LoadData(adapter, bucket, page, Common.Config.JqGridPageSize, sidx, isSortAscending);

                return(CreateJsonResponse(partnerPager.CreateJqGridRespose()));
            }
        }
Exemplo n.º 2
0
        public static RelationPredicateBucket CreateBucket(short godina, string jqGridFilters)
        {
            RelationPredicateBucket bucket = new RelationPredicateBucket(RacunGlavaFields.Godina == godina);

            if (!string.IsNullOrWhiteSpace(jqGridFilters))
            {
                bucket.PredicateExpression.Add(PredicateHelper.CreatePredicateFromJqGridFilterString(jqGridFilters, typeof(RacunGlavaFields), DbGenericHelper.GetDbGenericTypeByName));

                JqGridFilter jqGrid = JsonConvert.DeserializeObject <JqGridFilter>(jqGridFilters);
                if (jqGrid != null &&
                    jqGrid.rules != null)
                {
                    DateTime?datumOd = null;
                    DateTime?datumDo = null;
                    foreach (JqGridFilterItem item in jqGrid.rules.Where(r => r.field == "Datum"))
                    {
                        if (item.op == "ge")
                        {
                            datumOd = DateTime.Parse(item.data).Date;
                        }

                        if (item.op == "le")
                        {
                            datumDo = DateTime.Parse(item.data).Date.AddDays(1);
                        }

                        bucket.PredicateExpression.Add(PredicateHelper.FilterValidEntities(datumOd, datumDo, RacunGlavaFields.Datum));
                    }
                }
            }

            return(bucket);
        }
Exemplo n.º 3
0
        public ActionResult GridData()
        {
            JqGridData<Log> gridData = GetGridData();

            var filter = new JqGridFilter<Log>(Request, gridData);
            var jqGridJsonResult = new JqGridJsonResult<Log>(gridData, filter);

            IEnumerable<Log> logs = GetMockLogs();
            if (filter.OrderByFunc != null)
            {
                logs = filter.Ascending
                           ? logs.OrderBy(filter.OrderByFunc)
                           : logs.OrderByDescending(filter.OrderByFunc);
            }

            return jqGridJsonResult.Result(logs
                                               .Skip((filter.Page - 1)*filter.Rows)
                                               .Take(filter.Rows)
                                           , logs.Count());
        }
Exemplo n.º 4
0
        public ActionResult GridData()
        {
            JqGridData <Log> gridData = GetGridData();

            var filter           = new JqGridFilter <Log>(Request, gridData);
            var jqGridJsonResult = new JqGridJsonResult <Log>(gridData, filter);


            IEnumerable <Log> logs = GetMockLogs();

            if (filter.OrderByFunc != null)
            {
                logs = filter.Ascending
                           ? logs.OrderBy(filter.OrderByFunc)
                           : logs.OrderByDescending(filter.OrderByFunc);
            }

            return(jqGridJsonResult.Result(logs
                                           .Skip((filter.Page - 1) * filter.Rows)
                                           .Take(filter.Rows)
                                           , logs.Count()));
        }
Exemplo n.º 5
0
        private StringBuilder ParseFilter(JqGridFilter filters, Type targetSearchType)
        {
            var parsedRules = ParseRule(filters.Rules, filters.GroupOp, targetSearchType);
            var parsedGroups = ParseFilter(filters.Groups, filters.GroupOp, targetSearchType);

            if (parsedRules != null && parsedRules.Length > 0)
            {
                if (parsedGroups != null && parsedGroups.Length > 0)
                {
                    var groupOpStr = filters.GroupOp.ToString();
                    var sb = new StringBuilder(parsedRules.Length + parsedGroups.Length + groupOpStr.Length + 4);
                    AppendWithBrackets(sb, parsedRules);
                    sb.Append(groupOpStr);
                    AppendWithBrackets(sb, parsedGroups);
                    return sb;
                }
                return parsedRules;
            }
            return parsedGroups;
        }