Esempio n. 1
0
        private static String processPageIndex(String apath, Route x)
        {
            String[] arrP     = apath.Split(separator[0]);
            String   lastItem = arrP[arrP.Length - 1];

            if (isPageNumber(lastItem))
            {
                int pageIndex = cvt.ToInt(lastItem.TrimStart('p'));
                x.setPage(pageIndex);
                CurrentRequest.setCurrentPage(pageIndex);

                apath = strUtil.TrimEnd(apath, lastItem).TrimEnd(separator[0]);
            }
            return(apath);
        }
Esempio n. 2
0
        private static void setStrongTypeValue(Route result)
        {
            if (result.getItem("controller") != null)
            {
                result.setController(result.getItem("controller"));
            }
            if (result.getItem("action") != null)
            {
                result.setAction(result.getItem("action"));
            }
            if (result.getItem("query") != null)
            {
                result.setQuery(result.getItem("query"));
            }
            if (result.getItem("owner") != null)
            {
                result.setOwner(result.getItem("owner"));
            }
            if (result.getItem("ownertype") != null)
            {
                result.setOwnerType(result.getItem("ownertype"));
            }
            if (result.getItem("id") != null)
            {
                result.setId(cvt.ToLong(result.getItem("id")));
            }
            if (result.getItem("appid") != null)
            {
                result.setAppId(cvt.ToLong(result.getItem("appid")));
            }

            int page = 1;

            if (result.getItem("page") != null)
            {
                int routePage = Requirements.getPageNumber(result.getItem("page"));
                if (routePage > 1)
                {
                    page = routePage;
                }
            }

            result.setItem("page", page);
            result.setPage(page);
            CurrentRequest.setCurrentPage(page);
        }
Esempio n. 3
0
        public void findPage()
        {
            int pageSize = 5;

            //------------- 第1页 ---------------
            int current = 1;

            CurrentRequest.setCurrentPage(current);

            DataPage <TBoard> list = TBoard.findPage("Id>0", pageSize);

            Assert.AreEqual(current, list.Current);
            Assert.AreEqual(12, list.RecordCount);
            Assert.AreEqual(3, list.PageCount);
            Assert.AreEqual(pageSize, list.Size);
            Assert.AreEqual(pageSize, list.Results.Count);

            //------------- 第2页 ---------------
            current = 2;
            CurrentRequest.setCurrentPage(current);

            list = TBoard.findPage("Id>0", pageSize);

            Assert.AreEqual(current, list.Current);
            Assert.AreEqual(12, list.RecordCount);
            Assert.AreEqual(3, list.PageCount);
            Assert.AreEqual(pageSize, list.Size);
            Assert.AreEqual(pageSize, list.Results.Count);


            //------------- 第3页 ---------------

            current = 3;
            CurrentRequest.setCurrentPage(current);

            list = TBoard.findPage("Id>0", pageSize);

            Assert.AreEqual(current, list.Current);
            Assert.AreEqual(12, list.RecordCount);
            Assert.AreEqual(3, list.PageCount);
            Assert.AreEqual(pageSize, list.Size);
            Assert.AreEqual(2, list.Results.Count);
        }
Esempio n. 4
0
        public void findPage()
        {
            int pageSize = 5;

            //------------- 第1页 ---------------
            int current = 1;

            CurrentRequest.setCurrentPage(current);

            DataPage <TBoard> list = TBoard.findPage("Id>0", pageSize);

            Assert.AreEqual(current, list.Current);
            Assert.AreEqual(12, list.RecordCount);
            Assert.AreEqual(3, list.PageCount);
            Assert.AreEqual(pageSize, list.Size);
            Assert.AreEqual(pageSize, list.Results.Count);

            //------------- 第2页 ---------------
            current = 2;
            CurrentRequest.setCurrentPage(current);

            list = TBoard.findPage("Id>0", pageSize);

            Assert.AreEqual(current, list.Current);
            Assert.AreEqual(12, list.RecordCount);
            Assert.AreEqual(3, list.PageCount);
            Assert.AreEqual(pageSize, list.Size);
            Assert.AreEqual(pageSize, list.Results.Count);


            //------------- 第3页 ---------------

            current = 3;
            CurrentRequest.setCurrentPage(current);

            list = TBoard.findPage("Id>0", pageSize);

            Assert.AreEqual(current, list.Current);
            Assert.AreEqual(12, list.RecordCount);
            Assert.AreEqual(3, list.PageCount);
            Assert.AreEqual(pageSize, list.Size);
            Assert.AreEqual(2, list.Results.Count);


            //------------- 第n页 ---------------

            for (int i = 0; i < 100; i++)
            {
                TBoard board = new TBoard();
                board.Name = "board_pageTest_" + i;
                board.insert();
            }


            current = 2;

            CurrentRequest.setCurrentPage(current);

            list = TBoard.findPage("Id>0 order by Id asc", 10);
            Assert.AreEqual(current, list.Current);

            Assert.AreEqual(112, list.RecordCount);
            Assert.AreEqual(12, list.PageCount);
            Assert.AreEqual(10, list.Results.Count);

            String ids = "";

            foreach (TBoard bd in list.Results)
            {
                ids += bd.Id + ", " + bd.Name + Environment.NewLine;
            }
            Console.WriteLine(ids);

            String bar = strUtil.ParseHtml(list.PageBar).Replace("&nbsp;", ",");

            Console.WriteLine(bar);
        }
Esempio n. 5
0
 public void SetCurrentPage(int current)
 {
     CurrentRequest.setCurrentPage(current);
 }