protected void RelinquishRequest() { using (RequestJobProvider rjProvider = new RequestJobProvider(this.RequestQueueGuid, this.SystemMailbox)) { MapiUtils.RetryOnObjectChanged(delegate { using (TransactionalRequestJob transactionalRequestJob = (TransactionalRequestJob)rjProvider.Read <TransactionalRequestJob>(new RequestJobObjectId(this.RequestGuid, this.RequestQueueGuid, this.MessageId))) { if (transactionalRequestJob != null) { ReportData report = new ReportData(transactionalRequestJob.IdentifyingGuid, transactionalRequestJob.ReportVersion); transactionalRequestJob.RequestJobState = JobProcessingState.Ready; transactionalRequestJob.MRSServerName = null; transactionalRequestJob.TimeTracker.CurrentState = this.RelinquishAction(transactionalRequestJob, report); report.Append(MrsStrings.ReportRelinquishingJob); rjProvider.Save(transactionalRequestJob); CommonUtils.CatchKnownExceptions(delegate { report.Flush(rjProvider.SystemMailbox); }, null); transactionalRequestJob.UpdateAsyncNotification(report); this.AfterRelinquishAction(); } } }); } }
public static string GetOtherRequests(ADUser user, Guid?requestGuid) { IEnumerable <IRequestIndexEntry> requestIndexEntries = MailboxRequestIndexEntryHandler.GetRequestIndexEntries(user, null); IEnumerable <IRequestIndexEntry> source = from r in requestIndexEntries where !MailboxRelocationRequestStatistics.IsTerminalState(r.Status) && (requestGuid == null || r.RequestGuid != requestGuid) select r; List <IRequestIndexEntry> list = new List <IRequestIndexEntry>(); foreach (IGrouping <ADObjectId, IRequestIndexEntry> grouping in from r in source group r by r.StorageMDB) { using (RequestJobProvider requestJobProvider = new RequestJobProvider(grouping.Key.ObjectGuid)) { foreach (IRequestIndexEntry requestIndexEntry in grouping) { TransactionalRequestJob transactionalRequestJob = (TransactionalRequestJob)requestJobProvider.Read <TransactionalRequestJob>(requestIndexEntry.GetRequestJobId(), ReadJobFlags.SkipValidation | ReadJobFlags.SkipReadingMailboxRequestIndexEntries); if (transactionalRequestJob != null && !MailboxRelocationRequestStatistics.IsTerminalState(transactionalRequestJob)) { list.Add(requestIndexEntry); } } } } return(string.Join <Guid>(", ", from r in list select r.RequestGuid)); }
private void CleanupCompletedJob(TransactionalRequestJob requestJob, RequestJobProvider rjProvider) { DateTime t = requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.DoNotPickUntil) ?? DateTime.MaxValue; if (DateTime.UtcNow < t) { return; } MrsTracer.Service.Debug("Cleaning up expired completed job '{0}' on queue '{1}'", new object[] { requestJob, this.RequestQueueGuid }); rjProvider.Delete(requestJob); CommonUtils.CatchKnownExceptions(delegate { ReportData reportData = new ReportData(requestJob.IdentifyingGuid, requestJob.ReportVersion); reportData.Delete(rjProvider.SystemMailbox); }, null); CommonUtils.CatchKnownExceptions(delegate { rjProvider.DeleteIndexEntries(requestJob); }, null); requestJob.RemoveAsyncNotification(); MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_RemovedCompletedRequest, new object[] { requestJob.ToString(), this.RequestGuid.ToString(), requestJob.WorkItemQueueMdbName }); }
public override void Initialize(TransactionalRequestJob syncRequest) { base.Initialize(syncRequest); base.RequestJobIdentity = syncRequest.Identity.ToString(); base.IncrementalSyncInterval = syncRequest.IncrementalSyncInterval; Guid targetExchangeGuid = syncRequest.TargetExchangeGuid; MailboxCopierFlags mailboxCopierFlags = MailboxCopierFlags.None; LocalizedString sourceTracingID = LocalizedString.Empty; switch (syncRequest.SyncProtocol) { case SyncProtocol.Imap: mailboxCopierFlags |= MailboxCopierFlags.Imap; sourceTracingID = MrsStrings.ImapTracingId(syncRequest.EmailAddress.ToString()); break; case SyncProtocol.Eas: mailboxCopierFlags |= MailboxCopierFlags.Eas; sourceTracingID = MrsStrings.EasTracingId(syncRequest.EmailAddress.ToString()); break; case SyncProtocol.Pop: mailboxCopierFlags |= MailboxCopierFlags.Pop; sourceTracingID = MrsStrings.PopTracingId(syncRequest.EmailAddress.ToString()); break; } string orgID = (syncRequest.OrganizationId != null && syncRequest.OrganizationId.OrganizationalUnit != null) ? (syncRequest.OrganizationId.OrganizationalUnit.Name + "\\") : string.Empty; base.MailboxMerger = new MailboxMerger(Guid.Empty, targetExchangeGuid, syncRequest, this, mailboxCopierFlags, sourceTracingID, MrsStrings.PrimaryMailboxTracingId(orgID, targetExchangeGuid)); }
public TransactionalRequestJob ValidateAndPopulateRequestJob(TransactionalRequestJob requestJob, out List <ReportEntry> entries) { List <ReportEntry> entriesInternal = null; string resultString = null; string requestJobXML = XMLSerializableBase.Serialize(new RequestJobXML(requestJob), false); try { this.CallService(delegate() { string text = null; try { resultString = this.Channel.ValidateAndPopulateRequestJob(requestJobXML, out text); } finally { if (text != null) { entriesInternal = XMLSerializableBase.Deserialize <List <ReportEntry> >(text, false); } } }); } finally { entries = entriesInternal; } return(new TransactionalRequestJob(XMLSerializableBase.Deserialize <RequestJobXML>(resultString, false))); }
protected override RequestState RelinquishAction(TransactionalRequestJob requestJob, ReportData report) { requestJob.Status = RequestStatus.Suspended; requestJob.TimeTracker.SetTimestamp(RequestJobTimestamp.Suspended, new DateTime?(DateTime.UtcNow)); report.Append(MrsStrings.ReportSuspendingJob); return(RequestState.Suspended); }
public override void Initialize(TransactionalRequestJob syncRequest) { base.Initialize(syncRequest); string orgID = (syncRequest.OrganizationId != null && syncRequest.OrganizationId.OrganizationalUnit != null) ? (syncRequest.OrganizationId.OrganizationalUnit.Name + "\\") : string.Empty; base.MailboxMerger = new MailboxMerger(Guid.Empty, syncRequest.TargetExchangeGuid, syncRequest, this, MailboxCopierFlags.Olc, LocalizedString.Empty, MrsStrings.PrimaryMailboxTracingId(orgID, syncRequest.TargetExchangeGuid)); }
public static void CreateJob(TransactionalRequestJob requestJob, ReservationContext reservation) { BaseJob baseJob; lock (MailboxSyncerJobs.syncRoot) { Guid guid = (requestJob.RequestType == MRSRequestType.Move) ? requestJob.ExchangeGuid : requestJob.RequestGuid; baseJob = MailboxSyncerJobs.FindJob(guid, false); if (baseJob != null) { MrsTracer.Service.Error("Request {0} is already being worked on.", new object[] { guid }); return; } baseJob = MailboxSyncerJobs.ConstructJob(requestJob); if (baseJob == null) { MrsTracer.Service.Error("Don't know how to process '{0}' request", new object[] { requestJob.RequestType }); return; } baseJob.Initialize(requestJob); baseJob.Reservation = reservation; MailboxSyncerJobs.activeJobs.Add(guid, baseJob); MailboxSyncerJobs.activeJobsIsEmpty.Reset(); } JobScheduler.ScheduleJob(baseJob); }
public void DeleteIndexEntries(TransactionalRequestJob requestJob) { if (!requestJob.IsValid) { throw new ArgumentException("Should not attempt to delete AD data off an invalid request"); } using (this.IndexProvider.RescopeTo(requestJob.DomainControllerToUpdate, requestJob.OrganizationId)) { if (requestJob.RequestType == MRSRequestType.Move) { if (requestJob.User != null && !requestJob.CancelRequest) { this.IndexProvider.UpdateADData(requestJob.User, requestJob, false); this.IndexProvider.RecipientSession.Save(requestJob.User); } } else if (requestJob.IndexEntries != null) { foreach (IRequestIndexEntry instance in requestJob.IndexEntries) { this.IndexProvider.Delete(instance); } } } }
protected override void UpdateRequestOnSave(TransactionalRequestJob rj, UpdateRequestOnSaveType updateType) { if (this.MailboxMerger.MailboxSizeTracker.IsFinishedEstimating) { rj.TotalMailboxItemCount = (ulong)((long)this.MailboxMerger.MailboxSizeTracker.MessageCount); rj.TotalMailboxSize = this.MailboxMerger.MailboxSizeTracker.TotalMessageSize; } }
public static BaseJob ConstructJob(TransactionalRequestJob requestJob) { BaseJob result; lock (MailboxSyncerJobs.syncRoot) { switch (requestJob.RequestType) { case MRSRequestType.Move: if (requestJob.RequestStyle == RequestStyle.IntraOrg) { return(new LocalMoveJob()); } return(new RemoteMoveJob()); case MRSRequestType.Merge: if (requestJob.IncrementalSyncInterval > TimeSpan.Zero || requestJob.SuspendWhenReadyToComplete || !requestJob.AllowedToFinishMove) { return(new IncrementalMergeJob()); } return(new MergeJob()); case MRSRequestType.MailboxImport: return(new ImportJob()); case MRSRequestType.MailboxExport: return(new ExportJob()); case MRSRequestType.MailboxRestore: return(new RestoreJob()); case MRSRequestType.PublicFolderMove: return(new PublicFolderMoveJob()); case MRSRequestType.PublicFolderMigration: return(new PublicFolderMigrationJob()); case MRSRequestType.Sync: if (requestJob.SyncProtocol == SyncProtocol.Olc) { return(new OlcMigrationJob()); } return(new SyncJob()); case MRSRequestType.MailboxRelocation: return(new LocalMoveJob()); case MRSRequestType.FolderMove: return(new AuxFolderMoveJob()); case MRSRequestType.PublicFolderMailboxMigration: return(new PublicFolderMailboxMigrationJob()); } result = null; } return(result); }
internal static RequestStatisticsBase CreateRequestStatistics(Type t, TransactionalRequestJob rj, bool acceptBase) { RequestStatisticsBase result = null; if (t.Equals(typeof(MoveRequestStatistics))) { result = new MoveRequestStatistics(rj); } else if (t.Equals(typeof(MergeRequestStatistics))) { result = new MergeRequestStatistics(rj); } else if (t.Equals(typeof(MailboxImportRequestStatistics))) { result = new MailboxImportRequestStatistics(rj); } else if (t.Equals(typeof(MailboxExportRequestStatistics))) { result = new MailboxExportRequestStatistics(rj); } else if (t.Equals(typeof(MailboxRelocationRequestStatistics))) { result = new MailboxRelocationRequestStatistics(rj); } else if (t.Equals(typeof(MailboxRestoreRequestStatistics))) { result = new MailboxRestoreRequestStatistics(rj); } else if (t.Equals(typeof(PublicFolderMoveRequestStatistics))) { result = new PublicFolderMoveRequestStatistics(rj); } else if (t.Equals(typeof(PublicFolderMigrationRequestStatistics))) { result = new PublicFolderMigrationRequestStatistics(rj); } else if (t.Equals(typeof(PublicFolderMailboxMigrationRequestStatistics))) { result = new PublicFolderMailboxMigrationRequestStatistics(rj); } else if (t.Equals(typeof(SyncRequestStatistics))) { result = new SyncRequestStatistics(rj); } else if (t.Equals(typeof(FolderMoveRequestStatistics))) { result = new FolderMoveRequestStatistics(rj); } else if (acceptBase && t.Equals(typeof(RequestStatisticsBase))) { return(RequestJobProvider.CreateRequestStatistics(rj)); } return(result); }
public override void Initialize(TransactionalRequestJob importRequest) { base.Initialize(importRequest); base.RequestJobIdentity = importRequest.Identity.ToString(); Guid targetExchangeGuid = importRequest.TargetExchangeGuid; string orgID = (importRequest.OrganizationId != null && importRequest.OrganizationId.OrganizationalUnit != null) ? (importRequest.OrganizationId.OrganizationalUnit.Name + "\\") : string.Empty; LocalizedString sourceTracingID = MrsStrings.PstTracingId(importRequest.FilePath); LocalizedString targetTracingID = importRequest.TargetIsArchive ? MrsStrings.ArchiveMailboxTracingId(orgID, targetExchangeGuid) : MrsStrings.PrimaryMailboxTracingId(orgID, targetExchangeGuid); MailboxCopierFlags flags = MailboxCopierFlags.Merge | MailboxCopierFlags.SourceIsPST; base.MailboxMerger = new MailboxMerger(Guid.Empty, targetExchangeGuid, importRequest, this, flags, sourceTracingID, targetTracingID); }
public override void Initialize(TransactionalRequestJob mergeRequest) { base.Initialize(mergeRequest); if (mergeRequest.RequestType == MRSRequestType.MailboxImport || mergeRequest.RequestType == MRSRequestType.MailboxExport || mergeRequest.RequestType == MRSRequestType.MailboxRestore || mergeRequest.RequestType == MRSRequestType.Sync) { return; } base.RequestJobIdentity = mergeRequest.Identity.ToString(); bool flag = mergeRequest.RequestStyle == RequestStyle.CrossOrg && mergeRequest.Direction == RequestDirection.Pull; bool flag2 = mergeRequest.RequestStyle == RequestStyle.CrossOrg && mergeRequest.Direction == RequestDirection.Push; LocalizedString sourceTracingID = LocalizedString.Empty; LocalizedString targetTracingID = LocalizedString.Empty; string orgID = (mergeRequest.OrganizationId != null && mergeRequest.OrganizationId.OrganizationalUnit != null) ? (mergeRequest.OrganizationId.OrganizationalUnit.Name + "\\") : string.Empty; Guid guid; if (flag) { guid = Guid.Empty; sourceTracingID = MrsStrings.RPCHTTPMailboxId(mergeRequest.RemoteMailboxLegacyDN); } else { guid = mergeRequest.SourceExchangeGuid; sourceTracingID = (mergeRequest.SourceIsArchive ? MrsStrings.ArchiveMailboxTracingId(orgID, guid) : MrsStrings.PrimaryMailboxTracingId(orgID, guid)); } Guid guid2; if (flag2) { guid2 = Guid.Empty; targetTracingID = MrsStrings.RPCHTTPMailboxId(mergeRequest.RemoteMailboxLegacyDN); } else { guid2 = mergeRequest.TargetExchangeGuid; targetTracingID = (mergeRequest.TargetIsArchive ? MrsStrings.ArchiveMailboxTracingId(orgID, guid2) : MrsStrings.PrimaryMailboxTracingId(orgID, guid2)); } MailboxCopierFlags mailboxCopierFlags = MailboxCopierFlags.Merge; if (mergeRequest.RequestStyle == RequestStyle.CrossOrg) { mailboxCopierFlags |= MailboxCopierFlags.CrossOrg; } if (mergeRequest.SourceIsArchive) { mailboxCopierFlags |= MailboxCopierFlags.SourceIsArchive; } if (mergeRequest.TargetIsArchive) { mailboxCopierFlags |= MailboxCopierFlags.TargetIsArchive; } this.MailboxMerger = new MailboxMerger(guid, guid2, mergeRequest, this, mailboxCopierFlags, sourceTracingID, targetTracingID); }
internal static RequestStatisticsBase CreateRequestStatistics(TransactionalRequestJob rj) { RequestStatisticsBase result = null; switch (rj.RequestType) { case MRSRequestType.Move: result = new MoveRequestStatistics(rj); break; case MRSRequestType.Merge: result = new MergeRequestStatistics(rj); break; case MRSRequestType.MailboxImport: result = new MailboxImportRequestStatistics(rj); break; case MRSRequestType.MailboxExport: result = new MailboxExportRequestStatistics(rj); break; case MRSRequestType.MailboxRestore: result = new MailboxRestoreRequestStatistics(rj); break; case MRSRequestType.PublicFolderMove: result = new PublicFolderMoveRequestStatistics(rj); break; case MRSRequestType.PublicFolderMigration: result = new PublicFolderMigrationRequestStatistics(rj); break; case MRSRequestType.Sync: result = new SyncRequestStatistics(rj); break; case MRSRequestType.MailboxRelocation: result = new MailboxRelocationRequestStatistics(rj); break; case MRSRequestType.FolderMove: result = new FolderMoveRequestStatistics(rj); break; case MRSRequestType.PublicFolderMailboxMigration: result = new PublicFolderMailboxMigrationRequestStatistics(rj); break; } return(result); }
public override void Initialize(TransactionalRequestJob restoreRequest) { base.Initialize(restoreRequest); base.RequestJobIdentity = restoreRequest.Identity.ToString(); Guid targetExchangeGuid = restoreRequest.TargetExchangeGuid; Guid sourceExchangeGuid = restoreRequest.SourceExchangeGuid; string orgID = (restoreRequest.OrganizationId != null && restoreRequest.OrganizationId.OrganizationalUnit != null) ? (restoreRequest.OrganizationId.OrganizationalUnit.Name + "\\") : string.Empty; string dbName = (restoreRequest.SourceDatabase != null) ? restoreRequest.SourceDatabase.Name : ((restoreRequest.RemoteDatabaseGuid != null) ? restoreRequest.RemoteDatabaseGuid.Value.ToString() : string.Empty); LocalizedString sourceTracingID = MrsStrings.RestoreMailboxTracingId(dbName, restoreRequest.SourceExchangeGuid); LocalizedString targetTracingID = restoreRequest.TargetIsArchive ? MrsStrings.ArchiveMailboxTracingId(orgID, targetExchangeGuid) : MrsStrings.PrimaryMailboxTracingId(orgID, targetExchangeGuid); MailboxCopierFlags flags = MailboxCopierFlags.Merge; base.MailboxMerger = new MailboxMerger(sourceExchangeGuid, targetExchangeGuid, restoreRequest, this, flags, sourceTracingID, targetTracingID); }
protected override RequestState RelinquishAction(TransactionalRequestJob requestJob, ReportData report) { FailureRec failureRec = QuarantinedJobs.Get(base.RequestGuid); if (failureRec == null) { return(RequestState.Relinquished); } report.Append(MrsStrings.JobIsQuarantined, failureRec, ReportEntryFlags.Fatal); requestJob.Suspend = true; requestJob.Status = RequestStatus.Failed; requestJob.TimeTracker.SetTimestamp(RequestJobTimestamp.Failure, new DateTime?(DateTime.UtcNow)); QuarantinedJobs.Remove(base.RequestGuid); RequestJobLog.Write(requestJob); return(RequestState.Failed); }
public override void Initialize(TransactionalRequestJob moveRequestJob) { MrsTracer.Service.Function("AuxFolderMoveJob.Initialize: Moving folders from , SourceMailbox=\"{0}\", TargetMailbox=\"{1}\", Flags={2}", new object[] { moveRequestJob.SourceExchangeGuid, moveRequestJob.TargetExchangeGuid, moveRequestJob.Flags }); base.Initialize(moveRequestJob); this.foldersToMove = new List <byte[]>(moveRequestJob.FolderList.Count); foreach (MoveFolderInfo moveFolderInfo in moveRequestJob.FolderList) { this.foldersToMove.Add(HexConverter.HexStringToByteArray(moveFolderInfo.EntryId)); } string orgID = (moveRequestJob.OrganizationId != null && moveRequestJob.OrganizationId.OrganizationalUnit != null) ? (moveRequestJob.OrganizationId.OrganizationalUnit.Name + "\\") : string.Empty; LocalizedString sourceTracingID = MrsStrings.AuxFolderMoveTracingId(orgID, moveRequestJob.SourceExchangeGuid); LocalizedString targetTracingID = MrsStrings.AuxFolderMoveTracingId(orgID, moveRequestJob.TargetExchangeGuid); this.folderMover = new PublicFolderMover(moveRequestJob, this, this.foldersToMove, MailboxCopierFlags.Root, sourceTracingID, targetTracingID); }
public override void Initialize(TransactionalRequestJob migrationRequestJob) { MrsTracer.Service.Function("PublicFolderMailboxMigrationJob.Initialize: SourceDatabase=\"{0}\", Flags={1}", new object[] { migrationRequestJob.SourceDatabase, migrationRequestJob.Flags }); TenantPublicFolderConfigurationCache.Instance.RemoveValue(migrationRequestJob.OrganizationId); this.publicFolderConfiguration = TenantPublicFolderConfigurationCache.Instance.GetValue(migrationRequestJob.OrganizationId); base.Initialize(migrationRequestJob); LocalizedString sourceTracingID = LocalizedString.Empty; MailboxCopierFlags mailboxCopierFlags = MailboxCopierFlags.PublicFolderMigration; bool flag = migrationRequestJob.RequestStyle == RequestStyle.CrossOrg; if (flag) { sourceTracingID = MrsStrings.RPCHTTPPublicFoldersId(migrationRequestJob.RemoteMailboxServerLegacyDN); mailboxCopierFlags |= MailboxCopierFlags.CrossOrg; } this.publicFolderMailboxMigrator = new PublicFolderMailboxMigrator(this.publicFolderConfiguration, migrationRequestJob.FolderToMailboxMap, migrationRequestJob.TargetExchangeGuid, mailboxCopierFlags | MailboxCopierFlags.Root, migrationRequestJob, this, sourceTracingID); }
protected override RequestState RelinquishAction(TransactionalRequestJob requestJob, ReportData report) { requestJob.TimeTracker.SetTimestamp(RequestJobTimestamp.Failure, null); requestJob.TimeTracker.SetTimestamp(RequestJobTimestamp.Suspended, null); requestJob.FailureCode = null; requestJob.FailureType = null; requestJob.FailureSide = null; requestJob.Message = LocalizedString.Empty; if (requestJob.SyncStage <= SyncStage.None) { requestJob.Status = RequestStatus.Queued; requestJob.TimeTracker.CurrentState = RequestState.Queued; } else { requestJob.Status = RequestStatus.InProgress; requestJob.TimeTracker.CurrentState = RequestState.InitialSeeding; } report.Append(MrsStrings.ReportJobResumed(requestJob.Status.ToString())); return(RequestState.Relinquished); }
private static void UpdateIndexEntryData(IRequestIndexEntry indexEntry, TransactionalRequestJob requestJob) { if (indexEntry != null && requestJob != null) { indexEntry.Status = requestJob.Status; indexEntry.Flags = requestJob.Flags; indexEntry.SourceMDB = requestJob.SourceDatabase; indexEntry.StorageMDB = requestJob.WorkItemQueueMdb; indexEntry.TargetMDB = requestJob.TargetDatabase; indexEntry.SourceUserId = requestJob.SourceUserId; indexEntry.TargetUserId = requestJob.TargetUserId; indexEntry.FilePath = requestJob.FilePath; indexEntry.RemoteHostName = requestJob.RemoteHostName; indexEntry.BatchName = requestJob.BatchName; indexEntry.RequestGuid = requestJob.Identity.RequestGuid; AggregatedAccountConfigurationWrapper aggregatedAccountConfigurationWrapper = indexEntry as AggregatedAccountConfigurationWrapper; if (aggregatedAccountConfigurationWrapper != null) { aggregatedAccountConfigurationWrapper.UpdateData(requestJob); } } }
public override void Initialize(TransactionalRequestJob migrationRequestJob) { MrsTracer.Service.Function("PublicFolderMigrationJob.Initialize: SourceDatabase=\"{0}\", Flags={1}", new object[] { migrationRequestJob.SourceDatabase, migrationRequestJob.Flags }); TenantPublicFolderConfigurationCache.Instance.RemoveValue(migrationRequestJob.OrganizationId); this.publicFolderConfiguration = TenantPublicFolderConfigurationCache.Instance.GetValue(migrationRequestJob.OrganizationId); this.publicFolderMigrators = new Dictionary <Guid, PublicFolderMigrator>(); base.Initialize(migrationRequestJob); if (this.publicFolderConfiguration.GetHierarchyMailboxInformation().Type != PublicFolderInformation.HierarchyType.InTransitMailboxGuid) { return; } LocalizedString sourceTracingID = LocalizedString.Empty; MailboxCopierFlags mailboxCopierFlags = MailboxCopierFlags.PublicFolderMigration; bool flag = migrationRequestJob.RequestStyle == RequestStyle.CrossOrg; if (flag) { sourceTracingID = MrsStrings.RPCHTTPPublicFoldersId(migrationRequestJob.RemoteMailboxServerLegacyDN); mailboxCopierFlags |= MailboxCopierFlags.CrossOrg; } Guid hierarchyMailboxGuid = this.publicFolderConfiguration.GetHierarchyMailboxInformation().HierarchyMailboxGuid; PublicFolderMigrator value = new PublicFolderMigrator(this.publicFolderConfiguration, migrationRequestJob.FolderToMailboxMap, hierarchyMailboxGuid, mailboxCopierFlags | MailboxCopierFlags.Root, migrationRequestJob, this, sourceTracingID); this.publicFolderMigrators[hierarchyMailboxGuid] = value; foreach (FolderToMailboxMapping folderToMailboxMapping in migrationRequestJob.FolderToMailboxMap) { Guid mailboxGuid = folderToMailboxMapping.MailboxGuid; if (mailboxGuid != hierarchyMailboxGuid && !this.publicFolderMigrators.ContainsKey(mailboxGuid)) { PublicFolderMigrator value2 = new PublicFolderMigrator(this.publicFolderConfiguration, migrationRequestJob.FolderToMailboxMap, mailboxGuid, mailboxCopierFlags, migrationRequestJob, this, sourceTracingID); this.publicFolderMigrators[mailboxGuid] = value2; } } }
internal void UpdateADData(ADUser user, TransactionalRequestJob requestJob, bool save) { if (save) { user.MailboxMoveStatus = RequestJobBase.GetVersionAppropriateStatus(requestJob.Status, user.ExchangeVersion); user.MailboxMoveFlags = RequestJobBase.GetVersionAppropriateFlags(requestJob.Flags, user.ExchangeVersion); user.MailboxMoveSourceMDB = requestJob.SourceDatabase; user.MailboxMoveTargetMDB = requestJob.TargetDatabase; user.MailboxMoveSourceArchiveMDB = requestJob.SourceArchiveDatabase; user.MailboxMoveTargetArchiveMDB = requestJob.TargetArchiveDatabase; user.MailboxMoveRemoteHostName = requestJob.RemoteHostName; user.MailboxMoveBatchName = requestJob.BatchName; return; } user.MailboxMoveStatus = RequestStatus.None; user.MailboxMoveFlags = RequestFlags.None; user.MailboxMoveSourceMDB = null; user.MailboxMoveTargetMDB = null; user.MailboxMoveSourceArchiveMDB = null; user.MailboxMoveTargetArchiveMDB = null; user.MailboxMoveRemoteHostName = null; user.MailboxMoveBatchName = null; }
public MailboxInformation GetMailboxInformation(TransactionalRequestJob requestJob, Guid primaryMailboxGuid, Guid physicalMailboxGuid, TenantPartitionHint partitionHint, Guid targetMdbGuid, string targetMdbName, string remoteHostName, string remoteOrgName, string remoteDCName, NetworkCredential cred) { MailboxInformation result = null; this.CallService(delegate() { string username = (cred != null) ? cred.UserName : null; string password = (cred != null) ? cred.Password : null; string domain = (cred != null) ? cred.Domain : null; if (this.ServerVersion[11]) { string requestJobXml = XMLSerializableBase.Serialize(new RequestJobXML(requestJob), false); result = this.Channel.GetMailboxInformation4(requestJobXml, primaryMailboxGuid, physicalMailboxGuid, (partitionHint != null) ? partitionHint.GetPersistablePartitionHint() : null, targetMdbGuid, targetMdbName, remoteHostName, remoteOrgName, remoteDCName, username, password, domain); return; } if (this.ServerVersion[4]) { result = this.Channel.GetMailboxInformation3(primaryMailboxGuid, physicalMailboxGuid, (partitionHint != null) ? partitionHint.GetPersistablePartitionHint() : null, targetMdbGuid, targetMdbName, remoteHostName, remoteOrgName, remoteDCName, username, password, domain); return; } result = this.Channel.GetMailboxInformation2(primaryMailboxGuid, physicalMailboxGuid, targetMdbGuid, targetMdbName, remoteHostName, remoteOrgName, remoteDCName, username, password, domain); }); return(result); }
internal FolderMoveRequestStatistics(TransactionalRequestJob requestJob) : this((SimpleProviderPropertyBag)requestJob.propertyBag) { base.CopyNonSchematizedPropertiesFrom(requestJob); }
protected override void UpdateRequestOnSave(TransactionalRequestJob rj, UpdateRequestOnSaveType updateType) { }
internal PublicFolderMigrator(TenantPublicFolderConfiguration publicFolderConfiguration, List <FolderToMailboxMapping> folderToMailboxMap, Guid targetMailboxGuid, MailboxCopierFlags copierFlags, TransactionalRequestJob migrationRequestJob, BaseJob publicFolderMigrationJob, LocalizedString sourceTracingID) : base(Guid.Empty, targetMailboxGuid, migrationRequestJob, publicFolderMigrationJob, copierFlags, sourceTracingID, new LocalizedString(targetMailboxGuid.ToString())) { MrsTracer.Service.Function("PublicFolderMigrator.Constructor", new object[0]); this.publicFolderConfiguration = publicFolderConfiguration; this.folderToMailboxMap = folderToMailboxMap; }
MailboxInformation IMailboxReplicationService.GetMailboxInformation4(string requestJobXml, Guid primaryMailboxGuid, Guid physicalMailboxGuid, byte[] partitionHint, Guid targetMdbGuid, string targetMdbName, string remoteHostName, string remoteOrgName, string remoteDCName, string username, string password, string domain) { MailboxInformation info = null; this.ForwardKnownExceptions(delegate { TenantPartitionHint partitionHint2 = (partitionHint != null) ? TenantPartitionHint.FromPersistablePartitionHint(partitionHint) : null; bool flag = string.IsNullOrEmpty(targetMdbName) && targetMdbGuid == Guid.Empty; NetworkCredential networkCredential = (!string.IsNullOrEmpty(username)) ? new NetworkCredential(username, password, domain) : null; MailboxType mbxType; IMailbox mailbox; if (string.IsNullOrEmpty(remoteHostName)) { if (!string.IsNullOrEmpty(remoteDCName)) { if (flag) { mbxType = MailboxType.SourceMailbox; mailbox = new MapiSourceMailbox(LocalMailboxFlags.Move); } else { mbxType = MailboxType.DestMailboxIntraOrg; mailbox = new MapiDestinationMailbox(LocalMailboxFlags.None); } mailbox.ConfigADConnection(remoteDCName, remoteDCName, networkCredential); } else { ProxyServerSettings proxyServerSettings; if (targetMdbGuid != Guid.Empty) { proxyServerSettings = CommonUtils.MapDatabaseToProxyServer(targetMdbGuid); } else { proxyServerSettings = CommonUtils.MapMailboxToProxyServer(new Guid?(physicalMailboxGuid), new Guid?(primaryMailboxGuid), partitionHint); } if (flag) { if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy) { mailbox = new StorageSourceMailbox(LocalMailboxFlags.Move); } else { mailbox = new RemoteSourceMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move); } mbxType = MailboxType.SourceMailbox; } else { if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy) { mailbox = new StorageDestinationMailbox(LocalMailboxFlags.Move); } else { mailbox = new RemoteDestinationMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move); } mbxType = MailboxType.DestMailboxIntraOrg; } } } else { ProxyControlFlags proxyControlFlags = ProxyControlFlags.DoNotApplyProxyThrottling; RequestJobXML requestJobXML = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXml, true); if (requestJobXML != null) { using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJobXML)) { transactionalRequestJob.IsFake = true; proxyControlFlags |= transactionalRequestJob.GetProxyControlFlags(); } } if (flag) { mailbox = new RemoteSourceMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move); mbxType = MailboxType.SourceMailbox; } else { mailbox = new RemoteDestinationMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move); mbxType = MailboxType.DestMailboxCrossOrg; } } using (mailbox) { mailbox.Config(null, primaryMailboxGuid, physicalMailboxGuid, partitionHint2, targetMdbGuid, mbxType, null); if (!string.IsNullOrEmpty(targetMdbName)) { mailbox.ConfigMDBByName(targetMdbName); } mailbox.Connect(MailboxConnectFlags.None); using (SettingsContextBase.ActivateContext(mailbox as ISettingsContextProvider)) { info = mailbox.GetMailboxInformation(); ADUser aduser = mailbox.GetADUser(); if (!this.clientVersion[2] && aduser.HasSeparatedArchive) { throw new UnsupportedClientVersionPermanentException(this.clientVersion.ComputerName, this.clientVersion.ToString(), "ArchiveSeparation"); } info.UserDataXML = ConfigurableObjectXML.Serialize <ADUser>(aduser); info.ServerInformation = mailbox.GetMailboxServerInformation(); mailbox.Disconnect(); } } }, null); return(info); }
string IMailboxReplicationService.ValidateAndPopulateRequestJob(string requestJobXML, out string reportEntryXMLs) { string reportString = null; string resultString = null; try { this.ForwardKnownExceptions(delegate { List <ReportEntry> list = new List <ReportEntry>(); try { RequestJobXML requestJob = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXML, true); using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJob)) { transactionalRequestJob.IsFake = true; transactionalRequestJob.Identity = new RequestJobObjectId((transactionalRequestJob.RequestType == MRSRequestType.Move) ? transactionalRequestJob.ExchangeGuid : transactionalRequestJob.RequestGuid, (transactionalRequestJob.WorkItemQueueMdb == null) ? Guid.Empty : transactionalRequestJob.WorkItemQueueMdb.ObjectGuid, null); RequestIndexEntryProvider requestIndexEntryProvider = new RequestIndexEntryProvider(); using (requestIndexEntryProvider.RescopeTo(transactionalRequestJob.DomainControllerToUpdate, transactionalRequestJob.OrganizationId)) { if (transactionalRequestJob.SourceUserId != null) { transactionalRequestJob.SourceUser = requestIndexEntryProvider.ReadADUser(transactionalRequestJob.SourceUserId, transactionalRequestJob.SourceExchangeGuid); } if (transactionalRequestJob.TargetUserId != null) { transactionalRequestJob.TargetUser = requestIndexEntryProvider.ReadADUser(transactionalRequestJob.TargetUserId, transactionalRequestJob.TargetExchangeGuid); } } if (MailboxSyncerJobs.ContainsJob(transactionalRequestJob.IdentifyingGuid)) { resultString = requestJobXML; } else { BaseJob baseJob = MailboxSyncerJobs.ConstructJob(transactionalRequestJob); if (baseJob == null) { MrsTracer.Service.Error("Don't know how to process '{0}' request", new object[] { transactionalRequestJob.RequestType }); throw new RequestTypeNotUnderstoodPermanentException(CommonUtils.LocalComputerName, VersionInformation.MRS.ToString(), (int)transactionalRequestJob.RequestType); } using (baseJob) { baseJob.Initialize(transactionalRequestJob); baseJob.ValidateAndPopulateRequestJob(list); transactionalRequestJob.Message = baseJob.CachedRequestJob.Message; transactionalRequestJob.SourceVersion = baseJob.CachedRequestJob.SourceVersion; transactionalRequestJob.SourceArchiveVersion = baseJob.CachedRequestJob.SourceArchiveVersion; transactionalRequestJob.SourceServer = baseJob.CachedRequestJob.SourceServer; transactionalRequestJob.SourceArchiveServer = baseJob.CachedRequestJob.SourceArchiveServer; transactionalRequestJob.TargetVersion = baseJob.CachedRequestJob.TargetVersion; transactionalRequestJob.TargetArchiveVersion = baseJob.CachedRequestJob.TargetArchiveVersion; transactionalRequestJob.TargetServer = baseJob.CachedRequestJob.TargetServer; transactionalRequestJob.TargetArchiveServer = baseJob.CachedRequestJob.TargetArchiveServer; transactionalRequestJob.RemoteDatabaseGuid = baseJob.CachedRequestJob.RemoteDatabaseGuid; resultString = XMLSerializableBase.Serialize(new RequestJobXML(transactionalRequestJob), false); } } } } finally { reportString = XMLSerializableBase.Serialize(list, false); } }, null); } finally { reportEntryXMLs = reportString; } return(resultString); }
protected override RequestState RelinquishAction(TransactionalRequestJob requestJob, ReportData report) { requestJob.RehomeRequest = false; return(RequestState.Relinquished); }