/// <summary> /// Restricts access to the fax functionality for the device. /// </summary> /// <param name="deviceId">The internal id of the device. If null, then ignore or don't modify attribute.</param> /// <param name="currentAccessControl">The existing <see cref="UserAccessControl"/> settings.</param> /// <param name="accessControl">The device controls to modify.</param> /// <param name="allow">Enable or disable access. If null, then ignore or don't modify attribute.</param> /// <returns>True if the call was successful, false if otherwise.</returns> protected bool SetAccessControl(uint deviceId, UserAccessControl currentAccessControl, DeviceAccessControl accessControl, bool allow = false) { return(Connect(() => { try { IEnumerable <field> fields = currentAccessControl.Fields.GetUpdatableFields(f => f.Type == typeof(bool)); if ((fields == null) || (!fields.Any())) { return (false); } IEnumerable <string> names = accessControl.GetExternalNames(); // Get all of the external names that match the requested accessControl type. // Update the requested changes. fields.AsParallel().ForAll(f => { if (names.Any(n => String.Equals(n, f.name, StringComparison.CurrentCultureIgnoreCase))) { // The external service views the ON / OFF from a RESTRICTION point of view instead of ALLOW bool toogle = !allow;// f.IsFax() ? ! allow :allow; Trace.TraceWarning("Changing accessControl '{1}' from '{2}' to '{3}' for {0}.", currentAccessControl.Id, f.name, f.value, toogle.ToOnOff()); f.value = toogle.ToOnOff(); } }); return (Update(deviceId, Convert.ToString(currentAccessControl.Index), currentAccessControl.Id, fields.ToArray(), USAGE_CONTROL_USER, false)); } catch (Exception e) { Trace.TraceError(e.Message); Trace.TraceError(e.StackTrace); throw (new RicohOperationFailedException(this, "Restrict", e)); } })); }
/// <summary> /// Checks to see if the field is one of the specified names. /// </summary> /// <param name="field">The field to check.</param> /// <param name="accessControl">The access control type to check for.</param> /// <returns>True if the field is one of the specified value, false if otherwise.</returns> public static bool Is(this field field, DeviceAccessControl accessControl) { return(Is(field, accessControl.GetExternalNames())); }