public static IEnumerable <TRow> Select <TKey, TTable, TDataContext, TRow>(
            this BaseDataSourceView <TKey, TTable, TDataContext, TRow> view,
            StoreReadDataEventArgs e,
            BaseFilterControl <TKey, TTable, TDataContext> filter,
            GridFilters gridFilter,
            BaseGridColumns columns,
            bool sort)
            where TKey : struct
            where TTable : class
            where TDataContext : DataContext, new()
            where TRow : BaseRow, new()
        {
            var dataSourceSelectArguments = new DataSourceSelectArguments(e.Start, e.Limit);

            dataSourceSelectArguments.RetrieveTotalRowCount = true;

            if (sort && e.Sort != null && e.Sort.Length > 0)
            {
                dataSourceSelectArguments.SortExpression = GetSortExpression(columns, e.Sort);
            }

            IEnumerable result = null;

            view.Select(dataSourceSelectArguments, data => { result = data; });
            e.Total = dataSourceSelectArguments.TotalRowCount;

            return(result.Cast <TRow>());
        }
 public static void InitializeListConfig <TKey>(this BaseDataSourceView <TKey> view, IListConfig config)
     where TKey : struct
 {
     if (config != null)
     {
         foreach (var column in config.Columns)
         {
             view.SetLookupVisible(column.ServerMaping, true);
         }
     }
 }
 public static IEnumerable <TRow> Select <TKey, TTable, TDataContext, TRow>(
     this BaseDataSourceView <TKey, TTable, TDataContext, TRow> view,
     StoreReadDataEventArgs e,
     BaseFilterControl <TKey, TTable, TDataContext> filter,
     GridFilters gridFilter,
     BaseGridColumns columns)
     where TKey : struct
     where TTable : class
     where TDataContext : DataContext, new()
     where TRow : BaseRow, new()
 {
     return(Select(view, e, filter, gridFilter, columns, true));
 }
Beispiel #4
0
 public static void ReadData <TKey, TTable, TDataContext, TRow>(
     this GridPanel gridPanel,
     BaseDataSourceView <TKey, TTable, TDataContext, TRow> view,
     StoreReadDataEventArgs e,
     BaseFilterControl <TKey, TTable, TDataContext> filter,
     GridFilters gridFilter,
     BaseGridColumns columns)
     where TKey : struct
     where TTable : class
     where TDataContext : DataContext, new()
     where TRow : BaseRow, new()
 {
     gridPanel.GetStore().ReadData <TKey, TTable, TDataContext, TRow>(view, e, filter, gridFilter, columns);
 }
        private void CreateInstanceOfDataSourceView(string viewName)
        {
            if ("Default".Equals(viewName, StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(viewName))
            {
                viewName = DataSourceName;
            }
            if (!DatasourcesSectionCollection.DataSources.ContainsKey(viewName))
            {
                throw new Exception(string.Format("Configuration section 'Nat.Initializer/Initializer/datasources' not contains datasource name '{0}' ({1})", viewName, ID));
            }

            var instance = Activator.CreateInstance(DatasourcesSectionCollection.DataSources[viewName], (IDataSource)this, viewName);

            _baseView = (BaseDataSourceView <TKey>)instance;
            _baseView.SelectForAddType         = SelectForAddType;
            _baseView.HideRecordCanNotSelected = HideRecordCanNotSelected;
        }
Beispiel #6
0
        public static void ReadData <TKey, TTable, TDataContext, TRow>(
            this Store store,
            BaseDataSourceView <TKey, TTable, TDataContext, TRow> view,
            StoreReadDataEventArgs e,
            BaseFilterControl <TKey, TTable, TDataContext> filter,
            GridFilters gridFilter,
            BaseGridColumns columns)
            where TKey : struct
            where TTable : class
            where TDataContext : DataContext, new()
            where TRow : BaseRow, new()
        {
            if (filter.Url.UserControl == null)
            {
                filter.Url.UserControl = filter.GetTableName() + "Journal";
            }
            try
            {
                var data = view.Select(e, filter, gridFilter, columns, store.RemoteSort);
                if (!string.IsNullOrEmpty(store.DataSourceID))
                {
                    store.DataSourceID = null;
                }
                store.DataSource = data;
            }
            catch (SqlException exception)
            {
                if (exception.Number != -2)
                {
                    throw;
                }

                store.DataSource = new TRow[0];
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = Properties.Resources.SInformation,
                    Message = Properties.Resources.STimeOut,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.WARNING,
                });
            }
        }
Beispiel #7
0
        private void GenerateHtmlInOneRow <TKey, TTable, TDataContext, TRow>(StringBuilder sb, string cssClass, string cssClass0, string cssClass1, GenearetHtml handler, BaseDataSourceView <TKey, TTable, TDataContext, TRow> view, TTable currentRow, SetDataRow <TRow> setDataRowDelegate, int countChilds, int allCountChilds, int level)
            where TKey : struct
            where TTable : class
            where TDataContext : DataContext, new()
            where TRow : BaseRow, new()
        {
            string id = view.GetStringID(currentRow);

            if (_loadedIDs.ContainsKey(id))
            {
                UsePostBackForChilds = false;
                GenerateHtmlInOneRow(sb, cssClass, null, handler);
            }
            else if ((
                         (LoadTreeCount >= allCountChilds && _sumCounts < MaxSumCounts) ||
                         countChilds <= MinCountNotCheckLoad
                         ) && level < MaxLevelTreeLoad && countChilds > 0)
            {
                _sumCounts          += countChilds;
                UsePostBackForChilds = false;
                GenerateHtmlInOneRow(sb, cssClass, null, handler);
                ChildsID.Add(id);
                _loadedIDs.Add(id, true);
                var          data             = view.GetDataByRefParent(currentRow);
                bool         class0           = true;
                PropertyInfo itemPropertyInfo = null;
                foreach (var row in data)
                {
                    if (itemPropertyInfo == null)
                    {
                        itemPropertyInfo = row.GetType().GetProperty("Item");
                    }
                    var count = row.CountChildsData();
                    setDataRowDelegate(row);
                    GenerateHtmlInOneRow(sb, class0 ? cssClass0 : cssClass1,
                                         cssClass0, cssClass1, handler, view,
                                         (TTable)itemPropertyInfo.GetValue(row, null), setDataRowDelegate,
                                         count, allCountChilds * count, level + 1);
                    class0 = !class0;
                }
                ChildsID.RemoveAt(ChildsID.Count - 1);
            }
            else
            {
                UsePostBackForChilds = true;
                GenerateHtmlInOneRow(sb, cssClass, null, handler);
            }
        }
Beispiel #8
0
 public void GeneateReadHtml <TKey, TTable, TDataContext, TRow>(StringBuilder sb, string cssClass, string cssClass0, string cssClass1, BaseDataSourceView <TKey, TTable, TDataContext, TRow> view, TTable currentRow, SetDataRow <TRow> setDataRowDelegate, int countChilds)
     where TKey : struct
     where TTable : class
     where TDataContext : DataContext, new()
     where TRow : BaseRow, new()
 {
     if (ChildsID == null)
     {
         ChildsID = new List <string>();
     }
     if (GenerateWithoutRow)
     {
         GenerateHtmlWithoutRow(sb, GenerateReadHtml);
     }
     else if (CountRowsInOneRow == 0)
     {
         GenerateHtmlInOneRow(sb, cssClass, cssClass0, cssClass1, GenerateReadHtml, view, currentRow, setDataRowDelegate, countChilds, countChilds, 0);
     }
     else
     {
         GenerateHtmlInMultipleRow(sb, cssClass, cssClass, GenerateReadHtml);
     }
 }