del método ScheduledItem.IsScheduledItem
Confirma que un elemento SPListItem es una instancia válida de la clase ScheduledItem .
Espacio de nombres: Microsoft.SharePoint.Publishing
Ensamblado: Microsoft.SharePoint.Publishing (en Microsoft.SharePoint.Publishing.dll)
Sintaxis
'Declaración
Public Shared Function IsScheduledItem ( _
sourceListItem As SPListItem _
) As Boolean
'Uso
Dim sourceListItem As SPListItem
Dim returnValue As Boolean
returnValue = ScheduledItem.IsScheduledItem(sourceListItem)
public static bool IsScheduledItem(
SPListItem sourceListItem
)
Parámetros
sourceListItem
Tipo: Microsoft.SharePoint.SPListItemSPListItem para comprobar la validez.
Valor devuelto
Tipo: System.Boolean
true si la SPListItem es un ScheduledItem; en caso contrario, false.
Excepciones
Excepción | Condición |
---|---|
[System.ArgumentNullException] | El parámetro sourceListItem no puede ser una referencia null (Nothing en Visual Basic). |
Comentarios
Este método confirma que el SPListItem es un miembro de una biblioteca de documentos que admite la programación y que tiene fechas de inicio y final, que se requieren para la programación.
Ejemplos
En este ejemplo se establece una fecha inicial y final de un objeto ScheduledItem y programa el elemento, por lo que se publica cuando se alcanza la fecha de inicio y es no publicado cuando se alcanza la fecha de finalización.
Antes de compilar y ejecutar este ejemplo, compruebe que la SPListItem es un elemento de lista en una biblioteca de documentos es compatible con la programación.
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