Exemplo n.º 1
0
        public void Can_Generate_Links_To_Other_Pages()
        {
            // Arrange: We're going to extend the HtmlHelper class.
            // It doesn't matter if the variable we use is null.
            HtmlHelper html = null;

            // Arrange: The helper should take a PagingInfo instance (that's a class we haven't yet defined)
            // and a lambda to specify the URLs
            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };

            Func<int, string> pageUrl = (i => "Page" + i);

            // Act
            MvcHtmlString result = html.PageLinks(pagingInfo, pageUrl);

            // Assert: Here's how it should format the links
            // Выравнивание не трогать - это такое многострочное значение с переводами строк, т.е. \r\n
            result.ToString().ShouldEqual(@"<a href=""Page1"">1</a>
            <a class=""selected"" href=""Page2"">2</a>
            <a href=""Page3"">3</a>
            ");
        }
Exemplo n.º 2
0
 public StatsResultVM()
 {
     StatItems = new List<StatItem>();
     StatRoomItems = new List<StatRoomItem>();
     StatMessageItems = new List<StatMessageItem>();
     PaginationInfo = new PagingInfo() { CurrentPage = 1 };
 }
Exemplo n.º 3
0
 public PagerModel(PagingInfo info, string action, string controller, object parameters)
 {
     PageInfo = info;
     Action = action;
     Controller = controller;
     Parameters = parameters;
 }
Exemplo n.º 4
0
        public void Can_Generate_Page_Links()
        {
            // przygotowanie - definiowanie metody pomocniczej HTML — potrzebujemy tego,
            // aby użyć metody rozszerzającej
            HtmlHelper myHelper = null;

            // przygotowanie - tworzenie danych PagingInfo
            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };

            // przygotowanie - konfigurowanie delegatu z użyciem wyrażenia lambda
            Func<int, string> pageUrlDelegate = i => "Strona" + i;

            // działanie
            MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);

            // asercje
            Assert.AreEqual(@"<a class=""btn btn-default"" href=""Strona1"">1</a>"
                + @"<a class=""btn btn-default btn-primary selected"" href=""Strona2"">2</a>"
                + @"<a class=""btn btn-default"" href=""Strona3"">3</a>",
                result.ToString());
        }
Exemplo n.º 5
0
        public void Can_Generate_Page_Links()
        {
            //arrange
            //define an helper, we need to do this in order to apply the extensionmethod
            HtmlHelper myHelper = null;

            //arrange paginginfo
            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };
            // arrange- set lambda
            Func<int, string> pageUrlDelegate = i => "Page" + i;

            //act
            MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);

            //assert
            Assert.AreEqual(@"<a class=""btn btn-default"" href=""Page1"">1</a>" +
                @"<a class=""btn btn-default btn-primary selected"" href=""Page2"">2</a>" +
                @"<a class=""btn btn-default"" href=""Page3"">3</a>"
            ,result.ToString());
        }
Exemplo n.º 6
0
        public void Can_Generate_Links_To_Other_Pages()
        {
            //  Arrange: Create a reference to the HtmlHelper class instance
            //  We can use a null reference here because we're going to extend
            //  the HtmlHelper class with an extension method
            HtmlHelper html = null;

            //  Arrange: The helper should take a paging info instance
            //  and a lambda to specify the URLs
            //  Create an anonymous instance of the paging info class
            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };

            //  Create a lambda expression that takes an
            //  integer and spits out a string
            Func<int, string> pageUrl = i => "Page" + i;

            //  Act: Create the html string to supply to the view
            MvcHtmlString result = html.PageLinks(pagingInfo, pageUrl);

            //  Assert: Here's how it should format the links
            result.ToString().ShouldEqual(@"<a href=""Page1"">1</a>
            <a class=""selected"" href=""Page2"">2</a>
            <a href=""Page3"">3</a>
            ");
        }
Exemplo n.º 7
0
        // GET: Product
        public ViewResult List(string category = "", int page = 1)
        {
            Func<Product, bool> filter;
            if (string.IsNullOrEmpty(category))
            {
                filter = p => p.Category != null;
            }
            else
            {
                filter = p => p.Category == category;
            }

            var model = _repository.Products
                .Where(filter)
                .Skip((page - 1)*PageSize)
                .Take(PageSize).ToList();

            var pageInfo = new PagingInfo
            {
                CurrentPage = page,
                ItemsPerPage = PageSize,
                TotalItems = _repository.Products.Count()
            };

            return View(new ProductListViewModel
            {
                Products = model,
                PagingInfo = pageInfo,
                CurrentCategory = category

            });
        }
Exemplo n.º 8
0
    private SyndicationLibrary.RSS.RssFeed CreateRssFeed()
    {
        DateTime fromDate = DateTime.Now.AddDays(-MESSAGE_AGE);

        SyndicationLibrary.RSS.RssFeed rss;
        using (System.IO.FileStream stream = new System.IO.FileStream(Eucalypto.PathHelper.LocateServerPath(TEMPLATE_FILE), System.IO.FileMode.Open, System.IO.FileAccess.Read))
          rss = SyndicationLibrary.RSS.RssFeed.GetFeed(stream);

        if (rss == null)
          throw new ApplicationException("Failed to load rss from " + TEMPLATE_FILE);

        PagingInfo paging = new PagingInfo(MAX_MESSAGES, 0);
        IList<Eucalypto.Forum.Message> messages = Eucalypto.Forum.ForumManager.FindMessages(
                                                Eucalypto.Common.Filter.MatchOne(GetSelectedForums()),
                                                null,
                                                null,
                                                null,
                                                fromDate,
                                                null,
                                                paging);

        DateTime lastPubDate = DateTime.MinValue;
        foreach (Eucalypto.Forum.Message msg in messages)
        {
          rss.Channel.Items.Add(CreateRssItem(msg));

          if (msg.UpdateDate > lastPubDate)
        lastPubDate = msg.UpdateDate;
        }

        rss.Channel.PublicationDate = lastPubDate;
        rss.Channel.LastBuildDate = lastPubDate;

        return rss;
    }
Exemplo n.º 9
0
        public ViewResult List(string category, int page = 1)
        {
            IEnumerable<Product> productList = _productRepository.Products.Where(p => category == null || p.Category == category);

            var products = productList
                .OrderBy(p => p.ProductId)
                .Skip((page - 1) * PageSize)
                .Take(PageSize);

            var pagingInfo = new PagingInfo
            {
                CurrentPage = page,
                ItemsPerPage = PageSize,
                TotalItems = productList.Count(p => category == null || p.Category == category)
            };

            var productsListViewModel = new ProductsListViewModel
            {
                Products = products,
                PagingInfo = pagingInfo,
                CurrentCategory = category
            };

            return View(productsListViewModel);
        }
Exemplo n.º 10
0
        public void Can_Generate_Page_Links()
        {
            // Arrange - define an HTML helper - we need to do this
            // in order to apply the extension method
            HtmlHelper myHelper = null;

            // Arrange - create PagingInfo data
            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };

            // Arrange - set up the delegate using a lambda expression
            Func<int, string> pageUrlDelegate = i => "Page" + i;

            // Act
            MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);

            // Assert
            Assert.AreEqual(result.ToString(), @"<a href=""Page1"">1</a>"
                + @"<a class=""selected"" href=""Page2"">2</a>"
                + @"<a href=""Page3"">3</a>");
        }
Exemplo n.º 11
0
        public void Can_Generate_Page_Links()
        {
            // Arrange

            // define an HtmlHelper in order to apply the extension method
            HtmlHelper myHelper = null;

            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };

            // set up delegate using lambda expression
            Func<int, string> pageUrlDelegate = i => "Page" + i;

            // Act
            MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);

            // Assert
            string expected = @"<a class=""btn btn-default"" href=""Page1"">Page 1</a>";
            expected += @"<a class=""btn btn-default btn-primary selected"" href=""Page2"">Page 2</a>";
            expected += @"<a class=""btn btn-default"" href=""Page3"">Page 3</a>";
            Assert.AreEqual(expected, result.ToString());
        }
