Esempio n. 1
0
        protected EasSyncResult SyncMessages(EasConnectionWrapper easConnectionWrapper, EasSyncOptions options)
        {
            MrsTracer.Provider.Function("EasFolder.SyncMessages: SyncKey={0}", new object[]
            {
                options.SyncKey
            });
            bool         recentOnly = !EasFolder.IsCalendarFolder(base.EasFolderType) && options.RecentOnly && !EasFolder.IsContactFolder(base.EasFolderType);
            SyncResponse syncResponse;

            try
            {
                syncResponse = easConnectionWrapper.Sync(base.ServerId, options, recentOnly);
            }
            catch (EasRequiresSyncKeyResetException ex)
            {
                MrsTracer.Provider.Error("Encountered RequiresSyncKeyReset error: {0}", new object[]
                {
                    ex
                });
                options.SyncKey = "0";
                syncResponse    = easConnectionWrapper.Sync(base.ServerId, options, recentOnly);
            }
            if (!(options.SyncKey == "0"))
            {
                return(this.GetMessageRecsAndNewSyncKey(syncResponse, options));
            }
            return(this.ProcessPrimingSync(easConnectionWrapper, options, syncResponse));
        }
Esempio n. 2
0
 protected int GetItemEstimate(EasConnectionWrapper easConnectionWrapper, EasSyncOptions options)
 {
     MrsTracer.Provider.Function("EasFolder.GetItemEstimate: SyncKey={0}", new object[]
     {
         options.SyncKey
     });
     return(easConnectionWrapper.GetCountOfItemsToSync(base.ServerId, options));
 }
        private static T WrapException <T>(Func <T> function, Func <ConnectionsTransientException, MailboxReplicationTransientException> wrapTransientException, Func <ConnectionsPermanentException, MailboxReplicationPermanentException> wrapPermanentException) where T : class
        {
            T result = default(T);

            EasConnectionWrapper.WrapException(delegate()
            {
                result = function();
            }, wrapTransientException, wrapPermanentException);
            return(result);
        }
Esempio n. 4
0
        void IMailbox.Connect(MailboxConnectFlags connectFlags)
        {
            base.CheckDisposed();
            MrsTracer.Provider.Function("EasMailbox.IMailbox.Connect", new object[0]);
            EasConnectionWrapper easConnectionWrapper = new EasConnectionWrapper(EasConnection.CreateInstance(this.EasConnectionParameters, this.EasAuthenticationParameters, this.EasDeviceParameters));

            easConnectionWrapper.Connect();
            this.EasConnectionWrapper = easConnectionWrapper;
            this.AfterConnect();
            MrsTracer.Provider.Debug("EasMailbox.IMailbox.Connect succeeded.", new object[0]);
        }
        private SyncResponse SyncCreation(string itemId, SyncRequest syncRequest)
        {
            SyncResponse response = this.Sync(syncRequest);
            SyncStatus   status   = response.GetAddResponseStatus(0);

            EasConnectionWrapper.WrapException(delegate()
            {
                response.ThrowIfStatusIsFailed(status);
            }, (ConnectionsTransientException e) => new EasSyncFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasSyncFailedPermanentException(e.Message, e));
            return(response);
        }
Esempio n. 6
0
        private EasSyncResult ProcessPrimingSync(EasConnectionWrapper easConnection, EasSyncOptions options, SyncResponse syncResponse)
        {
            bool   flag;
            string syncKeyForFolder = this.GetSyncKeyForFolder(syncResponse, out flag);

            if (string.IsNullOrEmpty(syncKeyForFolder))
            {
                throw new EasSyncCouldNotFindFolderException(base.ServerId);
            }
            options.SyncKey = syncKeyForFolder;
            return(this.SyncMessages(easConnection, options));
        }
        internal Properties FetchMessageItem(string messageId, string folderId)
        {
            ItemOperationsRequest  itemOperationsRequest = EasRequestGenerator.CreateItemOpsRequest(messageId, folderId);
            ItemOperationsResponse response = this.ItemOperations(itemOperationsRequest);
            ItemOperationsStatus   status;
            Properties             messageProperties = response.GetMessageProperties(0, out status);

            EasConnectionWrapper.WrapException(delegate()
            {
                response.ThrowIfStatusIsFailed(status);
            }, (ConnectionsTransientException e) => new EasFetchFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasFetchFailedPermanentException(e.Message, e));
            return(messageProperties);
        }
        private void SyncUpdate(string messageId, SyncRequest syncRequest)
        {
            SyncResponse response = this.Sync(syncRequest);
            SyncStatus   status   = response.GetChangeResponseStatus(0);

            if (status == SyncStatus.SyncItemNotFound)
            {
                MrsTracer.Provider.Warning("Source message {0} doesn't exist", new object[]
                {
                    messageId
                });
                throw new EasObjectNotFoundException(messageId);
            }
            EasConnectionWrapper.WrapException(delegate()
            {
                response.ThrowIfStatusIsFailed(status);
            }, (ConnectionsTransientException e) => new EasSyncFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasSyncFailedPermanentException(e.Message, e));
        }
 private SyncResponse Sync(SyncRequest syncRequest)
 {
     return(EasConnectionWrapper.WrapException <SyncResponse>(() => this.wrappedObject.Sync(syncRequest), (ConnectionsTransientException e) => new EasSyncFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasSyncFailedPermanentException(e.Message, e)));
 }
 private SendMailResponse SendMail(SendMailRequest sendMailRequest)
 {
     return(EasConnectionWrapper.WrapException <SendMailResponse>(() => this.wrappedObject.SendMail(sendMailRequest), (ConnectionsTransientException e) => new EasSendFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasSendFailedPermanentException(e.Message, e)));
 }
 private MoveItemsResponse MoveItems(MoveItemsRequest moveItemsRequest)
 {
     return(EasConnectionWrapper.WrapException <MoveItemsResponse>(() => this.wrappedObject.MoveItems(moveItemsRequest), (ConnectionsTransientException e) => new EasMoveFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasMoveFailedPermanentException(e.Message, e)));
 }
 private ItemOperationsResponse ItemOperations(ItemOperationsRequest itemOperationsRequest)
 {
     return(EasConnectionWrapper.WrapException <ItemOperationsResponse>(() => this.wrappedObject.ItemOperations(itemOperationsRequest), (ConnectionsTransientException e) => new EasFetchFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasFetchFailedPermanentException(e.Message, e)));
 }
 private GetItemEstimateResponse GetItemEstimate(GetItemEstimateRequest getItemEstimateRequest)
 {
     return(EasConnectionWrapper.WrapException <GetItemEstimateResponse>(() => this.wrappedObject.GetItemEstimate(getItemEstimateRequest), (ConnectionsTransientException e) => new EasCountFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasCountFailedPermanentException(e.Message, e)));
 }
 private FolderUpdateResponse FolderUpdate(FolderUpdateRequest folderUpdateRequest)
 {
     return(EasConnectionWrapper.WrapException <FolderUpdateResponse>(() => this.wrappedObject.FolderUpdate(folderUpdateRequest), (ConnectionsTransientException e) => new EasFolderUpdateFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasFolderUpdateFailedPermanentException(e.Message, e)));
 }