Exemplo n.º 1
0
        private LOVsGeneralGridParameters SetSortFieldParameter(LOVsGeneralGridParameters filterParam)
        {
            if (!string.IsNullOrEmpty(filterParam.SortField))
            {
                switch (filterParam.SortField.ToLower())
                {
                case name:
                    filterParam.SortField = name;
                    break;

                default:
                    filterParam.SortField = string.Empty;
                    break;
                }
            }

            return(filterParam);
        }
Exemplo n.º 2
0
        private List <int> FilterGridDataIds(GridPropertyObejctModel gridPropertyData)
        {
            List <GridFilterObejctModel> andFilters  = new List <GridFilterObejctModel>();
            LOVsGeneralGridParameters    filterParam = new LOVsGeneralGridParameters();
            List <GridFilterObejctModel> orFilters   = new List <GridFilterObejctModel>();
            List <GridFilterObejctModel> filters     = new List <GridFilterObejctModel>();
            List <int> itemResultIds    = new List <int>();
            List <int> itemResultLovIds = new List <int>();
            string     sqlQueryBody     = string.Empty;
            string     sortDir          = direction;
            string     sortfield        = name;
            int        pageSize         = 20;
            int        skip             = 0;
            string     searchWord       = string.Empty;

            try {
                if (gridPropertyData != null) //Grid Property operations Handled
                {
                    sortDir    = string.IsNullOrEmpty(gridPropertyData.sortDir) ? direction : gridPropertyData.sortDir;
                    sortfield  = string.IsNullOrEmpty(gridPropertyData.sortfield) ? name : gridPropertyData.sortfield;
                    skip       = gridPropertyData.skip.HasValue ? gridPropertyData.skip.Value : 0;
                    pageSize   = gridPropertyData.pageSize.HasValue ? gridPropertyData.pageSize.Value : 0;
                    filters    = gridPropertyData.filters;
                    searchWord = gridPropertyData.SearchWord;

                    var sample = filters.GroupBy(f => f.Operator);

                    foreach (var subFilter in sample)
                    {
                        if (subFilter.Key == and)
                        {
                            andFilters = subFilter.ToList();
                        }
                        if (subFilter.Key == or)
                        {
                            orFilters = subFilter.ToList();
                        }
                    }

                    foreach (GridFilterObejctModel item in andFilters)
                    {
                        bool isAnd = false;

                        isAnd = item.Operator == and ? true : false;
                        if (isAnd)
                        {
                            switch (item.Field.ToLower())
                            {
                            case name:
                                sqlQueryBody += " AND LOWER(A.Name) LIKE '%" + item.Value.Trim().ToLower() + "%'";
                                break;

                            default:
                                sqlQueryBody = string.Empty;
                                break;
                            }
                        }
                    }
                }



                GridOperationRepository <int> repo = new GridOperationRepository <int>();
                searchWord = GetCommonSearchQuery(searchWord);

                if (orFilters.Any())
                {
                    gridPropertyData.filters = orFilters;
                }

                gridPropertyData.sortDir   = sortDir;
                gridPropertyData.sortfield = sortfield;
                gridPropertyData.skip      = skip;
                gridPropertyData.pageSize  = pageSize;

                filterParam.TableName      = "Firm";
                filterParam.sqlQueryString = sqlQueryBody;
                filterParam.PageSize       = (int)gridPropertyData.pageSize;
                filterParam.SortField      = gridPropertyData.sortfield;
                filterParam.SortDirection  = gridPropertyData.sortDir;
                filterParam.Skip           = (int)gridPropertyData.skip;

                // itemResultIds = repo.LOVFilterTableContent(gridPropertyData, firm, sqlQueryBody, searchWord).ToList();
                //SetSortFieldParameter(filterParam);
                itemResultLovIds = repo.LOVsGridTableContentIds(filterParam).ToList();
            }
            catch (OptimisticConcurrencyException ex)
            {
                EventLogger.LogEvent(ex);
            }
            catch (Exception ex)
            {
                EventLogger.LogEvent(ex);
                throw;
            }

            return(itemResultLovIds);
        }