Exemplo n.º 12
0
	    public async Task CanBrowseWithSharding()
	    {
            var ms = new MemoryStream();
            var streamWriter = new StreamWriter(ms);
            var expected = new string('a', 1024);
            streamWriter.Write(expected);
            streamWriter.Flush();
            ms.Position = 0;

            await shardedClient.UploadAsync("a.txt", ms);
            await shardedClient.UploadAsync("b.txt", ms);
            await shardedClient.UploadAsync("c.txt", ms);
            await shardedClient.UploadAsync("d.txt", ms);
            await shardedClient.UploadAsync("e.txt", ms);

	        var pagingInfo = new PagingInfo(shardedClient.NumberOfShards);
	        var result = await shardedClient.BrowseAsync(2, pagingInfo);
            Assert.Equal(2, result.Length);

	        pagingInfo.CurrentPage++;
            result = await shardedClient.BrowseAsync(2, pagingInfo);
            Assert.Equal(2, result.Length);

            pagingInfo.CurrentPage++;
            result = await shardedClient.BrowseAsync(2, pagingInfo);
            Assert.Equal(1, result.Length);

            pagingInfo.CurrentPage++;
            result = await shardedClient.BrowseAsync(2, pagingInfo);
            Assert.Equal(0, result.Length);
	    }
			public void Serializes_Unbounded_Value()
			{
				PagingInfo pagingInfo = new PagingInfo(PageNumberAndSize.Unbounded, 1701);
				string serializedPagingInfo = JsonConvert.SerializeObject(pagingInfo, DefaultFormatting, this.settings);

				Assert.AreEqual(Unbounded_Total1701, serializedPagingInfo);
			}
 public ListSitesQueryResult Execute(PagingInfo pagingInfo)
 {
     return new ListSitesQueryResult(
         this.Context.Sites
         .Skip((pagingInfo.PageNumber - 1) * pagingInfo.PageSize)
         .Take(pagingInfo.PageSize)
         .ToList());
 }
Exemplo n.º 15
0
 public ListOfBooksModel(List<Book> books, List<Author> authors,
                         List<Category> categories, PagingInfo pagingModel)
 {
     Books = books;
     Authors = authors;
     Categories = categories;
     PageInfo = pagingModel;
 }
			public void Serializes_With_All_Pages_When_Specified()
			{
				PagingInfo pagingInfo = new PagingInfo(2, 10, 27, true);
				string serializedPagingInfo = JsonConvert.SerializeObject(
					pagingInfo, DefaultFormatting, this.settings);

				Assert.AreEqual(Page2_Size10_Total27_WithAllPages, serializedPagingInfo);
			}
			public void Serializes_All_Properties()
			{
				PagingInfo pagingInfo = new PagingInfo(7, 20, 1138);
				string serializedPagingInfo = JsonConvert.SerializeObject(
					pagingInfo, DefaultFormatting, this.settings);

				Assert.AreEqual(Page7_Size20_Total1138, serializedPagingInfo);
			}
Exemplo n.º 18
0
 public void Can_Generate_Page_Links()
 {
     HtmlHelper helper = null;
     var pagingInfo = new PagingInfo { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 };
     Func<int, string> pageUrlDelegate = i => "Page" + i;
     MvcHtmlString result = helper.PageLinks(pagingInfo, pageUrlDelegate);
     var expect = @"<a href=""Page1"">1</a>" + @"<a class=""selected"" href=""Page2"">2</a>" + @"<a href=""Page3"">3</a>";
     Assert.AreEqual(expect, result.ToString());
 }
Exemplo n.º 19
0
    public void Display_View()
    {
        PagingInfo pInfo = new PagingInfo(m_PageSize > 0 ? m_PageSize : 0);
        pInfo.CurrentPage = m_intCurrentPage;
        m_aGroups = m_refCommunityGroupApi.GetInvitedCommunityGroups(this.m_refContentApi.UserId, pInfo);
        m_intTotalPages = pInfo.TotalPages;

        Populate_ViewCommunityGroupsGrid(m_aGroups);
    }
Exemplo n.º 20
0
        /// <summary>
        /// 使用 ROWNUM 来进行分页。
        /// </summary>
        /// <param name="raw">The raw.</param>
        /// <param name="pagingInfo">The paging information.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">pagingInfo</exception>
        /// <exception cref="System.InvalidProgramException">必须排序后才能使用分页功能。</exception>
        protected override ISqlSelect ModifyToPagingTree(SqlSelect raw, PagingInfo pagingInfo)
        {
            if (PagingInfo.IsNullOrEmpty(pagingInfo)) { throw new ArgumentNullException("pagingInfo"); }
            if (!raw.HasOrdered()) { throw new InvalidProgramException("必须排序后才能使用分页功能。"); }

            var startRow = pagingInfo.PageSize * (pagingInfo.PageNumber - 1) + 1;
            var endRow = startRow + pagingInfo.PageSize - 1;

            var res = MakePagingTree(raw, startRow, endRow);

            return res;
        }
Exemplo n.º 21
0
        public void CanGeneratePageLinks()
        {
            HtmlHelper myHelper = null;
            PagingInfo pagingInfo = new PagingInfo(){CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10};
            Func<int, string> pageUrlDelegate = i => "Strona" + i;

            MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);

            Assert.AreEqual(@"<a class=""btn btn-default"" href=""Strona1"">1</a>"+
                @"<a class=""btn btn-default btn-primary selected"" href=""Strona2"">2</a>"+
                @"<a class=""btn btn-default"" href=""Strona3"">3</a>", result.ToString());
        }
Exemplo n.º 22
0
        public void Can_Generate_Page_Links()
        {
            //arrange
            HtmlHelper myHelper = null;
            PagingInfo pagingInfo = new PagingInfo { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 };
            Func<int, string> pageUrlDelegate = i => "Page" + i;

            //act
            MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);

            //assert
            Assert.AreEqual(@"<a class=""btn btn-default"" href=""Page1"">1</a>" + @"<a class=""btn btn-default btn-primary selected"" href=""Page2"">2</a>" + @"<a class=""btn btn-default"" href=""Page3"">3</a>", result.ToString());
        }
Exemplo n.º 23
0
        private void PageLinkArrange()
        {
            pageLinkHelper = null;

             pagingInfo = new PagingInfo
             {
            CurrentPage = 2,
            TotalItems = 28,
            ItemsPerPage = 10
             };

             pageUrlDelegate = i => "Page" + i;
        }
        public void Can_Create_Page_Links()
        {
            //Arrange
            HtmlHelper helper = null;
            var pagingInfo = new PagingInfo {CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10};

            Func<int, string> pageUrlDelegate = i => "Page" + i.ToString();
            //Action
            MvcHtmlString result = helper.PageLinks(pagingInfo, pageUrlDelegate);

            //Asserts
            Assert.AreEqual(@"<a href=""Page1"">1</a><a class=""selected"" href=""Page2"">2</a><a href=""Page3"">3</a>", result.ToString());
        }
Exemplo n.º 25
0
 public void Can_Generate_Page_Links()
 {
     SportsStore.WebUI.HtmlHelper myHelper = null;
     PagingInfo pagingInfo = new PagingInfo
     {
         CurrentPage = 2,
         TotalItems = 28,
         ItemsPerPage = 10
     };
     Func<int, string> pageUrlDelegate = i => "Page" + i;
     MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);
     Assert.AreEqual(result.ToString(),@"<a href=""Page1"">1</a>"+@"<a class=""selected"" href=""Page2"">2</a>"+@"<a href=""Page3"">3</a>");
 }
