Пример #1
0
        public void SetFiltersToStorageValues(StorageValues storageValues)
        {
            var filterValues = GetFilterValues();

            foreach (var item in storageValues.GetStorageNames())
            {
                if (!filterValues.ContainsKey(item))
                {
                    continue;
                }
                if (filterValues[item].Count == 0)
                {
                    storageValues.SetStorageValues(item, ColumnFilterType.None, new object[2]);
                }
                else
                {
                    var filterItem = filterValues[item][0];
                    storageValues.SetStorageValues(item, filterItem.ColumnFilterType.Value, filterItem.Value1, filterItem.Value2);
                }
            }
            for (int i = 0; i < storageValues.CountListValues; i++)
            {
                foreach (var item in storageValues.GetCircleStorageNames(i))
                {
                    if (!filterValues.ContainsKey(item) || filterValues[item].Count <= i)
                    {
                        continue;
                    }
                    var filterItem = filterValues[item][i];
                    storageValues.SetCircleStorageValues(item, i, filterItem.Value1, filterItem.Value2);
                }
            }
        }
Пример #2
0
        public virtual void SetFiltersByStorageValues(StorageValues storageValues, MainPageUrlBuilder urlBuilder)
        {
            var filterValues = GetFilterValues();

            foreach (var item in storageValues.GetStorageNames())
            {
                var columnFilterType = storageValues.GetStorageFilterType(item);
                if (columnFilterType == null || columnFilterType == ColumnFilterType.None)
                {
                    continue;
                }

                var values = storageValues.GetStorageValues(item);
                if (!filterValues.ContainsKey(item))
                {
                    filterValues[item] = new List <FilterItem>();
                }
                else
                {
                    filterValues[item].Clear();
                }
                if (columnFilterType == ColumnFilterType.In || columnFilterType == ColumnFilterType.OutOf)
                {
                    filterValues[item].AddRange(values.Select(r => new FilterItem(item, columnFilterType, new[] { r })));
                }
                else
                {
                    var filterItem = new FilterItem(item, columnFilterType, values);
                    filterValues[item].Add(filterItem);
                }
            }
            for (int i = 0; i < storageValues.CountListValues; i++)
            {
                foreach (var item in storageValues.GetCircleStorageNames(i))
                {
                    var columnFilterType = storageValues.GetCircleStorageFilterType(item, i);
                    if (columnFilterType == null || columnFilterType == ColumnFilterType.None)
                    {
                        continue;
                    }

                    var values     = storageValues.GetCircleStorageValues(item, i);
                    var filterItem = new FilterItem(item, columnFilterType, values);
                    if (!filterValues.ContainsKey(item))
                    {
                        filterValues[item] = new List <FilterItem>();
                    }
                    else if (i == 0)
                    {
                        filterValues[item].Clear();
                    }

                    filterValues[item].Add(filterItem);
                }
            }
            urlBuilder.SetFilter(TableName, filterValues);
        }