MessageRec IMailbox.SaveSyncState(byte[] key, string syncState) { MrsTracer.ProxyClient.Function("RemoteMailbox.SaveSyncState", new object[0]); if (!(this is RemoteDestinationMailbox)) { throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "IMailbox_SaveSyncState"); } this.VerifyMailboxConnection(); IDataExport dataExport = new PagedTransmitter(syncState, base.MrsProxyClient.UseCompression); DataExportBatch dataExportBatch = dataExport.ExportData(); long handle = base.MrsProxy.IDestinationMailbox_SaveSyncState2(base.Handle, key, dataExportBatch); if (!dataExportBatch.IsLastBatch) { using (IDataImport dataImport = new RemoteDataImport(base.MrsProxy, handle, null)) { do { dataExportBatch = dataExport.ExportData(); IDataMessage message = DataMessageSerializer.Deserialize(dataExportBatch.Opcode, dataExportBatch.Data, base.MrsProxyClient.UseCompression); dataImport.SendMessage(message); }while (!dataExportBatch.IsLastBatch); } } return(null); }
DataExportBatch IDataExport.ExportData() { if (this.curIndex == -1) { throw new UnexpectedErrorPermanentException(-2147024809); } DataExportBatch dataExportBatch = new DataExportBatch(); if (this.dataToSend == null || this.curIndex + this.chunkSize >= this.dataToSend.Length) { dataExportBatch.Opcode = 211; if (this.dataToSend == null || this.curIndex == 0) { dataExportBatch.Data = this.dataToSend; } else { int num = this.dataToSend.Length - this.curIndex; dataExportBatch.Data = new byte[num]; Array.Copy(this.dataToSend, this.curIndex, dataExportBatch.Data, 0, num); } dataExportBatch.IsLastBatch = true; this.curIndex = -1; } else { dataExportBatch.Opcode = 210; dataExportBatch.Data = new byte[this.chunkSize]; Array.Copy(this.dataToSend, this.curIndex, dataExportBatch.Data, 0, this.chunkSize); this.curIndex += this.chunkSize; } return(dataExportBatch); }
public static void ExportRoutine(IMailboxReplicationProxyService mrsProxy, long dataExportHandle, IDataImport destProxy, DataExportBatch firstBatch, bool useCompression) { try { DataExportBatch dataExportBatch; do { if (firstBatch != null) { dataExportBatch = firstBatch; firstBatch = null; } else { if (TestIntegration.Instance.AbortConnectionDuringFX) { MailboxReplicationProxyClient mailboxReplicationProxyClient = (MailboxReplicationProxyClient)mrsProxy; mailboxReplicationProxyClient.Abort(); } dataExportBatch = mrsProxy.DataExport_ExportData2(dataExportHandle); if (dataExportBatch.IsLastBatch) { dataExportHandle = 0L; } } bool flag = false; try { if (dataExportBatch.Opcode != 0) { IDataMessage message = DataMessageSerializer.Deserialize(dataExportBatch.Opcode, dataExportBatch.Data, useCompression); destProxy.SendMessage(message); } if (dataExportBatch.FlushAfterImport) { destProxy.SendMessageAndWaitForReply(FlushMessage.Instance); } flag = true; } finally { if (!flag && dataExportHandle != 0L) { MrsTracer.ProxyClient.Error("Exception was thrown during import/flush, canceling export.", new object[0]); mrsProxy.DataExport_CancelExport(dataExportHandle); dataExportHandle = 0L; } } }while (!dataExportBatch.IsLastBatch); } finally { if (dataExportHandle != 0L) { mrsProxy.CloseHandle(dataExportHandle); } } }
void ISourceMailbox.CopyTo(IFxProxy destMailbox, PropTag[] excludeProps) { MrsTracer.ProxyClient.Function("RemoteSourceMailbox.CopyTo", new object[0]); base.VerifyMailboxConnection(); byte[] objectData = destMailbox.GetObjectData(); DataExportBatch dataExportBatch = base.MrsProxy.ISourceMailbox_Export2(base.Handle, DataConverter <PropTagConverter, PropTag, int> .GetData(excludeProps), objectData); using (FxProxyReceiver fxProxyReceiver = new FxProxyReceiver(destMailbox, false)) { using (BufferedReceiver bufferedReceiver = new BufferedReceiver(fxProxyReceiver, false, base.MrsProxyClient.UseBuffering, base.MrsProxyClient.UseCompression)) { RemoteDataExport.ExportRoutine(base.MrsProxy, dataExportBatch.DataExportHandle, bufferedReceiver, dataExportBatch, base.MrsProxyClient.UseCompression); } } }
string ISourceMailbox.GetMailboxSyncState() { MrsTracer.ProxyClient.Function("RemoteSourceMailbox.GetMailboxSyncState", new object[0]); base.VerifyMailboxConnection(); DataExportBatch dataExportBatch = base.MrsProxy.ISourceMailbox_GetMailboxSyncState(base.Handle); string syncState = null; using (PagedReceiver pagedReceiver = new PagedReceiver(delegate(string data) { syncState = data; }, base.MrsProxyClient.UseCompression)) { RemoteDataExport.ExportRoutine(base.MrsProxy, dataExportBatch.DataExportHandle, pagedReceiver, dataExportBatch, base.MrsProxyClient.UseCompression); } return(syncState); }
void ISourceMailbox.ExportFolders(List <byte[]> folderIds, IFxProxyPool proxyPool, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags) { MrsTracer.ProxyClient.Function("RemoteSourceMailbox.ExportFolders", new object[0]); base.VerifyMailboxConnection(); if (!base.ServerVersion[54]) { throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "ISourceMailbox_ExportFolders"); } DataExportBatch dataExportBatch = base.MrsProxy.ISourceMailbox_ExportFolders(base.Handle, folderIds, (int)exportFoldersDataToCopyFlags, (int)folderRecFlags, DataConverter <PropTagConverter, PropTag, int> .GetData(additionalFolderRecProps), (int)copyPropertiesFlags, DataConverter <PropTagConverter, PropTag, int> .GetData(excludeProps), (int)extendedAclFlags); using (IDataImport dataImport = new FxProxyPoolReceiver(proxyPool, false)) { using (BufferedReceiver bufferedReceiver = new BufferedReceiver(dataImport, false, base.MrsProxyClient.UseBuffering, base.MrsProxyClient.UseCompression)) { RemoteDataExport.ExportRoutine(base.MrsProxy, dataExportBatch.DataExportHandle, bufferedReceiver, dataExportBatch, base.MrsProxyClient.UseCompression); } } }
void ISourceFolder.ExportMessages(IFxProxy destFolderProxy, CopyMessagesFlags flags, byte[][] entryIds) { MrsTracer.ProxyClient.Function("ISourceFolder.ExportMessages({0}): {1}", new object[] { flags, base.FolderName }); byte[] objectData = destFolderProxy.GetObjectData(); DataExportBatch dataExportBatch = base.MrsProxy.ISourceFolder_ExportMessages(base.Handle, (int)flags, entryIds, objectData); long dataExportHandle = dataExportBatch.DataExportHandle; using (FxProxyReceiver fxProxyReceiver = new FxProxyReceiver(destFolderProxy, false)) { using (BufferedReceiver bufferedReceiver = new BufferedReceiver(fxProxyReceiver, false, base.MrsProxyClient.UseBuffering, base.MrsProxyClient.UseCompression)) { RemoteDataExport.ExportRoutine(base.MrsProxy, dataExportHandle, bufferedReceiver, dataExportBatch, base.MrsProxyClient.UseCompression); } } }
string IMailbox.LoadSyncState(byte[] key) { MrsTracer.ProxyClient.Function("RemoteMailbox.LoadSyncState", new object[0]); if (!(this is RemoteDestinationMailbox)) { throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "IMailbox_LoadSyncState"); } this.VerifyMailboxConnection(); DataExportBatch dataExportBatch = base.MrsProxy.IDestinationMailbox_LoadSyncState2(base.Handle, key); string syncState = null; using (PagedReceiver pagedReceiver = new PagedReceiver(delegate(string data) { syncState = data; }, base.MrsProxyClient.UseCompression)) { RemoteDataExport.ExportRoutine(base.MrsProxy, dataExportBatch.DataExportHandle, pagedReceiver, dataExportBatch, base.MrsProxyClient.UseCompression); } return(syncState); }
void ISourceMailbox.SetMailboxSyncState(string syncState) { MrsTracer.ProxyClient.Function("RemoteSourceMailbox.SetMailboxSyncState", new object[0]); base.VerifyMailboxConnection(); IDataExport dataExport = new PagedTransmitter(syncState, base.MrsProxyClient.UseCompression); DataExportBatch dataExportBatch = dataExport.ExportData(); long handle = base.MrsProxy.ISourceMailbox_SetMailboxSyncState(base.Handle, dataExportBatch); if (!dataExportBatch.IsLastBatch) { using (IDataImport dataImport = new RemoteDataImport(base.MrsProxy, handle, null)) { do { dataExportBatch = dataExport.ExportData(); IDataMessage message = DataMessageSerializer.Deserialize(dataExportBatch.Opcode, dataExportBatch.Data, base.MrsProxyClient.UseCompression); dataImport.SendMessage(message); }while (!dataExportBatch.IsLastBatch); } } }
DataExportBatch IDataExport.ExportData() { DataExportBatch dataExportBatch = null; int opcode; byte[] data; for (;;) { DataExport.DataExportResult dataExportResult; if (this.storedOpcode != 0) { dataExportResult = DataExport.DataExportResult.MoreData; opcode = this.storedOpcode; data = this.storedData; this.storedOpcode = 0; this.storedData = null; } else { dataExportResult = this.GetNextOutput(out opcode, out data); } bool flag = dataExportBatch == null; if (flag) { dataExportBatch = new DataExportBatch(); } switch (dataExportResult) { case DataExport.DataExportResult.Done: goto IL_B2; case DataExport.DataExportResult.MoreData: if (!flag) { goto Block_4; } dataExportBatch.Opcode = opcode; dataExportBatch.Data = data; break; case DataExport.DataExportResult.Flush: dataExportBatch.FlushAfterImport = true; break; case DataExport.DataExportResult.Timeout: goto IL_88; } } Block_4: this.storedOpcode = opcode; this.storedData = data; return(dataExportBatch); IL_88: MrsTracer.ProxyService.Warning("ExportThread appears to be stuck in a call. Returning to prevent WCF call timeout. Will continue waiting on the next call.", new object[0]); dataExportBatch.FlushAfterImport = true; return(dataExportBatch); IL_B2: dataExportBatch.IsLastBatch = true; return(dataExportBatch); }