Esempio n. 1
0
        internal static MigrationJob GetMigrationJobByBatchId(Task task, MigrationBatchDataProvider batchProvider, MigrationBatchId migrationBatchId, bool skipCorrupt, bool failIfNotFound = true)
        {
            MigrationJob migrationJob = null;
            Exception    ex           = null;

            try
            {
                migrationJob = batchProvider.JobCache.GetJob(migrationBatchId);
            }
            catch (PropertyErrorException ex2)
            {
                ex = ex2;
            }
            catch (InvalidDataException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                MigrationLogger.Log(MigrationEventType.Warning, MigrationLogger.GetDiagnosticInfo(ex, null), new object[0]);
                task.WriteError(new MigrationPermanentException(Strings.MigrationJobCorrupted, ex), ExchangeErrorCategory.Client, null);
            }
            if (migrationJob != null && migrationJob.Status == MigrationJobStatus.Corrupted && skipCorrupt)
            {
                migrationJob = null;
            }
            if (migrationJob == null && failIfNotFound)
            {
                MigrationObjectTaskBase <TIdentityParameter> .WriteJobNotFoundError(task, migrationBatchId.ToString());
            }
            return(migrationJob);
        }
Esempio n. 2
0
        protected override void InternalProcessRecord()
        {
            MigrationBatchDataProvider migrationBatchDataProvider = (MigrationBatchDataProvider)base.DataSession;

            migrationBatchDataProvider.MigrationJob.ReportData.Append(Strings.MigrationReportJobStarted(base.ExecutingUserIdentityName));
            if (migrationBatchDataProvider.MigrationJob.IsPAW)
            {
                migrationBatchDataProvider.MigrationJob.SetMigrationFlags(migrationBatchDataProvider.MailboxProvider, MigrationFlags.Start);
            }
            else
            {
                MigrationBatchFlags migrationBatchFlags = migrationBatchDataProvider.MigrationJob.BatchFlags;
                if (this.Validate)
                {
                    migrationBatchFlags |= MigrationBatchFlags.UseAdvancedValidation;
                }
                else
                {
                    migrationBatchFlags &= ~MigrationBatchFlags.UseAdvancedValidation;
                }
                MigrationObjectTaskBase <MigrationBatchIdParameter> .StartJob(this, migrationBatchDataProvider, migrationBatchDataProvider.MigrationJob, null, migrationBatchFlags);
            }
            MigrationObjectTaskBase <MigrationBatchIdParameter> .RegisterMigrationBatch(this, migrationBatchDataProvider.MailboxSession, base.CurrentOrganizationId, false, false);

            base.InternalProcessRecord();
        }
        protected override void InternalValidate()
        {
            MigrationBatchDataProvider migrationBatchDataProvider = (MigrationBatchDataProvider)base.DataSession;

            migrationBatchDataProvider.MigrationJob = base.GetAndValidateMigrationJob(false);
            if (!this.Force)
            {
                LocalizedString?localizedString;
                bool            flag;
                if (migrationBatchDataProvider.MigrationJob.IsPAW)
                {
                    flag = migrationBatchDataProvider.MigrationJob.SupportsFlag(MigrationFlags.Remove, out localizedString);
                }
                else
                {
                    flag = migrationBatchDataProvider.MigrationJob.SupportsRemoving(out localizedString);
                }
                if (!flag)
                {
                    if (localizedString == null)
                    {
                        localizedString = new LocalizedString?(Strings.MigrationJobCannotBeRemoved);
                    }
                    base.WriteError(new LocalizedException(localizedString.Value));
                    migrationBatchDataProvider.MigrationJob = null;
                }
            }
            if (migrationBatchDataProvider.MigrationJob == null)
            {
                MigrationObjectTaskBase <MigrationBatchIdParameter> .WriteJobNotFoundError(this, this.Identity.RawIdentity);
            }
            base.InternalValidate();
        }
        protected override void InternalProcessRecord()
        {
            base.InternalProcessRecord();
            MigrationUserDataProvider migrationUserDataProvider = (MigrationUserDataProvider)base.DataSession;

            MigrationObjectTaskBase <MigrationBatchIdParameter> .RegisterMigrationBatch(this, migrationUserDataProvider.MailboxSession, base.CurrentOrganizationId, false, false);
        }
        protected override void InternalProcessRecord()
        {
            MigrationBatchDataProvider batchProvider = (MigrationBatchDataProvider)base.DataSession;

            try
            {
                MigrationHelper.RunUpdateOperation(delegate
                {
                    if (this.Force)
                    {
                        batchProvider.MigrationJob.Delete(batchProvider.MailboxProvider, true);
                        return;
                    }
                    if (batchProvider.MigrationJob.IsPAW)
                    {
                        batchProvider.MigrationJob.SetMigrationFlags(batchProvider.MailboxProvider, MigrationFlags.Remove);
                        return;
                    }
                    batchProvider.MigrationJob.RemoveJob(batchProvider.MailboxProvider);
                });
            }
            catch (ObjectNotFoundException ex)
            {
                MigrationObjectTaskBase <MigrationBatchIdParameter> .WriteJobNotFoundError(this, this.Identity.RawIdentity, ex);
            }
            batchProvider.MigrationJob.ReportData.Append(Strings.MigrationReportJobRemoved(base.ExecutingUserIdentityName));
            MigrationObjectTaskBase <MigrationBatchIdParameter> .RegisterMigrationBatch(this, batchProvider.MailboxSession, base.CurrentOrganizationId, false, false);

            base.InternalProcessRecord();
        }
