Exemplo n.º 1
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="RoleFunction"/> object.
 /// </summary>
 /// <param name="aRoleFunction">A <see cref="RoleFunction"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(RoleFunction aRoleFunction, SqlDataReader aSqlDataReader)
 {
     aRoleFunction.RolKey = Convert.ToInt32(aSqlDataReader["ROL_Key"]);
     aRoleFunction.RolName = Convert.ToString(aSqlDataReader["ROL_Name"]);
     aRoleFunction.FncKey = Convert.ToInt32(aSqlDataReader["FNC_Key"]);
     aRoleFunction.FncName = Convert.ToString(aSqlDataReader["FNC_Name"]);
     aRoleFunction.RfcAccessMap = Convert.ToInt32(aSqlDataReader["RFC_AccessMap"]);
 }
Exemplo n.º 2
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="RoleFunction"/> object, with keys in <c>aRoleFunction</c>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aRoleFunction">A <see cref="RoleFunction"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aRoleFunction</c> is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, RoleFunction aRoleFunction)
        {
            if (aRoleFunction == null)
            {
                throw new ArgumentNullException("Load RoleFunction Business");
            }

            if (!UserFunctionAccessData.HasModeAccess(aUserKey, "RoleFunction", AccessMode.Read))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.Read, "RoleFunction");
            }

            RoleFunctionData.Load(aRoleFunction);
        }