Exemplo n.º 26
0
 public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInfo pagingInfo,Func<int, string> pageUrl)
 {
     StringBuilder result = new StringBuilder();
     for (int i = 1; i <= pagingInfo.TotalPages; i++)
     {
         TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag
         tag.MergeAttribute("href", pageUrl(i));
         tag.InnerHtml = i.ToString();
         if (i == pagingInfo.CurrentPage)
             tag.AddCssClass("selected");
         result.Append(tag.ToString());
     }
     return MvcHtmlString.Create(result.ToString());
 }
Exemplo n.º 27
0
 public void GivenAListPagingInfoShouldBeCorrects1()
 {
     var pagingInfo = new PagingInfo(0, 10, 10);
     pagingInfo.TotalItemCount.Should().Be.EqualTo(10);
     pagingInfo.PageCount.Should().Be.EqualTo(1);
     pagingInfo.FirstItemOnPage.Should().Be.EqualTo(0);
     pagingInfo.LastItemOnPage.Should().Be.EqualTo(9);
     pagingInfo.HasPreviousPage.Should().Be.False();
     pagingInfo.HasNextPage.Should().Be.False();
     pagingInfo.PageNumber.Should().Be.EqualTo(0);
     pagingInfo.PageSize.Should().Be.EqualTo(10);
     pagingInfo.IsFirstPage.Should().Be.True();
     pagingInfo.IsLastPage.Should().Be.True();
 }
Exemplo n.º 28
0
            public void can_page_and_render_correct_html()
            {
                var pagingInfo = new PagingInfo { CurrentPage = 2, ItemsPerPage = 3, TotalItems = 5 };
                Func<int, string> pageUrl = x => "Page" + x.ToString();
                HtmlHelper sut = null;
                var res = sut.PageLinks(pagingInfo, pageUrl);

                res.ToString()
                    .Should()
                        .NotBeNullOrEmpty()
                    .And
                        .NotBeBlank()
                    .And
                        .Be(@"<a href=""Page1"">1</a><a class=""selected"" href=""Page2"">2</a>");
            }
Exemplo n.º 29
0
        public ViewResult List(string category, int page = 1)
        {
            productsOfCategory = repository.Products.Where(p => category == null || p.Category == category);
            productsForDisplay = productsOfCategory.OrderBy(x => x.ProductId).Skip((page - 1) * PageSize).Take(PageSize);

            pagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = productsOfCategory.Count() };

            ProductListViewModel viewModel = new ProductListViewModel
            {
                Products = productsForDisplay,
                PagingInfo = pagingInfo
            };
            currentCategory = category;
            viewModel.CurrentCategory = category;
            return View(viewModel);
        }
Exemplo n.º 30
0
 public void Can_Generate_Page_Links()
 {
     //准备  定义一个HTML辅助器,为了运用扩展方法,需要这样
     HtmlHelper myHelper=null;
     //准备  创建PageInfo数据
     PagingInfo pagingInfo=new PagingInfo{
         CurrentPage=2,
         TotalItems=28,
         ItemsPerPage=10
     };
     //准备 用lambda表达式建立委托
     Func<int, string> pageUrlDelegate = i => "Page" + i;
     //动作
     MvcHtmlString result = myHelper.PageLinks(pagingInfo, pageUrlDelegate);
     //断言
     Assert.AreEqual(result.ToString(), @"<a href=""Page1"">1</a>" + @"<a class=""selected"" href=""Page2"">2</a>" + @"<a href=""Page3"">3</a>");
 }
Exemplo n.º 31
0
 public IHttpActionResult GetFunctionsInJob(string jobName, [FromUri] PagingInfo pagingInfo)
 {
     return(GetFunctionsInJob(WebJobTypes.Continuous, jobName, null, pagingInfo));
 }
Exemplo n.º 32
0
        public IActionResult Index(string filter, int page = 1, int sort = 1, bool ascending = true)
        {
            int pagesize = appSettings.PageSize;
            var query    = ctx.Certifikati.AsQueryable();

            CertifikatiFilter cf = new CertifikatiFilter();

            if (!string.IsNullOrWhiteSpace(filter))
            {
                cf = CertifikatiFilter.FromString(filter);
                if (!cf.IsEmpty())
                {
                    if (cf.Id.HasValue)
                    {
                        cf.Naziv = ctx.Certifikati
                                   .Where(c => c.Id == c.Id)
                                   .Select(c => c.Naziv)
                                   .FirstOrDefault();
                    }
                    query = cf.Apply(query);
                }
            }

            int count = query.Count();

            var pagingInfo = new PagingInfo {
                CurrentPage  = page,
                Sort         = sort,
                Ascending    = ascending,
                ItemsPerPage = pagesize,
                TotalItems   = count
            };

            if (page < 1)
            {
                page = 1;
            }
            else if (page > pagingInfo.TotalPages)
            {
                if (page != 1 || cf.IsEmpty())
                {
                    return(RedirectToAction(nameof(Index),
                                            new { page = pagingInfo.TotalPages, sort, ascending, filter }));
                }
            }

            query = ApplySort(sort, ascending, query);


            var certifikati = query
                              .Skip((page - 1) * pagesize)
                              .Take(pagesize)
                              .ToList();

            var model = new CertifikatiViewModel {
                certifikati = certifikati,
                PagingInfo  = pagingInfo,
                Filter      = cf
            };

            return(View(model));
        }
Exemplo n.º 33
0
        public DataPaged <EE_DETALLES_ORDEN> GetAllDetallesOrdenProduccion(PagingInfo info, string Codigo)
        {
            var context = (Entities)Context;

            this.Context.ContextOptions.LazyLoadingEnabled = false;
            IQueryable <EE_DETALLES_ORDEN> result = null;
            int Total = 0;

            if ((info.search == null) || (info.search == ""))
            {
                Total  = Query().Count();
                result = QueryPaged(Query(), info.limit, info.start, info.sort, info.dir);
            }
            else
            {
                if (Codigo == "CODIGO")
                {
                    info.search = info.search.ToUpper();
                    result      = from p in context.EE_DETALLES_ORDEN
                                  where p.NRO_OP.Contains(info.search) || p.DETALLE_ITEM.Contains(info.search)
                                  select p;
                }
                else if (Codigo == "RECIBO")
                {
                    result = from p in context.EE_DETALLES_ORDEN
                             where p.NRO_OP.Contains(info.search) && p.TOTAL_A_CANCELAR > 0
                             select p;
                }
                else if (Codigo == "FACTURACLIENTE")
                {
                    int id = Convert.ToInt32(info.search);
                    info.search = info.search.ToUpper();
                    result      = from p in context.EE_DETALLES_ORDEN
                                  join c in context.EE_ORDENES_PRODUCCION on p.ID_ORDEN_PRODUCCION equals c.ID_ORDEN_PRODUCCION
                                  where c.ID_TIPO_CLIENTE == id && c.CLIENTE != null && c.IMPORTE_FACTURADO < c.TOTAL
                                  select p;
                }
                else if (Codigo == "FACTURAEMPRESA")
                {
                    int id = Convert.ToInt32(info.search);
                    info.search = info.search.ToUpper();
                    result      = from p in context.EE_DETALLES_ORDEN
                                  join c in context.EE_ORDENES_PRODUCCION on p.ID_ORDEN_PRODUCCION equals c.ID_ORDEN_PRODUCCION
                                  where c.ID_TIPO_CLIENTE == id && c.EMPRESA != null && c.IMPORTE_FACTURADO < c.TOTAL
                                  select p;
                }
                else
                {
                    //var id = Convert.ToInt32(info.search);
                    info.search = info.search.ToUpper();
                    result      = from p in context.EE_DETALLES_ORDEN
                                  join c in context.EE_ORDENES_PRODUCCION on p.ID_ORDEN_PRODUCCION equals c.ID_ORDEN_PRODUCCION
                                  where c.TIPO_CLIENTE.Contains(info.search) || p.NRO_OP.Contains(info.search)
                                  select p;
                }
                Total  = result.Count();
                result = QueryPaged(result, info.limit, info.start, info.sort, info.dir);
            }
            var resultado = new DataPaged <EE_DETALLES_ORDEN>()
            {
                Page    = info.page,
                Records = info.limit,
                Rows    = result.ToList(),
                Total   = Total
            };

            return(resultado);
        }
