public static CompliancePolicySyncNotificationClient Create(IConfigurationSession configurationSession, WriteVerboseDelegate writeVerboseDelegate) { ArgumentValidator.ThrowIfNull("configurationSession", configurationSession); OrganizationId organizationId = configurationSession.GetOrgContainer().OrganizationId; return(ProvisioningCache.Instance.TryAddAndGetOrganizationDictionaryValue <CompliancePolicySyncNotificationClient, Workload>(CannedProvisioningCacheKeys.OrganizationUnifiedPolicyNotificationClients, organizationId, Workload.SharePoint, delegate() { if (writeVerboseDelegate != null) { writeVerboseDelegate(Strings.VerboseCreateNotificationClient(Workload.SharePoint.ToString())); } Uri syncSvrUrlFromCache = CompliancePolicySyncNotificationClient.GetSyncSvrUrlFromCache(SyncSvcEndPointType.RestOAuth); ICredentials credentials = UnifiedPolicyConfiguration.GetInstance().GetCredentials(configurationSession, null); Uri uri = null; Uri uri2 = null; UnifiedPolicyConfiguration.GetInstance().GetTenantSharePointUrls(configurationSession, out uri, out uri2); if (uri == null || uri2 == null || syncSvrUrlFromCache == null) { throw new CompliancePolicySyncNotificationClientException(Strings.ErrorCannotInitializeNotificationClientToSharePoint(uri, uri2, syncSvrUrlFromCache)); } SpCompliancePolicySyncNotificationClient result = new SpCompliancePolicySyncNotificationClient(uri, uri2, credentials, syncSvrUrlFromCache); if (writeVerboseDelegate != null) { writeVerboseDelegate(Strings.VerboseSpNotificationClientInfo(uri, syncSvrUrlFromCache, credentials.GetType().Name)); } return result; })); }
private static string CreateJsonNotificationBody(Guid tenantId, bool useFullSync, bool syncNow, IEnumerable <SyncChangeInfo> syncChangeInfos) { Uri syncSvrUrlFromCache = CompliancePolicySyncNotificationClient.GetSyncSvrUrlFromCache(SyncSvcEndPointType.SoapOAuth); IntuneCompliancePolicySyncNotificationClient.ODMSBody odmsbody = new IntuneCompliancePolicySyncNotificationClient.ODMSBody { Key = tenantId.ToString(), TenantId = tenantId.ToString(), SyncSvcUrl = syncSvrUrlFromCache.AbsoluteUri, FullSyncForTenant = useFullSync.ToString(), SyncNow = syncNow.ToString(), ChangeInfoList = new List <IntuneCompliancePolicySyncNotificationClient.ChangeInfo>() }; foreach (SyncChangeInfo syncChangeInfo in syncChangeInfos) { odmsbody.ChangeInfoList.Add(new IntuneCompliancePolicySyncNotificationClient.ChangeInfo { ChangeType = syncChangeInfo.ChangeType.ToString("d"), ObjectId = syncChangeInfo.ObjectId.ToString(), ObjectType = syncChangeInfo.ObjectType.ToString("d"), Version = syncChangeInfo.Version.InternalStorage.ToString() }); } string result; using (MemoryStream memoryStream = new MemoryStream()) { DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(IntuneCompliancePolicySyncNotificationClient.ODMSBody)); dataContractJsonSerializer.WriteObject(memoryStream, odmsbody); memoryStream.Seek(0L, SeekOrigin.Begin); byte[] array = new byte[memoryStream.Length]; result = ((memoryStream.Read(array, 0, (int)memoryStream.Length) > 0) ? Encoding.UTF8.GetString(array) : string.Empty); } return(result); }