private static void CreateUserConfiguration(StoreRetentionPolicyTagHelper tagHelper) { byte[] xmlData = MrmFaiFormatter.Serialize(tagHelper.TagData, tagHelper.defaultArchiveTagData, tagHelper.deletedTags, tagHelper.retentionHoldData, tagHelper.fullCrawlRequired, tagHelper.exchangePrincipal); CreateUserConfigurationType createUserConfiguration = new CreateUserConfigurationType { UserConfiguration = new UserConfigurationType { UserConfigurationName = new UserConfigurationNameType { Name = "MRM", Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.inbox } }, XmlData = xmlData } }; StoreRetentionPolicyTagHelper.CallEwsWithRetries(() => tagHelper.serviceBinding.CreateUserConfiguration(createUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass == ResponseClassType.Success) { ExTraceGlobals.ELCTracer.TraceDebug(0L, "Successfully created MRM user configuration"); return true; } ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration was not created"); return false; }, tagHelper); }
private static void FetchRetentionPolicyTagDataFromService(StoreRetentionPolicyTagHelper srpth) { StoreRetentionPolicyTagHelper.InitializeServiceBinding(srpth); if (srpth.serviceBinding != null) { GetUserConfigurationType getUserConfiguration = new GetUserConfigurationType { UserConfigurationName = new UserConfigurationNameType { Name = "MRM", Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.inbox } }, UserConfigurationProperties = (UserConfigurationPropertyType.Dictionary | UserConfigurationPropertyType.XmlData | UserConfigurationPropertyType.BinaryData) }; StoreRetentionPolicyTagHelper.CallEwsWithRetries(() => srpth.serviceBinding.GetUserConfiguration(getUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex) { GetUserConfigurationResponseMessageType getUserConfigurationResponseMessageType = responseMessage as GetUserConfigurationResponseMessageType; if (getUserConfigurationResponseMessageType.ResponseClass == ResponseClassType.Success && getUserConfigurationResponseMessageType.UserConfiguration != null) { if (getUserConfigurationResponseMessageType.UserConfiguration.XmlData != null) { ExTraceGlobals.ELCTracer.TraceDebug(0L, "Acquired MRM user configuration."); srpth.TagData = MrmFaiFormatter.Deserialize(getUserConfigurationResponseMessageType.UserConfiguration.XmlData, srpth.exchangePrincipal, out srpth.deletedTags, out srpth.retentionHoldData, true, out srpth.defaultArchiveTagData, out srpth.fullCrawlRequired); srpth.configItemExists = true; } else { ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration is null"); srpth.TagData = new Dictionary<Guid, StoreTagData>(); srpth.configItemExists = false; } return true; } if (getUserConfigurationResponseMessageType.ResponseClass == ResponseClassType.Error && getUserConfigurationResponseMessageType.ResponseCode == ResponseCodeType.ErrorItemNotFound) { ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration not found"); srpth.TagData = new Dictionary<Guid, StoreTagData>(); srpth.configItemExists = false; return true; } ExTraceGlobals.ELCTracer.TraceDebug(0L, "Getting MRM user configuration failed"); return false; }, srpth); return; } throw new ElcUserConfigurationException(Strings.ElcUserConfigurationServiceBindingNotAvailable); }