Esempio n. 6
0
        protected override void InternalStateReset()
        {
            base.CurrentOrganizationId = this.ResolveCurrentOrganization();
            this.partitionMailbox      = MigrationObjectTaskBase <TIdentityParameter> .ResolvePartitionMailbox(base.Partition, base.TenantGlobalCatalogSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.ErrorLoggerDelegate(base.WriteError), base.CurrentOrganizationId == OrganizationId.ForestWideOrgId && MapiTaskHelper.IsDatacenter);

            base.InternalStateReset();
        }
Esempio n. 7
0
 protected override void InternalBeginProcessing()
 {
     base.InternalBeginProcessing();
     if (this.Organization != null)
     {
         base.CurrentOrganizationId = this.GetCurrentOrganizationId();
     }
     this.partitionMailbox = MigrationObjectTaskBase <OrganizationIdParameter> .ResolvePartitionMailbox(this.Partition, base.TenantGlobalCatalogSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.ErrorLoggerDelegate(base.WriteError), base.CurrentOrganizationId == OrganizationId.ForestWideOrgId && MapiTaskHelper.IsDatacenter);
 }
        protected override IConfigDataProvider CreateSession()
        {
            base.CurrentOrganizationId = this.ResolveCurrentOrganization();
            this.partitionMailbox      = MigrationObjectTaskBase <MigrationConfigIdParameter> .ResolvePartitionMailbox(this.Partition, base.TenantGlobalCatalogSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.ErrorLoggerDelegate(base.WriteError), base.CurrentOrganizationId == OrganizationId.ForestWideOrgId && MapiTaskHelper.IsDatacenter);

            TenantPartitionHint partitionHint = TenantPartitionHint.FromOrganizationId(base.CurrentOrganizationId);

            MigrationLogger.Initialize();
            MigrationLogContext.Current.Source       = "Set-MigrationConfig";
            MigrationLogContext.Current.Organization = base.CurrentOrganizationId.OrganizationalUnit;
            return(MigrationSessionDataProvider.CreateDataProvider("SetMigrationConfig", MigrationHelperBase.CreateRecipientSession(partitionHint), this.partitionMailbox));
        }
Esempio n. 9
0
        private void InternalProcessCsv(MigrationBatchDataProvider batchProvider)
        {
            MigrationCsvSchemaBase migrationCsvSchemaBase = MigrationCSVDataRowProvider.CreateCsvSchema(batchProvider.MigrationJob);

            if (migrationCsvSchemaBase == null)
            {
                base.WriteError(new MigrationPermanentException(Strings.MigrationCSVNotAllowed));
            }
            LocalizedException ex = MigrationObjectTaskBase <MigrationBatchIdParameter> .ProcessCsv(((MigrationBatchDataProvider)base.DataSession).MailboxProvider, this.DataObject, migrationCsvSchemaBase, this.CSVData);

            if (ex != null)
            {
                base.WriteError(ex);
            }
        }
