public static void Start(IAirSyncContext context)
 {
     lock (ADNotificationManager.startLock)
     {
         if (!ADNotificationManager.started)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "ADNotificationManager is being started ...");
             ADNotificationManager.topoSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 189, "Start", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADNotificationManager.cs");
             ADNotificationManager.LoadAutoBlockThresholds();
             ADNotificationManager.started = true;
             context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, ADNotificationManager.topoSession.LastUsedDc);
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "ADNotificationManager is started.");
             int expireTimeInMinutes = (GlobalSettings.ADCacheExpirationTimeout.TotalMinutes < 1.0) ? 1 : ((int)GlobalSettings.ADCacheExpirationTimeout.TotalMinutes);
             ADNotificationManager.policies = new MruDictionaryCache <string, ADNotificationManager.ADSettingsInfo <PolicyData> >(GlobalSettings.ADCacheMaxOrgCount, GlobalSettings.ADCacheMaxOrgCount, expireTimeInMinutes);
             ADNotificationManager.organizationSettingsCache = new MruDictionaryCache <string, ADNotificationManager.ADSettingsInfo <IOrganizationSettingsData> >(GlobalSettings.ADCacheMaxOrgCount, GlobalSettings.ADCacheMaxOrgCount, expireTimeInMinutes);
             ADNotificationManager.vDirSettingsCache         = new ADObjIdToVDirMap();
         }
     }
 }
 public static DeviceAutoBlockThreshold GetAutoBlockThreshold(AutoblockThresholdType type)
 {
     AirSyncDiagnostics.TraceDebug <AutoblockThresholdType>(ExTraceGlobals.RequestsTracer, null, "GetAutoblockThreshold data.AutoblockThresholdType {0}", type);
     if (!Enum.IsDefined(typeof(AutoblockThresholdType), type))
     {
         AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, null, "InvalidAutoblockReason");
         throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateCorrupt, null, false)
               {
                   ErrorStringForProtocolLogger = "InvalidAutoblockReason"
               };
     }
     if (ADNotificationManager.autoBlockThresholds == null || ADNotificationManager.autoBlockThresholds.DeviceAutoBlockThresholds == null || ADNotificationManager.autoBlockThresholds.WhenCreated.Add(GlobalSettings.ADCacheExpirationTimeout) < ExDateTime.UtcNow)
     {
         lock (ADNotificationManager.startLock)
         {
             if (ADNotificationManager.autoBlockThresholds == null || ADNotificationManager.autoBlockThresholds.DeviceAutoBlockThresholds == null || ADNotificationManager.autoBlockThresholds.WhenCreated.Add(GlobalSettings.ADCacheExpirationTimeout) < ExDateTime.UtcNow)
             {
                 AirSyncDiagnostics.TraceDebug <AutoblockThresholdType>(ExTraceGlobals.RequestsTracer, null, "refresh AutoblockThreshold data from AD.AutoblockThresholdType {0}", type);
                 ADNotificationManager.LoadAutoBlockThresholds();
             }
         }
     }
     return(ADNotificationManager.autoBlockThresholds.DeviceAutoBlockThresholds[(int)type]);
 }