Compartir a través de


SyncFolderHierarchyType Clase

Definición

La SyncFolderHierarchyType clase representa una solicitud para sincronizar una jerarquía de carpetas de cliente con el equipo que ejecuta Microsoft Exchange Server 2007.

public ref class SyncFolderHierarchyType : ExchangeWebServices::BaseRequestType
public class SyncFolderHierarchyType : ExchangeWebServices.BaseRequestType
Public Class SyncFolderHierarchyType
Inherits BaseRequestType
Herencia
SyncFolderHierarchyType

Ejemplos

En el ejemplo siguiente se muestra cómo sincronizar una jerarquía de carpetas. Dado que la SyncState propiedad está establecida, esta jerarquía de carpetas se ha sincronizado antes. Esta operación SyncFolderHierarchy devolverá todos los cambios realizados desde la llamada de sincronización representada por la SyncState propiedad . Esta llamada devolverá todas las propiedades definidas por la forma de AllProperties carpeta.

static void SyncFolderHierarchy(ExchangeServiceBinding esb)
{ 
    // Create the request.
    SyncFolderHierarchyType <span class="label">request</span> = new SyncFolderHierarchyType();

    // Identify the properties that are synchronized.
    FolderResponseShapeType shape = new FolderResponseShapeType();
    shape.BaseShape = DefaultShapeNamesType.AllProperties;

    // Add synchronized properties to request.
<span class="label">request</span>.FolderShape = shape;

    // Add the synchronization state to the request. This
    // property should be null for the initial synchronization.
<span class="label">request</span>.SyncState = "H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/";

    // Send the request and get the response.
    SyncFolderHierarchyResponseType response = esb.SyncFolderHierarchy(<span class="label">request</span>);

    ArrayOfResponseMessagesType aormt = response.ResponseMessages;
    ResponseMessageType[] rmta = aormt.Items;

    foreach (ResponseMessageType rmt in rmta)
    {
        if (rmt.ResponseClass == ResponseClassType.Success)
        {
            SyncFolderHierarchyResponseMessageType sfhrmt = rmt as SyncFolderHierarchyResponseMessageType;

            // Get the sync state string to use in later synchronization calls.
            string syncState = sfhrmt.SyncState;

            // Get the array of changes that are returned in the response. 
            SyncFolderHierarchyChangesType changeArray = sfhrmt.Changes;

            // This contains the array of folder changes.
            object[] changes = changeArray.Items;

            // This identifies the type of change that occurred on a folder.
            ItemsChoiceType1 changeType; 

            for (int count = 0; count &lt; changes.Length; count++)
            {
                // This identifies the type of change that is represented by the objects
                // in the changes object[].
                changeType = changeArray.ItemsElementName[count];

                // Check for the change type of each folder that is returned in the response.
                switch (changeType)
                { 
                    case ItemsChoiceType1.Create:
                        SyncFolderHierarchyCreateOrUpdateType createdFolder = changes[count] as SyncFolderHierarchyCreateOrUpdateType;
                        // TODO: Handle the created folder.
                        if (createdFolder.Item is CalendarFolderType)
                        {
                            // TODO: Cast to calendar folder and handle properties.
                        }
                        else;
                            // TODO: Check and cast to SearchFolderType, TasksFolderType,
                            //       ContactsFolderType, or FolderType.
                        break;

                    case ItemsChoiceType1.Update:
                        SyncFolderHierarchyCreateOrUpdateType updatedFolder = changes[count] as SyncFolderHierarchyCreateOrUpdateType; ;
                        // TODO: Handle the updated folder.    
                        // TODO: Check and cast to one of the five folder types.
                        break;

                    case ItemsChoiceType1.Delete:
                        SyncFolderHierarchyDeleteType deletedFolder = changes[count] as SyncFolderHierarchyDeleteType;
                        // TODO: Get the identifier of the deleted folder.
                        break;
                }
            }
        }
    }
}

La SyncState propiedad devuelta en la respuesta debe guardarse para las solicitudes de sincronización posteriores. Tenga en cuenta también que las carpetas que se devuelven en la respuesta deben convertirse al tipo de carpeta adecuado para que la aplicación cliente pueda acceder a todas las propiedades que están disponibles para cada tipo de carpeta.

Importante: Si se devuelven actualizaciones, la aplicación cliente debe comparar la diferencia entre las carpetas de la respuesta y en el cliente para determinar qué cambios se han producido.

Dado que todos los objetos de cambio no tienen el mismo tipo base, se devuelve una matriz de objetos.

Comentarios

Para sincronizar los elementos de cada carpeta, use el SyncFolderItemsType objeto proxy.

Constructores

SyncFolderHierarchyType()

El SyncFolderHierarchyType constructor inicializa una nueva instancia de la SyncFolderHierarchyType clase .

Propiedades

FolderShape

La FolderShape propiedad obtiene o establece la forma de carpeta de sincronización que describe qué propiedades se devuelven en la respuesta. La propiedad es obligatoria. Se trata de una propiedad de lectura y escritura.

SyncFolderId

La SyncFolderId propiedad obtiene o establece la identidad de la carpeta que contiene los elementos que se van a sincronizar. Esta propiedad es opcional. Se trata de una propiedad de lectura y escritura.

SyncState

La SyncState propiedad obtiene o establece el identificador de estado de sincronización. Esta propiedad es opcional con advertencias. Se trata de una propiedad de lectura y escritura.

Se aplica a