Esempio n. 10
0
        protected override void InternalProcessRecord()
        {
            MigrationBatchDataProvider batchProvider = (MigrationBatchDataProvider)base.DataSession;
            bool      isPAW = batchProvider.MigrationJob.IsPAW;
            Exception ex    = null;

            try
            {
                if (isPAW)
                {
                    this.DataObject.CompleteAfter                = new DateTime?(DateTime.MinValue);
                    this.DataObject.CompleteAfterUTC             = new DateTime?(DateTime.MinValue);
                    this.DataObject.SubscriptionSettingsModified = (DateTime)ExDateTime.UtcNow;
                    MigrationHelper.RunUpdateOperation(delegate
                    {
                        batchProvider.MigrationJob.UpdateJob(batchProvider.MailboxProvider, false, this.DataObject);
                    });
                }
                else
                {
                    if (this.DataObject.MigrationType == MigrationType.PublicFolder)
                    {
                        this.VerifyLegacyPublicFolderDatabaseLocked();
                    }
                    MigrationHelper.RunUpdateOperation(delegate
                    {
                        batchProvider.MigrationJob.FinalizeJob(batchProvider.MailboxProvider, this.resolvedNotificationEmails);
                    });
                }
                batchProvider.MigrationJob.ReportData.Append(Strings.MigrationReportJobCompletedByUser(base.ExecutingUserIdentityName));
            }
            catch (InvalidOperationException ex2)
            {
                ex = ex2;
            }
            if (ex != null)
            {
                base.WriteError(new MigrationPermanentException(Strings.MigrationCannotBeCompleted, ex));
            }
            if (isPAW)
            {
                MigrationObjectTaskBase <MigrationBatchIdParameter> .RegisterMigrationBatch(this, batchProvider.MailboxSession, base.CurrentOrganizationId, false, false);
            }
            base.InternalProcessRecord();
        }
Esempio n. 11
0
        protected override void InternalProcessRecord()
        {
            MigrationBatchDataProvider batchProvider = (MigrationBatchDataProvider)base.DataSession;

            if (batchProvider.MigrationJob.IsPAW)
            {
                batchProvider.MigrationJob.SetMigrationFlags(batchProvider.MailboxProvider, MigrationFlags.Stop);
            }
            else
            {
                MigrationHelper.RunUpdateOperation(delegate
                {
                    batchProvider.MigrationJob.StopJob(batchProvider.MailboxProvider, batchProvider.MigrationSession.Config, JobCancellationStatus.CancelledByUserRequest);
                });
            }
            MigrationObjectTaskBase <MigrationBatchIdParameter> .RegisterMigrationBatch(this, batchProvider.MailboxSession, base.CurrentOrganizationId, false, false);

            base.InternalProcessRecord();
        }
Esempio n. 12
0
        protected override void InternalValidate()
        {
            MigrationBatchDataProvider migrationBatchDataProvider = (MigrationBatchDataProvider)base.DataSession;

            if (!migrationBatchDataProvider.MigrationSession.Config.IsSupported(MigrationFeature.MultiBatch))
            {
                base.WriteError(new MigrationPermanentException(Strings.CompleteMigrationBatchNotSupported));
            }
            migrationBatchDataProvider.MigrationJob = base.GetAndValidateMigrationJob(true);
            if (migrationBatchDataProvider.MigrationJob == null)
            {
                MigrationObjectTaskBase <MigrationBatchIdParameter> .WriteJobNotFoundError(this, this.Identity.RawIdentity);
            }
            LocalizedString?localizedString;

            if (migrationBatchDataProvider.MigrationJob.IsPAW)
            {
                if (!migrationBatchDataProvider.MigrationJob.SupportsMultiBatchFinalization)
                {
                    base.WriteError(new MigrationBatchCannotBeCompletedException(Strings.CompleteMigrationBatchNotSupported));
                }
            }
            else if (!migrationBatchDataProvider.MigrationJob.SupportsCompleting(out localizedString))
            {
                if (localizedString == null)
                {
                    localizedString = new LocalizedString?(Strings.MigrationJobCannotBeCompleted);
                }
                base.WriteError(new MigrationBatchCannotBeCompletedException(localizedString.Value));
                migrationBatchDataProvider.MigrationJob = null;
            }
            if (base.Fields.IsModified("NotificationEmails"))
            {
                this.resolvedNotificationEmails = base.GetUpdatedNotificationEmails(this.NotificationEmails);
            }
            else
            {
                this.resolvedNotificationEmails = null;
            }
            base.InternalValidate();
        }
