/// <summary> /// Gets a specific access for a user. /// </summary> /// <param name="aFanKey">A user key composite.</param> /// <param name="aFunction">A function.</param> /// <returns></returns> public static Access GetAccess(FanKey aFanKey, string aFunction) { FanFunctionAccess vFanFunctionAccess = new FanFunctionAccess() { FannKey = aFanKey.FannKey }; vFanFunctionAccess.FunctionAccess.Function = aFunction; Load(vFanFunctionAccess); return vFanFunctionAccess.FunctionAccess.Access; }
/// <summary> /// Gets a specific access for a user. /// </summary> /// <param name="aFanKey">A user key composite.</param> /// <param name="aFunction">A function.</param> /// <returns></returns> public static Access GetAccess(FanKey aFanKey, string aFunction) { FanFunctionAccess vFanFunctionAccess = new FanFunctionAccess() { FannKey = aFanKey.FannKey }; vFanFunctionAccess.FunctionAccess.Function = aFunction; Load(vFanFunctionAccess); return(vFanFunctionAccess.FunctionAccess.Access); }
/// <summary> /// Gets a specific access of a Specific mode for a user. /// </summary> /// <param name="aFanKey">A user key composite.</param> /// <param name="aFunction">A function.</param> /// <param name="aAccessMode">A access mode.</param> /// <returns></returns> public static bool HasModeAccess(FanKey aFanKey, string aFunction, AccessMode aAccessMode) { FanFunctionAccess vFanFunctionAccess = new FanFunctionAccess() { FannKey = aFanKey.FannKey }; vFanFunctionAccess.FunctionAccess.Function = aFunction; Load(vFanFunctionAccess); bool vAccess = false; switch (aAccessMode) { case AccessMode.List: { vAccess = vFanFunctionAccess.FunctionAccess.Access.List; break; } case AccessMode.Read: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Read; break; } case AccessMode.Create: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Create; break; } case AccessMode.Update: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Update; break; } case AccessMode.Delete: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Delete; break; } default: { vAccess = false; break; } } return(vAccess); }
/// <summary> /// Loads the access to a specific function for a specific user. /// </summary> /// <param name="aFanFunctionAccess">A user function access.</param> public static void Load(FanFunctionAccess aFanFunctionAccess) { if (aFanFunctionAccess == null) { throw new ArgumentNullException("aFanFunctionAccess"); } // Clear the map aFanFunctionAccess.FunctionAccess.Access.AccessMap = 0; using (var vSqlCommand = new SqlCommand() { CommandType = CommandType.Text, Connection = new SqlConnection(Connection.Instance.SqlConnectionString) }) { var vStringBuilder = new StringBuilder(); vStringBuilder.AppendLine("select RFC_AccessMap"); vStringBuilder.AppendLine("from FRL_FanRole t1, RFC_RoleFunction t2, FNC_Function t3"); vStringBuilder.AppendLine("where t1.ROL_Key = t2.ROL_Key"); vStringBuilder.AppendLine("and t2.FNC_Key = t3.FNC_Key"); vStringBuilder.AppendLine("and t1.FAN_Key = @FANKey"); vStringBuilder.AppendLine("and t3.FNC_Code = @FNCCode"); vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFunctionAccess.FannKey); vSqlCommand.Parameters.AddWithValue("@FNCCode", aFanFunctionAccess.FunctionAccess.Function); vSqlCommand.CommandText = vStringBuilder.ToString(); vSqlCommand.Connection.Open(); using (var vSqlDataReader = vSqlCommand.ExecuteReader()) { bool _haveRows = Read(vSqlDataReader); while (_haveRows) { aFanFunctionAccess.FunctionAccess.Access.Merge(new Access() { AccessMap = Convert.ToInt32(vSqlDataReader["RFC_AccessMap"]) }); _haveRows = Read(vSqlDataReader); } aFanFunctionAccess.FunctionAccess.Access.Loaded = true; vSqlDataReader.Close(); } vSqlCommand.Connection.Close(); } }
/// <summary> /// Gets a specific access of a Specific mode for a user. /// </summary> /// <param name="aFanKey">A user key composite.</param> /// <param name="aFunction">A function.</param> /// <param name="aAccessMode">A access mode.</param> /// <returns></returns> public static bool HasModeAccess(FanKey aFanKey, string aFunction, AccessMode aAccessMode) { FanFunctionAccess vFanFunctionAccess = new FanFunctionAccess() { FannKey = aFanKey.FannKey }; vFanFunctionAccess.FunctionAccess.Function = aFunction; Load(vFanFunctionAccess); bool vAccess = false; switch (aAccessMode) { case AccessMode.List: { vAccess = vFanFunctionAccess.FunctionAccess.Access.List; break; } case AccessMode.Read: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Read; break; } case AccessMode.Create: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Create; break; } case AccessMode.Update: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Update; break; } case AccessMode.Delete: { vAccess = vFanFunctionAccess.FunctionAccess.Access.Delete; break; } default: { vAccess = false; break; } } return vAccess; }
/// <summary> /// Get a specific <see cref="FanFunctionAccess"/>. /// </summary> /// <param name="aFanToken">A fantoken.</param> /// <param name="aFanFunctionAccess">The FanFunctionAccess to return</param> public static void GetFanFunctionAccessCollection(FanToken aFanToken, FanFunctionAccess aFanFunctionAccess) { FanCallHandler.ServiceCall <FanFunctionAccess>(aFanToken, "GetFanFunctionAccess", aFanFunctionAccess); }
/// <summary> /// Get a specific <see cref="FanFunctionAccess"/>. /// </summary> /// <param name="aFanToken">A fantoken.</param> /// <param name="aFanFunctionAccess">The FanFunctionAccess to return</param> public static void GetFanFunctionAccessCollection(FanToken aFanToken, FanFunctionAccess aFanFunctionAccess) { FanCallHandler.ServiceCall<FanFunctionAccess>(aFanToken, "GetFanFunctionAccess", aFanFunctionAccess); }