Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 private void EnsureStoreConnectionExists(Guid mdbGuid)
 {
     if (!this.MdbGuid.Equals(mdbGuid) && this.store != null)
     {
         MrsTracer.Common.Error("This RequestJobProvider is opened against Mailbox Database '{0}'; it cannot be used for items in Mailbox Database '{1}'.", new object[]
         {
             this.MdbGuid,
             mdbGuid
         });
         throw new ArgumentException(MrsStrings.ProviderAlreadySpecificToDatabase(this.MdbGuid, mdbGuid));
     }
     if (this.store == null && mdbGuid != Guid.Empty)
     {
         this.MdbGuid   = mdbGuid;
         this.store     = MapiUtils.GetSystemMailbox(this.MdbGuid);
         this.ownsStore = true;
     }
 }
        public void PickupJobs(out string failure)
        {
            string dbName      = null;
            string scanFailure = null;

            failure = null;
            using (new DatabaseSettingsContext(this.MdbGuid, null).Activate())
            {
                CommonUtils.CatchKnownExceptions(delegate
                {
                    DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(this.MdbGuid, null, null, FindServerFlags.None);
                    dbName = databaseInformation.DatabaseName;
                    if (!databaseInformation.IsOnThisServer)
                    {
                        scanFailure = string.Format("MDB is mounted on remote server {0}", databaseInformation.ServerFqdn);
                        MRSQueue.RemoveQueue(this.MdbGuid);
                        return;
                    }
                    MrsTracer.Service.Debug("Picking up jobs from '{0}' ({1})", new object[]
                    {
                        dbName,
                        this.MdbGuid
                    });
                    using (MapiStore systemMailbox = MapiUtils.GetSystemMailbox(this.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);
                                    this.ProcessJobs(systemMailbox, contentsTable, requestJobNamedPropertySet);
                                }
                            }
                        }
                    }
                    MrsTracer.Service.Debug("Pick up jobs from Mdb: '{0}' - complete.", new object[]
                    {
                        dbName
                    });
                }, delegate(Exception f)
                {
                    if (dbName == null)
                    {
                        dbName = MrsStrings.MissingDatabaseName(this.MdbGuid).ToString();
                    }
                    MrsTracer.Service.Debug("PickupJobs() failed for mdb '{0}'. Error: {1}", new object[]
                    {
                        dbName,
                        CommonUtils.FullExceptionMessage(f)
                    });
                    scanFailure = CommonUtils.FullExceptionMessage(f, true);
                    MRSService.LogEvent(MRSEventLogConstants.Tuple_UnableToProcessJobsInDatabase, new object[]
                    {
                        dbName,
                        CommonUtils.FullExceptionMessage(f)
                    });
                });
            }
            failure = scanFailure;
        }
Esempio n. 4
0
 public static MapiStore GetSystemMailbox(Guid mdbGuid, string dcName, NetworkCredential cred)
 {
     return(MapiUtils.GetSystemMailbox(mdbGuid, dcName, cred, true));
 }
Esempio n. 5
0
 public static MapiStore GetSystemMailbox(Guid mdbGuid, bool allowCrossSiteLogon)
 {
     return(MapiUtils.GetSystemMailbox(mdbGuid, null, null, allowCrossSiteLogon));
 }
Esempio n. 6
0
 public static MapiStore GetSystemMailbox(Guid mdbGuid)
 {
     return(MapiUtils.GetSystemMailbox(mdbGuid, null, null));
 }
Esempio n. 7
0
        public override void Run()
        {
            Guid currentQueueGuid        = this.CurrentRequestQueue.ObjectGuid;
            Guid newQueueGuid            = this.NewRequestQueue.ObjectGuid;
            RequestJobObjectId currentId = new RequestJobObjectId(base.RequestGuid, currentQueueGuid, this.MessageId);
            RequestJobObjectId newId     = new RequestJobObjectId(base.RequestGuid, newQueueGuid, null);

            CommonUtils.CatchKnownExceptions(delegate
            {
                DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(this.NewRequestQueue, null, null, FindServerFlags.None);
                if (databaseInformation.ServerVersion < Server.E15MinVersion)
                {
                    throw new UnsupportedRehomeTargetVersionPermanentException(newQueueGuid.ToString(), new ServerVersion(databaseInformation.ServerVersion).ToString());
                }
                this.NewSystemMailbox = MapiUtils.GetSystemMailbox(newQueueGuid);
                using (RequestJobProvider currentQueueProvider = new RequestJobProvider(currentQueueGuid, this.CurrentSystemMailbox))
                {
                    using (RequestJobProvider newQueueProvider = new RequestJobProvider(newQueueGuid, this.NewSystemMailbox))
                    {
                        using (TransactionalRequestJob requestJob = (TransactionalRequestJob)currentQueueProvider.Read <TransactionalRequestJob>(currentId))
                        {
                            if (requestJob != null)
                            {
                                RequestJobProvider origProvider       = requestJob.Provider;
                                MoveObjectInfo <RequestJobXML> origMO = requestJob.MoveObject;
                                ReportData currentReport = new ReportData(requestJob.IdentifyingGuid, requestJob.ReportVersion);
                                currentReport.Load(currentQueueProvider.SystemMailbox);
                                ReportData newReport = new ReportData(currentReport.IdentifyingGuid, requestJob.ReportVersion);
                                newReport.Append(currentReport.Entries);
                                try
                                {
                                    requestJob.Provider           = null;
                                    requestJob.MoveObject         = null;
                                    requestJob.RequestQueue       = this.NewRequestQueue;
                                    requestJob.Identity           = newId;
                                    requestJob.OriginatingMDBGuid = Guid.Empty;
                                    requestJob.RehomeRequest      = false;
                                    if (requestJob.IndexEntries != null)
                                    {
                                        foreach (IRequestIndexEntry requestIndexEntry in requestJob.IndexEntries)
                                        {
                                            requestIndexEntry.StorageMDB = this.NewRequestQueue;
                                        }
                                    }
                                    newQueueProvider.Save(requestJob);
                                    CommonUtils.CatchKnownExceptions(delegate
                                    {
                                        newReport.Append(MrsStrings.ReportJobRehomed(currentQueueGuid.ToString(), newQueueGuid.ToString()));
                                        newReport.Flush(newQueueProvider.SystemMailbox);
                                    }, null);
                                    CommonUtils.CatchKnownExceptions(delegate
                                    {
                                        requestJob.Provider           = origProvider;
                                        requestJob.MoveObject         = origMO;
                                        requestJob.RequestQueue       = this.CurrentRequestQueue;
                                        requestJob.Identity           = currentId;
                                        requestJob.OriginatingMDBGuid = currentQueueGuid;
                                        requestJob.RehomeRequest      = true;
                                        MapiUtils.RetryOnObjectChanged(delegate
                                        {
                                            currentQueueProvider.Delete(requestJob);
                                        });
                                        currentReport.Delete(currentQueueProvider.SystemMailbox);
                                    }, null);
                                }
                                catch
                                {
                                    requestJob.Provider           = origProvider;
                                    requestJob.MoveObject         = origMO;
                                    requestJob.RequestQueue       = this.CurrentRequestQueue;
                                    requestJob.Identity           = currentId;
                                    requestJob.OriginatingMDBGuid = currentQueueGuid;
                                    requestJob.RehomeRequest      = true;
                                    throw;
                                }
                            }
                        }
                    }
                }
            }, delegate(Exception failure)
            {
                MrsTracer.Service.Warning("Failed to rehome request.", new object[0]);
                this.RehomeFailure = failure;
            });
            base.Run();
        }