Exemplo n.º 34
0
 public new TestRoleList GetAll(PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetAll(paging, eagerLoad) as TestRoleList);
 }
Exemplo n.º 35
0
 /// <summary>
 /// SqlServer 、 Oracle 都支持在数据库层面进行分页。
 /// </summary>
 protected override PagingLocation GetPagingLocation(PagingInfo pagingInfo)
 {
     //虽然本类默认使用数据库分页,但是它的子类可以重写本方法来使用内存分页。
     //所以本类中的所有方法,在重新实现时,都会分辨这两种情况。
     return(PagingLocation.Database);
 }
Exemplo n.º 36
0
        public async Task <Tuple <IList <SearchResultDto>, int> > BestMatchWeighted(string query, PagingInfo pagingInfo, string startDate, string endDate)
        {
            using (var db = new StackoverflowDbContext())
            {
                var conn = (MySqlConnection)db.Database.GetDbConnection();
                conn.Open();

                var cmd = InitCommand(conn, query, pagingInfo, startDate, endDate);
                cmd.CommandText = "call BestMatchWeighted(@query, @pageSize, @pageNumber, @startDate, @endDate)";

                var result = await ReadFromDatabase(cmd);

                var numberOfRows = await GetNumberOfRows(cmd, "call BestMatchWeighted_Count(@query, @startDate, @endDate)");

                return(new Tuple <IList <SearchResultDto>, int>(result, numberOfRows));
            }
        }
Exemplo n.º 37
0
        public override List <soft_Suppliers> SearchBy(PagingInfo pageinfo, out int count, out int min, out double totalMoney, int BranchesId = 0)
        {
            totalMoney = 0;

            var lstTmp = GetAll();

            var isSort = false;

            #region Sort
            if (!string.IsNullOrEmpty(pageinfo.sortby))
            {
                switch (pageinfo.sortby)
                {
                case "SuppliersId":
                    isSort = true;
                    if (pageinfo.sortbydesc)
                    {
                        lstTmp = lstTmp.OrderByDescending(o => o.SuppliersId);
                    }
                    else
                    {
                        lstTmp = lstTmp.OrderBy(o => o.SuppliersId);
                    }
                    break;

                case "Name":
                    isSort = true;
                    if (pageinfo.sortbydesc)
                    {
                        lstTmp = lstTmp.OrderByDescending(o => o.Name);
                    }
                    else
                    {
                        lstTmp = lstTmp.OrderBy(o => o.Name);
                    }
                    break;

                case "Email":
                    isSort = true;
                    if (pageinfo.sortbydesc)
                    {
                        lstTmp = lstTmp.OrderByDescending(o => o.Email);
                    }
                    else
                    {
                        lstTmp = lstTmp.OrderBy(o => o.Email);
                    }
                    break;

                case "Phone":
                    isSort = true;
                    if (pageinfo.sortbydesc)
                    {
                        lstTmp = lstTmp.OrderByDescending(o => o.Phone);
                    }
                    else
                    {
                        lstTmp = lstTmp.OrderBy(o => o.Phone);
                    }
                    break;

                case "Address":
                    isSort = true;
                    if (pageinfo.sortbydesc)
                    {
                        lstTmp = lstTmp.OrderByDescending(o => o.Address);
                    }
                    else
                    {
                        lstTmp = lstTmp.OrderBy(o => o.Address);
                    }
                    break;
                }
            }
            #endregion

            #region Search
            if (!string.IsNullOrEmpty(pageinfo.keyword))
            {
                pageinfo.keyword = pageinfo.keyword.ToLower();

                lstTmp = lstTmp.Where(o => o.Name.Contains(pageinfo.keyword) ||
                                      o.Phone.Contains(pageinfo.keyword) ||
                                      o.Email.Contains(pageinfo.keyword) ||
                                      o.Address.Contains(pageinfo.keyword)
                                      );
            }
            #endregion

            min = Helpers.FindMin(pageinfo.pageindex, pageinfo.pagesize);

            count = lstTmp.Count();

            if (!isSort)
            {
                lstTmp = lstTmp.OrderByDescending(o => o.Name);
            }

            var result = lstTmp.Skip(min).Take(pageinfo.pagesize).ToList();

            return(result);
        }
Exemplo n.º 38
0
        /// <summary>
        /// The PageLinks extension method(HtmlHelper) generates the HTML for a set of page links
        /// using the information provided in a PagingInfo object.
        /// The Func parameter accepts a delegate that it uses to generate the links to view other pages.
        /// Bootsrap pagination
        /// </summary>
        /// <param name="html">Extention</param>
        /// <param name="pagingInfo">PagignInfo object</param>
        /// <param name="sizePatginatonBar">Size pagination bar</param>
        /// <param name="pageUrl">Route Url</param>
        /// <returns></returns>
        public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInfo pagingInfo, int sizePatginatonBar, Func <int, string> pageUrl)
        {
            //if (html == null) throw new ArgumentNullException("html");

            StringBuilder result = new StringBuilder();

            //for best view paging (selection always in middle)
            int startIndex = (int)Math.Max(1,
                                           Math.Max(0, pagingInfo.CurrentPage - (int)Math.Round((double)sizePatginatonBar / 2)) -
                                           Math.Max(0, Math.Round((double)(pagingInfo.CurrentPage - (pagingInfo.TotalPages - sizePatginatonBar)) / 2)));

            int endIndex = Math.Min(pagingInfo.TotalPages, startIndex + sizePatginatonBar);

            #region Previos Page
            TagBuilder ulTag = new TagBuilder("ul");
            ulTag.AddCssClass("pagination");
            TagBuilder stliTag = new TagBuilder("li");
            if (pagingInfo.CurrentPage == startIndex)
            {
                stliTag.AddCssClass("disabled");
            }
            TagBuilder atag = new TagBuilder("a");
            //retrive url
            atag.MergeAttribute("href", pagingInfo.CurrentPage > 1 ? pageUrl(pagingInfo.CurrentPage - 1) : pageUrl(1));
            atag.MergeAttribute("aria-label", "Previous");

            TagBuilder stspanTag = new TagBuilder("span");
            stspanTag.MergeAttribute("aria-hidden", "true");
            stspanTag.InnerHtml = "&laquo";

            atag.InnerHtml    = stspanTag.ToString();
            stliTag.InnerHtml = atag.ToString();
            //ulTag.InnerHtml = stliTag.ToString();
            //result.Append(ulTag);
            #endregion

            #region PageLinks
            string linkPage = "";
            for (int i = startIndex; i <= endIndex; i++)
            {
                TagBuilder lipageTag = new TagBuilder("li");
                if (i == pagingInfo.CurrentPage)
                {
                    lipageTag.AddCssClass("active");
                }

                TagBuilder apagetag = new TagBuilder("a");
                TagBuilder srSpan   = new TagBuilder("span");
                srSpan.AddCssClass("sr-only");
                srSpan.InnerHtml = "(current)";
                apagetag.MergeAttribute("href", pageUrl(i));
                if (i == pagingInfo.CurrentPage)
                {
                    //lipageTag.AddCssClass("active");
                    apagetag.InnerHtml = i + srSpan.ToString();
                }
                apagetag.InnerHtml = i.ToString();

                lipageTag.InnerHtml = apagetag.ToString();
                linkPage            = linkPage + lipageTag;
                //result.Append(lipageTag);
            }
            #endregion

            #region Next Page
            TagBuilder endliTag = new TagBuilder("li");
            if (pagingInfo.CurrentPage == endIndex)
            {
                endliTag.AddCssClass("disabled");
            }
            TagBuilder nexttag = new TagBuilder("a");

            nexttag.MergeAttribute("href", pagingInfo.CurrentPage < pagingInfo.TotalPages ? pageUrl(pagingInfo.CurrentPage + 1) : pageUrl(pagingInfo.TotalPages));
            nexttag.MergeAttribute("aria-label", "Next");

            TagBuilder endSpanTag = new TagBuilder("span");
            endSpanTag.MergeAttribute("aria-hidden", "true");
            endSpanTag.InnerHtml = "&raquo";

            nexttag.InnerHtml  = endSpanTag.ToString();
            endliTag.InnerHtml = nexttag.ToString();
            //result.Append(endliTag);
            #endregion

            ulTag.InnerHtml = stliTag + linkPage + endliTag;
            result.Append(ulTag);

            return(MvcHtmlString.Create(result.ToString()));
        }
