ScheduledItem.ListItem - Propriété
Obtient l'objet SPListItem sous-jacent encapsulé par l'objet ScheduledItem .
Espace de noms : Microsoft.SharePoint.Publishing
Assembly : Microsoft.SharePoint.Publishing (dans Microsoft.SharePoint.Publishing.dll)
Syntaxe
'Déclaration
Public ReadOnly Property ListItem As SPListItem
Get
'Utilisation
Dim instance As ScheduledItem
Dim value As SPListItem
value = instance.ListItem
public SPListItem ListItem { get; }
Valeur de propriété
Type : Microsoft.SharePoint.SPListItem
Le sous-jacent SPListItem qui est encapsulée par le ScheduledItem.
Remarques
La valeur de ListItem est initialisée lorsqu'un ScheduledItem est instancié et ne peut pas être modifié.
Exemples
Cet exemple définit une date de début et de fin pour un objet ScheduledItem et planifie l'élément afin qu'il est publié lorsque la date de début est atteinte et qu'il est non publié lorsque la date de fin est atteinte.
Avant de compiler et d'exécuter cet exemple, vérifiez que le SPListItem est un élément de liste dans une bibliothèque de documents qui prend en charge la planification.
using ScheduledItem = Microsoft.SharePoint.Publishing.ScheduledItem;
using SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType;
using SPListItem = Microsoft.SharePoint.SPListItem;
using DateTime = System.DateTime;
namespace Microsoft.SDK.SharePointServer.Samples
{
public static class ScheduledItemCodeSamples
{
public static void SetDatesAndSchedule(SPListItem listItem,
DateTime startDate, DateTime endDate)
{
// Set the input parameter values with
// your own values.
//
// validate the input parameters
if (null == listItem)
{
throw new System.ArgumentNullException("listItem");
}
// Get the ScheduledItem wrapper for the SPListItem
// that was passed in.
//
ScheduledItem scheduledItem = null;
if (ScheduledItem.IsScheduledItem(listItem))
{
scheduledItem = ScheduledItem.GetScheduledItem(listItem);
}
else
{
throw new System.ArgumentException
("The document library containing this SPListItem must support scheduling",
"listItem");
}
// Set and save the date values.
scheduledItem.StartDate = startDate;
scheduledItem.EndDate = endDate;
scheduledItem.ListItem.Update();
// Schedule the item so that the StartDate and EndDate
// take effect.
scheduledItem.Schedule();
}
}
}
Imports ScheduledItem = Microsoft.SharePoint.Publishing.ScheduledItem
Imports SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType
Imports SPListItem = Microsoft.SharePoint.SPListItem
Namespace Microsoft.SDK.SharePointServer.Samples
Public NotInheritable Class ScheduledItemCodeSamples
Private Sub New()
End Sub
Public Shared Sub SetDatesAndSchedule(ByVal listItem As SPListItem, ByVal startDate As Date, ByVal endDate As Date)
' Set the input parameter values with
' your own values.
'
' validate the input parameters
If Nothing Is listItem Then
Throw New System.ArgumentNullException("listItem")
End If
' Get the ScheduledItem wrapper for the SPListItem
' that was passed in.
'
Dim scheduledItem As ScheduledItem = Nothing
If ScheduledItem.IsScheduledItem(listItem) Then
scheduledItem = ScheduledItem.GetScheduledItem(listItem)
Else
Throw New System.ArgumentException ("The document library containing this SPListItem must support scheduling", "listItem")
End If
' Set and save the date values.
scheduledItem.StartDate = startDate
scheduledItem.EndDate = endDate
scheduledItem.ListItem.Update()
' Schedule the item so that the StartDate and EndDate
' take effect.
scheduledItem.Schedule()
End Sub
End Class
End Namespace