本文整理汇总了C#中PageInfo类的典型用法代码示例。如果您正苦于以下问题:C# PageInfo类的具体用法?C# PageInfo怎么用?C# PageInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PageInfo类属于命名空间,在下文中一共展示了PageInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUser
/// <summary>
/// 获取用户
/// </summary>
/// <param name="userInfo">用户实体</param>
/// <param name="pageInfo">分页实体</param>
/// <returns></returns>
public IList<UsersInfo> GetUser(UsersInfo userInfo, PageInfo pageInfo)
{
using (DataContextDB DB = new DataContextDB())
{
IQueryable<UsersInfo> userInfos =
(
from item in DB.GetTable<UsersInfo>()
orderby item.ID descending
select item
);
if (userInfo != null && userInfo.ID != 0)
userInfos = userInfos.Where<UsersInfo>(m => m.ID == userInfo.ID);
if (userInfo != null && !string.IsNullOrEmpty(userInfo.Name))
userInfos = userInfos.Where<UsersInfo>(m => m.Name.Contains(userInfo.Name));
if (userInfo != null && userInfo.UserGroup != 0)
userInfos = userInfos.Where<UsersInfo>(m => m.UserGroup == userInfo.UserGroup);
if (pageInfo != null)
{
pageInfo.TotalRecord = userInfos.Count();
return userInfos.Skip(pageInfo.PageSize * (pageInfo.PageIndex - 1)).Take(pageInfo.PageSize).ToList<UsersInfo>();
}
else
return userInfos.ToList<UsersInfo>();
}
}
示例2: Details
public ActionResult Details(int id)
{
ViewQuestionDetailsViewModel vm = new ViewQuestionDetailsViewModel { HighlightAnswers = new List<Answer>() };
var pageInfo = new PageInfo(AppConfigs.AnswersPageSize, 1);
var feedback = _qRepo.GetQuestionDetails(id);
var feedback2 = _aRepo.GetAllAnswers(id, pageInfo);
var feedback3 = _aRepo.GetHighlightAnswers(id, AppConfigs.HighlightAnswerNumber);
if (feedback.Success && feedback2.Success && feedback3.Success)
{
vm = new ViewQuestionDetailsViewModel
{
Question = feedback.Data,
Answers = feedback2.Answers,
Total = feedback2.Total,
HasMore = feedback2.Total > pageInfo.PageSize * pageInfo.PageNo,
CurrentUserId = CurrentUser != null ? CurrentUser.UserInfo.Id : 0,
HighlightAnswers = feedback3.Data,
CanEdit = CurrentUser != null ? SecurityHelper.CanEditContentsDirectly() : false,
};
return View(vm);
}
return View("NotFound");
}
示例3: ParentPageComboItem
public ParentPageComboItem(PageInfo pageInfo, int indentLevel, ArrayList children)
: base(pageInfo.Id, pageInfo.Title)
{
_pageInfo = pageInfo;
_indentLevel = indentLevel;
_children = children;
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
CurrentPage = new PageInfo()
{
TemplatePath = @"Default/DetailPage.ascx"
};
}
示例5: FindByAjax
public ActionResult FindByAjax(int id = 1, int page = 1)
{
int pageSize = 3;
var userKnowledgers = serviceForUserKnowl.GetAll().Where((x) => x.KnowledgeId == id).Select(x => x.ToWebUserKnowl());
var usersTemp = service.GetAll().Select(y => y.ToWebUser());
Dictionary<int, string> usersForViewBag = new Dictionary<int, string>();
foreach (var x in service.GetAll().ToList())
{
usersForViewBag.Add(x.UserId, x.Name);
}
ViewBag.Users = usersForViewBag;
ViewBag.ID = id;
var q = from t in userKnowledgers
join tID in usersTemp on t.UserId equals tID.UserId
select new UserViewModel { Email = tID.Email, Name = tID.Name, Photo = tID.Photo, UserId = tID.UserId };
var users = q.Skip((page - 1) * pageSize).Take(pageSize);
PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = userKnowledgers.Count() };
IndexViewModel ivm = new IndexViewModel { PageInfo = pageInfo, UserViewModel = users };
return PartialView("FindByAjax", ivm);
}
示例6: PageLinks
public static MvcHtmlString PageLinks(this HtmlHelper html, PageInfo pageInfo, Func<int, string> pageUrl)
{
StringBuilder result = new StringBuilder();
for (int i = 1; i <= pageInfo.TotalPages; i++)
{
TagBuilder tag = new TagBuilder("a");
tag.MergeAttribute("href", pageUrl(i));
tag.MergeAttribute("data-ajax-update", "#address-cursor-rows");
tag.MergeAttribute("data-ajax-success", "OnSuccess");
tag.MergeAttribute("data-ajax-mode", "replace");
tag.MergeAttribute("data-ajax", "true");
tag.InnerHtml = i.ToString();
// если текущая страница, то выделяем ее, например, добавляя класс
if (i == pageInfo.PageNumber)
{
tag.AddCssClass("selected");
tag.AddCssClass("btn-primary");
}
tag.AddCssClass("btn btn-default");
result.Append(tag.ToString());
}
return MvcHtmlString.Create(result.ToString());
}
示例7: SearchUsers
public ActionResult SearchUsers(string searchText, int page = 1)
{
UsersViewModel vm = new UsersViewModel();
List<ApplicationUser> users = new List<ApplicationUser>();
if (searchText == null)
{
return View();
}
if (searchText == "All")
{
users = UserManager.Users.ToList();
}
else
{
users = UserManager.Users.Where(u => u.UserName.Contains(searchText) || u.Email.Contains(searchText)).ToList();
}
PageInfo pageInfo = new PageInfo() { PageSize = 20, CurrentPage = 1 };
pageInfo.PageCount = (users.Count() - 1) / pageInfo.PageSize + 1;
pageInfo.CurrentPage = page <= pageInfo.PageCount ? page : 1;
pageInfo.Url = "/admin/adminaccount/searchUsers?searchText=" + searchText + "@page=";
vm.Users = users.Skip((pageInfo.CurrentPage - 1) * pageInfo.PageSize).Take(pageInfo.PageSize).ToList();
vm.PageInfo = pageInfo;
return View(vm);
}
示例8: Can_Generate_Page_Links
public void Can_Generate_Page_Links()
{
// Arrange - define and HTML helper - we need to do this
// in order to apply the extension method
HtmlHelper myHelper = null;
// Arrange - create PageInfo data
PageInfo pagingInfo = new PageInfo
{
CurrentPage = 2,
TotalItems = 28,
ItemsPerPage = 10
};
// Arrange - set up the delegate using the Lambda expression
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());
}
示例9: GetPageInfo
public List<PageInfo> GetPageInfo()
{
List<PageInfo> pageInfos = new List<PageInfo>();
foreach (XmlNode pageNode in getAllPageNodes())
{
PageInfo pageInfo = new PageInfo()
{
Id = pageNode.Attributes[@"ID"].Value,
Name = pageNode.Attributes[@"name"].Value,
DateTime = DateTime.Parse(pageNode.Attributes[@"dateTime"].Value),
LastModifiedTime = DateTime.Parse(pageNode.Attributes[@"lastModifiedTime"].Value),
PageLevel = Int32.Parse(pageNode.Attributes[@"pageLevel"].Value),
};
if (pageNode.Attributes[@"isCurrentlyViewed"] != null)
{
pageInfo.IsCurrentlyViewed = pageNode.Attributes[@"isCurrentlyViewed"].Value;
}
pageInfo.LocationPath = getLocationPath(pageNode);
pageInfos.Add(pageInfo);
}
return pageInfos;
}
示例10: PageLinks
public static MvcHtmlString PageLinks(this HtmlHelper html,
PageInfo pageInfo, Func<int, string> pageUrl, String elementId)
{
TagBuilder ul = new TagBuilder("ul");
ul.AddCssClass("pagination");
int startPage = pageInfo.PageNumber > 3 ? pageInfo.PageNumber - 2 : 1;
//if (pageInfo.PageNumber > 3)
if (startPage != 1)
{
ul.InnerHtml += MakeListItem(1, pageUrl, elementId);
ul.InnerHtml += MakeListItem(1, pageUrl, elementId, "disabled", "...");
}
int totalPages = pageInfo.TotalPages;
int lastPage = pageInfo.PageNumber + 3 < totalPages ? pageInfo.PageNumber + 2 : totalPages;
//for (int i = 1; i <= pageInfo.TotalPages; i++)
for (int i = startPage; i <= lastPage; i++)
{
ul.InnerHtml += MakeListItem(i, pageUrl, elementId, i == pageInfo.PageNumber ? "active" : null);
}
if (lastPage != totalPages)
{
ul.InnerHtml += MakeListItem(totalPages, pageUrl, elementId, "disabled", "...");
ul.InnerHtml += MakeListItem(totalPages, pageUrl, elementId);
}
return MvcHtmlString.Create(ul.ToString());
}
示例11: AspNetParsedDocument
public AspNetParsedDocument (string fileName, WebSubtype type, RootNode rootNode, PageInfo info) : base (fileName)
{
Flags |= ParsedDocumentFlags.NonSerializable;
Info = info;
RootNode = rootNode;
Type = type;
}
示例12: ParseRequest
public static PageInfo ParseRequest(Microsoft.AspNetCore.Http.HttpRequest request, int totalCount)
{
PageInfo result = new PageInfo();
string paramStartIndex = null;
string paramPageSize = null;
Microsoft.AspNetCore.Http.IQueryCollection parameters = request.Query;
if (parameters != null)
{
paramStartIndex = parameters["startIndex"];
paramPageSize = parameters["pageSize"];
}
int startIndex, pageSize;
if (!int.TryParse(paramStartIndex, out startIndex))
startIndex = 0;
if (!int.TryParse(paramPageSize, out pageSize))
pageSize = 20;
result.StartIndex = startIndex;
result.TotalCount = totalCount;
if (totalCount < 0)
{
result.ItemsCount = Math.Min(pageSize, Math.Abs(totalCount));
result.AddPreviousNextPageLinks(request, pageSize);
result.TotalCount = -1;
}
else
{
result.ItemsCount = Math.Max(0, Math.Min((startIndex + pageSize), totalCount) - startIndex);
result.AddPreviousNextPageLinks(request, pageSize);
}
return result;
}
示例13: IndexViewModel
public IndexViewModel(
PageInfo pageInfo, IEnumerable<BookView> bookViews, Int32 bookTagId)
{
this.PageInfo = pageInfo;
this.BookViews = bookViews;
this.BookTagId = bookTagId;
}
示例14: GetAllProduct
public List<BLL.BusinessObject.Product> GetAllProduct(PageInfo vobjPageInfo)
{
Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("CSWebDSN");//DatabaseFactory.CreateDatabase(Config);
DbCommand dbCommand = db.GetStoredProcCommand("[sprocCS_GetProducts_V2]");
db.AddInParameter(dbCommand, "SortColumnName", DbType.String, vobjPageInfo.SortColumnName);
db.AddInParameter(dbCommand, "SortDirection", DbType.String, vobjPageInfo.SortDirection);
db.AddInParameter(dbCommand, "SearchText", DbType.String, vobjPageInfo.SearchText);
List<BLL.BusinessObject.Product> list = new List<BLL.BusinessObject.Product>();
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
while (dataReader.Read())
{
BLL.BusinessObject.Product obj = new BLL.BusinessObject.Product();
list.Add(PopulateProductInfo(dataReader));
}
}
return list;
}
示例15: Get
public IHttpActionResult Get(int CurrentPage)
{
//申明参数
int _pageSize = 10;
try
{
PageInfo pageInfo = new PageInfo()
{
PageIndex = CurrentPage,
PageSize = _pageSize,
OrderField = "POSTID",
Order = OrderEnum.asc
};
var list = bll.GetList(pageInfo);
Response<IEnumerable<V_tm_pm_post>> response = new Response<IEnumerable<V_tm_pm_post>>
{
Data = list,
PagesCount = pageInfo.Total / _pageSize
};
return Ok(response);
}
catch (Exception ex)
{
LogHelper.WriteInfo(ex.ToString());
return BadRequest("异常");
}
}