protected NativeStorePropertyDefinition GetPropertyDefinitionFromPropTag(StoreSession storeSession, int propTag) { return(MapiUtils.ConvertPropTagsToDefinitions(storeSession, new PropTag[] { (PropTag)propTag })[0]); }
protected override byte[] MessageSaveChanges(StorageFxProxyPool.MessageEntry entry) { CoreItem referencedObject = entry.WrappedObject.ReferenceCoreItem.ReferencedObject; if (entry.MimeStream != null || entry.CachedItemProperties.Count > 0) { using (Item item = new Item(referencedObject, true)) { if (entry.MimeStream != null) { InboundConversionOptions scopedInboundConversionOptions = MapiUtils.GetScopedInboundConversionOptions(this.destMailbox.StoreSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); using (entry.MimeStream) { ItemConversion.ConvertAnyMimeToItem(item, entry.MimeStream, scopedInboundConversionOptions); } } foreach (ItemPropertiesBase itemPropertiesBase in entry.CachedItemProperties) { itemPropertiesBase.Apply((MailboxSession)this.destMailbox.StoreSession, item); } } } if (entry.CachedPropValues.Count > 0) { this.SetProps(entry.WrappedObject.PropertyBag, entry.CachedPropValues.ToArray()); } entry.WrappedObject.Save(); referencedObject.PropertyBag.Load(StorageFxProxyPool.EntryIdPropDef); return(referencedObject.PropertyBag[StorageFxProxyPool.EntryIdPropDef[0]] as byte[]); }
public static DatabaseInformation FindServerForMdb(ADObjectId database, string dcName, NetworkCredential cred, FindServerFlags flags) { if (!ConfigBase <MRSConfigSchema> .GetConfig <bool>("CrossResourceForestEnabled")) { return(MapiUtils.FindServerForMdb(database.ObjectGuid, dcName, cred, flags)); } Guid empty = Guid.Empty; DatabaseInformation result; try { if (database.GetPartitionId().IsLocalForestPartition()) { result = MapiUtils.FindServerForMdb(database.ObjectGuid, dcName, cred, flags); } else { BackEndServer backEndServer = BackEndLocator.GetBackEndServer(database); result = DatabaseInformation.FromBackEndServer(database, backEndServer); } } catch (BackEndLocatorException) { MrsTracer.Common.Debug("BE Locator was unable to locate MDB {0}.", new object[] { database.ObjectGuid }); if ((flags & FindServerFlags.AllowMissing) == FindServerFlags.None) { throw; } result = DatabaseInformation.Missing(database.ObjectGuid, database.PartitionFQDN); } return(result); }
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(); } } }); } }
private static bool ExportMessageBatch(ISourceMailbox mailbox, List <MessageRec> messages, Func <IFxProxyPool> getProxyPool, ExportMessagesFlags flags, PropTag[] propsToCopyExplicitly, PropTag[] excludeProps, TestIntegration testIntegration, out Exception failure) { failure = null; try { using (IFxProxyPool fxProxyPool = getProxyPool()) { mailbox.ExportMessages(messages, fxProxyPool, flags, propsToCopyExplicitly, excludeProps); } return(true); } catch (Exception ex) { if (!MapiUtils.IsBadItemIndicator(ex, out failure)) { if (failure != ex) { failure.PreserveExceptionStack(); throw failure; } throw; } } return(false); }
private XElement GetQueueDiagnosticInfo(MRSDiagnosticArgument arguments) { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(this.MdbGuid, null, null, FindServerFlags.AllowMissing); string argument = arguments.GetArgument <string>("queues"); if (!string.IsNullOrEmpty(argument) && (databaseInformation.IsMissing || !CommonUtils.IsValueInWildcardedList(databaseInformation.DatabaseName, argument))) { return(null); } MRSQueueDiagnosticInfoXML mrsqueueDiagnosticInfoXML = new MRSQueueDiagnosticInfoXML { MdbGuid = this.MdbGuid, MdbName = databaseInformation.DatabaseName, LastJobPickup = this.LastJobPickup, LastInteractiveJobPickup = this.LastInteractiveJobPickup, QueuedJobsCount = this.QueuedJobsCount, InProgressJobsCount = this.InProgressJobsCount, LastScanFailure = this.LastScanFailure, MdbDiscoveryTimestamp = this.MdbDiscoveryTimestamp, LastScanTimestamp = this.LastScanTimestamp, LastScanDurationMs = (int)this.LastScanDuration.TotalMilliseconds, NextRecommendedScan = this.NextRecommendedScan, LastActiveJobFinishTime = this.LastActiveJobFinishTime, LastActiveJobFinished = this.LastActiveJobFinished }; if (arguments.HasArgument("pickupresults")) { mrsqueueDiagnosticInfoXML.LastScanResults = this.LastScanResults; } return(mrsqueueDiagnosticInfoXML.ToDiagnosticInfo(null)); }
private static TimeSpan PickLightJobs() { TestIntegration.Instance.Barrier("DontPickupJobs", null); CommonUtils.CatchKnownExceptions(delegate { DateTime utcNow = DateTime.UtcNow; if (utcNow > MRSService.nextLightJobsFullScanTime) { double num = CommonUtils.Randomize(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("FullScanLightJobsPollingPeriod").TotalSeconds, 0.2); MRSService.nextLightJobsFullScanTime = utcNow + TimeSpan.FromSeconds(num); MrsTracer.Service.Debug("Next light job full scan in {0} seconds, at {1}", new object[] { (int)num, MRSService.nextLightJobsFullScanTime }); foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer()) { MRSQueue.Get(mdbGuid).Tickle(MRSQueue.ScanType.Light); } } List <Guid> queuesToScan = MRSQueue.GetQueuesToScan(MRSQueue.ScanType.Light); if (queuesToScan != null) { foreach (Guid mdbGuid2 in queuesToScan) { CommonUtils.CheckForServiceStopping(); MRSQueue.Get(mdbGuid2).PickupLightJobs(); } } }, null); return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("LightJobPickupPeriod")); }
private byte[] FindMessageId() { using (MapiFolder mapiFolder = MapiUtils.OpenFolderUnderRoot(this.store, this.folderName, false)) { if (mapiFolder == null) { return(null); } this.FolderId = mapiFolder.GetProp(PropTag.EntryId).GetBytes(); using (MapiTable contentsTable = mapiFolder.GetContentsTable(ContentsTableFlags.DeferredErrors)) { PropTag propTag = PropTag.ReplyTemplateID; contentsTable.SetColumns(new PropTag[] { PropTag.EntryId }); contentsTable.SortTable(new SortOrder(propTag, SortFlags.Ascend), SortTableFlags.None); if (contentsTable.FindRow(Restriction.EQ(propTag, this.searchKey), BookMark.Beginning, FindRowFlag.None)) { PropValue[][] array = contentsTable.QueryRows(1); if (array == null || array.Length == 0 || array[0].Length == 0) { return(null); } return(array[0][0].GetBytes()); } } } return(null); }
internal void SaveToMailbox(MapiStore mailbox, int maxMoveHistoryLength) { MrsTracer.Common.Function("MoveHistoryEntryInternal.SaveToMailbox(maxHistoryLength={0})", new object[] { maxMoveHistoryLength }); List <byte[]> list = new List <byte[]>(); using (MapiFolder folder = MapiUtils.OpenFolderUnderRoot(mailbox, MoveHistoryEntryInternal.MHEFolderName, true)) { using (MapiTable contentsTable = folder.GetContentsTable(ContentsTableFlags.DeferredErrors)) { contentsTable.SortTable(new SortOrder(PropTag.LastModificationTime, SortFlags.Ascend), SortTableFlags.None); PropValue[][] array = MapiUtils.QueryAllRows(contentsTable, null, new PropTag[] { PropTag.EntryId }); foreach (PropValue[] array3 in array) { list.Add(array3[0].GetBytes()); } } MrsTracer.Common.Debug("Move history contains {0} items.", new object[] { list.Count }); List <byte[]> list2 = new List <byte[]>(); while (list.Count >= maxMoveHistoryLength && list.Count > 0) { list2.Add(list[0]); list.RemoveAt(0); } if (list2.Count > 0) { MrsTracer.Common.Debug("Clearing {0} entries from move history", new object[] { list2.Count }); MapiUtils.ProcessMapiCallInBatches <byte[]>(list2.ToArray(), delegate(byte[][] batch) { folder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, batch); }); } } if (maxMoveHistoryLength <= 0) { MrsTracer.Common.Debug("Move history saving is disabled.", new object[0]); return; } DateTime dateTime = this.TimeTracker.GetTimestamp(RequestJobTimestamp.Creation) ?? DateTime.MinValue; string subject = string.Format("MoveHistoryEntry {0}", dateTime.ToString()); byte[] bytes = BitConverter.GetBytes(dateTime.ToBinary()); MoveObjectInfo <MoveHistoryEntryInternal> moveObjectInfo = new MoveObjectInfo <MoveHistoryEntryInternal>(Guid.Empty, mailbox, null, MoveHistoryEntryInternal.MHEFolderName, MoveHistoryEntryInternal.MHEMessageClass, subject, bytes); using (moveObjectInfo) { moveObjectInfo.SaveObject(this); } }
public static Guid GetSystemMailboxGuid(Guid mdbGuid, string dcName, NetworkCredential cred, FindServerFlags flags) { Guid guid = Guid.Empty; if ((flags & FindServerFlags.ForceRediscovery) == FindServerFlags.None) { lock (MapiUtils.syncRoot) { if (MapiUtils.mdbToSystemMailboxMap.TryGetValue(mdbGuid, out guid)) { return(guid); } } } try { ADSystemMailbox adsystemMailbox = MapiUtils.GetADSystemMailbox(mdbGuid, dcName, cred); guid = adsystemMailbox.ExchangeGuid; } catch (SystemMailboxNotFoundPermanentException) { if ((flags & FindServerFlags.AllowMissing) == FindServerFlags.None) { throw; } return(Guid.Empty); } lock (MapiUtils.syncRoot) { MapiUtils.mdbToSystemMailboxMap[mdbGuid] = guid; } return(guid); }
internal static bool IsMessageTypeSupported(MapiMessage message, MapiStore store) { RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(store); PropValue prop = message.GetProp(requestJobNamedPropertySet.PropTags[9]); MRSJobType value = MapiUtils.GetValue <MRSJobType>(prop, MRSJobType.RequestJobE14R3); return(RequestJobXML.IsKnownJobType(value)); }
byte[] IMapiFxProxy.GetObjectData() { if (this.targetObjectData == null) { this.targetObjectData = MapiUtils.CreateObjectData((this.targetObject is PstFxFolder) ? InterfaceIds.IMAPIFolderGuid : InterfaceIds.IMessageGuid); } return(this.targetObjectData); }
protected override byte[] MessageGetObjectData(PSTFxProxyPool.MessageEntry message) { if (message == null) { return(MapiUtils.CreateObjectData(InterfaceIds.IMessageGuid)); } return(message.Proxy.GetObjectData()); }
private static TimeSpan PickHeavyJobs() { TestIntegration.Instance.Barrier("DontPickupJobs", null); CommonUtils.CatchKnownExceptions(delegate { DateTime utcNow = DateTime.UtcNow; bool flag = false; TimeSpan config = ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ADInconsistencyCleanUpPeriod"); if (config != TimeSpan.Zero && MRSService.lastADCleanUpScanFinishTime != null) { DateTime t = utcNow; if (t >= MRSService.lastADCleanUpScanFinishTime + config) { ThreadPool.QueueUserWorkItem(new WaitCallback(MRSService.CleanADOprhanAndInconsistency)); } } ReservationManager.UpdateHealthState(); if (utcNow >= MRSService.NextFullScanTime) { MailboxReplicationServicePerformanceCounters.LastScanTime.RawValue = CommonUtils.TimestampToPerfcounterLong(utcNow); MRSService.lastFullScanTime = utcNow; flag = true; double value = CommonUtils.Randomize(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("FullScanMoveJobsPollingPeriod").TotalSeconds, 0.2); MRSService.NextFullScanTime = utcNow + TimeSpan.FromSeconds(value); MrsTracer.Service.Debug("Next full scan at {0}", new object[] { MRSService.NextFullScanTime }); foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer()) { MRSQueue.Get(mdbGuid).Tickle(MRSQueue.ScanType.Heavy); } } int num = 0; List <Guid> queuesToScan = MRSQueue.GetQueuesToScan(MRSQueue.ScanType.Heavy); if (queuesToScan != null) { foreach (Guid mdbGuid2 in queuesToScan) { CommonUtils.CheckForServiceStopping(); bool flag2; MRSQueue.Get(mdbGuid2).PickupHeavyJobs(out flag2); if (flag2) { num++; } } } if (flag) { MRSService.lastFullScanDuration = (long)(DateTime.UtcNow - utcNow).TotalMilliseconds; MailboxReplicationServicePerformanceCounters.LastScanDuration.RawValue = MRSService.lastFullScanDuration; MailboxReplicationServicePerformanceCounters.UnreachableDatabases.RawValue = (long)num; } }, null); return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("HeavyJobPickupPeriod")); }
public static bool IsStoreDisconnectedMailbox(ExRpcAdmin rpcAdmin, Guid mdbGuid, Guid mailboxGuid) { if (MapiUtils.IsStoreDisconnectedMailboxInternal(rpcAdmin, mdbGuid, mailboxGuid)) { return(true); } rpcAdmin.SyncMailboxWithDS(mdbGuid, mailboxGuid); return(MapiUtils.IsStoreDisconnectedMailboxInternal(rpcAdmin, mdbGuid, mailboxGuid)); }
public static List <Guid> GetDatabasesOnThisServer() { if (MapiUtils.localMDBs != null && DateTime.UtcNow - MapiUtils.LocalMDBRefreshInterval < MapiUtils.lastLocalMDBRefresh) { return(MapiUtils.localMDBs); } List <Guid> list = new List <Guid>(); MdbStatus[] mdbStatuses = null; CommonUtils.ProcessKnownExceptions(delegate { using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=MSExchangeMigration", null, null, null, null)) { mdbStatuses = exRpcAdmin.ListMdbStatus(true); } }, delegate(Exception failure) { LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure); CommonUtils.LogEvent(MRSEventLogConstants.Tuple_UnableToDetermineHostedMdbsOnServer, new object[] { CommonUtils.LocalComputerName, localizedString.ToString() }); return(false); }); if (mdbStatuses == null) { MrsTracer.Common.Debug("MapiUtils.GetDatabasesOnServer() returned null.", new object[0]); return(list); } foreach (MdbStatus mdbStatus in mdbStatuses) { if (mdbStatus.Status.HasFlag(MdbStatusFlags.Online)) { list.Add(mdbStatus.MdbGuid); } } if (list.Count == 0) { MrsTracer.Common.Debug("MapiUtils.GetDatabasesOnServer() found {0} databases, but none of them are online.", new object[] { mdbStatuses.Length }); } foreach (Guid mdbGuid in list) { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.AllowMissing); if (!databaseInformation.IsMissing && !databaseInformation.IsOnThisServer) { databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.ForceRediscovery | FindServerFlags.AllowMissing); } } MapiUtils.localMDBs = list; MapiUtils.lastLocalMDBRefresh = DateTime.UtcNow; return(list); }
void IDestinationFolder.SetReadFlagsOnMessages(SetReadFlags flags, byte[][] entryIds) { MapiUtils.ProcessMapiCallInBatches <byte[]>(entryIds, delegate(byte[][] batch) { using (this.Mailbox.RHTracker.Start()) { this.Folder.SetReadFlags(flags, batch); } }); }
void IFolder.DeleteMessages(byte[][] entryIds) { MapiUtils.ProcessMapiCallInBatches <byte[]>(entryIds, delegate(byte[][] batch) { using (this.Mailbox.RHTracker.Start()) { this.Folder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, batch); } }); }
public override void Apply(MailboxSession session, Item item) { if (string.IsNullOrEmpty(this.ICalContents)) { return; } InboundConversionOptions scopedInboundConversionOptions = MapiUtils.GetScopedInboundConversionOptions(session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); ItemConversion.ConvertICalToItem(item, scopedInboundConversionOptions, this.ICalContents); }
internal static List <MoveHistoryEntryInternal> LoadMoveHistory(MapiStore mailbox) { MrsTracer.Common.Function("MoveHistoryEntryInternal.LoadMoveHistory", new object[0]); List <MoveHistoryEntryInternal> list = new List <MoveHistoryEntryInternal>(); using (MapiFolder mapiFolder = MapiUtils.OpenFolderUnderRoot(mailbox, MoveHistoryEntryInternal.MHEFolderName, false)) { if (mapiFolder == null) { return(list); } using (MapiTable contentsTable = mapiFolder.GetContentsTable(ContentsTableFlags.DeferredErrors)) { PropValue[][] array = MapiUtils.QueryAllRows(contentsTable, null, new PropTag[] { PropTag.EntryId }); foreach (PropValue[] array3 in array) { byte[] bytes = array3[0].GetBytes(); string subject = string.Format("MoveHistoryEntry {0}", TraceUtils.DumpEntryId(bytes)); MoveObjectInfo <MoveHistoryEntryInternal> moveObjectInfo = new MoveObjectInfo <MoveHistoryEntryInternal>(Guid.Empty, mailbox, bytes, MoveHistoryEntryInternal.MHEFolderName, MoveHistoryEntryInternal.MHEMessageClass, subject, null); using (moveObjectInfo) { MoveHistoryEntryInternal moveHistoryEntryInternal = null; try { moveHistoryEntryInternal = moveObjectInfo.ReadObject(ReadObjectFlags.DontThrowOnCorruptData); } catch (MailboxReplicationPermanentException ex) { MrsTracer.Common.Warning("Failed to read move history entry: {0}", new object[] { ex.ToString() }); } if (moveHistoryEntryInternal != null) { list.Add(moveHistoryEntryInternal); } else if (moveObjectInfo.CreationTimestamp < DateTime.UtcNow - TimeSpan.FromDays(365.0)) { MrsTracer.Common.Warning("Removing old corrupt MHEI entry {0}", new object[] { TraceUtils.DumpEntryId(bytes) }); moveObjectInfo.DeleteMessage(); } } } } } list.Sort(); return(list); }
private static bool ShouldRemovePerfCounter(Guid mdbGuid, MDBPerfCounterHelper perfCounter) { bool result = false; CommonUtils.CatchKnownExceptions(delegate { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.AllowMissing); result = (databaseInformation.IsMissing || !databaseInformation.IsOnThisServer); }, null); return(result); }
internal static MailboxReplicationServiceClient Create(IConfigurationSession session, MRSJobType jobType, Guid mdbGuid, List <string> unreachableMrsServers) { MRSCapabilities requiredCapability = RequestJobXML.MapJobTypeToCapability(jobType); string text = null; DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None); if (!string.IsNullOrEmpty(databaseInformation.ServerFqdn)) { text = databaseInformation.ServerFqdn.ToLower(CultureInfo.InvariantCulture); } List <string> mrsServers = MailboxReplicationServiceClient.GetMrsServers(session, mdbGuid); List <string> list = new List <string>(mrsServers.Count); foreach (string text2 in mrsServers) { string text3 = text2.ToLower(CultureInfo.InvariantCulture); if (string.Compare(text3, text, CultureInfo.InvariantCulture, CompareOptions.Ordinal) != 0 && !unreachableMrsServers.Contains(text3)) { list.Add(text2); } } List <string> list2 = CommonUtils.RandomizeSequence <string>(list); if (text != null) { list2.Insert(0, text); } foreach (string text4 in list2) { try { return(MailboxReplicationServiceClient.Create(text4, requiredCapability)); } catch (MailboxReplicationPermanentException ex) { MrsTracer.Common.Warning("Attempt to connect to CAS Server {0} failed with error: {1}", new object[] { text4, CommonUtils.FullExceptionMessage(ex) }); } catch (MailboxReplicationTransientException ex2) { MrsTracer.Common.Warning("Attempt to connect to CAS Server {0} failed with error: {1}", new object[] { text4, CommonUtils.FullExceptionMessage(ex2) }); } unreachableMrsServers.Add(text4.ToLower(CultureInfo.InvariantCulture)); } throw new NoMRSAvailableTransientException(); }
public static void CleanADOrphanAndInconsistency() { PartitionId[] allAccountPartitionIds = ADAccountPartitionLocator.GetAllAccountPartitionIds(); for (int i = 0; i < allAccountPartitionIds.Length; i++) { PartitionId partitionId = allAccountPartitionIds[i]; CommonUtils.CheckForServiceStopping(); ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); adsessionSettings.IncludeSoftDeletedObjects = true; adsessionSettings.IncludeInactiveMailbox = true; IRecipientSession recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, false, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 45, "CleanADOrphanAndInconsistency", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\ADInconsistencyCheck.cs"); IConfigurationSession configSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, false, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 52, "CleanADOrphanAndInconsistency", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\ADInconsistencyCheck.cs"); using (List <Guid> .Enumerator enumerator = MapiUtils.GetDatabasesOnThisServer().GetEnumerator()) { while (enumerator.MoveNext()) { Guid dbGuid = enumerator.Current; CommonUtils.CheckForServiceStopping(); DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(dbGuid, null, null, FindServerFlags.AllowMissing); if (databaseInformation.IsMissing) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistency Database {0} in Forest {1} is missing, skip it", new object[] { dbGuid, databaseInformation.ForestFqdn }); } else { CommonUtils.CatchKnownExceptions(delegate { ADInconsistencyCheck.CleanADOrphanAndInconsistencyForRequests(recipientSession, configSession, dbGuid); }, delegate(Exception f) { MrsTracer.Service.Error("CleanADOrphanAndInconsistency() failed for DB {0}. Error: {1}", new object[] { dbGuid, CommonUtils.FullExceptionMessage(f, true) }); MRSService.LogEvent(MRSEventLogConstants.Tuple_ScanADInconsistencyRequestFailEvent, new object[] { dbGuid, string.Empty, string.Empty, CommonUtils.FullExceptionMessage(f, true) }); }); } } } } }
private bool InitializeIdentity() { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(this.DatabaseGuid, null, null, FindServerFlags.AllowMissing); if (databaseInformation.IsMissing) { this.databaseName = string.Format("LegacyMdblCiUnresolved({0}{1})", this.DatabaseGuid.ToString(), databaseInformation.ForestFqdn); } else { this.databaseName = string.Format("LegacyMdblCi({0})", databaseInformation.DatabaseName); } return(!databaseInformation.IsMissing); }
private MailboxSession OpenSystemMailbox() { MrsTracer.Provider.Function("StorageMailbox.OpenSystemMailbox", new object[0]); base.CheckDisposed(); Server server = LocalServer.GetServer(); ADSystemMailbox adsystemMailbox = MapiUtils.GetADSystemMailbox(base.MdbGuid, null, null); MailboxSession result; using (base.RHTracker.Start()) { ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADSystemMailbox(ADSessionSettings.FromRootOrgScopeSet(), adsystemMailbox, server); result = MailboxSession.OpenAsSystemService(mailboxOwner, CultureInfo.InvariantCulture, "Client=MSExchangeMigration"); } return(result); }
void IReportHelper.Delete(ReportData report, MapiStore storeToUse) { MapiUtils.RetryOnObjectChanged(delegate { using (MoveObjectInfo <T> moveObjectInfo = new MoveObjectInfo <T>(Guid.Empty, storeToUse, report.MessageId, this.reportFolderName, this.reportMessageClass, this.CreateMessageSubject(report), this.CreateMessageSearchKey(report))) { moveObjectInfo.OpenMessage(); if (moveObjectInfo.MessageFound) { moveObjectInfo.DeleteMessage(); } } }); report.MessageId = null; }
protected override ICollection <ServiceIssue> RunFullIssueScan() { ICollection <ServiceIssue> collection = new List <ServiceIssue>(); foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer()) { using (new DatabaseSettingsContext(mdbGuid, null).Activate()) { try { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None); string databaseName = databaseInformation.DatabaseName; if (!databaseInformation.IsOnThisServer) { return(null); } using (MapiStore systemMailbox = MapiUtils.GetSystemMailbox(mdbGuid, false)) { using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(systemMailbox)) { using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors)) { if (contentsTable.GetRowCount() > 0) { RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(systemMailbox); contentsTable.SetColumns(requestJobNamedPropertySet.PropTags); Restriction restriction = Restriction.GT(requestJobNamedPropertySet.PropTags[23], ConfigBase <MRSConfigSchema> .GetConfig <int>("PoisonLimit")); List <MoveJob> allMoveJobs = SystemMailboxJobs.GetAllMoveJobs(restriction, null, contentsTable, mdbGuid, null); if (allMoveJobs != null) { foreach (MoveJob job in allMoveJobs) { collection.Add(new MRSPoisonedJobIssue(job)); } } } } } } } catch (LocalizedException lastScanError) { base.LastScanError = lastScanError; } } } return(collection); }
public static PropValue[][] QueryAllRows(MapiTable msgTable, Restriction restriction, ICollection <PropTag> propTags, int pageSize) { MapiUtils.InitQueryAllRows(msgTable, restriction, propTags); List <PropValue[]> list = new List <PropValue[]>(); for (;;) { PropValue[][] array = msgTable.QueryRows(pageSize); if (array.GetLength(0) == 0) { break; } list.AddRange(array); } return(list.ToArray()); }
internal static List <MoveHistoryEntryInternal> LoadMoveHistory(Guid mailboxGuid, Guid mdbGuid, UserMailboxFlags flags) { List <MoveHistoryEntryInternal> result; using (MapiStore userMailbox = MapiUtils.GetUserMailbox(mailboxGuid, mdbGuid, flags)) { if (userMailbox == null) { result = null; } else { result = MoveHistoryEntryInternal.LoadMoveHistory(userMailbox); } } return(result); }
public static MDBPerfCounterHelper GetMDBHelper(Guid mdbGuid, bool createIfNotPresent) { MDBPerfCounterHelper mdbperfCounterHelper = null; MDBPerfCounterHelper result; lock (MDBPerfCounterHelperCollection.locker) { if (!MDBPerfCounterHelperCollection.data.TryGetValue(mdbGuid, out mdbperfCounterHelper) && createIfNotPresent) { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.AllowMissing); mdbperfCounterHelper = new MDBPerfCounterHelper(databaseInformation.DatabaseName ?? MrsStrings.MissingDatabaseName2(mdbGuid, databaseInformation.ForestFqdn)); MDBPerfCounterHelperCollection.data.TryInsertSliding(mdbGuid, mdbperfCounterHelper, MDBPerfCounterHelperCollection.RefreshInterval); } result = mdbperfCounterHelper; } return(result); }