Beispiel #1
0
        public static PublicFolderSyncJobState StartSyncHierarchy(OrganizationId organizationId, Guid mailboxGuid, string serverFqdn, bool executeReconcileFolders = false)
        {
            ArgumentValidator.ThrowIfNull("organizationId", organizationId);
            ArgumentValidator.ThrowIfEmpty("mailboxGuid", mailboxGuid);
            ArgumentValidator.ThrowIfNull("server", serverFqdn);
            PublicFolderSyncJobState publicFolderSyncJobState;

            try
            {
                using (JobQueueRpcClient jobQueueRpcClient = new JobQueueRpcClient(serverFqdn))
                {
                    PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction syncAction  = executeReconcileFolders ? PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.StartSyncHierarchyWithFolderReconciliation : PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.StartSyncHierarchy;
                    PublicFolderSyncJobRpcInParameters publicFolderSyncJobRpcInParameters = new PublicFolderSyncJobRpcInParameters(organizationId, mailboxGuid, syncAction);
                    byte[] data = jobQueueRpcClient.EnqueueRequest(1, 1, publicFolderSyncJobRpcInParameters.Serialize());
                    EnqueueRequestRpcOutParameters   enqueueRequestRpcOutParameters   = new EnqueueRequestRpcOutParameters(data);
                    PublicFolderSyncJobEnqueueResult publicFolderSyncJobEnqueueResult = enqueueRequestRpcOutParameters.Result as PublicFolderSyncJobEnqueueResult;
                    if (publicFolderSyncJobEnqueueResult == null || publicFolderSyncJobEnqueueResult.PublicFolderSyncJobState == null)
                    {
                        throw new PublicFolderSyncPermanentException(ServerStrings.PublicFolderStartSyncFolderHierarchyRpcFailed);
                    }
                    publicFolderSyncJobState = publicFolderSyncJobEnqueueResult.PublicFolderSyncJobState;
                }
            }
            catch (RpcException innerException)
            {
                throw new PublicFolderSyncTransientException(ServerStrings.PublicFolderStartSyncFolderHierarchyRpcFailed, innerException);
            }
            catch (SerializationException innerException2)
            {
                throw new PublicFolderSyncPermanentException(ServerStrings.PublicFolderStartSyncFolderHierarchyRpcFailed, innerException2);
            }
            return(publicFolderSyncJobState);
        }
Beispiel #2
0
        public static PublicFolderSyncJobState SyncFolder(OrganizationId organizationId, Guid mailboxGuid, string serverFqdn, byte[] folderId)
        {
            ArgumentValidator.ThrowIfNull("organizationId", organizationId);
            ArgumentValidator.ThrowIfEmpty("mailboxGuid", mailboxGuid);
            ArgumentValidator.ThrowIfNull("server", serverFqdn);
            ArgumentValidator.ThrowIfNull("folderId", folderId);
            ArgumentValidator.ThrowIfZeroOrNegative("folderId.Length", folderId.Length);
            PublicFolderSyncJobState publicFolderSyncJobState;

            try
            {
                using (JobQueueRpcClient jobQueueRpcClient = new JobQueueRpcClient(serverFqdn))
                {
                    PublicFolderSyncJobRpcInParameters publicFolderSyncJobRpcInParameters = new PublicFolderSyncJobRpcInParameters(organizationId, mailboxGuid, folderId);
                    byte[] data = jobQueueRpcClient.EnqueueRequest(1, 1, publicFolderSyncJobRpcInParameters.Serialize());
                    EnqueueRequestRpcOutParameters   enqueueRequestRpcOutParameters   = new EnqueueRequestRpcOutParameters(data);
                    PublicFolderSyncJobEnqueueResult publicFolderSyncJobEnqueueResult = enqueueRequestRpcOutParameters.Result as PublicFolderSyncJobEnqueueResult;
                    if (publicFolderSyncJobEnqueueResult == null || publicFolderSyncJobEnqueueResult.PublicFolderSyncJobState == null)
                    {
                        throw new PublicFolderSyncPermanentException(ServerStrings.PublicFolderSyncFolderRpcFailed);
                    }
                    publicFolderSyncJobState = publicFolderSyncJobEnqueueResult.PublicFolderSyncJobState;
                }
            }
            catch (RpcException innerException)
            {
                throw new PublicFolderSyncTransientException(ServerStrings.PublicFolderSyncFolderRpcFailed, innerException);
            }
            catch (SerializationException innerException2)
            {
                throw new PublicFolderSyncPermanentException(ServerStrings.PublicFolderSyncFolderRpcFailed, innerException2);
            }
            return(publicFolderSyncJobState);
        }