public OrganizationHasConstraintsException(UpgradeRequestTypes requestedType, string orgId, string orgName, string constraints, Exception innerException) : base(UpgradeHandlerStrings.OrganizationHasConstraints(requestedType, orgId, orgName, constraints), innerException) { this.requestedType = requestedType; this.orgId = orgId; this.orgName = orgName; this.constraints = constraints; }
public static LocalizedString UnsupportedUpgradeRequestType(UpgradeRequestTypes upgradeRequest) { return(new LocalizedString("UnsupportedUpgradeRequestType", UpgradeHandlerStrings.ResourceManager, new object[] { upgradeRequest })); }
public static LocalizedString InvalidRequestedType(string orgId, UpgradeRequestTypes currentType, string requestedType) { return(new LocalizedString("InvalidRequestedType", UpgradeHandlerStrings.ResourceManager, new object[] { orgId, currentType, requestedType })); }
public static LocalizedString OrganizationHasConstraints(UpgradeRequestTypes requestedType, string orgId, string orgName, string constraints) { return(new LocalizedString("OrganizationHasConstraints", UpgradeHandlerStrings.ResourceManager, new object[] { requestedType, orgId, orgName, constraints })); }
void IOrganizationOperation.SetUser(RecipientWrapper user, UpgradeStatusTypes status, UpgradeRequestTypes request, string message, string details, UpgradeStage?stage) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand("Set-User"); pscommand.AddParameter("Identity", user.Id.ToDNString()); if (user.UpgradeStatus != status) { pscommand.AddParameter("UpgradeStatus", status); user.UpgradeStatus = status; } if (user.UpgradeRequest != request) { pscommand.AddParameter("UpgradeRequest", request); user.UpgradeRequest = request; } if (user.UpgradeMessage != message) { pscommand.AddParameter("UpgradeMessage", message); user.UpgradeMessage = message; } if (user.UpgradeDetails != details) { pscommand.AddParameter("UpgradeDetails", details); user.UpgradeDetails = details; } if (user.UpgradeStage != stage) { pscommand.AddParameter("UpgradeStage", stage); user.UpgradeStage = stage; user.UpgradeStageTimeStamp = ((stage != null) ? new DateTime?(DateTime.UtcNow) : null); pscommand.AddParameter("UpgradeStageTimeStamp", user.UpgradeStageTimeStamp); } if (pscommand.Commands[0].Parameters.Count > 1) { this.RunPSCommandForOrgOrUser(pscommand); return; } this.Context.Logger.Log(MigrationEventType.Information, "Set-User will not be invoked because no property values have been changed", new object[0]); }
void IOrganizationOperation.SetOrganization(TenantOrganizationPresentationObjectWrapper tenant, UpgradeStatusTypes status, UpgradeRequestTypes request, string message, string details, UpgradeStage?upgradeStage, int e14MbxCountForCurrentStage, int nonUpgradeMoveRequestCount) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand("Set-Organization"); pscommand.AddParameter("Identity", tenant.ExternalDirectoryOrganizationId); if (tenant.UpgradeStatus != status) { tenant.UpgradeStatus = status; pscommand.AddParameter("UpgradeStatus", status); } if (tenant.UpgradeRequest != request) { tenant.UpgradeRequest = request; pscommand.AddParameter("UpgradeRequest", request); } if (tenant.UpgradeMessage != message) { tenant.UpgradeMessage = message; pscommand.AddParameter("UpgradeMessage", message); } if (tenant.UpgradeDetails != details) { tenant.UpgradeDetails = details; pscommand.AddParameter("UpgradeDetails", details); } if (upgradeStage != UpgradeStage.None) { DateTime?dateTime = (upgradeStage != null) ? new DateTime?(DateTime.UtcNow) : null; if (tenant.UpgradeStage != upgradeStage) { tenant.UpgradeStage = upgradeStage; pscommand.AddParameter("UpgradeStage", upgradeStage); tenant.UpgradeStageTimeStamp = dateTime; pscommand.AddParameter("UpgradeStageTimeStamp", dateTime); } if (upgradeStage == null || tenant.UpgradeE14MbxCountForCurrentStage != e14MbxCountForCurrentStage) { tenant.UpgradeE14MbxCountForCurrentStage = ((upgradeStage != null) ? new int?(e14MbxCountForCurrentStage) : null); pscommand.AddParameter("UpgradeE14MbxCountForCurrentStage", tenant.UpgradeE14MbxCountForCurrentStage); } if (upgradeStage == null || tenant.UpgradeE14RequestCountForCurrentStage != nonUpgradeMoveRequestCount) { tenant.UpgradeE14RequestCountForCurrentStage = ((upgradeStage != null) ? new int?(nonUpgradeMoveRequestCount) : null); pscommand.AddParameter("UpgradeE14RequestCountForCurrentStage", tenant.UpgradeE14RequestCountForCurrentStage); } tenant.UpgradeLastE14CountsUpdateTime = ((upgradeStage != null) ? dateTime : null); pscommand.AddParameter("UpgradeLastE14CountsUpdateTime", tenant.UpgradeLastE14CountsUpdateTime); } this.RunPSCommandForOrgOrUser(pscommand); }
internal AnchorJobProcessorResult InternalProcessEntry(ICacheEntry cacheEntryProxy) { this.queriedCount = 0; this.tenantUpdatedCount = 0; this.workItemUpdatedCount = 0; using (UpgradeHandlerSyncLog upgradeHandlerSyncLog = new UpgradeHandlerSyncLog("UpgradeHandlerSync")) { foreach (UpgradeRequestTypes upgradeRequestTypes in UpgradeHandlerScheduler.RequestTypes) { foreach (WorkItemStatus workItemStatus in UpgradeHandlerScheduler.WorkItemStatuses) { base.Context.Logger.Log(MigrationEventType.Information, "Querying UpgradeRequestType '{0}' and WorkItemStatus '{1}'", new object[] { upgradeRequestTypes, workItemStatus }); WorkItemInfo[] array; try { array = this.QueryWorkItems(workItemStatus, upgradeRequestTypes.ToString()); } catch (ErrorQueryingWorkItemException ex) { base.Context.Logger.Log(MigrationEventType.Error, "Error Querying WorkItems of Status: {0} Type: {1} Error: {2}", new object[] { workItemStatus, upgradeRequestTypes, ex.Message }); return(AnchorJobProcessorResult.Deleted); } foreach (WorkItemInfo workItemInfo in array) { TenantOrganizationPresentationObjectWrapper tenantOrganizationPresentationObjectWrapper = null; RecipientWrapper recipientWrapper = null; try { if (cacheEntryProxy is CacheEntryProxy) { AnchorJobProcessorResult anchorJobProcessorResult = base.ShouldProcessEntry(((CacheEntryProxy)cacheEntryProxy).CacheEntryBase); if (anchorJobProcessorResult != AnchorJobProcessorResult.Working) { base.Context.Logger.Log(MigrationEventType.Information, "Returning to anchor service because cacheEntry is '{0}'.", new object[] { anchorJobProcessorResult }); return(anchorJobProcessorResult); } } UpgradeRequestTypes upgradeRequestTypes2 = (UpgradeRequestTypes)Enum.Parse(typeof(UpgradeRequestTypes), workItemInfo.WorkItemType, true); string text = workItemInfo.Tenant.TenantId.ToString(); string text2 = (upgradeRequestTypes2 == UpgradeRequestTypes.PilotUpgrade) ? workItemInfo.PilotUser.PilotUserId.ToString() : null; base.Context.Logger.Log(MigrationEventType.Information, "Processing workitemId '{0}' Type '{1}' Status '{2}' for TenantId '{3}'{4}", new object[] { workItemInfo.WorkItemId, workItemInfo.WorkItemType, workItemInfo.WorkItemStatus.Status, text, (text2 != null) ? (" PilotUserId '" + text2 + "'") : string.Empty }); tenantOrganizationPresentationObjectWrapper = this.orgOperationProxy.GetOrganization(text); base.Context.Logger.Log(MigrationEventType.Information, "Found organization '{0}' ('{1}') with UpgradeRequest '{2}' UpgradeStatus '{3}'", new object[] { text, tenantOrganizationPresentationObjectWrapper.Name, tenantOrganizationPresentationObjectWrapper.UpgradeRequest, tenantOrganizationPresentationObjectWrapper.UpgradeStatus }); if (tenantOrganizationPresentationObjectWrapper.UpgradeStatus == UpgradeStatusTypes.Error) { this.UpdateWIStatus(workItemInfo, WorkItemStatus.Error, tenantOrganizationPresentationObjectWrapper.UpgradeMessage); } else { if (tenantOrganizationPresentationObjectWrapper.AdminDisplayVersion.ExchangeBuild.Major != ExchangeObjectVersion.Exchange2012.ExchangeBuild.Major && (tenantOrganizationPresentationObjectWrapper.AdminDisplayVersion.ExchangeBuild.Major != ExchangeObjectVersion.Exchange2010.ExchangeBuild.Major || tenantOrganizationPresentationObjectWrapper.AdminDisplayVersion.ExchangeBuild.Minor < 16)) { throw new InvalidOrganizationVersionException(text, tenantOrganizationPresentationObjectWrapper.AdminDisplayVersion); } if (tenantOrganizationPresentationObjectWrapper.UpgradeRequest == UpgradeRequestTypes.TenantUpgradeDryRun) { throw new OrganizationInDryRunModeException(text, workItemInfo.WorkItemType); } if (upgradeRequestTypes2 != UpgradeRequestTypes.CancelPrestageUpgrade) { TenantData tenantData = new TenantData(text); tenantData.UpdateFromTenant(tenantOrganizationPresentationObjectWrapper); if (tenantData.Constraints != null && tenantData.Constraints.Length > 0) { throw new OrganizationHasConstraintsException(upgradeRequestTypes2, text, tenantOrganizationPresentationObjectWrapper.Name, string.Join(",", tenantData.Constraints)); } } RecipientWrapper recipientWrapper2 = null; if (!this.orgOperationProxy.TryGetAnchorMailbox(text, out recipientWrapper2)) { base.Context.Logger.Log(MigrationEventType.Information, "AnchorMailbox for '{0}' not found. Need to create it.", new object[] { tenantOrganizationPresentationObjectWrapper.Name }); this.orgOperationProxy.CreateAnchorMailbox(tenantOrganizationPresentationObjectWrapper.Name); } else if (!recipientWrapper2.PersistedCapabilities.Contains(Capability.OrganizationCapabilityTenantUpgrade)) { base.Context.Logger.Log(MigrationEventType.Information, "Anchor mbx for organization '{0}' exists, but need to set TenantUpgrade capability", new object[] { text }); this.orgOperationProxy.SetTenantUpgradeCapability(recipientWrapper2.Identity, true); } WorkItemStatus newStatus = WorkItemStatus.InProgress; string comment = string.Empty; if (upgradeRequestTypes2 == UpgradeRequestTypes.PilotUpgrade && tenantOrganizationPresentationObjectWrapper.UpgradeRequest != UpgradeRequestTypes.TenantUpgrade) { recipientWrapper = this.orgOperationProxy.GetUser(text, text2); if (recipientWrapper.RecipientType != RecipientType.UserMailbox) { string text3 = string.Format("Pilot user '{0}' cannot be piloted because it is of type '{1}' instead of 'UserMailbox', completing WI", text2, recipientWrapper.RecipientType.ToString()); base.Context.Logger.Log(MigrationEventType.Information, text3, new object[0]); this.orgOperationProxy.SetUser(recipientWrapper, UpgradeStatusTypes.Complete, UpgradeRequestTypes.PilotUpgrade, text3, string.Empty, new UpgradeStage?(UpgradeStage.SyncedWorkItem)); } if (recipientWrapper.UpgradeRequest != UpgradeRequestTypes.PilotUpgrade) { base.Context.Logger.Log(MigrationEventType.Information, "PilotUpgrade. initializing user '{0}' to PilotUpgrade InProgress", new object[] { text2 }); this.orgOperationProxy.SetUser(recipientWrapper, UpgradeStatusTypes.InProgress, UpgradeRequestTypes.PilotUpgrade, string.Empty, string.Empty, new UpgradeStage?(UpgradeStage.SyncedWorkItem)); upgradeHandlerSyncLog.Write(tenantOrganizationPresentationObjectWrapper, recipientWrapper, string.Empty, string.Empty); } else { if (!Enum.TryParse <WorkItemStatus>(recipientWrapper.UpgradeStatus.ToString(), out newStatus)) { throw new InvalidUpgradeStatusException(recipientWrapper.Id.ToString(), recipientWrapper.UpgradeStatus); } comment = recipientWrapper.UpgradeMessage; } this.UpdateWIStatus(workItemInfo, newStatus, comment); } else { if (upgradeRequestTypes2 != UpgradeRequestTypes.TenantUpgrade && ((upgradeRequestTypes2 != UpgradeRequestTypes.PrestageUpgrade && upgradeRequestTypes2 != UpgradeRequestTypes.CancelPrestageUpgrade) || tenantOrganizationPresentationObjectWrapper.UpgradeRequest == UpgradeRequestTypes.TenantUpgrade)) { throw new InvalidRequestedTypeException(text, tenantOrganizationPresentationObjectWrapper.UpgradeRequest, workItemInfo.WorkItemType); } if (upgradeRequestTypes2 != tenantOrganizationPresentationObjectWrapper.UpgradeRequest) { base.Context.Logger.Log(MigrationEventType.Information, "Changing organization '{0}' from '{1}','{2}' to '{3}','InProgress'", new object[] { text, tenantOrganizationPresentationObjectWrapper.UpgradeRequest, tenantOrganizationPresentationObjectWrapper.UpgradeStatus, upgradeRequestTypes2 }); this.SetOrganization(tenantOrganizationPresentationObjectWrapper, UpgradeStatusTypes.InProgress, upgradeRequestTypes2, UpgradeStage.SyncedWorkItem); upgradeHandlerSyncLog.Write(tenantOrganizationPresentationObjectWrapper, null, string.Empty, string.Empty); } else { if (tenantOrganizationPresentationObjectWrapper.UpgradeStatus == UpgradeStatusTypes.Complete || tenantOrganizationPresentationObjectWrapper.UpgradeStatus == UpgradeStatusTypes.ForceComplete) { base.Context.Logger.Log(MigrationEventType.Information, "organization '{0}' has UpgradeStatus '{1}'. Removing Upgrade capability", new object[] { text, tenantOrganizationPresentationObjectWrapper.UpgradeStatus }); this.orgOperationProxy.SetTenantUpgradeCapability(recipientWrapper2.Identity, false); } if (!Enum.TryParse <WorkItemStatus>(tenantOrganizationPresentationObjectWrapper.UpgradeStatus.ToString(), out newStatus)) { throw new InvalidUpgradeStatusException(text, tenantOrganizationPresentationObjectWrapper.UpgradeStatus); } comment = tenantOrganizationPresentationObjectWrapper.UpgradeMessage; } this.UpdateWIStatus(workItemInfo, newStatus, comment); } } } catch (Exception ex2) { base.Context.Logger.Log(MigrationEventType.Error, "Processing workitem id '{0}' failed due to: {1}", new object[] { workItemInfo.WorkItemId, ex2.ToString() }); upgradeHandlerSyncLog.Write(tenantOrganizationPresentationObjectWrapper, recipientWrapper, ex2.GetType().ToString(), ex2.Message); try { this.UpdateWIStatus(workItemInfo, (ex2 is MigrationTransientException) ? WorkItemStatus.Warning : WorkItemStatus.Error, ex2.Message); } catch (Exception ex3) { base.Context.Logger.Log(MigrationEventType.Error, "Could not report exception for workitemId '{0}' due to: {1}", new object[] { workItemInfo.WorkItemId, ex3 }); upgradeHandlerSyncLog.Write(tenantOrganizationPresentationObjectWrapper, recipientWrapper, ex3.GetType().ToString(), ex3.Message); } try { if (recipientWrapper != null && recipientWrapper.UpgradeStatus != UpgradeStatusTypes.Warning && recipientWrapper.UpgradeStatus != UpgradeStatusTypes.Error) { this.orgOperationProxy.SetUser(recipientWrapper, UpgradeStatusTypes.Warning, recipientWrapper.UpgradeRequest, ex2.Message, ex2.ToString(), recipientWrapper.UpgradeStage); } else if (tenantOrganizationPresentationObjectWrapper != null && tenantOrganizationPresentationObjectWrapper.UpgradeStatus != UpgradeStatusTypes.Warning && tenantOrganizationPresentationObjectWrapper.UpgradeStatus != UpgradeStatusTypes.Error) { this.orgOperationProxy.SetOrganization(tenantOrganizationPresentationObjectWrapper, UpgradeStatusTypes.Warning, tenantOrganizationPresentationObjectWrapper.UpgradeRequest, ex2.Message, ex2.ToString(), tenantOrganizationPresentationObjectWrapper.UpgradeStage, -1, -1); } } catch (Exception ex4) { base.Context.Logger.Log(MigrationEventType.Error, "Could not report exception for workitemId '{0}' for '{1}' due to: {2}", new object[] { workItemInfo.WorkItemId, (recipientWrapper != null) ? recipientWrapper.ToString() : tenantOrganizationPresentationObjectWrapper.ToString(), ex4 }); upgradeHandlerSyncLog.Write(tenantOrganizationPresentationObjectWrapper, recipientWrapper, ex4.GetType().ToString(), ex4.Message); } if (!(ex2 is LocalizedException)) { throw; } } } } } } base.Context.Logger.Log(MigrationEventType.Information, "Total WorkItems Queried: {0} Total Tenants Updated: {1} Total WorkItems Updated: {2}", new object[] { this.queriedCount, this.tenantUpdatedCount, this.workItemUpdatedCount }); return(AnchorJobProcessorResult.Deleted); }
private void SetOrganization(TenantOrganizationPresentationObjectWrapper tenant, UpgradeStatusTypes workitemStatus, UpgradeRequestTypes requestType, UpgradeStage upgradeStage = UpgradeStage.None) { base.Context.Logger.Log(MigrationEventType.Information, "updating {0} organization with status {1} and type {2}", new object[] { tenant.ExternalDirectoryOrganizationId, workitemStatus, requestType }); this.orgOperationProxy.SetOrganization(tenant, workitemStatus, requestType, string.Empty, string.Empty, new UpgradeStage?(upgradeStage), -1, -1); this.tenantUpdatedCount++; }
public InvalidRequestedTypeException(string orgId, UpgradeRequestTypes currentType, string requestedType, Exception innerException) : base(UpgradeHandlerStrings.InvalidRequestedType(orgId, currentType, requestedType), innerException) { this.orgId = orgId; this.currentType = currentType; this.requestedType = requestedType; }
public UnsupportedUpgradeRequestTypeException(UpgradeRequestTypes upgradeRequest, Exception innerException) : base(UpgradeHandlerStrings.UnsupportedUpgradeRequestType(upgradeRequest), innerException) { this.upgradeRequest = upgradeRequest; }