public void TestUserCacheFilter()
        {
            var logger          = LogManager.CreateNullLogger();
            var cacheSvcFactory = new CacheServiceFactory();
            var cacheFilter     = new UserCacheFilter(logger, cacheSvcFactory);

            // create the test user
            var testUser = new ActiveDirectoryUser();

            testUser.Attributes[ActiveDirectoryService.AttributeWhenChanged]       = DateTime.Now;
            testUser.Attributes[ActiveDirectoryService.AttributeDistinguishedName] = "cn=Thomas";

            var job = new JobElement
            {
                Name = "TestJob"
            };

            var cachedCheckedUser = cacheFilter.Execute(testUser, job);

            Assert.IsNotNull(cachedCheckedUser);

            // clean up the cache filter...this will cause the cache
            // entries to be persisted to disk
            ((IDisposable)cacheFilter).Dispose();

            // validate that the cache entry is present
            // by trying to filter the user again
            cacheFilter = new UserCacheFilter(logger, cacheSvcFactory);

            cachedCheckedUser = cacheFilter.Execute(testUser, job);
            Assert.IsNull(cachedCheckedUser);
        }
Пример #2
0
        /// <summary>
        /// Opens the stream for writing
        /// </summary>
        /// <param name="jobConfig">The current job configuration.</param>
        /// <param name="streamConfig">The stream configuration.</param>
        public void Open(JobElement jobConfig, StreamElement streamConfig)
        {
            JobConfig    = jobConfig;
            StreamConfig = streamConfig;

            // get the login interval
            int loginIntervalMinutes;

            if (!int.TryParse(streamConfig.Settings["loginIntervalMinutes"], out loginIntervalMinutes))
            {
                loginIntervalMinutes = 20;
            }
            var loginInterval = loginIntervalMinutes * 60 * 1000;

            // authenticate with the c360 api
            var loginSettings = new LoginSettings
            {
                BaseAddress  = StreamConfig.Settings["baseAddress"],
                Organization = StreamConfig.Settings["organization"],
                Username     = StreamConfig.Settings["username"],
                Password     = StreamConfig.Settings["password"]
            };

            Login(loginSettings);

            // setup a task to renew the token on a regular interval
            // authenticate with the c360 api

            _timer = new Timer(Login, loginSettings, loginInterval, loginInterval);

            // load the cache services for cached content
            EmployeeCache        = CacheServiceFactory.CreateCacheService(Logger, "Employee", false);
            JobTitleCache        = CacheServiceFactory.CreateCacheService(Logger, "JobTitle", false);
            DepartmentCache      = CacheServiceFactory.CreateCacheService(Logger, "Department", false);
            WorkflowCache        = CacheServiceFactory.CreateCacheService(Logger, "Workflow", false);
            EmployeeGroupCache   = CacheServiceFactory.CreateCacheService(Logger, "EmployeeGroup", true);
            EmployeeProfileCache = CacheServiceFactory.CreateCacheService(Logger, "EmployeeProfile", false);
            DivisionCache        = CacheServiceFactory.CreateCacheService(Logger, "Division", false);
        }
Пример #3
0
 protected ICacheService GetCacheService(CacheServiceType cacheServiceType)
 {
     return(CacheServiceFactory.GetCacheService(cacheServiceType));
 }