/// <summary> /// Loads the access to all functions for a specific user. /// </summary> /// <param name="aFanFunctionAccessCollection">A user function access collection.</param> public static void Load(FanFunctionAccessCollection aFanFunctionAccessCollection) { if (aFanFunctionAccessCollection == null) { throw new ArgumentNullException("aFanFunctionAccessCollection"); } // Clear the list aFanFunctionAccessCollection.FunctionAccessList.Clear(); using (var vSqlCommand = new SqlCommand() { CommandType = CommandType.Text, Connection = new SqlConnection(Connection.Instance.SqlConnectionString) }) { var vStringBuilder = new StringBuilder(); vStringBuilder.AppendLine("select FNC_Code, 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"); vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFunctionAccessCollection.FannKey); vSqlCommand.CommandText = vStringBuilder.ToString(); vSqlCommand.Connection.Open(); using (var vSqlDataReader = vSqlCommand.ExecuteReader()) { bool _haveRows = Read(vSqlDataReader); while (_haveRows) { // Create an initialized FunctionAccess FunctionAccess vFunctionAccess = new FunctionAccess(); vFunctionAccess.Function = Convert.ToString(vSqlDataReader["FNC_Code"]); vFunctionAccess.Access.AccessMap = 0; while (_haveRows && vFunctionAccess.Function == Convert.ToString(vSqlDataReader["FNC_Code"])) { vFunctionAccess.Access.Merge(new Access() { AccessMap = Convert.ToInt32(vSqlDataReader["RFC_AccessMap"]) }); _haveRows = Read(vSqlDataReader); } aFanFunctionAccessCollection.FunctionAccessList.Add(vFunctionAccess); } vSqlDataReader.Close(); } vSqlCommand.Connection.Close(); } }
/// <summary> /// Get a Collection of <see cref="FanFunctionAccess"/>. /// </summary> /// <param name="aFanToken">A fantoken.</param> /// <param name="aFanFunctionAccessCollection">The FanFunctionAccessCollection containing the List to return</param> public static void GetFanFunctionAccessCollection(FanToken aFanToken, FanFunctionAccessCollection aFanFunctionAccessCollection) { FanCallHandler.ServiceCall <FanFunctionAccessCollection>(aFanToken, "GetFanFunctionAccessCollection", aFanFunctionAccessCollection); }
/// <summary> /// Get a Collection of <see cref="FanFunctionAccess"/>. /// </summary> /// <param name="aFanToken">A fantoken.</param> /// <param name="aFanFunctionAccessCollection">The FanFunctionAccessCollection containing the List to return</param> public static void GetFanFunctionAccessCollection(FanToken aFanToken, FanFunctionAccessCollection aFanFunctionAccessCollection) { FanCallHandler.ServiceCall<FanFunctionAccessCollection>(aFanToken, "GetFanFunctionAccessCollection", aFanFunctionAccessCollection); }