예제 #1
0
        /// <summary>
        /// Loads the access to all functions for a specific user.
        /// </summary>
        /// <param name="aUserFunctionAccessCollection">A user function access collection.</param>
        public static void Load(UserFunctionAccessCollection aUserFunctionAccessCollection)
        {
            if (aUserFunctionAccessCollection == null)
            {
                throw new ArgumentNullException("aUserFunctionAccessCollection");
            }

            // Clear the list
            aUserFunctionAccessCollection.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 URL_UserRole 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.USR_Key = @USRKey");
                vSqlCommand.Parameters.AddWithValue("@USRKey", aUserFunctionAccessCollection.UsrKey);
                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);
                        }
                        aUserFunctionAccessCollection.FunctionAccessList.Add(vFunctionAccess);
                    }
                    vSqlDataReader.Close();
                }
                vSqlCommand.Connection.Close();
            }
        }
예제 #2
0
 /// <summary>
 /// Get a Collection of <see cref="UserFunctionAccess"/>.
 /// </summary>
 /// <param name="aUserToken">A user token.</param>
 /// <param name="aUserFunctionAccessCollection">The UserFunctionAccessCollection containing the List to return</param>
 public static void GetUserFunctionAccessCollection(UserToken aUserToken, UserFunctionAccessCollection aUserFunctionAccessCollection)
 {
     UserCallHandler.ServiceCall<UserFunctionAccessCollection>(aUserToken, "GetUserFunctionAccessCollection", aUserFunctionAccessCollection);
 }
예제 #3
0
 /// <summary>
 /// Get a Collection of <see cref="UserFunctionAccess"/>.
 /// </summary>
 /// <param name="aUserToken">A user token.</param>
 /// <param name="aUserFunctionAccessCollection">The UserFunctionAccessCollection containing the List to return</param>
 public static void GetUserFunctionAccessCollection(UserToken aUserToken, UserFunctionAccessCollection aUserFunctionAccessCollection)
 {
     UserCallHandler.ServiceCall <UserFunctionAccessCollection>(aUserToken, "GetUserFunctionAccessCollection", aUserFunctionAccessCollection);
 }
예제 #4
0
        /// <summary>
        /// Loads the access to all functions for a specific user.
        /// </summary>
        /// <param name="aUserFunctionAccessCollection">A user function access collection.</param>
        public static void Load(UserFunctionAccessCollection aUserFunctionAccessCollection)
        {
            if (aUserFunctionAccessCollection == null)
            {
                throw new ArgumentNullException("aUserFunctionAccessCollection");
            }

            // Clear the list
            aUserFunctionAccessCollection.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 URL_UserRole 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.USR_Key = @USRKey");
                vSqlCommand.Parameters.AddWithValue("@USRKey", aUserFunctionAccessCollection.UsrKey);
                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);
                        }
                        aUserFunctionAccessCollection.FunctionAccessList.Add(vFunctionAccess);
                    }
                    vSqlDataReader.Close();
                }
                vSqlCommand.Connection.Close();
            }
        }