protected virtual void AllocMem() { Sample = new Paged<ulong>(Memory.Available); State = new ComparerState { SampleSize = Sample.Size, Time_FirstStarted = DateTime.Now }; }
public void Next(Paged<ulong> buffer, ulong offset, ulong length) { ulong limit = offset + length; for (ulong i = offset; i < limit; i++) { State ^= State >> 12; State ^= State << 25; State ^= State >> 27; buffer[i] = State * 2685821657736338717; } Offset += offset + limit; }
public void StackExchangeActionRendersMyQuestions() { var cache = new Cache(); caches.Setup(x => x.Get()).Returns(cache); var returnModel = new Paged<Answer>(); answers.Setup(x => x.Page(cache, 0, 10)).Returns(returnModel); controller = new PortfolioController(caches.Object, answers.Object); var stackExchange = controller.StackExchange(); var model = (Paged<Answer>)stackExchange.Model; Assert.Equal(returnModel, model); }
public ActionResult <ItemsResponse <FileUpload> > SearchPaginated(int pageIndex, int pageSize, string query) { try { Paged <FileUpload> pagedList = _fileService.SearchPaginated(pageIndex, pageSize, query); if (pagedList == null) { return(NotFound404(new ErrorResponse("Records Not Found"))); } else { ItemResponse <Paged <FileUpload> > response = new ItemResponse <Paged <FileUpload> >(); response.Item = pagedList; return(Ok200(response)); } } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public Paged <Product> Get(int pageIndex, int pageSize) { Paged <Product> pagedResult = null; List <Product> result = null; string procName = "[dbo].[Products_SelectAll_V2]"; int totalCount = 0; _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@PageIndex", pageIndex); parameterCollection.AddWithValue("@PageSize", pageSize); }, singleRecordMapper : delegate(IDataReader reader, short set) { Product product = MapProduct(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(20); } if (result == null) { result = new List <Product>(); } result.Add(product); } ); if (result != null) { pagedResult = new Paged <Product>(result, pageIndex, pageSize, totalCount); } return(pagedResult); }
public static Paged <Models.Customer> Search(int pageIndex = 1, int pageSize = 5, string sortBy = "lastname", string sortOrder = "asc", string keyword = "") { IQueryable <Customer> allCustomers = (IQueryable <Customer>)db.Customers; Paged <Models.Customer> customers = new Paged <Customer>(); if (!string.IsNullOrEmpty(keyword)) { allCustomers = allCustomers.Where(e => e.FirstName.Contains(keyword) || e.LastName.Contains(keyword)); } var queryCount = allCustomers.Count(); var skip = pageSize * (pageIndex - 1); long pageCount = (long)Math.Ceiling((decimal)(queryCount / pageSize)); if (sortBy.ToLower() == "firstname" && sortOrder.ToLower() == "asc") { customers.Items = allCustomers.OrderBy(e => e.FirstName).Skip(skip).Take(pageSize).ToList(); } else if (sortBy.ToLower() == "firstname" && sortOrder.ToLower() == "desc") { customers.Items = allCustomers.OrderByDescending(e => e.FirstName).Skip(skip).Take(pageSize).ToList(); } else if (sortBy.ToLower() == "lastname" && sortOrder.ToLower() == "asc") { customers.Items = allCustomers.OrderBy(e => e.LastName).Skip(skip).Take(pageSize).ToList(); } else { customers.Items = allCustomers.OrderByDescending(e => e.LastName).Skip(skip).Take(pageSize).ToList(); } customers.PageCount = pageCount; customers.PageIndex = pageIndex; customers.PageSize = pageSize; customers.QueryCount = queryCount; return(customers); }
public Paged <Event> GetByEventType(int pageIndex, int pageSize, int eventType) { Paged <Event> pagedResult = null; List <Event> result = null; int totalCount = 0; _data.ExecuteCmd( "[dbo].[Events_Select_ByEventType]", inputParamMapper : delegate(SqlParameterCollection col) { col.AddWithValue("@PageIndex", pageIndex); col.AddWithValue("@PageSize", pageSize); col.AddWithValue("@EventType", eventType); }, singleRecordMapper : delegate(IDataReader reader, short set) { Event model = MapEvent(reader); int index = 0; if (totalCount == 0) { totalCount = reader.GetSafeInt32(index++); } if (result == null) { result = new List <Event>(); } result.Add(model); } ); if (result != null) { pagedResult = new Paged <Event>(result, pageIndex, pageSize, totalCount); } return(pagedResult); }
public Tuple <IList <Products>, int> getByPage(Paged page) { try { SqlCommand command = new SqlCommand(String.Format("SELECT * FROM {4} {2} {3} OFFSET {0} ROWS FETCH NEXT {1} ROWS ONLY;SELECT COUNT(ID) TotalRecords FROM {4} WHERE ISDELETED=0", page.pageNumber * page.pageSize, page.pageSize, !String.IsNullOrEmpty(page.search) ? String.Format("WHERE {0} AND ISDELETED=0 ", page.search) : " WHERE ISDELETED=0 ", (!String.IsNullOrEmpty(page.orderby) ? String.Format("ORDER BY {0}", page.orderby) : "ORDER BY ID"), tableName)); DataSet productData = command.ExecuteDataSet(); if (productData.Tables[0].Rows.Count == 0) { return(null); } return(new Tuple <IList <Products>, int>(productData.Tables[0].ConvertList <Products>(), Convert.ToInt32(productData.Tables[1].Rows[0]["TotalRecords"]))); } catch (Exception ex) { throw ex; } }
public Paged <Appointment> GetSeekerUserAppointments(int seekerId, int providerId, int pageIndex, int pageSize) { Paged <Appointment> pagedAppointments = null; List <Appointment> appointments = null; int totalCount = 0; _data.ExecuteCmd( "[dbo].[Appointments_SelectByProviderId_Users]", inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@seekerId", seekerId); parameterCollection.AddWithValue("@providerId", providerId); parameterCollection.AddWithValue("@pageIndex", pageIndex); parameterCollection.AddWithValue("@pageSize", pageSize); }, singleRecordMapper : delegate(IDataReader reader, short set) { Appointment appointment; int startingIndex; MapAppointment(reader, out appointment, out startingIndex); if (totalCount == 0) { totalCount = reader.GetSafeInt32(startingIndex++); } if (appointments == null) { appointments = new List <Appointment>(); } appointments.Add(appointment); } ); if (appointments != null) { pagedAppointments = new Paged <Appointment>(appointments, pageIndex, pageSize, totalCount); } return(pagedAppointments); }
/// <summary> /// Возвращает постраничный список категорий товаров из магазина /// </summary> /// <param name="filter"></param> /// <returns></returns> public Paged <CartCategoryModel> GetCartCategories(CartFilter filter) { using (var db = new CMSdb(_context)) { var result = new Paged <CartCategoryModel>(); var query = db.cart_categories .Where(w => !w.b_disabled); if (!String.IsNullOrWhiteSpace(filter.SearchText)) { query = query.Where(w => w.c_name.Contains(filter.SearchText)); } int itemsCount = query.Count(); var list = query .Skip(filter.Size * (filter.Page - 1)) .Take(filter.Size) .Select(s => new CartCategoryModel { Id = s.id, Icon = s.c_icon, Title = s.c_name, Desc = s.c_desc, Disabled = s.b_disabled }).ToArray(); return(new Paged <CartCategoryModel> { Items = list, Pager = new PagerModel { PageNum = filter.Page, PageSize = filter.Size, TotalCount = itemsCount } }); } }
public Paged <Faq> GetByCreatedBy(int PageIndex, int PageSize, int CreatedBy) { Paged <Faq> pagedList = null; List <Faq> list = null; int totalCount = 0; string procName = "[dbo].[Faqs_SelectAllDetails_Providers]"; _data.ExecuteCmd( procName, delegate(SqlParameterCollection inputCollection) { inputCollection.AddWithValue("@PageIndex", PageIndex); inputCollection.AddWithValue("@PageSize", PageSize); inputCollection.AddWithValue("@CreatedBy", CreatedBy); }, delegate(IDataReader reader, short set) { Faq faq = MapFaq(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(LastColumn); } if (list == null) { list = new List <Faq>(); } list.Add(faq); } ); if (list != null) { pagedList = new Paged <Faq>(list, PageIndex, PageSize, totalCount); } return(pagedList); }
public Paged <EnderecoDto> ObterTodosEnderecos(Guid Id, string pesquisa, int pageSize, int pageNumber) { var sql = @"SELECT a.AgenciaId, e.EnderecoId, e.Logradouro, e.Complemento, e.Numero, e.Cidade, e.Estado, e.cep, e.descricao " + "FROM Agencia AS a INNER JOIN Enderecos AS e ON a.AgenciaId = e.AgenciaId " + "WHERE a.AgenciaId = @sid AND @Spesquisa IS NULL OR " + "a.AgenciaId = @sid AND e.Descricao LIKE @Spesquisa + '%' OR " + "a.AgenciaId = @sid AND e.Logradouro LIKE @Spesquisa + '%' OR " + "a.AgenciaId = @sid AND e.Estado LIKE @Spesquisa + '%' OR " + "a.AgenciaId = @sid AND e.Cidade LIKE @Spesquisa + '%' " + "ORDER BY Logradouro ASC " + "OFFSET " + pageSize * (pageNumber - 1) + " ROWS " + "FETCH NEXT " + pageSize + " ROWS ONLY " + " " + "SELECT COUNT(e.EnderecoId) FROM Agencia AS a INNER JOIN Enderecos AS e ON a.AgenciaId = e.AgenciaId " + "WHERE a.AgenciaId = @sid AND @Spesquisa IS NULL OR " + "a.AgenciaId = @sid AND e.Descricao LIKE @Spesquisa + '%' OR " + "a.AgenciaId = @sid AND e.Logradouro LIKE @Spesquisa + '%' OR " + "a.AgenciaId = @sid AND e.Estado LIKE @Spesquisa + '%' OR " + "a.AgenciaId = @sid AND e.Cidade LIKE @Spesquisa + '%' "; var multi = cn.QueryMultiple(sql, new { sid = Id, Spesquisa = pesquisa }); var enderecos = multi.Read <EnderecoDto>(); var total = multi.Read <int>().FirstOrDefault(); var pagedList = new Paged <EnderecoDto>() { List = enderecos, Count = total }; return(pagedList); }
public Paged <AgenciaUsuarioDto> ObterTodosAgenciaUsuario(Guid id, string descricao, int pageSize, int pageNumber) { var sql = @"SELECT au.AgenciaId, au.UsuarioId, au.Nome, au.Sobrenome, au.CPF, au.Email, au.Celular, au.TelefoneFixo, au.DataCadastro, au.Descricao, au.Status " + "FROM AgenciaUsuario AS au " + "WHERE au.AgenciaId = @sid AND au.Status <> 'false' AND " + "@Spesquisa IS NULL OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.Nome LIKE @Spesquisa + '%' OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.Sobrenome LIKE @Spesquisa + '%' OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.CPF LIKE @Spesquisa + '%' OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.Descricao LIKE @Spesquisa + '%' " + "ORDER BY Nome ASC " + "OFFSET " + pageSize * (pageNumber - 1) + " ROWS " + "FETCH NEXT " + pageSize + " ROWS ONLY " + " " + "SELECT COUNT(au.UsuarioId) FROM AgenciaUsuario AS au " + "WHERE au.AgenciaId = @sid AND au.Status <> 'false' AND " + "@Spesquisa IS NULL OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.Nome LIKE @Spesquisa + '%' OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.Sobrenome LIKE @Spesquisa + '%' OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.CPF LIKE @Spesquisa + '%' OR " + "au.AgenciaId = @sid AND au.Status <> 'false' AND au.Descricao LIKE @Spesquisa + '%' "; var multi = cn.QueryMultiple(sql, new { sid = id, Spesquisa = descricao }); var agenciausuario = multi.Read <AgenciaUsuarioDto>(); var total = multi.Read <int>().FirstOrDefault(); var pagedList = new Paged <AgenciaUsuarioDto>() { List = agenciausuario, Count = total }; return(pagedList); }
public Paged <InsurancePlan> GetByProvider(int pageIndex, int pageSize, int providerId) { Paged <InsurancePlan> pagedResults = null; List <InsurancePlan> result = null; InsurancePlan plan = null; int totalCount = 0; _data.ExecuteCmd( "dbo.InsurancePlans_Select_ByProviderId_V2", delegate(SqlParameterCollection col) { col.AddWithValue("@PageIndex", pageIndex); col.AddWithValue("@PageSize", pageSize); col.AddWithValue("@ProviderId", providerId); }, delegate(IDataReader reader, short set) { int index = 0; plan = PlanMapper(reader, ref index); if (totalCount == 0) { totalCount = reader.GetSafeInt32(index++); } if (result == null) { result = new List <InsurancePlan>(); } result.Add(plan); }); if (result != null) { pagedResults = new Paged <InsurancePlan>(result, pageIndex, pageSize, totalCount); } return(pagedResults); }
public Paged <Product> Get(int pageIndex, int pageSize, int createdBy) { Paged <Product> pagedList = null; List <Product> list = null; string procName = "[dbo].[Products_Select_ByCreatedBy_V2]"; int totalCount = 0; _data.ExecuteCmd(procName, delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@CreatedBy", createdBy); parameterCollection.AddWithValue("@PageIndex", pageIndex); parameterCollection.AddWithValue("@PageSize", pageSize); }, (reader, recordSetIndex) => { Product product = MapProduct(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(20); } if (list == null) { list = new List <Product>(); } list.Add(product); }); if (list != null) { pagedList = new Paged <Product>(list, pageIndex, pageSize, totalCount); } return(pagedList); }
public async Task <Feedback> getMinifiedPage(string tenant, Paged page) { Feedback feedback = new Feedback(); try { var userList = _userRepo.GetInstance(tenant).getByPage(page); if (userList != null) { feedback = new Feedback { Code = 1, Message = "Data fetched sucessfully", data = userList }; } else { feedback = new Feedback { Code = 0, Message = "Record not found", data = null }; } } catch (Exception ex) { feedback = new Feedback { Code = 0, Message = "Got the error while removing data", data = ex }; GitHub.createIssue(ex, new { tenant = tenant, page = page }, _accessor.HttpContext.Request.Headers); } return(feedback); }
public Paged <CMSTemplate> SelectByCreatedBy(int pageIndex, int pageSize) { Paged <CMSTemplate> pagedResult = null; List <CMSTemplate> result = null; int totalCount = 0; string procName = "[dbo].[CMSTemplate_SelectByCreatedBy]"; _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection col) { col.AddWithValue("@CreatedBy", _authservice.GetCurrentUserId()); col.AddWithValue("@PageIndex", pageIndex); col.AddWithValue("@PageSize", pageSize); }, singleRecordMapper : delegate(IDataReader reader, short set) { CMSTemplate cmsTemplate; int index; NewCmsTemplateMapper(reader, out cmsTemplate, out index); if (totalCount == 0) { totalCount = reader.GetSafeInt32(index++); } if (result == null) { result = new List <CMSTemplate>(); } result.Add(cmsTemplate); }); if (result != null) { pagedResult = new Paged <CMSTemplate>(result, pageIndex, pageSize, totalCount); } return(pagedResult); }
public Paged <UserProfile> GetAll(int pageIndex, int pageSize) { Paged <UserProfile> pagedList = null; List <UserProfile> list = null; int totalCount = 0; string procName = "[dbo].[UserProfiles_SelectAll]"; _data.ExecuteCmd( procName, delegate(SqlParameterCollection inputCollection) { inputCollection.AddWithValue("@PageIndex", pageIndex); inputCollection.AddWithValue("@PageSize", pageSize); }, delegate(IDataReader reader, short set) { UserProfile userProfile = MapUserProfile(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(10); } if (list == null) { list = new List <UserProfile>(); } list.Add(userProfile); } ); if (list != null) { pagedList = new Paged <UserProfile>(list, pageIndex, pageSize, totalCount); } return(pagedList); }
public Paged <InsurancePlan> GetSearchPagination(int pageIndex, int pageSize, string query) { Paged <InsurancePlan> pagedResults = null; List <InsurancePlan> list = null; InsurancePlan plan = null; int totalCount = 0; _data.ExecuteCmd( "dbo.InsurancePlans_Search", delegate(SqlParameterCollection col) { col.AddWithValue("@PageIndex", pageIndex); col.AddWithValue("@PageSize", pageSize); col.AddWithValue("@Query", query); }, delegate(IDataReader reader, short set) { int index = 0; plan = PlanMapper(reader, ref index); if (totalCount == 0) { totalCount = reader.GetSafeInt32(index++); } if (list == null) { list = new List <InsurancePlan>(); } list.Add(plan); }); if (list != null) { pagedResults = new Paged <InsurancePlan>(list, pageIndex, pageSize, totalCount); } return(pagedResults); }
public ActionResult <ItemResponse <Paged <Business> > > GetSearch(int pageIndex, int pageSize, string query) { try { Paged <Business> pagedList = null; pagedList = _businessVenturesService.SearchPagination(pageIndex, pageSize, query); if (pagedList == null) { return(StatusCode(404, new ErrorResponse("Records Not Found"))); } else { ItemResponse <Paged <Business> > response = new ItemResponse <Paged <Business> >(); response.Item = pagedList; return(Ok200(response)); } } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public Tuple <IList <Category>, int> getByPage(Paged page) { try { SqlCommand command = new SqlCommand(String.Format("SELECT C.*,COUNT(P.ID) PRODUCTCOUNT FROM {5} C LEFT JOIN PRODUCTCATEGORIES P ON C.ID=P.CATEGORYID {2} {3} {4} OFFSET {0} ROWS FETCH NEXT {1} ROWS ONLY;SELECT COUNT(ID) TotalRecords FROM {5} C {2}", page.pageNumber * page.pageSize, page.pageSize, (!String.IsNullOrEmpty(page.search) ? String.Format("WHERE {0} AND C.ISDELETED=0 ", page.search) : " WHERE C.ISDELETED=0 "), " GROUP BY C.ID,C.NAME,C.ISDELETED ", (!String.IsNullOrEmpty(page.orderby) ? String.Format("ORDER BY {0}", page.orderby) : "ORDER BY C.ID"), tableName)); DataSet categoryData = command.ExecuteDataSet(); if (categoryData.Tables[0].Rows.Count == 0) { return(null); } return(new Tuple <IList <Category>, int>(categoryData.Tables[0].ConvertList <Category>(), Convert.ToInt32(categoryData.Tables[1].Rows[0]["TotalRecords"]))); } catch (Exception ex) { throw ex; } }
public ActionResult <ItemResponse <Paged <Venue> > > GetAll(string query, int type, int pageIndex, int pageSize) { try { Paged <Venue> pagedData = _venuesService.GetAll(query, type, pageIndex, pageSize); if (pagedData == null) { return(StatusCode(404, new ErrorResponse("Record not found."))); } else { ItemResponse <Paged <Venue> > resp = new ItemResponse <Paged <Venue> >(); resp.Item = pagedData; return(Ok200(resp)); } } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
/// <summary> /// 查询分页数据对象 /// </summary> /// <param name="selectSql">截至到from</param> /// <param name="whereSql">where</param> /// <param name="orderbySql">排序</param> /// <param name="query">查询对象,PageIndex起始页,每页数量PageSize,Param参数格式L new {A="1",B="2"}</param> /// <returns>结果集合</returns> public Paged <TResult> QueryPage <TResult>(string selectSql, string whereSql, string orderbySql, IQuery query) { this.CreateDbConnection(); this.Open(); Paged <TResult> pagedResult = new Paged <TResult>(); var parameters = ToDictionary(query.Param); var sql = selectSql.Add(whereSql); var limit = "limit ?PageIndex,?PageSize"; var dataSql = sql.Add(orderbySql).Add(limit); var countSql = sql.PageCount(); parameters.Add("PageIndex", (query.PageIndex - 1) * query.PageSize); parameters.Add("PageSize", query.PageSize); WriteTraceLogPage(dataSql, countSql, parameters); var count = DbConnection.QueryFirst <int>(countSql, parameters); var data = DbConnection.Query <TResult>(dataSql, parameters); pagedResult.PageIndex = query.PageIndex; pagedResult.TotalCount = count; pagedResult.Result = data.ToList(); _log.Trace("分页结束:"); return(pagedResult); }
public static Paged <Models.Customer> Search(int pageIndex = 1, int pageSize = 1, string customerorderBy = "CustomerName", string sortOrder = "Ascending") { Paged <Models.Customer> customers = new Paged <Models.Customer>(); var queryCount = db.Customers.Count(); var skip = pageSize * (pageIndex - 1); long pageCount = (long)Math.Ceiling((decimal)(queryCount / pageSize)); if (customerorderBy.ToLower() == "CustomerName" && sortOrder.ToLower() == "Ascending") { customers.Items = db.Customers.OrderBy(a => a.CustomerName).Skip(skip).Take(pageSize).ToList(); } else if (customerorderBy.ToLower() == "ProductName" && sortOrder.ToLower() == "Descending") { customers.Items = db.Customers.OrderByDescending(a => a.CustomerName).Skip(skip).Take(pageSize).ToList(); } customers.PageCount = pageCount; customers.QueryCount = queryCount; customers.PageIndex = pageIndex; customers.PageSize = pageSize; return(customers); }
public Paged <Programador> ObterTodosPaginado(int s, int t) { var cn = Db.Database.Connection; var sql = @"SELECT * FROM Programadores " + "ORDER BY [ID] " + $"OFFSET {s * (t - 1)} " + $"FETCH NEXT {s} ROWS ONLY;" + " " + "SELECT COUNT(Id) FROM Programadores; "; var multi = cn.QueryMultiple(sql); var programadores = multi.Read <Programador>(); var count = multi.Read <int>().FirstOrDefault(); var pagedList = new Paged <Programador> { Lista = programadores, Count = count }; return(pagedList); }
public ActionResult <ItemResponse <Paged <AuthUser> > > Get(int pageIndex, int pageSize, string userRole = null) { try { Paged <AuthUser> paged = _userService.Get(pageIndex, pageSize, userRole); if (paged == null) { return(NotFound404(new ErrorResponse("Records Not Found"))); } else { ItemResponse <Paged <AuthUser> > response = new ItemResponse <Paged <AuthUser> >(); response.Item = paged; return(Ok200(response)); } } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public Paged <OrdemDeServico> ObterTodosPaginado(int s, int t) { var cn = Db.Database.Connection; var sql = @"SELECT * FROM OrdemDeServicos " + "ORDER BY DataCadastro, HoraCadastro " + $"OFFSET {s * (t - 1) } ROWS " + $"FETCH NEXT {s} ROWS ONLY;" + " " + "SELECT COUNT(Id) FROM OrdemDeServicos"; var multi = cn.QueryMultiple(sql); var ordemDeServico = multi.Read <OrdemDeServico>(); var total = multi.Read <int>().FirstOrDefault(); var pagedList = new Paged <OrdemDeServico> { Lista = ordemDeServico, Count = total }; return(pagedList); }
public void ExportPropertiesAllFields_ExcelX_Query_Success(Uri uri) { // Arrange var helper = new TestHelper(); var controller = helper.CreateController <PropertyController>(Permissions.PropertyView, uri); var headers = helper.GetService <Mock <Microsoft.AspNetCore.Http.IHeaderDictionary> >(); headers.Setup(m => m["Accept"]).Returns(ContentTypes.CONTENT_TYPE_EXCELX); var parcel1 = new Entity.Parcel(1, 51, 25) { Id = 1 }; var parcel2 = new Entity.Parcel(2, 51, 26) { Id = 2 }; var parcels = new[] { parcel1, parcel2 }; var service = helper.GetService <Mock <IPimsService> >(); var mapper = helper.GetService <IMapper>(); var items = parcels.Select(p => new Entity.Views.Property(p)); var page = new Paged <Entity.Views.Property>(items); service.Setup(m => m.Property.GetPage(It.IsAny <Entity.Models.AllPropertyFilter>())).Returns(page); // Act var result = controller.ExportPropertiesAllFields(); // Assert var actionResult = Assert.IsType <FileStreamResult>(result); Assert.Equal(ContentTypes.CONTENT_TYPE_EXCELX, actionResult.ContentType); Assert.NotNull(actionResult.FileDownloadName); Assert.True(actionResult.FileStream.Length > 0); service.Verify(m => m.Property.GetPage(It.IsAny <Entity.Models.AllPropertyFilter>()), Times.Once()); }
public Paged <Vendor> Get(int pageIndex, int pageSize) { Paged <Vendor> pagedResult = null; List <Vendor> result = null; int totalCount = 0; _data.ExecuteCmd( "dbo.Vendors_SelectAll", inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@PageIndex", pageIndex); parameterCollection.AddWithValue("@PageSize", pageSize); }, singleRecordMapper : delegate(IDataReader reader, short set) { Vendor model = VendorMapper(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(10); } if (result == null) { result = new List <Vendor>(); } result.Add(model); } ); if (result != null) { pagedResult = new Paged <Vendor>(result, pageIndex, pageSize, totalCount); } return(pagedResult); }
/// <summary> /// Возвращает список(массив) категорий товаров из магазина /// </summary> /// <returns></returns> public CartProductModel[] GetProductsList(CartFilter filter) { using (var db = new CMSdb(_context)) { var result = new Paged <CartProductModel>(); var query = db.cart_products_categories .Where(c => !c.fkproductscategoriesproducts.b_disabled); if (filter.CategoryId.HasValue) { query = query .Where(c => c.f_category == filter.CategoryId.Value); } var list = query .Select(s => new CartProductModel { Id = s.f_product, Number = s.fkproductscategoriesproducts.n_product, Title = s.fkproductscategoriesproducts.c_title, Desc = s.fkproductscategoriesproducts.c_desc, Price = s.fkproductscategoriesproducts.n_price, PricePrev = s.fkproductscategoriesproducts.n_price_old, PriceInfoPrev = s.fkproductscategoriesproducts.c_price_old, PriceInfo = s.fkproductscategoriesproducts.c_price, Disabled = s.fkproductscategoriesproducts.b_disabled, Categories = GetCartCategoriesList(new CartFilter() { ProductId = s.f_product }), //Images = }).ToArray(); return(list); } }
public Paged <Location> PagedGeo(int Latitude, int Longitude, int Radius) { Paged <Location> pagedList = null; List <Location> list = null; int radius = 0; int totalCount = 0; _data.ExecuteCmd("[dbo].[Locations_SelectByGeo]", inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@Latitude", Latitude); parameterCollection.AddWithValue("@Longitude", Longitude); parameterCollection.AddWithValue("@Radius", Radius); }, singleRecordMapper : delegate(IDataReader reader, short set) { int startingIndex = 0; Location location = MapLocation(reader, out startingIndex); if (totalCount == 0) { totalCount = reader.GetSafeInt32(startingIndex++); } if (list == null) { list = new List <Location>(); } list.Add(location); } ); if (list != null) { pagedList = new Paged <Location>(list, Latitude, Longitude, radius); } return(pagedList); }
public Paged <ActivityEntry> GetAllActivitiesForUserId(int userId, int pageIndex, int pageSize) { Paged <ActivityEntry> response = null; List <ActivityEntry> list = null; int totalCount = 0; string prokName = "[dbo].[ActivityEntries_PageActivitiesForUserId]"; _dataProvider.ExecuteCmd(prokName , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@PageIndex", pageIndex); paramCollection.AddWithValue("@PageSize", pageSize); paramCollection.AddWithValue("@UserId", userId); } , singleRecordMapper : delegate(IDataReader reader, short set) { ActivityEntry activity = new ActivityEntry(); activity = MapActivity(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(14); } if (list == null) { list = new List <ActivityEntry>(); } list.Add(activity); } ); if (list != null) { response = new Paged <ActivityEntry>(list, pageIndex, pageSize, totalCount); return(response); } return(response); }
public Paged <Provider> SelectByExpertise(int expertiseId, int pageIndex, int pageSize) { string procName = "[dbo].[Providers_Select_byExpertise]"; List <Provider> list = null; Paged <Provider> pagedItems = null; int totalCount = 0; _data.ExecuteCmd(procName, paramCol => { paramCol.AddWithValue("@pageIndex", pageIndex); paramCol.AddWithValue("@pageSize", pageSize); paramCol.AddWithValue("@expertiseId", expertiseId); }, (reader, set) => { Provider provider = HydrateProviderDetails(reader, out int lastIndex); if (list == null) { list = new List <Provider>(); } list.Add(provider); if (totalCount == 0) { totalCount = reader.GetSafeInt32(lastIndex); } }); if (list != null) { pagedItems = new Paged <Provider>(list, pageIndex, pageSize, totalCount); } return(pagedItems); }
public virtual void Collect() { UpdateTimer.Stop(); UpdateTimer.Dispose(); UpdateTimer = null; Sample = null; GC.Collect(); }
public void Next(Paged<ulong> buffer) => Next(buffer, 0, buffer.Length);