コード例 #1
0
ファイル: ObjectPool.cs プロジェクト: yumingzhe1012/wojilu
 public static void AddPage(Type t, String condition, ObjectPage pager, IList list)
 {
     foreach (IObjectPool pool in pools)
     {
         pool.AddPage(t, condition, pager, list);
     }
 }
コード例 #2
0
        /// <summary>
        /// 根据查询条件、每页数量,返回分页数据集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="condition">查询条件</param>
        /// <param name="pageSize">每页需要显示的数据量</param>
        /// <returns>分页数据列表,包括当前页、总记录数、分页条等</returns>
        public static DataPage <T> findPage <T>(String condition, int pageSize) where T : IEntity
        {
            if (pageSize <= 0)
            {
                pageSize = 20;
            }

            ObjectInfo state = new ObjectInfo(typeof(T));

            state.includeAll();
            state.Pager.setSize(pageSize);

            IPageList result = ObjectPool.FindPage(typeof(T), condition, state.Pager);

            if (result == null)
            {
                IList      list = ObjectDB.FindPage(state, condition);
                ObjectPage p    = state.Pager;
                ObjectPool.AddPage(typeof(T), condition, p, list);

                result             = new PageList();
                result.Results     = list;
                result.PageCount   = p.PageCount;
                result.RecordCount = p.RecordCount;
                result.Size        = p.getSize();
                result.PageBar     = p.PageBar;
                result.Current     = p.getCurrent();
            }
            else
            {
                result.PageBar = new ObjectPage(result.RecordCount, result.Size, result.Current).PageBar;
            }

            return(new DataPage <T>(result));
        }
コード例 #3
0
        public void AddPage(Type t, String condition, ObjectPage pager, IList list)
        {
            String key = CacheKey.getPageList(t, condition, pager.getSize(), pager.getCurrent());

            addList(key, list);
            addToApplication(CacheKey.getPagerInfoKey(key), pager);     // 添加分页统计数据
        }
コード例 #4
0
        public IPageList FindPage(Type t, String condition, ObjectPage pager)
        {
            String key = CacheKey.getPageList(t, condition, pager.getSize(), pager.getCurrent());

            logger.Debug("FindPage=>" + t.FullName);
            IList list = getListFromCache(key, t);

            if (list == null)
            {
                return(null);
            }

            IPageList result = new PageList();

            ObjectPage pageInfo = getPagerInfo(key);

            if (pageInfo == null)
            {
                return(null);
            }

            result.Results     = list;
            result.PageCount   = pageInfo.PageCount;
            result.RecordCount = pageInfo.RecordCount;
            result.Size        = pageInfo.getSize();
            result.PageBar     = pageInfo.PageBar;
            result.Current     = pageInfo.getCurrent();

            return(result);
        }
