Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 仅从SharePoint 2007检索已发布页面的CAML查询?_C#_Sharepoint_Caml - Fatal编程技术网

C# 仅从SharePoint 2007检索已发布页面的CAML查询?

C# 仅从SharePoint 2007检索已发布页面的CAML查询?,c#,sharepoint,caml,C#,Sharepoint,Caml,我目前正在检索所有页面,并筛选出代码中未发布的页面,检查是否DateTime。现在小于此值: static readonly DateTime IMMEDIATE_PUBLISH = new DateTime(1900, 1, 1); public static DateTime PublicationDate(this SPListItem item) { // get start publish date PublishingPage page = item.Publish

我目前正在检索所有页面,并筛选出代码中未发布的页面,检查是否
DateTime。现在
小于此值:

static readonly DateTime IMMEDIATE_PUBLISH = new DateTime(1900, 1, 1);

public static DateTime PublicationDate(this SPListItem item)
{
    // get start publish date
    PublishingPage page = item.Publishing();
    if (page != null)
    {
        bool isPublished = (page.ListItem.File != null)
            ? (page.ListItem.File.Level == SPFileLevel.Published)
            : true;
        bool isApproved = (page.ListItem.ModerationInformation != null)
            ? (page.ListItem.ModerationInformation.Status == SPModerationStatusType.Approved)
            : true;
        if (isPublished && isApproved && (DateTime.Now < page.EndDate))
        {
            return page.StartDate == IMMEDIATE_PUBLISH ? page.CreatedDate : page.StartDate;
        }
        return DateTime.MaxValue;
    }
    // not a scheduled item. treat as published
    return DateTime.MinValue;
}
static readonly DateTime IMMEDIATE\u PUBLISH=new DateTime(1900,1,1);
公共静态日期时间发布日期(此SPListItem项)
{
//获取开始发布日期
PublishingPage=item.Publishing();
如果(第页!=null)
{
bool isPublished=(page.ListItem.File!=null)
?(page.ListItem.File.Level==SPFileLevel.Published)
:正确;
bool isApproved=(page.ListItem.ModerationInformation!=null)
?(page.ListItem.ModerationInformation.Status==SPModerationStatusType.Approved)
:正确;
如果(已发布并获得批准&&(DateTime.Now

什么是等效的CAML查询,这样我就不会从数据库中提取不必要的项目了?

在我看来,你检查得太多了

您今天只需勾选“PublishingStartDate”

对于普通用户,您找不到未发布/批准的页面。

对于有权查找这些页面的用户,您可能不想仅仅因为当前版本未发布/批准而将其排除在外。如果您只想要至少发布一个版本的页面,那么您可以在我看来添加一个“\u UIVersion”>=512

的检查,您检查得太多了

您今天只需勾选“PublishingStartDate”

对于普通用户,您找不到未发布/批准的页面。

对于有权查找这些页面的用户,您可能不想仅仅因为当前版本未发布/批准而将其排除在外。如果您只需要至少发布一个版本的页面,则可以添加对“\u UIVersion”>=512的检查。以下是用于检查文档发布的CAML查询示例。我知道这是一个相当老的问题,但希望这对下一个用谷歌搜索的人有帮助:

<Query>
    <Where>
        <And>
            <Or>
                <Leq>
                    <FieldRef Name='PublishingStartDate'/>
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>
                        <Today/>
                    </Value>
                </Leq>
                <IsNull>
                    <FieldRef Name='PublishingStartDate'/>
                </IsNull>
            </Or>
            <Or>
                <Geq>
                    <FieldRef Name='PublishingExpirationDate'/>
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>
                        <Today/>
                    </Value>
                </Geq>
                <IsNull>
                    <FieldRef Name='PublishingExpirationDate'/>
                </IsNull>
            </Or>
        </And>
    </Where>
</Query>

以下是用于检查文档是否发布的CAML查询示例。我知道这是一个相当老的问题,但希望这对下一个用谷歌搜索的人有帮助:

<Query>
    <Where>
        <And>
            <Or>
                <Leq>
                    <FieldRef Name='PublishingStartDate'/>
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>
                        <Today/>
                    </Value>
                </Leq>
                <IsNull>
                    <FieldRef Name='PublishingStartDate'/>
                </IsNull>
            </Or>
            <Or>
                <Geq>
                    <FieldRef Name='PublishingExpirationDate'/>
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>
                        <Today/>
                    </Value>
                </Geq>
                <IsNull>
                    <FieldRef Name='PublishingExpirationDate'/>
                </IsNull>
            </Or>
        </And>
    </Where>
</Query>


根据此示例(),无论答案是什么,这都将是一种可怕的亵渎,并提醒人们为什么Sharepoint是魔鬼的化身。CAML.Net有点帮助。根据此示例(),无论答案是什么,这将是一种可怕的亵渎,提醒人们为什么Sharepoint是魔鬼的化身。CAML.Net有点帮助。问题是我正在尝试缓存结果,并且初始查询正在以完全权限运行。我现在正在考虑更改缓存的工作方式。但是,如果使用问题中指定的条件运行,则即使发布/批准了旧版本,也会排除正在运行新版本的页面。问题是我正在尝试缓存结果,并且初始查询正在以完全权限运行。我现在正在研究更改缓存的工作方式。但如果您使用问题中指定的条件运行,则即使发布/批准了旧版本,也会排除正在使用新版本的页面