Esempio n. 13
0
        protected override void InternalValidate()
        {
            MigrationBatchDataProvider migrationBatchDataProvider = (MigrationBatchDataProvider)base.DataSession;

            migrationBatchDataProvider.MigrationJob = base.GetAndValidateMigrationJob(true);
            bool isPAW = migrationBatchDataProvider.MigrationJob.IsPAW;

            if (migrationBatchDataProvider.MigrationJob == null)
            {
                MigrationObjectTaskBase <MigrationBatchIdParameter> .WriteJobNotFoundError(this, this.Identity.RawIdentity);
            }
            LocalizedString?localizedString;
            bool            flag;

            if (isPAW)
            {
                flag = migrationBatchDataProvider.MigrationJob.SupportsFlag(MigrationFlags.Start, out localizedString);
            }
            else
            {
                flag = migrationBatchDataProvider.MigrationJob.SupportsStarting(out localizedString);
            }
            if (!flag)
            {
                if (localizedString == null)
                {
                    localizedString = new LocalizedString?(Strings.MigrationOperationFailed);
                }
                base.WriteError(new MigrationPermanentException(localizedString.Value));
                migrationBatchDataProvider.MigrationJob = null;
            }
            if (this.Validate && (isPAW || (migrationBatchDataProvider.MigrationJob.MigrationType != MigrationType.ExchangeLocalMove && migrationBatchDataProvider.MigrationJob.MigrationType != MigrationType.ExchangeRemoteMove)))
            {
                base.WriteError(new ValidateNotSupportedException());
            }
            base.InternalValidate();
        }
Esempio n. 14
0
        internal MigrationJob GetAndValidateMigrationJob(bool skipCorrupt)
        {
            MigrationBatchDataProvider batchProvider = (MigrationBatchDataProvider)base.DataSession;

            return(MigrationObjectTaskBase <TIdentityParameter> .GetAndValidateMigrationJob(this, batchProvider, (MigrationBatchIdParameter)((object)this.Identity), skipCorrupt, true));
        }
