Esempio n. 1
0
		public ActionsForBoardRequest(IBoardId board, ISince since, Paging paging, IEnumerable<ActionType> types)
			: base(board, "actions")
		{
			this.AddTypeFilter(types);
			this.AddSince(since);
			this.AddPaging(paging);
		}		
		public ActionsForMemberRequest(IMemberId member, ISince since, Paging paging, IEnumerable<ActionType> filter)
			: base(member, "actions")
		{
			this.AddTypeFilter(filter);
			this.AddSince(since);
			this.AddPaging(paging);
		}
		public ActionsForOrganizationRequest(IOrganizationId organization, ISince since, Paging paging, IEnumerable<ActionType> filter)
			: base(organization, "actions")
		{
			this.AddTypeFilter(filter);
			this.AddSince(since);
			this.AddPaging(paging);
		}
Esempio n. 4
0
        /// <summary>
        /// 分頁
        /// </summary>
        /// <param name="total">總數量</param>
        /// <param name="current_page">目前頁數</param>
        /// <param name="page_count">單頁數量</param>
        /// <returns>分頁</returns>
        public static Paging Get_Page(int total, int current_page = 1, int page_count = 10, int pages = 5)
        {
            Paging page = new Paging();

            int count = pages;
            int count_com = Convert.ToInt32(Math.Floor((double)count / 2));

            page.First = 1;
            int last = Convert.ToInt32(Math.Ceiling((double)total / (double)page_count));
            page.Last = last <= 0 ? 1 : last;
            page.Total = total;
            page.Now = current_page;

            page.Back = (current_page > 1) ? current_page - 1 : current_page;
            page.Next = (current_page < last) ? current_page + 1 : current_page;

            int start = current_page - count_com;
            page.Start = (start < 1) ? 1 : start;

            int end = page.Start + count - 1;
            end = (end >= last) ? last : end;
            page.End = (end == 0) ? 1 : end;

            return page;
        }
		public ActionsForCardRequest(ICardId card, ISince since, Paging paging, IEnumerable<ActionType> filter)
			: base(card, "actions")
		{
			this.AddTypeFilter(filter);
			this.AddSince(since);
			this.AddPaging(paging);
		}
        public IEnumerable<Activity> Get(Feed feed, Paging paging)
        {
            SortedSet<Activity> activities = new SortedSet<Activity>(Activity.Comparer);

            foreach (var streamId in feed.Streams)
            {
                var streamIdQuery = Convert.ToBase64String(streamId);

                var prepared = session
                        .Prepare(LoadActivityStreamQueryTemplate)
                        .Bind(streamIdQuery, paging.Timestamp)
                        .SetAutoPage(false)
                        .SetPageSize(paging.Take);

                var rowSet = session.Execute(prepared);
                foreach (var row in rowSet.GetRows())
                {
                    using (var stream = new MemoryStream(row.GetValue<byte[]>("data")))
                    {
                        var storedActivity = (Activity)serializer.Deserialize(stream);
                        activities.Add(storedActivity);
                    }
                }
            }
            return activities.Take(paging.Take);
        }
Esempio n. 7
0
		public NotificationsForMeRequest(IMemberId member, IEnumerable<NotificationType> filter, ReadFilter readFilter, Paging paging)
			: base(member, "notifications")
		{
			AddTypeFilter(filter);
			this.AddFilter(readFilter, "read_filter");
			this.AddPaging(paging);
		}
Esempio n. 8
0
		public ActionsForListRequest(IListId list, ISince since, Paging paging, IEnumerable<ActionType> filter)
			: base(list, "actions")
		{
			this.AddTypeFilter(filter);
			this.AddSince(since);
			this.AddPaging(paging);
		}
        public void ProcessRequest(HttpContext context)
        {
            this.context = context;
            context.Response.ContentType = "text/json";

            int count;
            List<Employee> result = Employee.GetEmployeesFilter(this.Start, this.Limit, this.Sort, out count);
            Paging<Employee> pagingEmployees = new Paging<Employee>(result, count);

            StoreResponseData sr = new StoreResponseData();
            sr.Total = pagingEmployees.TotalRecords;

            sr.Data = JSON.Serialize(from e in pagingEmployees.Data select new
            {
                  e.Address,
                  e.BirthDate,
                  e.City,
                  e.Country,
                  e.EmployeeID,
                  e.Extension,
                  e.FirstName,
                  e.HireDate,
                  e.HomePhone,
                  e.LastName,
                  e.Notes,
                  e.PhotoPath,
                  e.PostalCode,
                  e.Region,
                  e.ReportsTo,
                  e.Title,
                  e.TitleOfCourtesy
            });

            sr.Return();
        }
		public DataSelectParameter(string fullName, ICondition condition, string scope, Paging paging, Sorting[] sortings) : base(fullName)
		{
			_condition = condition;
			_scope = scope;
			_paging = paging;
			_sortings = sortings;
		}
		[Test] public void ConstructorToken()
		{
			Paging p = new Paging();
			Assert.AreEqual(string.Format("{0},{1}",int.MaxValue,0),p.Token);
			
			p = new Paging(7,55);
			Assert.AreEqual(string.Format("{0},{1}",55,7),p.Token);
		}
		public static void AddPaging(this RestRequest request, Paging paging)
		{
			if (paging == null)
				return;

			request.AddParameter("limit", paging.Limit, ParameterType.GetOrPost);
			request.AddParameter("page", paging.Page, ParameterType.GetOrPost);
		}
		[Test] public void TokenEqualsToString()
		{
			Paging p = new Paging(5,25);

			string value = string.Format("{0},{1}",25,5);
			Assert.AreEqual(value,p.Token);
			Assert.AreEqual(value,p.ToString());
		}
