Пример #1
0
        public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig)
        {
            NotificationOption opt = GetOptions(type);

            if (opt != null && opt.Enabled)
            {
                if (opt.SendToUserMode == SendToUserType.All)
                {
                    return(true);
                }

                if (opt.SendToUserMode == SendToUserType.Admins && userConfig.IsAdministrator)
                {
                    return(true);
                }

                return(opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase));
            }

            return(false);
        }
Пример #2
0
 public UserConfig(UserConfiguration data)
 {
     this._data = data;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDto"/> class.
 /// </summary>
 public UserDto()
 {
     Configuration = new UserConfiguration();
     Policy = new UserPolicy();
 }
Пример #4
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     // Don't block. Let either the entire series rating or episode rating determine it
     return false;
 }
Пример #5
0
        private async Task UpdateConfiguration(User user, UserConfiguration config, bool fireEvent)
        {
            var path = GetConfigurationFilePath(user);

            // The xml serializer will output differently if the type is not exact
            if (config.GetType() != typeof(UserConfiguration))
            {
                var json = _jsonSerializer.SerializeToString(config);
                config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
            }

			_fileSystem.CreateDirectory(Path.GetDirectoryName(path));

            lock (_configSyncLock)
            {
                _xmlSerializer.SerializeToFile(config, path);
                user.Configuration = config;
            }

            if (fireEvent)
            {
                EventHelper.FireEventIfNotNull(UserConfigurationUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
            }
        }
Пример #6
0
 public Task UpdateConfiguration(string userId, UserConfiguration config)
 {
     var user = GetUserById(userId);
     return UpdateConfiguration(user, config, true);
 }
Пример #7
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
 }
Пример #8
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     return config.BlockUnratedMusic;
 }
Пример #9
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     // Don't block. 
     return false;
 }
Пример #10
0
        public void UpdateConfiguration(User user, UserConfiguration newConfiguration)
        {
            var xmlPath = user.ConfigurationFilePath;
            Directory.CreateDirectory(Path.GetDirectoryName(xmlPath));
            _xmlSerializer.SerializeToFile(newConfiguration, xmlPath);

            EventHelper.FireEventIfNotNull(UserConfigurationUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
        }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDto"/> class.
 /// </summary>
 public UserDto()
 {
     Configuration = new UserConfiguration();
 }
Пример #12
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="serializer">The serializer.</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        public void UpdateConfiguration(UserConfiguration config, IXmlSerializer serializer)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            var customLibraryChanged = config.UseCustomLibrary != Configuration.UseCustomLibrary;

            Configuration = config;
            SaveConfiguration(serializer);

            // Force these to be lazy loaded again
            if (customLibraryChanged)
            {
                RootFolder = null;
            }
        }
Пример #13
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        public void UpdateConfiguration(UserConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            Configuration = config;
            UserManager.UpdateConfiguration(this, Configuration);
        }
Пример #14
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="serializer">The serializer.</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        public void UpdateConfiguration(UserConfiguration config, IXmlSerializer serializer)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            Configuration = config;
            SaveConfiguration();
        }
Пример #15
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
 }
Пример #16
0
        public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig)
        {
            NotificationOption opt = GetOptions(type);

            if (opt != null && opt.Enabled)
            {
                if (opt.SendToUserMode == SendToUserType.All)
                {
                    return true;
                }

                if (opt.SendToUserMode == SendToUserType.Admins && userConfig.IsAdministrator)
                {
                    return true;
                }

                return ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId);
            }

            return false;
        }