Exemplo n.º 39
0
        public void Task_Can_Send_Pagination()
        {
            // Arrange
            Mock <ILogger <TasksController> > mockLogger             = new Mock <ILogger <TasksController> >();
            Mock <ITaskListRepository>        mockTaskListRepository = new Mock <ITaskListRepository>();
            Mock <IStatusRepository>          mockStatusRepository   = new Mock <IStatusRepository>();
            Mock <ILocationRepository>        mockLocationRepository = new Mock <ILocationRepository>();
            Mock <IIdentityRepository>        mockIdentityRepository = new Mock <IIdentityRepository>();

            mockTaskListRepository.Setup(m => m.GetTasks).Returns((new Task[] {
                new Task {
                    TaskId = 1, Description = "T1", StatusId = 1, LocationId = 1, UserId = "1", Location = new Location {
                        Description = "L1"
                    }, Status = new Status {
                        Name = "Open"
                    }, User = new AspNetUser {
                        FullName = "Joe"
                    }
                },
                new Task {
                    TaskId = 1, Description = "T2", StatusId = 1, LocationId = 1, UserId = "1", Location = new Location {
                        Description = "L2"
                    }, Status = new Status {
                        Name = "Open"
                    }, User = new AspNetUser {
                        FullName = "Joe"
                    }
                },
                new Task {
                    TaskId = 1, Description = "T3", StatusId = 1, LocationId = 1, UserId = "1", Location = new Location {
                        Description = "L3"
                    }, Status = new Status {
                        Name = "Open"
                    }, User = new AspNetUser {
                        FullName = "Joe"
                    }
                },
                new Task {
                    TaskId = 1, Description = "T4", StatusId = 1, LocationId = 1, UserId = "1", Location = new Location {
                        Description = "L4"
                    }, Status = new Status {
                        Name = "Open"
                    }, User = new AspNetUser {
                        FullName = "Joe"
                    }
                },
                new Task {
                    TaskId = 1, Description = "T5", StatusId = 1, LocationId = 1, UserId = "1", Location = new Location {
                        Description = "L5"
                    }, Status = new Status {
                        Name = "Open"
                    }, User = new AspNetUser {
                        FullName = "Joe"
                    }
                }
            }).AsQueryable <Task>());

            TasksController controller = new TasksController(mockLogger.Object, mockTaskListRepository.Object, mockStatusRepository.Object, mockLocationRepository.Object, mockIdentityRepository.Object);

            controller.PageSize = 3;

            // Act
            TasksListViewModel result = controller.List(string.Empty, string.Empty, 2).ViewData.Model as TasksListViewModel;

            // Assert
            PagingInfo pageInfo = result.PagingInfo;

            Assert.AreEqual(2, pageInfo.CurrentPage);
            Assert.AreEqual(3, pageInfo.ItemsPerPage);
            Assert.AreEqual(5, pageInfo.TotalItems);
            Assert.AreEqual(2, pageInfo.TotalPages);
        }
        private async Task <LinkedCollectionResourceWrapperDto <ReportInstanceDetailDto> > GetReportInstancesAsync(Guid workFlowGuid,
                                                                                                                   int pageNumber,
                                                                                                                   int pageSize,
                                                                                                                   DateTime searchFrom,
                                                                                                                   DateTime searchTo,
                                                                                                                   string qualifiedName     = "",
                                                                                                                   string searchTerm        = "",
                                                                                                                   bool feedbackReportsOnly = false,
                                                                                                                   bool activeReportsOnly   = false)
        {
            var pagingInfo = new PagingInfo()
            {
                PageNumber = pageNumber,
                PageSize   = pageSize
            };

            var orderby = Extensions.GetOrderBy <ReportInstance>("Created", "desc");

            // Filter list
            var predicate = PredicateBuilder.New <ReportInstance>(true);

            predicate = predicate.And(f => f.WorkFlow.WorkFlowGuid == workFlowGuid);
            predicate = predicate.And(f => f.Created >= searchFrom && f.Created <= searchTo);
            if (feedbackReportsOnly)
            {
                predicate = predicate.And(f => f.Activities.Any(a => a.QualifiedName == "Set MedDRA and Causality" && a.CurrentStatus.Description == "CAUSALITYSET"));
            }

            if (!String.IsNullOrWhiteSpace(qualifiedName))
            {
                if (activeReportsOnly)
                {
                    switch (qualifiedName)
                    {
                    case "Confirm Report Data":
                        predicate = predicate.And(f => f.Activities.Any(a => a.QualifiedName == qualifiedName && a.Current == true && a.CurrentStatus.Description != "DELETED"));
                        break;

                    case "Extract E2B":
                        predicate = predicate.And(f => f.Activities.Any(a => a.QualifiedName == qualifiedName && a.Current == true && a.CurrentStatus.Description != "E2BSUBMITTED"));
                        break;

                    default:
                        predicate = predicate.And(f => f.Activities.Any(a => a.QualifiedName == qualifiedName && a.Current == true));
                        break;
                    }
                }
                else
                {
                    predicate = predicate.And(f => f.Activities.Any(a => a.QualifiedName == qualifiedName && a.Current == true));
                }
            }

            if (!String.IsNullOrWhiteSpace(searchTerm))
            {
                predicate = predicate.And(f => f.PatientIdentifier.Contains(searchTerm) ||
                                          f.SourceIdentifier.Contains(searchTerm) ||
                                          f.TerminologyMedDra.MedDraTerm.Contains(searchTerm) ||
                                          f.Identifier.Contains(searchTerm) ||
                                          f.Medications.Any(fm => fm.MedicationIdentifier.Contains(searchTerm)));
            }

            var pagedReportsFromRepo = _reportInstanceRepository.List(pagingInfo, predicate, orderby, new string[] { "WorkFlow", "Medications", "TerminologyMedDra", "Activities.CurrentStatus", "Activities.ExecutionEvents.ExecutionStatus", "Tasks" });

            if (pagedReportsFromRepo != null)
            {
                // Map EF entity to Dto
                var mappedReportsWithLinks = new List <ReportInstanceDetailDto>();

                foreach (var pagedReport in pagedReportsFromRepo)
                {
                    var mappedReport = _mapper.Map <ReportInstanceDetailDto>(pagedReport);

                    await CustomMapAsync(pagedReport, mappedReport);
                    await CreateLinksAsync(pagedReport, mappedReport);

                    mappedReportsWithLinks.Add(mappedReport);
                }

                var wrapper = new LinkedCollectionResourceWrapperDto <ReportInstanceDetailDto>(pagedReportsFromRepo.TotalCount, mappedReportsWithLinks, pagedReportsFromRepo.TotalPages);

                CreateLinksForReportInstances(workFlowGuid, wrapper, "Created", "", DateTime.MinValue, DateTime.MaxValue, pageNumber, pageSize,
                                              pagedReportsFromRepo.HasNext, pagedReportsFromRepo.HasPrevious);

                return(wrapper);
            }

            return(null);
        }
