protected override void InternalProcessRecord() { if (this.forwardSyncDataAccessHelper == null) { this.forwardSyncDataAccessHelper = new ForwardSyncDataAccessHelper(this.ServiceInstanceId.InstanceId); } FailedMSOSyncObject existingDivergence = this.forwardSyncDataAccessHelper.GetExistingDivergence(this.ObjectId); if (existingDivergence != null) { this.forwardSyncDataAccessHelper.UpdateExistingDivergence(existingDivergence, 1, false, false, false, true, new string[] { "TenantWideDivergenceConvertedFromCompanyDivergence" }, 1, false, true, null); } else { this.forwardSyncDataAccessHelper.PersistNewDivergence(this.ObjectId, DateTime.UtcNow, this.IsIncrementalOnly, this.IsLinkRelated, this.IsTemporary, this.IsTenantWideDivergence, new string[] { "DivergenceInjectedFromOutside" }, this.IsValidationDivergence, this.IsRetriable, null); } if (this.IsTenantWideDivergence) { this.MarkDivergenceUnhaltingForContext(this.ObjectId.ContextId); } }
public void PersistNewDivergence(SyncObjectId syncObjectId, DateTime divergenceTime, bool incrementalOnly, bool linkRelated, bool temporary, bool tenantWide, string[] errors, bool validationDivergence, bool retriable, IDictionary divergenceInfoTable) { FailedMSOSyncObject failedMSOSyncObject = new FailedMSOSyncObject(); failedMSOSyncObject.LoadDivergenceInfoXml(); failedMSOSyncObject.SetId(this.GetDivergenceObjectId(syncObjectId)); failedMSOSyncObject.ObjectId = syncObjectId; failedMSOSyncObject.DivergenceTimestamp = new DateTime?(divergenceTime); failedMSOSyncObject.IsIncrementalOnly = incrementalOnly; failedMSOSyncObject.IsLinkRelated = linkRelated; failedMSOSyncObject.IsTemporary = temporary; failedMSOSyncObject.DivergenceCount = 1; failedMSOSyncObject.IsTenantWideDivergence = tenantWide; failedMSOSyncObject.IsValidationDivergence = validationDivergence; failedMSOSyncObject.IsRetriable = retriable; if (failedMSOSyncObject.IsValidationDivergence) { failedMSOSyncObject.IsIgnoredInHaltCondition = true; } else { failedMSOSyncObject.IsIgnoredInHaltCondition = false; } failedMSOSyncObject.Errors = new MultiValuedProperty <string>(); if (errors != null) { ForwardSyncDataAccessHelper.AddErrors(errors, failedMSOSyncObject); } if (divergenceInfoTable != null) { ForwardSyncDataAccessHelper.SetDivergenceInfoValues(divergenceInfoTable, failedMSOSyncObject); failedMSOSyncObject.SaveDivergenceInfoXml(); } this.SaveDivergence(failedMSOSyncObject); }
public void UpdateExistingDivergence(FailedMSOSyncObject divergence, int occurenceCount, bool incrementalOnly, bool linkRelated, bool temporary, bool tenantWide, string[] errors, int errorListLengthLimit, bool validationDivergence, bool retriable, IDictionary divergenceInfoTable) { divergence.IsIncrementalOnly = (divergence.IsIncrementalOnly && incrementalOnly); divergence.IsLinkRelated = (divergence.IsLinkRelated || linkRelated); divergence.IsTemporary = temporary; divergence.IsTenantWideDivergence = (divergence.IsTenantWideDivergence || tenantWide); divergence.IsValidationDivergence = (divergence.IsValidationDivergence && validationDivergence); divergence.IsRetriable = retriable; if (!validationDivergence && divergence.IsValidationDivergence) { divergence.DivergenceCount = 1; } else { divergence.DivergenceCount += occurenceCount; } if (divergence.Errors == null) { divergence.Errors = new MultiValuedProperty <string>(); } if (errors != null) { ForwardSyncDataAccessHelper.AddErrors(errors, divergence); } while (divergence.Errors.Count > 0 && divergence.Errors.Count > errorListLengthLimit) { divergence.Errors.RemoveAt(0); } if (divergenceInfoTable != null) { ForwardSyncDataAccessHelper.SetDivergenceInfoValues(divergenceInfoTable, divergence); divergence.SaveDivergenceInfoXml(); } this.SaveDivergence(divergence); }
private static void SetDivergenceInfoValues(IDictionary divergenceInfoTable, FailedMSOSyncObject divergence) { Type type = divergence.GetType(); foreach (object obj in divergenceInfoTable) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; if (dictionaryEntry.Key != null && dictionaryEntry.Value != null) { PropertyInfo property = type.GetProperty(dictionaryEntry.Key.ToString()); if (property != null) { property.SetValue(divergence, (string)dictionaryEntry.Value, null); } } } }
private static void AddErrors(IEnumerable <string> errors, FailedMSOSyncObject divergence) { foreach (string text in errors) { string item = text; if (text.Length > 100000) { item = text.Substring(0, 100000); } if (!divergence.Errors.Contains(item)) { divergence.Errors.Add(item); } if (text.Contains("WorkflowDelayCreationException") && divergence.IsLinkRelated && divergence.ObjectId.ObjectClass == DirectoryObjectClass.Group) { divergence.Comment = "PSDivergenceV2_Ignore, GroupMailbox divergence should be ignored by V2"; } } }
protected override void InternalValidate() { Exception innerException; if (!NewFailedMSOSyncObject.IsValidGuid(this.ObjectId.ContextId, out innerException) || !NewFailedMSOSyncObject.IsValidGuid(this.ObjectId.ObjectId, out innerException)) { base.WriteError(new LocalizedException(DirectoryStrings.ExArgumentException("ObjectId", this.ObjectId), innerException), ExchangeErrorCategory.Client, null); } if (this.IsTenantWideDivergence) { if (this.ObjectId.ObjectClass != DirectoryObjectClass.Company || string.CompareOrdinal(this.ObjectId.ContextId, this.ObjectId.ObjectId) != 0) { base.WriteError(new InvalidObjectIdForTenantWideDivergenceException(this.ObjectId.ToString()), ExchangeErrorCategory.Client, null); } } else if ((this.ObjectId.ObjectClass != DirectoryObjectClass.Company && string.CompareOrdinal(this.ObjectId.ContextId, this.ObjectId.ObjectId) == 0) || (this.ObjectId.ObjectClass == DirectoryObjectClass.Company && string.CompareOrdinal(this.ObjectId.ContextId, this.ObjectId.ObjectId) != 0)) { base.WriteError(new LocalizedException(DirectoryStrings.ExArgumentException("ObjectId", this.ObjectId), innerException), ExchangeErrorCategory.Client, null); } if (this.forwardSyncDataAccessHelper == null) { this.forwardSyncDataAccessHelper = new ForwardSyncDataAccessHelper(this.ServiceInstanceId.InstanceId); } FailedMSOSyncObject existingDivergence = this.forwardSyncDataAccessHelper.GetExistingDivergence(this.ObjectId); if (existingDivergence != null && (!this.IsTenantWideDivergence || existingDivergence.IsTenantWideDivergence)) { base.WriteError(new DivergenceAlreadyExistsException(this.ObjectId.ToString()), ExchangeErrorCategory.Client, existingDivergence); } if (this.IsValidationDivergence && this.IsTenantWideDivergence) { base.WriteError(new CannotBeBothValidationDivergenceAndTenantWideDivergenceException(this.ObjectId.ToString()), ExchangeErrorCategory.Client, null); } if (!this.IsValidationDivergence && !this.IsRetriable) { base.WriteError(new NoneValidationDivergenceMustBeRetriableException(this.ObjectId.ToString()), ExchangeErrorCategory.Client, null); } base.InternalValidate(); }
public void UpdateExistingDivergence(FailedMSOSyncObject divergence, int occurenceCount, bool incrementalOnly, bool linkRelated, bool temporary, bool tenantWide, string[] errors, int errorListLengthLimit) { this.UpdateExistingDivergence(divergence, occurenceCount, incrementalOnly, linkRelated, temporary, tenantWide, errors, errorListLengthLimit, false, true, null); }
protected virtual ADObjectId GetDivergenceObjectId(SyncObjectId syncObjectId) { return(this.divergenceContainerObjectId.GetChildId(FailedMSOSyncObject.GetObjectName(syncObjectId))); }
protected virtual void SaveDivergence(FailedMSOSyncObject divergence) { this.configSession.Save(divergence); }
internal static void CleanUpDivergenceIds(IConfigurationSession session, FailedMSOSyncObject divergence) { divergence.ExternalDirectoryOrganizationId = null; divergence.ExternalDirectoryObjectId = null; session.Save(divergence); }
public virtual void DeleteDivergence(FailedMSOSyncObject divergence) { ForwardSyncDataAccessHelper.CleanUpDivergenceIds(this.configSession, divergence); this.configSession.Delete(divergence); }