public int GetQueueLength() { MrsTracer.Common.Function("RequestJobProvider.GetQueueLength", new object[0]); RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(this.SystemMailbox); Restriction restriction = Restriction.EQ(requestJobNamedPropertySet.PropTags[4], true); Restriction restriction2 = Restriction.BitMaskNonZero(requestJobNamedPropertySet.PropTags[10], 256); Restriction restriction3 = Restriction.EQ(requestJobNamedPropertySet.PropTags[0], RequestStatus.Completed); Restriction restriction4 = Restriction.EQ(requestJobNamedPropertySet.PropTags[0], RequestStatus.CompletedWithWarning); Restriction restriction5 = Restriction.Or(new Restriction[] { restriction, restriction2, restriction3, restriction4 }); Restriction restriction6 = Restriction.Not(restriction5); int result; using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(this.SystemMailbox)) { using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors)) { contentsTable.Restrict(restriction6); int rowCount = contentsTable.GetRowCount(); MrsTracer.Common.Debug("Queue length is {0}", new object[] { rowCount }); result = rowCount; } } return(result); }
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 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; }
public LocalizedString ComputePositionInQueue(Guid requestGuid) { int crows = 1000; int num = 0; int num2 = 0; if (requestGuid.Equals(Guid.Empty)) { return(MrsStrings.ErrorEmptyMailboxGuid); } using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(this.SystemMailbox)) { using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors)) { RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(this.SystemMailbox); contentsTable.SetColumns(requestJobNamedPropertySet.PropTags); SortOrder sortOrder = new SortOrder(requestJobNamedPropertySet.PropTags[7], SortFlags.Ascend); contentsTable.SortTable(sortOrder, SortTableFlags.None); Restriction restriction = Restriction.EQ(requestJobNamedPropertySet.PropTags[0], RequestStatus.Queued); contentsTable.Restrict(restriction); contentsTable.SeekRow(BookMark.Beginning, 0); PropValue[][] array = contentsTable.QueryRows(crows); bool flag = false; while (array != null && array.Length > 0) { int num3 = 0; if (!flag) { foreach (PropValue[] array3 in array) { num3++; if (num2 + num3 >= 10000) { break; } Guid value = MapiUtils.GetValue <Guid>(array3[26], Guid.Empty); if (requestGuid.Equals(value)) { flag = true; num = num2 + num3; break; } } } num2 += array.Length; if (num2 >= 10000) { break; } array = contentsTable.QueryRows(crows); } } } LocalizedString value2 = LocalizedString.Empty; LocalizedString value3 = LocalizedString.Empty; if (num == 0) { if (num2 < 10000) { value2 = MrsStrings.MoveRequestNotFoundInQueue; value3 = MrsStrings.PositionInteger(num2); } else { value2 = MrsStrings.PositionIntegerPlus(10000); value3 = MrsStrings.PositionIntegerPlus(10000); } } else { value2 = MrsStrings.PositionInteger(num); if (num2 < 10000) { value3 = MrsStrings.PositionInteger(num2); } else { value3 = MrsStrings.PositionIntegerPlus(num2); } } return(MrsStrings.PositionOfMoveRequestInSystemMailboxQueue(value2, value3)); }