Exemplo n.º 41
0
 /// <summary>
 /// 使用 sql 语句来查询数据表。
 /// </summary>
 /// <param name="sql">Sql 语句.</param>
 /// <param name="paging">分页信息。</param>
 /// <returns></returns>
 public LiteDataTable QueryTable(FormattedSql sql, PagingInfo paging = null)
 {
     return(this.QueryTable(new TableQueryArgs(sql, paging)));
 }
Exemplo n.º 42
0
 public new BookCategoryList GetByParentId(object parentId, PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetByParentId(parentId, paging, eagerLoad) as BookCategoryList);
 }
Exemplo n.º 43
0
 public IHttpActionResult GetFunctionsInJob(string jobName, string runId, [FromUri] PagingInfo pagingInfo)
 {
     return(GetFunctionsInJob(WebJobTypes.Triggered, jobName, runId, pagingInfo));
 }
Exemplo n.º 44
0
        public IHttpActionResult GetFunctionDefinitions(
            [FromUri] PagingInfo pagingInfo,
            string host    = null,
            bool skipStats = false)
        {
            if (pagingInfo == null)
            {
                throw new ArgumentNullException("pagingInfo");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IResultSegment <FunctionIndexEntry> indexSegment = _functionIndexReader.Read(host, pagingInfo.Limit,
                                                                                         pagingInfo.ContinuationToken);

            var  model = new FunctionStatisticsSegment();
            bool foundItem;

            if (indexSegment != null && indexSegment.Results != null)
            {
                IEnumerable <FunctionStatisticsViewModel> query = indexSegment.Results
                                                                  .Select(entry => new FunctionStatisticsViewModel
                {
                    FunctionId       = entry.Id,
                    FunctionFullName = entry.FullName,
                    FunctionName     = entry.ShortName,
                    IsRunning        = HostHasHeartbeat(entry).GetValueOrDefault(true),
                    FailedCount      = 0,
                    SuccessCount     = 0
                });

                model.Entries           = query.ToArray();
                foundItem               = query.Any();
                model.ContinuationToken = indexSegment.ContinuationToken;
            }
            else
            {
                foundItem = false;
            }

            if (pagingInfo.ContinuationToken == null)
            {
                // For requests for the first page only, also provide a version to enable polling for updates.
                model.VersionUtc = _functionIndexReader.GetCurrentVersion().UtcDateTime;
            }

            model.StorageAccountName = _account.Credentials.AccountName;

            if (!foundItem)
            {
                model.IsOldHost = OnlyBeta1HostExists(alreadyFoundNoNewerEntries: true);
            }

            // This is very slow. Allow a flag to skip it, and then client can query the stats independently
            // via the /timeline API.
            if ((model.Entries != null) && !skipStats)
            {
                foreach (FunctionStatisticsViewModel statisticsModel in model.Entries)
                {
                    if (statisticsModel == null)
                    {
                        continue;
                    }

                    Tuple <int, int> counts = GetStatistics(statisticsModel.FunctionId);
                    statisticsModel.SuccessCount = counts.Item1;
                    statisticsModel.FailedCount  = counts.Item2;
                }
            }

            return(Ok(model));
        }
Exemplo n.º 45
0
 public static IList <Topic> GetTopics(Category category, PagingInfo paging)
 {
     return(Provider.GetTopics(category, paging));
 }
Exemplo n.º 46
0
            private static PagedResult <SimpleProduct> PopulateComplexProductProperties(long channelId, PagedResult <SimpleProduct> products, RequestContext context, SearchLocation searchLocation, bool?downloadedProductsFilter, bool calculatePrices)
            {
                // Retrieving all id collections needed to query the Data Service for complex properties.
                var productIds               = products.Results.Select(p => p.RecordId);
                var masterTypeProductIds     = products.Results.Where(p => p.ProductType == ProductType.Master).Select(p => p.RecordId);
                var kitVariantTypeProductIds = products.Results.Where(p => p.ProductType == ProductType.KitVariant).Select(v => v.RecordId);
                var kitMasterTypeProductIds  = products.Results.Where(p => p.ProductType == ProductType.KitMaster).Select(v => v.RecordId);
                var variantTypeProductIds    = products.Results.Where(p => p.ProductType == ProductType.Variant).Select(v => v.RecordId);

                // Products of types Master and KitMaster have dimensions that need to be retrieved.
                var idsOfProductsContainingDimensions = masterTypeProductIds.Concat(kitMasterTypeProductIds);

                IEnumerable <ProductComponent>      components        = new List <ProductComponent>();
                IEnumerable <ProductDimension>      productDimensions = new List <ProductDimension>();
                IEnumerable <ProductDimensionValue> dimensionValues   = new List <ProductDimensionValue>();

                // Products of type KitVariant have components that need to be retrieved.
                if (kitVariantTypeProductIds.Any())
                {
                    var getProductComponentsDataRequestColummnSet = ProductComponent.DefaultColumnSet;
                    getProductComponentsDataRequestColummnSet.Add("VARIANTPRODUCTID");
                    var getProductComponentsDataRequestSettings = new QueryResultSettings(getProductComponentsDataRequestColummnSet, PagingInfo.AllRecords);
                    var getProductComponentsDataRequest         = new GetProductComponentsForVariantProductsDataRequest(kitVariantTypeProductIds, getProductComponentsDataRequestSettings, downloadedProductsFilter);
                    components = context.Execute <EntityDataServiceResponse <ProductComponent> >(getProductComponentsDataRequest).PagedEntityCollection.Results;
                }

                if (idsOfProductsContainingDimensions.Any())
                {
                    var getDimensionsDataRequest = new GetProductDimensionsDataRequest(idsOfProductsContainingDimensions, QueryResultSettings.AllRecords);
                    productDimensions = context.Execute <EntityDataServiceResponse <ProductDimension> >(getDimensionsDataRequest).PagedEntityCollection.Results;
                }

                // Products of types Variant and KitVariant have dimension values that need to be retrieved.
                // This collection is populated after retrieving components so that dimension values of Variant type products can also be retrieved in the same transaction.
                var idsOfProductsContainingDimensionValues = variantTypeProductIds.Concat(kitVariantTypeProductIds).Concat(components.Where(c => c.ProductType == ProductType.Variant).Select(c => c.ProductId).Distinct());

                if (idsOfProductsContainingDimensionValues.Any())
                {
                    var getDimensionValuesDataRequest = new GetProductDimensionValuesForVariantProductsDataRequest(idsOfProductsContainingDimensionValues, QueryResultSettings.AllRecords, downloadedProductsFilter);
                    dimensionValues = context.Execute <EntityDataServiceResponse <ProductDimensionValue> >(getDimensionValuesDataRequest).PagedEntityCollection.Results;
                }

                var productIdsToFetchBehavior   = productIds.Concat(components.Select(c => c.ProductId).Distinct());
                var productBehaviorSettings     = new QueryResultSettings(ProductBehavior.DefaultColumnSet, PagingInfo.CreateWithExactCount(productIdsToFetchBehavior.Count(), skip: 0));
                var productsBehaviorDataRequest = new GetProductBehaviorDataRequest(productIdsToFetchBehavior, productBehaviorSettings, downloadedProductsFilter);
                PagedResult <ProductBehavior> productsBehavior = context.Execute <EntityDataServiceResponse <ProductBehavior> >(productsBehaviorDataRequest).PagedEntityCollection;

                var getLinkedProductRelationsDataRequest = new GetLinkedProductRelationsDataRequest(productIds, QueryResultSettings.AllRecords, downloadedProductsFilter);
                PagedResult <LinkedProductRelation> linkedProductRelations = context.Execute <EntityDataServiceResponse <LinkedProductRelation> >(getLinkedProductRelationsDataRequest).PagedEntityCollection;

                var linkedProductIds             = linkedProductRelations.Results.Select(r => r.LinkedProductId).Distinct();
                var getLinkedProductsDataRequest = new GetProductsServiceRequest(channelId, linkedProductIds, QueryResultSettings.AllRecords);

                getLinkedProductsDataRequest.SearchLocation = searchLocation;
                PagedResult <SimpleProduct> linkedProducts = context.Execute <GetProductsServiceResponse>(getLinkedProductsDataRequest).Products;

                PagedResult <ProductPrice> productPrices = PagedResult <ProductPrice> .Empty();

                if (calculatePrices)
                {
                    // Pricing APIs currently take Product instead of SimpleProduct. We manually build a Product object
                    // and populate the required field in the interim until uptake of SimpleProduct in pricing service.
                    List <Product> productsTransformedForPricing = ConvertSimpleProductsToProducts(products.Results).ToList();

                    var priceRequest = new GetProductPricesServiceRequest(productsTransformedForPricing);
                    productPrices = context.Execute <GetProductPricesServiceResponse>(priceRequest).ProductPrices;
                }

                return(InsertProductPropertiesIntoProduct(products, productsBehavior, productPrices, linkedProductRelations, linkedProducts, components, productDimensions, dimensionValues));
            }
Exemplo n.º 47
0
 public new TestRoleList GetByParentIdList(object[] parentIdList, PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetByParentIdList(parentIdList, paging, eagerLoad) as TestRoleList);
 }
