示例#1
0
        public Groups(
            IGroupDataAccess dataAccess,
            ILogger logger)
        {
            _logger = logger;

            Process(dataAccess.GetAll());
        }
示例#2
0
        private Groups loadGroups(
            IGroupDataAccess groupDataAccess,
            ILogger log,
            IConfigValues config,
            ICaching cache,
            CacheItem cachedGroup)
        {
            Groups group = null;

            try
            {
                group = new Groups(groupDataAccess, log);
                cache.Insert(GROUP_CACHE_KEY, group);
            }
            catch (Exception exception)
            {
                log.Write(
                    "An error occurred trying to load the GROUP information. " +
                    "Likely this is because of a corrupted data in the file. " +
                    (config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile
                        ? "This request will fail, and it's likely that all other requests " +
                     "will as well. Please have someone look at this as soon as possible."
                        : "The service is configured to use the cached data, so the service will " +
                     "continue to work as normal (just without the changes made to the file. " +
                     "Someone will need to address the file issue soon, as GROUP data will get stale."),
                    LogEntrySeverityEnum.Error,
                    exception);


                if (null == cachedGroup ||
                    null == cachedGroup.Obj ||
                    config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile)
                {
                    throw;
                }

                group = (Groups)cachedGroup.Obj;
            }

            return(group);
        }
示例#3
0
        private DateTime getGroupLastModified(
            IGroupDataAccess groupDataAccess,
            ILogger log,
            IConfigValues config)
        {
            // Just preset to something in the past.
            DateTime date = DateTime.UtcNow.AddDays(-1);

            try
            {
                date = groupDataAccess.LastUpdatedUTC;
            }
            catch (Exception exception)
            {
                log.Write(
                    "An error occurred trying to load the GROUP LAST MODIFIED (LastUpdatedUTC) information. " +
                    "Likely this is because of a corrupted data in the file. " +
                    (config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile
                        ? "This request will fail, and it's likely that all other requests " +
                     "will as well. Please have someone look at this as soon as possible."
                        : "The service is configured to use the cached data, so the service will " +
                     "continue to work as normal (just without the changes made to the file. " +
                     "Someone will need to address the file issue soon, as GROUP data will get stale." +
                     "It is possible there is some BLIP that is causing the file to not be accessible too. " +
                     "If this error is repeating please escalate ASAP. If it's not, that would indicate a short " +
                     "term connectivity/permissions issue that was likely self corrected."),
                    LogEntrySeverityEnum.Error,
                    exception);


                if (config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile)
                {
                    throw;
                }
            }

            return(date);
        }
示例#4
0
        public PasswdProvider(
            IUserDataAccess userDataAccess,
            IGroupDataAccess groupDataAccess,
            ICaching cache,
            ILogger log,
            IConfigValues config)
        {
            _cache  = cache;
            _log    = log;
            _config = config;

            CacheItem cachedUser  = _cache.Get(USER_CACHE_KEY);
            CacheItem cachedGroup = _cache.Get(GROUP_CACHE_KEY);

            if (null == cachedUser ||
                null == cachedUser.Obj ||
                cachedUser.TimeAddedUTC < getUsersLastModified(userDataAccess, log, config))
            {
                _users = loadUsers(userDataAccess, log, config, cache, cachedUser);
            }
            else
            {
                _users = (Users)cachedUser.Obj;
            }

            if (null == cachedGroup ||
                null == cachedGroup.Obj ||
                cachedGroup.TimeAddedUTC < getGroupLastModified(groupDataAccess, log, config))
            {
                _groups = loadGroups(groupDataAccess, log, config, cache, cachedGroup);
            }
            else
            {
                _groups = (Groups)cachedGroup.Obj;
            }
        }
示例#5
0
 public GroupService(IGroupDataAccess data)
 {
     this.data = data;
 }
示例#6
0
 public GroupGetService(IGroupDataAccess groupDataAccess)
 {
     this.GroupDataAccess = groupDataAccess;
 }
 public GroupUpdateService(IGroupDataAccess reservationDataAccess)
 {
     GroupDataAccess = reservationDataAccess;
 }
示例#8
0
 public Groups(
     IGroupDataAccess dataAccess)
 {
     Process(dataAccess.GetAll());
 }