コード例 #5
0
        private void bindShow(ContentPost post, DataPage <ContentImg> imgPage)
        {
            ctx.SetItem("ContentPost", post);
            set("post.Title", post.Title);
            set("post.Content", post.Content);
            set("post.CreateTime", post.Created);
            set("post.ReplyCount", post.Replies);
            set("post.Hits", post.Hits);

            set("post.Source", post.SourceLink);

            if (post.Creator != null)
            {
                set("post.Submitter", string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", Link.ToMember(post.Creator), post.Creator.Name));
            }
            else
            {
                set("post.Submitter", "нч");
            }

            IBlock block = getBlock("list");

            foreach (ContentImg img in imgPage.Results)
            {
                block.Set("img.Url", img.GetImgUrl());
                block.Set("img.Description", img.Description);
                block.Next();
            }

            String postLink = alink.ToAppData(post);
            String pageBar  = ObjectPage.GetPageBarByLink(postLink, imgPage.PageCount, imgPage.Current);

            set("page", pageBar);
        }
コード例 #6
0
ファイル: PageCondition.cs プロジェクト: mfz888/xcore
        public int beginCount( String countSql, ObjectPage pager, EntityInfo entityInfo ) {

            String commandText = countSql;
            logger.Info( "[Page Record Count] " + commandText );
            IDbCommand command = DataFactory.GetCommand( commandText, DbContext.getConnection( entityInfo ) );
            pager.RecordCount = cvt.ToInt( command.ExecuteScalar() );
            pager.computePageCount();
            pager.resetCurrent();

            return pager.getCurrent();
        }
コード例 #7
0
ファイル: ObjectPool.cs プロジェクト: yumingzhe1012/wojilu
 public static IPageList FindPage(Type t, String condition, ObjectPage pager)
 {
     foreach (IObjectPool pool in pools)
     {
         IPageList result = pool.FindPage(t, condition, pager);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
コード例 #8
0
        public int beginCount(String countSql, ObjectPage pager, EntityInfo entityInfo)
        {
            String commandText = countSql;

            logger.Info("[Page Record Count] " + commandText);
            IDbCommand command = DataFactory.GetCommand(commandText, DbContext.getConnection(entityInfo));

            pager.RecordCount = cvt.ToInt(command.ExecuteScalar());
            pager.computePageCount();
            pager.resetCurrent();

            return(pager.getCurrent());
        }
コード例 #9
0
        public static DataPage <T> GetPage(List <T> list, int pageSize, int pageIndex = 0)
        {
            ObjectPage op = new ObjectPage();

            if (pageSize <= 0)
            {
                pageSize = 20;
            }
            op.setSize(pageSize);
            op.RecordCount = list.Count;
            // 计算页数
            op.computePageCount();

            // 矫正当前页码
            int currentPageNumber = CurrentRequest.getCurrentPage();

            if (pageIndex > 0)
            {
                currentPageNumber = pageIndex;
            }
            op.setCurrent(currentPageNumber);
            op.resetCurrent();
            currentPageNumber = op.getCurrent();

            // 得到结果集
            List <T> results = new List <T>();
            int      start   = (currentPageNumber - 1) * pageSize;
            int      count   = 1;

            for (int i = start; i < list.Count; i++)
            {
                if (count > pageSize)
                {
                    break;
                }
                results.Add(list[i]);
                count++;
            }

            // 填充分页数据
            DataPage <T> page = new DataPage <T>();

            page.Results     = results;
            page.Current     = currentPageNumber;
            page.Size        = pageSize;
            page.RecordCount = list.Count;

            page.PageCount = op.PageCount;

            return(page);
        }
コード例 #10
0
        public MainPage()
        {
            Page itemsPage, aboutPage, objectPage = null;

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                itemsPage = new NavigationPage(new PictorialPage())
                {
                    Title = "Currency"
                };

                aboutPage = new NavigationPage(new AboutPage())
                {
                    Title = "Textual"
                };
                itemsPage.Icon = "tab_feed.png";
                aboutPage.Icon = "tab_about.png";
                break;

            default:
                itemsPage = new PictorialPage()
                {
                    Title = "Currency"
                };

                aboutPage = new AboutPage()
                {
                    Title = "Text"
                };
                objectPage = new ObjectPage
                {
                    Title = "Object"
                };


                break;
            }

            Children.Add(aboutPage);
            Children.Add(itemsPage);
            Children.Add(objectPage);
            NavigationPage.SetHasNavigationBar(this, false);
            Title = Children[0].Title;
        }
コード例 #11
0
        private String getPagedContent(ContentPost post, String pageSeparator)
        {
            String content;

            string[] ss         = { pageSeparator };
            string[] arrContent = post.Content.Split(ss, StringSplitOptions.None);

            int currentPage = ctx.GetInt("cp");
            int pidx        = currentPage - 1;

            if (pidx < 0)
            {
                pidx = 0;
            }

            content  = arrContent[pidx];
            content  = strUtil.CloseHtml(content);
            content += ObjectPage.GetPageBarByLink(alink.ToAppData(post), arrContent.Length, pidx + 1);
            return(content);
        }
コード例 #12
0
ファイル: ObjectPool.cs プロジェクト: mfz888/xcore
 public static IPageList FindPage( Type t, String condition, ObjectPage pager ) {
     foreach (IObjectPool pool in pools) {
         IPageList result = pool.FindPage( t, condition, pager );
         if (result != null) return result;
     }
     return null;
 }
コード例 #13
0
ファイル: ApplicationPool.cs プロジェクト: jilumvc/Sajoo
 public void AddPage( Type t, String condition, ObjectPage pager, IList list )
 {
     String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() );
     addList( key, list );
     addToApplication( CacheKey.getPagerInfoKey( key ), pager ); // 添加分页统计数据
 }
コード例 #14
0
ファイル: ApplicationPool.cs プロジェクト: jilumvc/Sajoo
        public IPageList FindPage( Type t, String condition, ObjectPage pager )
        {
            String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() );
            logger.Debug( "FindPage=>" + t.FullName );
            IList list = getListFromCache( key, t );
            if (list == null) return null;

            IPageList result = new PageList();

            ObjectPage pageInfo = getPagerInfo( key );
            if (pageInfo == null) return null;

            result.Results = list;
            result.PageCount = pageInfo.PageCount;
            result.RecordCount = pageInfo.RecordCount;
            result.Size = pageInfo.getSize();
            result.PageBar = pageInfo.PageBar;
            result.Current = pageInfo.getCurrent();

            return result;
        }
コード例 #15
0
        public void AddPage(Type t, String condition, ObjectPage pager, IList list)
        {
            String key = CacheKey.getPageList(t, condition, pager.getSize(), pager.getCurrent());

            addList(key, list);
        }
コード例 #16
0
 public IPageList FindPage(Type t, String condition, ObjectPage pager)
 {
     return(null);
 }
コード例 #17
0
ファイル: ContextPool.cs プロジェクト: robin88/wojilu
 public void AddPage( Type t, String condition, ObjectPage pager, IList list )
 {
     String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() );
     addList( key, list );
 }
コード例 #18
0
ファイル: ContextPool.cs プロジェクト: robin88/wojilu
 public IPageList FindPage( Type t, String condition, ObjectPage pager )
 {
     return null;
 }
コード例 #19
0
ファイル: ObjectPool.cs プロジェクト: mfz888/xcore
 public static void AddPage( Type t, String condition, ObjectPage pager, IList list ) {
     foreach (IObjectPool pool in pools) {
         pool.AddPage( t, condition, pager, list );
     }
 }