Exemplo n.º 48
0
        // GET: Web/ProductConcern
        public ActionResult Index(int pageSize = 10, int pageNo = 1)
        {
            var model = _iShopService.GetUserConcernShops(CurrentUser.Id, pageNo, pageSize);
            List <ShopConcernModel> list = new List <Models.ShopConcernModel>();

            foreach (var m in model.Models.ToList())
            {
                if (null != m.Himall_Shops)
                {
                    ShopConcernModel concern = new ShopConcernModel();
                    concern.FavoriteShopInfo.Id           = m.Id;
                    concern.FavoriteShopInfo.Logo         = m.Himall_Shops.Logo;
                    concern.FavoriteShopInfo.ConcernTime  = m.Date;
                    concern.FavoriteShopInfo.ShopId       = m.ShopId;
                    concern.FavoriteShopInfo.ShopName     = m.Himall_Shops.ShopName;
                    concern.FavoriteShopInfo.ConcernCount = m.Himall_Shops.Himall_FavoriteShops.Count();
                    #region 热门销售
                    var sale = _iProductService.GetHotSaleProduct(m.ShopId, 10);
                    if (sale != null)
                    {
                        foreach (var item in sale)
                        {
                            concern.HotSaleProducts.Add(new HotProductInfo
                            {
                                ImgPath   = item.ImagePath,
                                Name      = item.ProductName,
                                Price     = item.MinSalePrice,
                                Id        = item.Id,
                                SaleCount = (int)item.SaleCounts
                            });
                        }
                    }
                    #endregion

                    #region 最新上架
                    var newsale = _iProductService.GetNewSaleProduct(m.ShopId, 10);
                    if (newsale != null)
                    {
                        foreach (var item in newsale)
                        {
                            concern.NewSaleProducts.Add(new HotProductInfo
                            {
                                ImgPath   = item.ImagePath,
                                Name      = item.ProductName,
                                Price     = item.MinSalePrice,
                                Id        = item.Id,
                                SaleCount = (int)item.ConcernedCount
                            });
                        }
                    }
                    list.Add(concern);
                    #endregion
                }
            }
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total
            };
            ViewBag.pageInfo = info;
            return(View(list));
        }
Exemplo n.º 49
0
        public async Task <ReturnPagingInfo <ReadCategoryModel> > GetAllCategoryAsync(PagingInfo pagingInfo, CancellationToken cancellationToken)
        {
            var page = await _categoryRepository.GetAllDataAsync(pagingInfo, cancellationToken);

            var readCategoryModels = page.Data.Select(category => _mapper.Map <ReadCategoryModel>(category)).ToList();
            var result             = new ReturnPagingInfo <ReadCategoryModel>
            {
                CurrentPage = page.CurrentPage,
                PageSize    = page.PageSize,
                TotalItems  = page.TotalItems,
                TotalPages  = page.TotalPages,
                Data        = readCategoryModels
            };

            return(result);
        }
Exemplo n.º 50
0
 public new ChapterList GetByParentId(object parentId, PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetByParentId(parentId, paging, eagerLoad) as ChapterList);
 }
Exemplo n.º 51
0
 public new ProvinceList GetAll(PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetAll(paging, eagerLoad) as ProvinceList);
 }
Exemplo n.º 52
0
        /// <summary>
        ///     Get all users
        /// </summary>
        /// <param name="bitbucketClient">IUserDomain to pin the extension method to</param>
        /// <param name="pagingInfo">PagingInfo to get the next page, this should simply be the results object</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>Results with User instances</returns>
        public static async Task <Results <User> > GetAllAsync(this IUserDomain bitbucketClient, PagingInfo pagingInfo = null, CancellationToken cancellationToken = new CancellationToken())
        {
            var usersUri = bitbucketClient.BitbucketApiUri.AppendSegments("users");

            bitbucketClient.Behaviour.MakeCurrent();
            var response = await usersUri.GetAsAsync <HttpResponse <Results <User>, ErrorList> >(cancellationToken).ConfigureAwait(false);

            return(response.HandleErrors());
        }
        public static MvcHtmlString AddDropDownPagination(this HtmlHelper htmlHelper, PagingInfo pagingInfo, Func <int, string> url, bool isPagingEnabled = true)
        {
            if (isPagingEnabled == false || pagingInfo == null || pagingInfo.TotalPageCount <= 1)
            {
                return(MvcHtmlString.Create(string.Empty));
            }

            StringBuilder htmlStr   = new StringBuilder();
            TagBuilder    firstLink = new TagBuilder("a");

            firstLink.MergeAttribute("href", url(1));
            if (pagingInfo.CurentPageNo == 1)
            {
                firstLink.AddCssClass("selected");
                firstLink.AddCssClass("btn-primary");
            }
            firstLink.InnerHtml = "First";
            firstLink.AddCssClass("btn btn-default");
            if (pagingInfo.TotalPageCount <= 1 || pagingInfo.CurentPageNo == 1)
            {
                firstLink.MergeAttribute("disabled", "disabled");
            }

            htmlStr.Append(firstLink.ToString());

            TagBuilder previousLink = new TagBuilder("a");

            if (pagingInfo.CurentPageNo == 1)
            {
                previousLink.MergeAttribute("href", url(1));
            }
            else
            {
                previousLink.MergeAttribute("href", url(pagingInfo.CurentPageNo - 1));
            }

            previousLink.InnerHtml = "Prev.";
            previousLink.AddCssClass("btn btn-default");
            if (pagingInfo.TotalPageCount <= 1 || pagingInfo.CurentPageNo == 1)
            {
                previousLink.MergeAttribute("disabled", "disabled");
            }

            htmlStr.Append(previousLink.ToString());

            TagBuilder currentLink = new TagBuilder("text");
            int        pageCount   = pagingInfo.TotalPageCount == 0 ? 1 : pagingInfo.TotalPageCount;

            currentLink.InnerHtml = $"Page {pagingInfo.CurentPageNo} of {pageCount} pages";
            //currentLink.AddCssClass("btn btn-default");
            currentLink.AddCssClass("btn btn-primary");
            currentLink.MergeAttribute("style", "background-color:lightgray; color:black");
            htmlStr.Append(currentLink.ToString());

            TagBuilder nextLink = new TagBuilder("a");

            if (pagingInfo.CurentPageNo == pagingInfo.TotalPageCount)
            {
                nextLink.MergeAttribute("href", url(pagingInfo.TotalPageCount));
            }
            else
            {
                nextLink.MergeAttribute("href", url(pagingInfo.CurentPageNo + 1));
            }
            nextLink.InnerHtml = "Next";
            nextLink.AddCssClass("btn btn-default");
            if (pagingInfo.TotalPageCount <= 1 || pagingInfo.CurentPageNo == pagingInfo.TotalPageCount)
            {
                nextLink.MergeAttribute("disabled", "disabled");
            }

            htmlStr.Append(nextLink.ToString());

            TagBuilder lastLink = new TagBuilder("a");

            lastLink.MergeAttribute("href", url(pagingInfo.TotalPageCount));
            if (pagingInfo.CurentPageNo == pagingInfo.TotalPageCount)
            {
                lastLink.AddCssClass("selected");
                lastLink.AddCssClass("btn-primary");
            }
            lastLink.InnerHtml = "Last";
            lastLink.AddCssClass("btn btn-default");
            if (pagingInfo.TotalPageCount <= 1 || pagingInfo.CurentPageNo == pagingInfo.TotalPageCount)
            {
                lastLink.MergeAttribute("disabled", "disabled");
            }

            htmlStr.Append(lastLink.ToString());

            return(MvcHtmlString.Create(htmlStr.ToString()));
        }
