Compartilhar via


ScheduledItem.EndDate propriedade

Obtém ou define a hora Universal coordenada (UTC) em que essa classe ScheduledItem termina e não está mais visível no site publicado.

Namespace:  Microsoft.SharePoint.Publishing
Assembly:  Microsoft.SharePoint.Publishing (em Microsoft.SharePoint.Publishing.dll)

Sintaxe

'Declaração
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 propriedade

Tipo: System.DateTime
O tempo Universal Coordenado (UTC) em que essa classe ScheduledItem termina e não está mais visível no site publicado.

Exceções

Exceção Condição
[System.ArgumentNullException]

Esse valor não pode ser definido como uma referência nula (Nothing no Visual Basic).

[System.UnauthorizedAccessException]

O usuário atual não tem permissões suficientes para executar esta ação.

Comentários

Um valor de 01 de janeiro de 2050 indica que uma instância da classe ScheduledItem não é mais visível no site publicado. Se a data final é definida como esse valor, a propriedade é exibida, usando a seqüência de caracteres "Nunca" nas interfaces de usuário correspondente.

Para salvar as alterações após a definição desta propriedade, chame o método ScheduledItem.ListItem.Update .

A data e hora retornado por essa propriedade podem ser convertidos de UTC para a hora local no código do lado do servidor usando o método SPRegionalSettings.TimeZone.UTCToLocalTime(DateTime) .

O usuário deve ter permissões para editar no PublishingPage para definir este valor. O usuário deve ter permissões de exibição no PublishingPage inicialmente recuperá-lo e obter qualquer um dos seus valores de propriedade.

Exemplos

Este exemplo define uma data de início e de término para um objeto ScheduledItem e agenda o item para que ele é publicado quando for alcançada a data de início e é cancelada quando for alcançada a data de término.

Antes de compilar e executar esse exemplo, verifique se o SPListItem é um item de lista em uma biblioteca de documentos que oferece suporte ao agendamento.

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

Ver também

Referência

ScheduledItem classe

ScheduledItem membros

Microsoft.SharePoint.Publishing namespace

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

[Microsoft.SharePoint.SPContext.RegionalSettings]