Esempio n. 15
0
        protected override void InternalValidate()
        {
            MigrationBatchDataProvider migrationBatchDataProvider = (MigrationBatchDataProvider)base.DataSession;
            bool flag = migrationBatchDataProvider.MigrationSession.Config.IsSupported(MigrationFeature.PAW);

            migrationBatchDataProvider.MigrationJob = MigrationObjectTaskBase <MigrationBatchIdParameter> .GetAndValidateMigrationJob(this, (MigrationBatchDataProvider)base.DataSession, this.Identity, true, true);

            if (migrationBatchDataProvider.MigrationJob == null)
            {
                MigrationObjectTaskBase <MigrationBatchIdParameter> .WriteJobNotFoundError(this, this.Identity.RawIdentity);
            }
            LocalizedString?localizedString;

            if (!migrationBatchDataProvider.MigrationJob.SupportsSetting(out localizedString))
            {
                if (localizedString == null)
                {
                    localizedString = new LocalizedString?(Strings.MigrationOperationFailed);
                }
                base.WriteError(new MigrationPermanentException(localizedString.Value));
                migrationBatchDataProvider.MigrationJob = null;
            }
            if (this.CSVData != null && !migrationBatchDataProvider.MigrationJob.SupportsAppendingUsers(out localizedString))
            {
                if (localizedString == null)
                {
                    localizedString = new LocalizedString?(Strings.MigrationOperationFailed);
                }
                base.WriteError(new MigrationPermanentException(localizedString.Value));
                migrationBatchDataProvider.MigrationJob = null;
            }
            if (this.AllowIncrementalSyncs != null)
            {
                if (migrationBatchDataProvider.MigrationJob.Status == MigrationJobStatus.Stopped && !migrationBatchDataProvider.MigrationJob.AutoStop && this.AllowIncrementalSyncs.Value)
                {
                    base.WriteError(new MigrationPermanentException(Strings.MigrationPleaseUseStartForReenablingIncremental));
                }
                else if (migrationBatchDataProvider.MigrationJob.Status == MigrationJobStatus.SyncCompleted && !this.AllowIncrementalSyncs.Value)
                {
                    base.WriteError(new MigrationPermanentException(Strings.MigrationPleaseUseStopForDisablingIncremental));
                }
                if (migrationBatchDataProvider.MigrationJob.Status != MigrationJobStatus.Created && !MigrationJobStage.Sync.IsStatusSupported(migrationBatchDataProvider.MigrationJob.Status) && !MigrationJobStage.Incremental.IsStatusSupported(migrationBatchDataProvider.MigrationJob.Status))
                {
                    base.WriteError(new MigrationPermanentException(Strings.MigrationAutoStopForInProgressOnly));
                }
                if (this.AllowIncrementalSyncs.Value != migrationBatchDataProvider.MigrationJob.AutoStop)
                {
                    base.WriteError(new MigrationPermanentException(Strings.MigrationAutoStopAlreadySet));
                }
            }
            if (migrationBatchDataProvider.MigrationJob.MigrationType == MigrationType.ExchangeLocalMove && base.IsFieldSet("LargeItemLimit"))
            {
                base.WriteError(new MigrationPermanentException(Strings.MigrationNoLargeItemLimitForLocalBatches));
            }
            if (this.ReportInterval != null && !flag)
            {
                base.WriteError(new MigrationPermanentException(Strings.MigrationReportIntervalParameterInvalid));
            }
            if (base.IsFieldSet("SourcePublicFolderDatabase"))
            {
                this.ValidateSourcePublicFolderDatabase(migrationBatchDataProvider.MigrationJob);
            }
            this.ValidateSchedulingParameters(migrationBatchDataProvider.MigrationJob);
            base.InternalValidate();
        }
