Ejemplo n.º 1
0
        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));
        }
        internal static void ValidateRequestJob(RequestJobBase requestJob)
        {
            if (requestJob.IsFake || requestJob.WorkItemQueueMdb == null)
            {
                requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.DataMissing);
                requestJob.ValidationMessage = MrsStrings.ValidationMoveRequestNotDeserialized;
                return;
            }
            if (requestJob.OriginatingMDBGuid != Guid.Empty && requestJob.OriginatingMDBGuid != requestJob.WorkItemQueueMdb.ObjectGuid)
            {
                requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.Orphaned);
                requestJob.ValidationMessage = MrsStrings.ValidationMoveRequestInWrongMDB(requestJob.OriginatingMDBGuid, requestJob.WorkItemQueueMdb.ObjectGuid);
                return;
            }
            if (requestJob.OriginatingMDBGuid == Guid.Empty)
            {
                requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.Valid);
                requestJob.ValidationMessage = LocalizedString.Empty;
                return;
            }
            MailboxRelocationRequestStatistics.LoadAdditionalPropertiesFromUser(requestJob);
            if (MailboxRelocationRequestStatistics.IsTerminalState(requestJob))
            {
                requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.Valid);
                requestJob.ValidationMessage = LocalizedString.Empty;
                return;
            }
            if (!requestJob.ValidateUser(requestJob.User, requestJob.UserId))
            {
                return;
            }
            Guid guid;
            Guid guid2;

            RequestIndexEntryProvider.GetMoveGuids(requestJob.User, out guid, out guid2);
            if (guid != requestJob.ExchangeGuid)
            {
                MrsTracer.Common.Error("Orphaned RequestJob: mailbox guid does not match between AD {0} and workitem queue {1}.", new object[]
                {
                    requestJob.User.ExchangeGuid,
                    requestJob.ExchangeGuid
                });
                requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.DataMismatch);
                requestJob.ValidationMessage = MrsStrings.ValidationMailboxGuidsDontMatch(guid, requestJob.ExchangeGuid);
                return;
            }
            if (!MailboxRelocationRequestStatistics.ValidateNoOtherRequests(requestJob))
            {
                return;
            }
            if (CommonUtils.IsImplicitSplit(requestJob.Flags, requestJob.User))
            {
                requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.DataMismatch);
                requestJob.ValidationMessage = MrsStrings.ErrorImplicitSplit;
                return;
            }
            requestJob.ValidationResult  = new RequestJobBase.ValidationResultEnum?(RequestJobBase.ValidationResultEnum.Valid);
            requestJob.ValidationMessage = LocalizedString.Empty;
        }
 public static bool IsTerminalState(RequestJobBase requestJobBase)
 {
     return(requestJobBase.CancelRequest || MailboxRelocationRequestStatistics.IsTerminalState(requestJobBase.Status) || requestJobBase.SyncStage >= SyncStage.Cleanup);
 }