Esempio n. 14
0
    public static Paging GetPages(int itemCount, int itemsPerPage)
    {
        int page;
        int.TryParse(HttpContext.Current.Request.QueryString["page"], out page);
        if (page == 0) page = 1;

        var pages = new Paging { ItemsPerPage = itemsPerPage, CurrentPage = page, PreviousPage = page - 1, NextPage = page + 1, TotalPages = Math.Ceiling(itemCount / (Double)itemsPerPage), Skip = (page*itemsPerPage) - itemsPerPage, Take = itemsPerPage };
        return pages;
    }
 public SqlSentenceBuilder()
 {
     Select = new List<Part>();
     From = new List<FromPart>();
     Where = new List<WherePart>();
     GroupBy = new List<Part>();
     Having = new List<Part>();
     OrderBy = new List<Part>();
     Paging = new Paging();
 }
Esempio n. 16
0
 public virtual Paging<Screen> Select(Search search, int page, int size)
 {
     if (search == null)
         throw new ArgumentNullException("search");
     var query = this.GetQuery(search);
     query = query.OrderByDescending(s => s.CreateTime);
     var metas = new Paging<ScreenMeta>(query, page, size);
     var screens = Mapper.Map<ScreenMeta[], Screen[]>(metas.Data);
     return new Paging<Screen>(screens, metas.PageCount, metas.TotalCount);
 }
Esempio n. 17
0
 public virtual Paging<CommandLog> Select(Search search, int page, int size)
 {
     if (search == null)
         throw new ArgumentNullException("search");
     var query = this.GetQuery(search);
     query = query.OrderByDescending(l => l.CreateTime);
     var metas = new Paging<CommandLogMeta>(query, page, size);
     var logs = Mapper.Map<CommandLogMeta[], CommandLog[]>(metas.Data);
     return new Paging<CommandLog>(logs, metas.PageCount, metas.TotalCount);
 }
		[Test] public void ChangeToken()
		{
			Paging p = new Paging();
			p.PageSize = 12;
			Assert.AreEqual(string.Format("{0},{1}",12,0),p.Token);			
			p.Start = 38;
			Assert.AreEqual(string.Format("{0},{1}",12,38),p.Token);
			p.PageSize = 16;
			p.Start = 3;
			Assert.AreEqual(string.Format("{0},{1}",16,3),p.Token);
		}
Esempio n. 19
0
        public string All(FornecedorPesquisa parametros, int totalPerPage, int page)
        {
            var fornecedorRules = new FornecedorRules();

            var paging = new Paging()
            {
                page = page,
                totalPerPage = totalPerPage
            };

            return Success(fornecedorRules.All(parametros, paging), paging);
        }
Esempio n. 20
0
        public void PagingShouldEmpty()
        {
            const int currentPage = 1;

            var paging = new Paging<string>(new System.Collections.Generic.List<string>(), currentPage, _pageSize);

            Assert.AreEqual(currentPage, paging.CurrentPage);
            Assert.AreEqual(0, paging.Count);
            Assert.AreEqual(0, paging.PageCount);
            Assert.AreEqual(_pageSize, paging.PageSize);
            Assert.AreEqual(0, paging.Skip);
        }
Esempio n. 21
0
        public void PagingShouldNullSource()
        {
            const int currentPage = 1;

            var paging = new Paging<string>(null, currentPage, _pageSize);

            Assert.AreEqual(currentPage, paging.CurrentPage);
            Assert.AreEqual(0, paging.Count);
            Assert.AreEqual(0, paging.PageCount);
            Assert.AreEqual(_pageSize, paging.PageSize);
            Assert.AreEqual(0, paging.Skip);
        }
Esempio n. 22
0
 /// <summary>
 /// Gets the projects.
 /// </summary>
 /// <param name="paging">The paging.</param>
 /// <returns>
 /// A list of projects.
 /// </returns>
 public IList<Model.Project> GetProjects(Paging paging)
 {
     var result = DB.Projects
         .OrderBy(p => p.ProjectName)
         .Skip(paging.Skip)
         .Take(paging.PageSize)
         .Select
         (p => new Model.Project
         {
             ProjectId = p.ProjectId,
             ProjectName = p.ProjectName
         });
     return result.ToList();
 }
