コード例 #1
0
        public static IOrganizationSettingsData GetOrganizationSettingsData(OrganizationId organizationId, IAirSyncContext context)
        {
            if (organizationId == null)
            {
                throw new ArgumentException("OrganizationId is null");
            }
            if (!ADNotificationManager.started)
            {
                throw new InvalidOperationException("ADNotificationManager should be started first!");
            }
            IConfigurationSession scopedSession     = null;
            ADObjectId            configurationUnit = organizationId.ConfigurationUnit;

            if (configurationUnit == null)
            {
                if (ADNotificationManager.enterpriseConfigurationID == null)
                {
                    scopedSession = ADNotificationManager.CreateScopedADSession(organizationId, ConsistencyMode.IgnoreInvalid);
                    ADNotificationManager.enterpriseConfigurationID = scopedSession.GetOrgContainerId();
                    if (context != null)
                    {
                        context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc);
                    }
                }
                configurationUnit = ADNotificationManager.enterpriseConfigurationID;
            }
            ADNotificationManager.ADSettingsInfo <IOrganizationSettingsData> adsettingsInfo = null;
            AirSyncDiagnostics.TraceDebug <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "Loaded ConfigurationUnit {0}", configurationUnit);
            Func <IOrganizationSettingsData> loadDataAction = () => ADNotificationManager.LoadOrganizationSettings(scopedSession ?? ADNotificationManager.CreateScopedADSession(organizationId, ConsistencyMode.PartiallyConsistent), context);

            ADNotificationManager.LoadADSettingsData <IOrganizationSettingsData>(ADNotificationManager.organizationSettingsCache, configurationUnit.DistinguishedName, loadDataAction, organizationId.PartitionId, out adsettingsInfo);
            return(adsettingsInfo.ADSettingsData);
        }