private JArray GetData()
        {
            var data = new JArray();

            if (string.IsNullOrEmpty(GetSchemaName()))
            {
                return(data);
            }
            DashboardGridDataSelectBuilder selectBuilder = GetSelectBuilder();

            ApplySectionBindingFilter(selectBuilder);
            Select select          = selectBuilder.Build();
            var    entityColumnMap = selectBuilder.EntityColumnsMap;

            using (var dbExecutor = UserConnection.EnsureDBConnection()) {
                using (IDataReader dataReader = select.ExecuteReader(dbExecutor)) {
                    while (dataReader.Read())
                    {
                        var dataItem = new JObject();
                        foreach (var map in entityColumnMap)
                        {
                            object value = GetValueByColumnMap(dataReader, (Dictionary <string, object>)map.Value);
                            dataItem.Add(new JProperty(map.Key, value));
                        }
                        data.Add(dataItem);
                    }
                }
            }
            return(data);
        }
Exemplo n.º 2
0
        private JArray GetGridRecords(JArray columns, int rowCount, int rowOffset, int serieIndex, bool useFilter = false, string filterValue = null)
        {
            var    data       = new JArray();
            string schemaName = GetSchemaName(serieIndex);

            if (!string.IsNullOrEmpty(schemaName))
            {
                DashboardGridDataSelectBuilder selectBuilder =
                    GetDashboardGridDataSelectBuilder(columns, rowCount, rowOffset, serieIndex);
                JToken serieParameters = GetParameters(serieIndex);
                SetChartFilters(selectBuilder, serieParameters);
                if (useFilter)
                {
                    SetSerieFilter(selectBuilder, serieParameters, filterValue);
                }
                Select select = selectBuilder.Build();
                Dictionary <string, object> entityColumnMap = selectBuilder.EntityColumnsMap;
                using (var dbExecutor = UserConnection.EnsureDBConnection()) {
                    using (IDataReader dataReader = select.ExecuteReader(dbExecutor)) {
                        while (dataReader.Read())
                        {
                            var dataItem = new JObject();
                            foreach (var map in entityColumnMap)
                            {
                                object value = GetValueByColumnMap(dataReader, (Dictionary <string, object>)map.Value);
                                dataItem.Add(new JProperty(map.Key, value));
                            }
                            data.Add(dataItem);
                        }
                    }
                }
            }
            return(data);
        }
Exemplo n.º 3
0
        private JArray GetGridRecords(JArray columns, int rowCount, int rowOffset)
        {
            var data = new JArray();
            DashboardGridDataSelectBuilder selectBuilder = CreateDashboardGridDataSelectBuilder(columns);
            string filterData = Parameters.Value <string>("filterData");

            selectBuilder.AddFilterByJson(filterData);
            selectBuilder.EsqOptions = new EntitySchemaQueryOptions {
                PageableRowCount        = rowCount,
                RowsOffset              = rowOffset,
                PageableDirection       = PageableSelectDirection.Current,
                PageableConditionValues = new Dictionary <string, object>()
            };
            Select select          = selectBuilder.Build();
            var    entityColumnMap = selectBuilder.EntityColumnsMap;

            using (var dbExecutor = UserConnection.EnsureDBConnection()) {
                using (IDataReader dataReader = select.ExecuteReader(dbExecutor)) {
                    while (dataReader.Read())
                    {
                        var dataItem = new JObject();
                        foreach (var map in entityColumnMap)
                        {
                            object value = GetValueByColumnMap(dataReader, (Dictionary <string, object>)map.Value);
                            dataItem.Add(new JProperty(map.Key, value));
                        }
                        data.Add(dataItem);
                    }
                }
            }
            return(data);
        }