Exemplo n.º 3
0
 /// <summary>
 ///   Insert a <see cref="RoleFunction"/> passed as an argument via Stored Procedure that returns the newly inserted RoleFunction Key 
 /// </summary>
 /// <param name="aRoleFunction">A <see cref="RoleFunction"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aRoleFunction</c> argument is <c>null</c>.</exception>
 public static void Insert(RoleFunction aRoleFunction)
 {
     if (aRoleFunction == null)
     {
         throw new ArgumentNullException("aRoleFunction");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into RFC_RoleFunction");
         vStringBuilder.AppendLine("       (ROL_Key, FNC_Key, RFC_AccessMap)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@ROLKey, @FNCKey, @RFCAccessMap)");
         ObjectToData(vSqlCommand, aRoleFunction);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///   Delete a <see cref="RoleFunction"/> object passed as an argument.
 /// </summary>
 /// <param name="aRoleFunction">The <see cref="RoleFunction"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aRoleFunction</c> argument is <c>null</c>.</exception>
 public static void Delete(RoleFunction aRoleFunction)
 {
     if (aRoleFunction == null)
     {
         throw new ArgumentNullException("aRoleFunction");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete RFC_RoleFunction");
         vStringBuilder.AppendLine("where  ROL_Key = @ROLKey");
         vSqlCommand.Parameters.AddWithValue("@ROLKey", aRoleFunction.RolKey);
         vStringBuilder.AppendLine("and    FNC_Key = @FNCKey");
         vSqlCommand.Parameters.AddWithValue("@FNCKey", aRoleFunction.FncKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 ///   Update a <see cref="RoleFunction"/> passed as an argument .
 /// </summary>
 /// <param name="aRoleFunction">A <see cref="RoleFunction"/>.</param>
 public static void Update(RoleFunction aRoleFunction)
 {
     if (aRoleFunction == null)
     {
         throw new ArgumentNullException("aRoleFunction");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update RFC_RoleFunction");
         vStringBuilder.AppendLine("set    RFC_AccessMap = @RFCAccessMap");
         vStringBuilder.AppendLine("where  ROL_Key = @ROLKey");
         vStringBuilder.AppendLine("and    FNC_Key = @FNCKey");
         ObjectToData(vSqlCommand, aRoleFunction);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 6
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="RoleFunction"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aRoleFunction">A <see cref="RoleFunction"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, RoleFunction aRoleFunction)
 {
     aSqlCommand.Parameters.AddWithValue("@ROLKey", aRoleFunction.RolKey);
     aSqlCommand.Parameters.AddWithValue("@FNCKey", aRoleFunction.FncKey);
     aSqlCommand.Parameters.AddWithValue("@RFCAccessMap", aRoleFunction.RfcAccessMap);
 }
Exemplo n.º 7
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="RoleFunction"/>, with keys in the <c>aRoleFunction</c> argument.
 /// </summary>
 /// <param name="aRoleFunction">A <see cref="RoleFunction"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aRoleFunction</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(RoleFunction aRoleFunction)
 {
     if (aRoleFunction == null)
     {
         throw new ArgumentNullException("aRoleFunction");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and    t1.ROL_Key = @ROLKey");
         vSqlCommand.Parameters.AddWithValue("@ROLKey", aRoleFunction.RolKey);
         vStringBuilder.AppendLine("and    t2.FNC_Key = @FNCKey");
         vSqlCommand.Parameters.AddWithValue("@FNCKey", aRoleFunction.FncKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected RoleFunction not found: ROL_Key = {0}, FNC_Key = {1}", aRoleFunction.RolKey, aRoleFunction.FncKey));
             }
             vSqlDataReader.Read();
             DataToObject(aRoleFunction, vSqlDataReader);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 8
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>RoleFunctionList</c> property a <see cref="RoleFunctionCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="RoleFunction"/>, filtered by the filter properties of the passed <see cref="RoleFunctionCollection"/>.
 /// </summary>
 /// <param name="aRoleFunctionCollection">The <see cref="RoleFunctionCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="RoleFunctionCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aRoleFunctionCollection</c> argument is <c>null</c>.</exception>
 public static void Load(RoleFunctionCollection aRoleFunctionCollection)
 {
     if (aRoleFunctionCollection == null)
     {
         throw new ArgumentNullException("aRoleFunctionCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aRoleFunctionCollection.IsFiltered)
         {
             if (aRoleFunctionCollection.RoleKeyFilter > 0)
             {
                 vStringBuilder.AppendLine("and    t1.ROL_Key = @ROLKey");
                 vSqlCommand.Parameters.AddWithValue("@ROLKey", aRoleFunctionCollection.RoleKeyFilter);
             }
             if (aRoleFunctionCollection.FunctionKeyFilter > 0)
             {
                 vStringBuilder.AppendLine("and    t2.FNC_Key = @FNCKey");
                 vSqlCommand.Parameters.AddWithValue("@FNCKey", aRoleFunctionCollection.FunctionKeyFilter);
             }
         }
         vStringBuilder.AppendLine("order by t3.RFC_Key");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vRoleFunction = new RoleFunction();
                 DataToObject(vRoleFunction, vSqlDataReader);
                 aRoleFunctionCollection.RoleFunctionList.Add(vRoleFunction);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 9
0
 /// <summary>
 ///   The <c>EditRoleFunction</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="RoleFunction"/> object.
 ///   It invokes the <c>Update</c> method of <see cref="RoleFunctionBusiness"/> with the newly deserialized <see cref="RoleFunction"/> object.
 ///   Finally, it returns the updated object unchanged as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="RoleFunction"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string EditRoleFunction(UserKey aUserKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of EditRoleFunction");
     }
     RoleFunction vRoleFunction = new RoleFunction();
     vRoleFunction = XmlUtils.Deserialize<RoleFunction>(aXmlArgument);
     RoleFunctionBusiness.Update(aUserKey, vRoleFunction);
     return XmlUtils.Serialize<RoleFunction>(vRoleFunction, true);
 }
Exemplo n.º 10
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="RoleFunctionCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is RoleFunctionCollection))
            {
                throw new ArgumentException("Invalid assignment source", "RoleFunctionCollection");
            }

            _isFiltered = (aSource as RoleFunctionCollection)._isFiltered;
            _roleKeyFilter = (aSource as RoleFunctionCollection)._roleKeyFilter;
            _functionKeyFilter = (aSource as RoleFunctionCollection)._functionKeyFilter;
            _roleFunctionList.Clear();
            foreach (RoleFunction vRoleFunctionSource in (aSource as RoleFunctionCollection)._roleFunctionList)
            {
                RoleFunction vRoleFunctionTarget = new RoleFunction();
                vRoleFunctionTarget.AssignFromSource(vRoleFunctionSource);
                _roleFunctionList.Add(vRoleFunctionTarget);
            }
        }