Esempio n. 23
0
        public void PagingShouldWithQueryableList()
        {
            const int currentPage = 0;
            const int records = 30;

            var paging = new Paging<string>(_persons.AsQueryable(), currentPage, _pageSize);

            Assert.AreEqual(currentPage, paging.CurrentPage);
            Assert.AreEqual(8, paging.Count);
            Assert.AreEqual(4, paging.PageCount);
            Assert.AreEqual(_pageSize, paging.PageSize);
            Assert.AreEqual(records, (int) paging.Records);
            Assert.AreEqual(0, paging.Skip);
        }
        public string All(int? totalPerPage, int? page)
        {
            int tp = totalPerPage == null ? 10 : (int)totalPerPage;
            int pg = page == null ? 1 : (int)page;

            var notificacaoRules = new NotificacaoRules();
            var paging = new Paging()
            {
                totalPerPage = tp,
                page = pg
            };

            return Success(notificacaoRules.All(paging));
        }
Esempio n. 25
0
        public ActionResult Index(string id, int size = 100)
        {
            using (var service = new PhotosService())
            {
                var model = new Paging<Tag>
                                {
                                    Items =
                                        service.RecentTags(size)
                                        .Select(t => new Tag(t)),
                                    Total = -1
                                };

                return View(model);
            }
        }
 private void ZiyaretciKayitSayisi()
 {
     try
     {
         paging = new Paging();
         paging.CurentPage = QueryString.Value<int>("Sayfa");
         paging.TotolItem = ZiyaretciDefteriDB.ItemCount("web");
         paging.QueryString = Request.QueryString;
       
         ltlSayfalama.Text = PagingLinkWeb.GetHtmlCode(paging);
     }
     catch (Exception ex)
     {
         LogManager.SqlDB.Write("Ziyaretçi Defteri Kayıt Toplam", ex);
     }
 }
 private void UrunKayitSayisi()
 {
     try
     {
         paging = new Paging();
         paging.CurentPage = QueryString.Value<int>("Sayfa");
         paging.TotolItem = UrunDB.UrunToplamKayit("", "markaTek", markaId);
         paging.QueryString = Request.QueryString;
         ucProductList.PagingLinkToDisplay = PagingLinkWeb.GetHtmlCode(paging);
         lbllistelemeBilgisi.Text = paging.Mesaj;
     }
     catch (Exception ex)
     {
         LogManager.SqlDB.Write("Marka Ürün Listeleme Sayfa No Hatası", ex);
     }
 }
    private void KayitSayisi(string keyword, int markaId)
    {
        try
        {
            paging = new Paging();
            paging.CurentPage = QueryString.Value<int>("Sayfa");
            paging.TotolItem = UrunDB.UrunToplamKayit("arama", keyword, markaId);
            paging.QueryString = Request.QueryString;
            lbllistelemeBilgisi.Text = paging.Mesaj;

            ucProductList.PagingLinkToDisplay = PagingLinkWeb.GetHtmlCode(paging);
        }
        catch (Exception hata)
        {
            LogManager.SqlDB.Write("Arama Sonucu Sayfa No Hatası:", hata);
        }
    }
Esempio n. 29
0
        public void PagingShouldWithEnumerableList()
        {
            const int currentPage = 0;
            const int records = 30;

            var paging = new Paging<string>(_persons, currentPage, _pageSize);

            Assert.AreEqual(currentPage, paging.CurrentPage);
            Assert.AreEqual(8, paging.Count);
            Assert.AreEqual(4, paging.PageCount);
            Assert.AreEqual(_pageSize, paging.PageSize);
            Assert.AreEqual(records, (int) paging.Records);
            Assert.AreEqual(0, paging.Skip);
            Assert.IsTrue(paging.HasNextPage);
            Assert.IsFalse(paging.HasPreviousPage);
            Assert.IsTrue(paging.IsFirstPage);
            Assert.IsFalse(paging.IsLastPage);
        }
        public List<Notificacao> Fetch(int usuarioId, Paging paging)
        {
            var sql = PetaPoco.Sql.Builder.Append("SELECT Notificacao.*, De.*, Para.*, Unidade.*")
                                          .Append("FROM Notificacao")
                                          .Append("INNER JOIN Usuario AS De ON De.Id = Notificacao.DeId")
                                          .Append("INNER JOIN Usuario AS Para ON Para.Id = Notificacao.ParaId")
                                          .Append("INNER JOIN Unidade ON Unidade.Id = De.UnidadeId")
                                          .Append("WHERE Notificacao.ParaId = @0", usuarioId)
                                          .Append("ORDER BY Notificacao.Data DESC")
                                          .Append("LIMIT @0, @1", paging.LimitDown, paging.LimitUp);

            return this.Db.Fetch<Notificacao, Usuario, Usuario, Unidade, Notificacao>((n, d, p, u) => {

                n.De = d;
                n.Para = p;
                n.De.Unidade = u;

                return n;
            }, sql).ToList();
        }