Compartir a través de


de la propiedad ScheduledItem.EndDate

Obtiene o establece la hora Universal coordinada (UTC) en la que esta clase de ScheduledItem finaliza y ya no está visible en el sitio publicado.

Espacio de nombres:  Microsoft.SharePoint.Publishing
Ensamblado:  Microsoft.SharePoint.Publishing (en Microsoft.SharePoint.Publishing.dll)

Sintaxis

'Declaración
Public Property EndDate As DateTime
    Get
    Set
'Uso
Dim instance As ScheduledItem
Dim value As DateTime

value = instance.EndDate

instance.EndDate = value
public DateTime EndDate { get; set; }

Valor de propiedad

Tipo: System.DateTime
La hora Universal coordinada (UTC) en la que esta clase de ScheduledItem finaliza y ya no está visible en el sitio publicado.

Excepciones

Excepción Condición
[System.ArgumentNullException]

No se puede establecer este valor a una referencia null (Nothing en Visual Basic).

[System.UnauthorizedAccessException]

El usuario actual no tiene permisos suficientes para realizar esta acción.

Comentarios

Un valor de 01 de enero de 2050, indica que una instancia de la clase ScheduledItem ya no es visible en el sitio publicado. Si la fecha final se establece en este valor, la propiedad se muestra mediante la cadena "Nunca" en las interfaces de usuario correspondiente.

Para guardar los cambios después de establecer esta propiedad, llame al método ScheduledItem.ListItem.Update .

La fecha y hora devuelto por esta propiedad se pueden convertir de hora UTC a hora local en el código del servidor mediante el método de SPRegionalSettings.TimeZone.UTCToLocalTime(DateTime) .

El usuario debe tener permisos de edición en el PublishingPage para establecer este valor. El usuario debe tener permisos de vista en el PublishingPage inicialmente recuperarlo a cualquiera de sus valores de propiedad.

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

Vea también

Referencia

clase ScheduledItem

Miembros ScheduledItem

Espacio de nombres Microsoft.SharePoint.Publishing

[Microsoft.SharePoint.SPTimeZone.UTCToLocalTime(System.DateTime)]

[Microsoft.SharePoint.SPContext.RegionalSettings]