Example #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;
        }
Example #3
0
        internal static RequestStatisticsBase CreateRequestStatistics(Type t, RequestJobXML rj, bool acceptBase)
        {
            RequestStatisticsBase requestStatisticsBase = null;

            if (t.Equals(typeof(MoveRequestStatistics)))
            {
                requestStatisticsBase = new MoveRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MergeRequestStatistics)))
            {
                requestStatisticsBase = new MergeRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxImportRequestStatistics)))
            {
                requestStatisticsBase = new MailboxImportRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxExportRequestStatistics)))
            {
                requestStatisticsBase = new MailboxExportRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxRelocationRequestStatistics)))
            {
                requestStatisticsBase = new MailboxRelocationRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxRestoreRequestStatistics)))
            {
                requestStatisticsBase = new MailboxRestoreRequestStatistics(rj);
            }
            else if (t.Equals(typeof(PublicFolderMoveRequestStatistics)))
            {
                requestStatisticsBase = new PublicFolderMoveRequestStatistics(rj);
            }
            else if (t.Equals(typeof(PublicFolderMigrationRequestStatistics)))
            {
                requestStatisticsBase = new PublicFolderMigrationRequestStatistics(rj);
            }
            else if (t.Equals(typeof(PublicFolderMailboxMigrationRequestStatistics)))
            {
                requestStatisticsBase = new PublicFolderMailboxMigrationRequestStatistics(rj);
            }
            else if (t.Equals(typeof(SyncRequestStatistics)))
            {
                requestStatisticsBase = new SyncRequestStatistics(rj);
            }
            else if (t.Equals(typeof(FolderMoveRequestStatistics)))
            {
                requestStatisticsBase = new FolderMoveRequestStatistics(rj);
            }
            else if (acceptBase && t.Equals(typeof(RequestStatisticsBase)))
            {
                return(RequestJobProvider.CreateRequestStatistics(rj));
            }
            if (requestStatisticsBase != null)
            {
                rj.Retire();
            }
            return(requestStatisticsBase);
        }
Example #4
0
        internal static RequestStatisticsBase CreateRequestStatistics(RequestJobXML rj)
        {
            RequestStatisticsBase requestStatisticsBase = null;

            switch (rj.RequestType)
            {
            case MRSRequestType.Move:
                requestStatisticsBase = new MoveRequestStatistics(rj);
                break;

            case MRSRequestType.Merge:
                requestStatisticsBase = new MergeRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxImport:
                requestStatisticsBase = new MailboxImportRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxExport:
                requestStatisticsBase = new MailboxExportRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxRestore:
                requestStatisticsBase = new MailboxRestoreRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMove:
                requestStatisticsBase = new PublicFolderMoveRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMigration:
                requestStatisticsBase = new PublicFolderMigrationRequestStatistics(rj);
                break;

            case MRSRequestType.Sync:
                requestStatisticsBase = new SyncRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxRelocation:
                requestStatisticsBase = new MailboxRelocationRequestStatistics(rj);
                break;

            case MRSRequestType.FolderMove:
                requestStatisticsBase = new FolderMoveRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMailboxMigration:
                requestStatisticsBase = new PublicFolderMailboxMigrationRequestStatistics(rj);
                break;
            }
            if (requestStatisticsBase != null)
            {
                rj.Retire();
            }
            return(requestStatisticsBase);
        }
Example #5
0
        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 MailboxRelocationRequestIdParameter(MailboxRelocationRequestStatistics requestStats) : base(requestStats)
 {
 }
 public static bool IsTerminalState(RequestJobBase requestJobBase)
 {
     return(requestJobBase.CancelRequest || MailboxRelocationRequestStatistics.IsTerminalState(requestJobBase.Status) || requestJobBase.SyncStage >= SyncStage.Cleanup);
 }