Esempio n. 16
0
        protected override void InternalProcessRecord()
        {
            MigrationBatchDataProvider batchProvider = (MigrationBatchDataProvider)base.DataSession;
            bool flag         = batchProvider.MigrationSession.Config.IsSupported(MigrationFeature.PAW);
            bool flag2        = false;
            bool updateEmails = false;
            bool flag3        = false;
            bool flag4        = false;

            if (flag && this.ReportInterval != null)
            {
                this.DataObject.ReportInterval = new TimeSpan?(this.ReportInterval.Value);
                flag2 = true;
            }
            if (base.Fields.IsModified("NotificationEmails"))
            {
                MultiValuedProperty <SmtpAddress> updatedNotificationEmails = MigrationObjectTaskBase <MigrationBatchIdParameter> .GetUpdatedNotificationEmails(this, base.TenantGlobalCatalogSession, this.NotificationEmails);

                if (updatedNotificationEmails != null && updatedNotificationEmails.Count != 0)
                {
                    this.DataObject.NotificationEmails = updatedNotificationEmails;
                    flag2        = true;
                    updateEmails = true;
                }
            }
            if (base.Fields.IsModified("AllowUnknownColumnsInCsv"))
            {
                this.DataObject.AllowUnknownColumnsInCsv = this.AllowUnknownColumnsInCsv;
                flag2 = true;
            }
            if (this.CSVData != null)
            {
                this.InternalProcessCsv(batchProvider);
                flag2 = true;
            }
            if (this.AllowIncrementalSyncs != null)
            {
                if (!this.AllowIncrementalSyncs.Value)
                {
                    this.DataObject.BatchFlags |= MigrationBatchFlags.AutoStop;
                }
                else
                {
                    this.DataObject.BatchFlags &= ~MigrationBatchFlags.AutoStop;
                }
                flag2 = true;
            }
            if (base.IsFieldSet("UseAdvancedValidation"))
            {
                if (this.UseAdvancedValidation)
                {
                    this.DataObject.BatchFlags |= MigrationBatchFlags.UseAdvancedValidation;
                }
                else
                {
                    this.DataObject.BatchFlags &= ~MigrationBatchFlags.UseAdvancedValidation;
                }
                flag2 = true;
            }
            if (this.AutoRetryCount != null)
            {
                this.DataObject.AutoRetryCount = this.AutoRetryCount;
                flag2 = true;
            }
            if (base.IsFieldSet("BadItemLimit") && !this.BadItemLimit.Equals(this.DataObject.BadItemLimit))
            {
                this.DataObject.BadItemLimit = this.BadItemLimit;
                flag3 = true;
                flag2 = true;
            }
            if (base.IsFieldSet("LargeItemLimit") && !this.LargeItemLimit.Equals(this.DataObject.LargeItemLimit))
            {
                this.DataObject.LargeItemLimit = this.LargeItemLimit;
                flag3 = true;
                flag2 = true;
            }
            if (base.IsFieldSet("StartAfter"))
            {
                this.DataObject.StartAfter    = this.StartAfter;
                this.DataObject.StartAfterUTC = (DateTime?)MigrationHelper.GetUniversalDateTime((ExDateTime?)this.StartAfter);
                flag3 = true;
                flag2 = true;
                flag4 = true;
            }
            if (base.IsFieldSet("CompleteAfter"))
            {
                DateTime?completeAfterUTC = (DateTime?)MigrationHelper.GetUniversalDateTime((ExDateTime?)this.CompleteAfter);
                this.DataObject.CompleteAfter    = this.CompleteAfter;
                this.DataObject.CompleteAfterUTC = completeAfterUTC;
                flag3 = true;
                flag2 = true;
                flag4 = true;
            }
            if (base.IsFieldSet("SourcePublicFolderDatabase"))
            {
                this.DataObject.SourcePublicFolderDatabase = this.SourcePublicFolderDatabase.RawIdentity;
                flag2 = true;
                flag4 = true;
                flag3 = true;
            }
            if (flag3)
            {
                this.DataObject.SubscriptionSettingsModified = (DateTime)ExDateTime.UtcNow;
            }
            if (flag2)
            {
                MigrationHelper.RunUpdateOperation(delegate
                {
                    batchProvider.MigrationJob.UpdateJob(batchProvider.MailboxProvider, updateEmails, this.DataObject);
                });
                batchProvider.MigrationJob.ReportData.Append(Strings.MigrationReportJobModifiedByUser(base.ExecutingUserIdentityName));
                this.changed = true;
                if (flag4)
                {
                    MigrationObjectTaskBase <MigrationBatchIdParameter> .RegisterMigrationBatch(this, batchProvider.MailboxSession, base.CurrentOrganizationId, false, false);
                }
            }
            base.InternalProcessRecord();
        }
Esempio n. 17
0
        internal static MigrationJob GetAndValidateMigrationJob(Task task, MigrationBatchDataProvider batchProvider, MigrationBatchIdParameter identity, bool skipCorrupt, bool failIfNotFound = true)
        {
            MigrationObjectTaskBase <TIdentityParameter> .ValidateIdentity(task, batchProvider, identity);

            return(MigrationObjectTaskBase <TIdentityParameter> .GetMigrationJobByBatchId(task, batchProvider, identity.MigrationBatchId, skipCorrupt, failIfNotFound));
        }
Esempio n. 18
0
 internal static void WriteJobNotFoundError(Task task, string identity)
 {
     MigrationObjectTaskBase <TIdentityParameter> .WriteJobNotFoundError(task, identity, null);
 }
Esempio n. 19
0
 internal MultiValuedProperty <SmtpAddress> GetUpdatedNotificationEmails(MultiValuedProperty <SmtpAddress> originalEmails)
 {
     return(MigrationObjectTaskBase <TIdentityParameter> .GetUpdatedNotificationEmails(this, base.TenantGlobalCatalogSession, originalEmails));
 }