예제 #1
0
        /// <summary>
        /// Convert the whole ResultSet into a Page objects.
        /// </summary>
        /// <param name="rs">The ResultSet to process.</param>
        /// <returns>The Initialize Page objects</returns>
        public T Handle(DbDataReader rs)
        {
            T result = default(T);

            PageFilter filter = null;

            bool firstTime = true;

            while (rs.Read())
            {
                if (firstTime)
                {
                    filter    = processor.ToBean <PageFilter>(rs, typeof(PageFilter));
                    firstTime = false;
                }

                string          fieldId = rs["FilterFieldId"].ToString();
                PageFilterField field   = processor.ToBean <PageFilterField>(rs, typeof(PageFilterField));
                filter.Fields.Add(field);
            }

            result = (T)Convert.ChangeType(filter, type);

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Convert the first row of the ResultSet into a bean with the
        /// Type given in the constructor.
        /// </summary>
        /// <param name="rs">ResultSet to process.</param>
        /// <returns>An initialized Bean-Style object or null if there were no rows in the ResultSet.</returns>
        public T Handle(DbDataReader rs)
        {
            T result = default(T);

            if (rs.Read())
            {
                result = processor.ToBean <T>(rs, type);
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Convert the whole ResultSet into a Page objects.
        /// </summary>
        /// <param name="rs">The ResultSet to process.</param>
        /// <returns>The Initialize Page objects</returns>
        public T Handle(DbDataReader rs)
        {
            T result = default(T);

            Page page = null;

            bool    firstTime = true;
            PageTab prevTab   = null;

            while (rs.Read())
            {
                if (firstTime)
                {
                    page      = processor.ToBean <Page>(rs, typeof(Page));
                    firstTime = false;
                }

                string tabId = rs["TabId"].ToString();

                if (!String.IsNullOrEmpty(tabId))
                {
                    PageTab currentTab = prevTab;
                    if (prevTab == null || !tabId.Equals(prevTab.TabId))
                    {
                        currentTab = processor.ToBean <PageTab>(rs, typeof(PageTab));
                        page.Tabs.Add(currentTab);
                    }


                    string fieldId = rs["FieldId"].ToString();
                    if (!String.IsNullOrEmpty(fieldId))
                    {
                        PageField field    = processor.ToBean <PageField>(rs, typeof(PageField));
                        string    columnId = rs["ColumnId"].ToString();
                        if (!String.IsNullOrEmpty(columnId))
                        {
                            PageGridColumn column = processor.ToBean <PageGridColumn>(rs, typeof(PageGridColumn));

                            if (String.IsNullOrEmpty(column.ColumnName))
                            {
                                column.ColumnName = field.FieldName;
                            }

                            if (String.IsNullOrEmpty(column.ColumnLabel))
                            {
                                column.ColumnLabel = field.Label;
                            }

                            page.GridFields.Add(column);
                        }

                        currentTab.Fields.Add(field);
                        prevTab = currentTab;
                    }
                }
            }

            result = (T)Convert.ChangeType(page, type);

            return(result);
        }