Exemplo n.º 54
0
 public IList <Project> FindList(int AreaId, int TypeId, DateTime?fromDate, DateTime?ToDate, bool?IsActive, string keyword, PagingInfo paging)
 {
     return(projectDao.FindList(AreaId, TypeId, fromDate, ToDate, IsActive, keyword, paging));
 }
Exemplo n.º 55
0
        public DataTable GetOfficialPagingApproved(int group, int CateID, PagingInfo _paging, string _lang)
        {
            OfficialDAO officialDAO = new OfficialDAO();

            return(officialDAO.GetOfficialPagingApproved(group, CateID, _paging, _lang));
        }
Exemplo n.º 56
0
        public JsonResult GetOrder_Inside(PagingInfo pageinfo)
        {
            var Messaging = new RenderMessaging();

            try
            {
                if (User == null || User.ChannelId <= 0)
                {
                    Messaging.isError   = true;
                    Messaging.messaging = "Vui lòng đăng nhập lại!";
                }

                Channel_Paging <OrderModel> lstInfo = new Channel_Paging <OrderModel>();

                int count, min = 0;

                lstInfo.listTable = _IOrderBus.GetOrder_Input(pageinfo, User.BranchesId, out count, out min);

                lstInfo.totalItems = count;

                lstInfo.startItem = min;

                var sys_Employee = _unitOW.EmployeeRepository.GetAll().ToList();

                var soft_Branches = _unitOW.BrachesRepository.GetAll().ToList();

                foreach (var item in lstInfo.listTable)
                {
                    var userCreate = sys_Employee.FirstOrDefault(o => o.Id == item.EmployeeCreate);
                    item.EmployeeNameCreate = userCreate.Name + "(" + userCreate.Email + ")";

                    if (item.EmployeeUpdate.HasValue)
                    {
                        var userUpdate = sys_Employee.FirstOrDefault(o => o.Id == item.EmployeeUpdate);
                        item.EmployeeNameUpdate = userUpdate.Name + "(" + userUpdate.Email + ")";
                    }

                    var lstSup = new List <int>();

                    if (item.Id_From > 0)
                    {
                        var branch = soft_Branches.FirstOrDefault(o => o.BranchesId == item.Id_From);
                        if (branch != null)
                        {
                            item.Name_From = branch.BranchesName;
                        }
                        else
                        {
                            var orderSuppliers = _unitOW.OrderInputRepository.FindBy(o => o.Id == item.Id_From).FirstOrDefault();
                            if (orderSuppliers != null)
                            {
                                item.Name_From = "ĐH NPP";
                                foreach (var pro in item.Detail)
                                {
                                    if (pro.Product != null && pro.Product.soft_Suppliers != null)
                                    {
                                        var checkHas = lstSup.FirstOrDefault(o => o == pro.Product.soft_Suppliers.SuppliersId);
                                        if (checkHas <= 0)
                                        {
                                            item.Name_From += " - " + pro.Product.soft_Suppliers.Name;

                                            lstSup.Add(pro.Product.soft_Suppliers.SuppliersId);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (item.Id_To > 0)
                    {
                        var branch = soft_Branches.FirstOrDefault(o => o.BranchesId == item.Id_To);
                        if (branch != null)
                        {
                            item.Name_To = branch.BranchesName;
                        }
                    }
                }

                Messaging.Data = lstInfo;
            }
            catch
            {
                Messaging.isError   = true;
                Messaging.messaging = "Hiển thị đơn hàng nhập không thành công!";
            }
            return(Json(Messaging, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 57
0
        /// <summary>
        /// 使用 IDataReader 的内存分页读取方案。
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="rowReader">每一行数据,会调用此方法进行调取。</param>
        /// <param name="pagingInfo">分页信息。如果这个参数不为空,则使用其中描述的分页规则进行内存分页查询。</param>
        public static void MemoryPaging(IDataReader reader, Action <IDataReader> rowReader, PagingInfo pagingInfo)
        {
            bool isPaging   = !PagingInfo.IsNullOrEmpty(pagingInfo);
            bool needCount  = isPaging && pagingInfo.IsNeedCount;
            long totalCount = 0;
            long startRow   = 1;//从一开始的行号
            long endRow     = int.MaxValue;

            if (isPaging)
            {
                startRow = pagingInfo.PageSize * (pagingInfo.PageNumber - 1) + 1;
                endRow   = startRow + pagingInfo.PageSize - 1;
            }

            while (reader.Read())
            {
                totalCount++;

                if (totalCount >= startRow)
                {
                    if (totalCount <= endRow)
                    {
                        rowReader(reader);
                    }
                    else
                    {
                        //如果已经超出该页,而且需要统计行数,则直接快速循环到最后。
                        if (needCount)
                        {
                            while (reader.Read())
                            {
                                totalCount++;
                            }
                            break;
                        }
                    }
                }
            }

            if (needCount)
            {
                pagingInfo.TotalCount = totalCount;
            }
        }
Exemplo n.º 58
0
 public new ChapterList GetAll(PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetAll(paging, eagerLoad) as ChapterList);
 }
Exemplo n.º 59
0
 public new BookCategoryList GetAll(PagingInfo paging = null, EagerLoadOptions eagerLoad = null)
 {
     return(base.GetAll(paging, eagerLoad) as BookCategoryList);
 }
Exemplo n.º 60
0
        private IHttpActionResult GetFunctionsInJob(WebJobTypes webJobType, string jobName, string runId, [FromUri] PagingInfo pagingInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (pagingInfo == null)
            {
                return(BadRequest());
            }

            var runIdentifier = new WebJobRunIdentifier(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"),
                                                        (InternalWebJobTypes)webJobType, jobName, runId);

            IResultSegment <RecentInvocationEntry> indexSegment = _recentInvocationsByJobRunReader.Read(runIdentifier,
                                                                                                        pagingInfo.Limit, pagingInfo.ContinuationToken);
            InvocationLogSegment results;

            if (indexSegment != null)
            {
                results = new InvocationLogSegment
                {
                    Entries           = CreateInvocationEntries(indexSegment.Results),
                    ContinuationToken = indexSegment.ContinuationToken
                };
            }
            else
            {
                results = new InvocationLogSegment
                {
                    IsOldHost = OnlyBeta1HostExists(alreadyFoundNoNewerEntries: false)
                };
            }

            return(Ok(results));
        }