本文整理汇总了C#中Page.GetParents方法的典型用法代码示例。如果您正苦于以下问题:C# Page.GetParents方法的具体用法?C# Page.GetParents怎么用?C# Page.GetParents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page.GetParents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPageList
public List<Page> GetPageList(Primitive owner, User loggedInMember, Page current)
{
Database db = core.Db;
long loggedIdUid = User.GetMemberId(loggedInMember);
SelectQuery query = Page.GetSelectQueryStub(core, typeof(Page));
query.AddCondition("page_item_id", owner.Id);
query.AddCondition("page_item_type_id", owner.TypeId);
query.AddCondition("page_status", "PUBLISH");
QueryCondition qc1 = query.AddCondition("page_parent_id", 0);
if (current != null)
{
ParentTree pt = current.GetParents();
if (pt != null)
{
foreach (ParentTreeNode ptn in pt.Nodes)
{
qc1.AddCondition(ConditionRelations.Or, "page_parent_id", ptn.ParentId);
}
}
qc1.AddCondition(ConditionRelations.Or, "page_parent_id", current.Id);
}
query.AddSort(SortOrder.Ascending, "page_order");
System.Data.Common.DbDataReader pagesReader = db.ReaderQuery(query);
List<IPermissibleItem> tempPages = new List<IPermissibleItem>();
List<Page> pages = new List<Page>();
while (pagesReader.Read())
{
tempPages.Add(new Page(core, owner, pagesReader));
}
pagesReader.Close();
pagesReader.Dispose();
core.AcessControlCache.CacheGrants(tempPages);
foreach (IPermissibleItem page in tempPages)
{
if (page.Access.Can("VIEW"))
{
pages.Add((Page)page);
}
}
return pages;
}
示例2: GeneratePageList
public string GeneratePageList(Primitive owner, User loggedInMember, bool fragment, Page current)
{
Database db = core.Db;
//ushort readAccessLevel = owner.GetAccessLevel(loggedInMember);
long loggedIdUid = User.GetMemberId(loggedInMember);
SelectQuery query = Page.GetSelectQueryStub(core, typeof(Page));
query.AddCondition("page_item_id", owner.Id);
query.AddCondition("page_item_type_id", owner.TypeId);
query.AddCondition("page_status", "PUBLISH");
QueryCondition qc1 = query.AddCondition("page_parent_id", 0);
if (current != null)
{
ParentTree pt = current.GetParents();
if (pt != null)
{
foreach (ParentTreeNode ptn in pt.Nodes)
{
qc1.AddCondition(ConditionRelations.Or, "page_parent_id", ptn.ParentId);
}
}
qc1.AddCondition(ConditionRelations.Or, "page_parent_id", current.Id);
}
query.AddSort(SortOrder.Ascending, "page_order");
StringBuilder output = new StringBuilder();
int parents = 0;
int nextParents = 0;
List<IPermissibleItem> tempPages = new List<IPermissibleItem>();
List<Page> pages = new List<Page>();
System.Data.Common.DbDataReader pagesReader = db.ReaderQuery(query);
if (!fragment)
{
if (!pagesReader.HasRows)
{
return string.Empty;
}
else
{
output.Append("<ul>\n");
}
}
while (pagesReader.Read())
{
tempPages.Add(new Page(core, owner, pagesReader));
}
pagesReader.Close();
pagesReader.Dispose();
core.AcessControlCache.CacheGrants(tempPages);
foreach (IPermissibleItem page in tempPages)
{
if (page.Access.Can("VIEW"))
{
pages.Add((Page)page);
}
}
for (int i = 0; i < pages.Count; i++)
{
bool hasChildren = false;
if (i + 1 < pages.Count)
{
if (pages[i + 1].ParentId == 0)
{
nextParents = 0;
}
else
{
nextParents = pages[i + 1].ParentPath.Split('/').Length;
}
}
else
{
nextParents = 0;
}
if (pages[i].ParentId == 0)
{
parents = 0;
}
else
{
parents = pages[i].ParentPath.Split('/').Length;
}
if (nextParents > parents)
{
hasChildren = true;
}
//.........这里部分代码省略.........