Пример #1
0
        /// <summary>
        /// Gets a specific access for a user.
        /// </summary>
        /// <param name="aUserKey">A user key composite.</param>
        /// <param name="aFunction">A function.</param>
        /// <returns></returns>
        public static Access GetAccess(UserKey aUserKey, string aFunction)
        {
            UserFunctionAccess vUserFunctionAccess = new UserFunctionAccess()
            {
                UsrKey = aUserKey.UsrKey
            };

            vUserFunctionAccess.FunctionAccess.Function = aFunction;
            Load(vUserFunctionAccess);
            return(vUserFunctionAccess.FunctionAccess.Access);
        }
Пример #2
0
        /// <summary>
        ///   The <c>EditFunction</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="Function"/> object.
        ///   It invokes the <c>Update</c> method of <see cref="FunctionBusiness"/> with the newly deserialized <see cref="Function"/> 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="Function"/> as XML <see cref="string"/>.</returns>
        /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
        public static string EditFunction(UserKey aUserKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of EditFunction");
            }
            Function vFunction = new Function();

            vFunction = XmlUtils.Deserialize <Function>(aXmlArgument);
            FunctionBusiness.Update(aUserKey, vFunction);
            return(XmlUtils.Serialize <Function>(vFunction, true));
        }
Пример #3
0
        /// <summary>
        ///   The <c>DeleteUser</c> implementation method deserializes an incoming XML Argument as a new <see cref="User"/> object.
        ///   It invokes the <c>Delete</c> method of <see cref="UserBusiness"/> with the newly deserialized <see cref="User"/> object.
        ///   Finally, it returns the Deleted object unchanged as a serialized <c>string</c> of XML.
        /// </summary>
        /// <param name="aXmlArgument">A XML Argument <see cref="string"/>.</param>
        /// <returns><see cref="User"/> as XML <see cref="string"/>.</returns>
        /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
        public static string DeleteUser(UserKey aUserKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of DeleteUser");
            }
            User vUser = new User();

            vUser = XmlUtils.Deserialize <User>(aXmlArgument);
            UserBusiness.Delete(aUserKey, vUser);
            return(XmlUtils.Serialize <User>(vUser, true));
        }
Пример #4
0
        /// <summary>
        ///   The <c>GetUserCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="UserCollection"/> object.
        ///   It invokes the <c>Insert</c> method of <see cref="UserBusiness"/> with the newly deserialized <see cref="UserCollection"/> object.
        ///   Finally, it returns the collection object as a serialized <see cref="string"/> of XML.
        /// </summary>
        /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
        /// <returns><see cref="UserCollection"/> as XML <see cref="string"/>.</returns>
        /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
        public static string GetUserCollection(UserKey aUserKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of GetUserCollection");
            }
            UserCollection vUserCollection = new UserCollection();

            vUserCollection = XmlUtils.Deserialize <UserCollection>(aXmlArgument);
            UserBusiness.Load(aUserKey, vUserCollection);
            return(XmlUtils.Serialize <UserCollection>(vUserCollection, true));
        }
Пример #5
0
        /// <summary>
        ///   The <c>DeleteUserRole</c> implementation method deserializes an incoming XML Argument as a new <see cref="UserRole"/> object.
        ///   It invokes the <c>Delete</c> method of <see cref="UserRoleBusiness"/> with the newly deserialized <see cref="UserRole"/> object.
        ///   Finally, it returns the Deleted object unchanged as a serialized <c>string</c> of XML.
        /// </summary>
        /// <param name="aXmlArgument">A XML Argument <see cref="string"/>.</param>
        /// <returns><see cref="UserRole"/> as XML <see cref="string"/>.</returns>
        /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
        public static string DeleteUserRole(UserKey aUserKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of DeleteUserRole");
            }
            UserRole vUserRole = new UserRole();

            vUserRole = XmlUtils.Deserialize <UserRole>(aXmlArgument);
            UserRoleBusiness.Delete(aUserKey, vUserRole);
            return(XmlUtils.Serialize <UserRole>(vUserRole, true));
        }
Пример #6
0
        /// <summary>
        ///   The <c>EditRole</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="Role"/> object.
        ///   It invokes the <c>Update</c> method of <see cref="RoleBusiness"/> with the newly deserialized <see cref="Role"/> 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="Role"/> as XML <see cref="string"/>.</returns>
        /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
        public static string EditRole(UserKey aUserKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of EditRole");
            }
            Role vRole = new Role();

            vRole = XmlUtils.Deserialize <Role>(aXmlArgument);
            RoleBusiness.Update(aUserKey, vRole);
            return(XmlUtils.Serialize <Role>(vRole, true));
        }
Пример #7
0
        /// <summary>
        ///   The <c>DeleteRoleFunction</c> implementation method deserializes an incoming XML Argument as a new <see cref="RoleFunction"/> object.
        ///   It invokes the <c>Delete</c> method of <see cref="RoleFunctionBusiness"/> with the newly deserialized <see cref="RoleFunction"/> object.
        ///   Finally, it returns the Deleted object unchanged as a serialized <c>string</c> of XML.
        /// </summary>
        /// <param name="aXmlArgument">A 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 DeleteRoleFunction(UserKey aUserKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of DeleteRoleFunction");
            }
            RoleFunction vRoleFunction = new RoleFunction();

            vRoleFunction = XmlUtils.Deserialize <RoleFunction>(aXmlArgument);
            RoleFunctionBusiness.Delete(aUserKey, vRoleFunction);
            return(XmlUtils.Serialize <RoleFunction>(vRoleFunction, true));
        }
Пример #8
0
        /// <summary>
        /// Gets a specific access of a Specific mode for a user.
        /// </summary>
        /// <param name="aUserKey">A user key composite.</param>
        /// <param name="aFunction">A function.</param>
        /// <param name="aAccessMode">A access mode.</param>
        /// <returns></returns>
        public static bool HasModeAccess(UserKey aUserKey, string aFunction, AccessMode aAccessMode)
        {
            UserFunctionAccess vUserFunctionAccess = new UserFunctionAccess()
            {
                UsrKey = aUserKey.UsrKey
            };

            vUserFunctionAccess.FunctionAccess.Function = aFunction;
            Load(vUserFunctionAccess);
            bool vAccess = false;

            switch (aAccessMode)
            {
            case AccessMode.List:
            {
                vAccess = vUserFunctionAccess.FunctionAccess.Access.List;
                break;
            }

            case AccessMode.Read:
            {
                vAccess = vUserFunctionAccess.FunctionAccess.Access.Read;
                break;
            }

            case AccessMode.Create:
            {
                vAccess = vUserFunctionAccess.FunctionAccess.Access.Create;
                break;
            }

            case AccessMode.Update:
            {
                vAccess = vUserFunctionAccess.FunctionAccess.Access.Update;
                break;
            }

            case AccessMode.Delete:
            {
                vAccess = vUserFunctionAccess.FunctionAccess.Access.Delete;
                break;
            }

            default:
            {
                vAccess = false;
                break;
            }
            }
            return(vAccess);
        }
Пример #9
0
        /// <summary>
        ///   Insert a <see cref="FanRole"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>FanRole Key</i>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aFanRole">A <see cref="FanRole"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
        public static void Insert(UserKey aUserKey, FanRole aFanRole)
        {
            if (aFanRole == null)
            {
                throw new ArgumentNullException("Insert FanRole Business");
            }

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

            FanRoleData.Insert(aFanRole);
        }
Пример #10
0
        /// <summary>
        ///   Update a <see cref="RoleFunction"/> object passed as an argument.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aRoleFunction">A <see cref="RoleFunction"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aRoleFunction</c> argument is <c>null</c>.</exception>
        public static void Update(UserKey aUserKey, RoleFunction aRoleFunction)
        {
            if (aRoleFunction == null)
            {
                throw new ArgumentNullException("Update RoleFunction Business");
            }

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

            RoleFunctionData.Update(aRoleFunction);
        }
Пример #11
0
        /// <summary>
        ///   Insert a <see cref="User"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>User Key</i>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aUser">A <see cref="User"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aUser</c> argument is <c>null</c>.</exception>
        public static void Insert(UserKey aUserKey, User aUser)
        {
            if (aUser == null)
            {
                throw new ArgumentNullException("Insert User Business");
            }

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

            UserData.Insert(aUser);
        }
Пример #12
0
        /// <summary>
        ///   Delete a <see cref="Function"/> object passed as an argument.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aFunction">A <see cref="Function"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFunction</c> argument is <c>null</c>.</exception>
        public static void Delete(UserKey aUserKey, Function aFunction)
        {
            if (aFunction == null)
            {
                throw new ArgumentNullException("Delete Function Business");
            }

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

            FunctionData.Delete(aFunction);
        }
Пример #13
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="Role"/> object, with keys in <c>aRole</c>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aRole">A <see cref="Role"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aRole</c> is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, Role aRole)
        {
            if (aRole == null)
            {
                throw new ArgumentNullException("Load Role Business");
            }

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

            RoleData.Load(aRole);
        }
Пример #14
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="FunctionCollection"/>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aFunctionCollection">A <see cref="FunctionCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFunctionCollection</c> argument is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, FunctionCollection aFunctionCollection)
        {
            if (aFunctionCollection == null)
            {
                throw new ArgumentNullException("Load Function Business");
            }

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

            FunctionData.Load(aFunctionCollection);
        }
Пример #15
0
        /// <summary>
        ///   Update a <see cref="UserRole"/> object passed as an argument.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aUserRole">A <see cref="UserRole"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aUserRole</c> argument is <c>null</c>.</exception>
        public static void Update(UserKey aUserKey, UserRole aUserRole)
        {
            if (aUserRole == null)
            {
                throw new ArgumentNullException("Update UserRole Business");
            }

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

            UserRoleData.Update(aUserRole);
        }
Пример #16
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="User"/> object, with keys in <c>aUser</c>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aUser">A <see cref="User"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aUser</c> is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, User aUser)
        {
            if (aUser == null)
            {
                throw new ArgumentNullException("Load User Business");
            }

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

            UserData.Load(aUser);
        }
Пример #17
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="User"/> object specified by a UserID.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aUser">A <see cref="User"/> object.</param>
        /// <param name="aUserID">A UserID <see cref="string"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aUser</c> argument is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">If <c>aUserID</c> argument is <c>null</c>, empty or whitespace.</exception>
        public static void LoadByID(UserKey aUserKey, User aUser)
        {
            if (aUser == null)
            {
                throw new ArgumentNullException("LoadByID User Business");
            }
            if (String.IsNullOrWhiteSpace(aUser.UsrID))
            {
                throw new ArgumentNullException("Empty ID in LoadByID User Business");
            }

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

            UserData.LoadById(aUser);
        }
Пример #18
0
        /// <summary>
        /// Initializes the session with the Session token file located
        /// </summary>
        /// <returns></returns>
        private static UserKey InitializeSession(UserToken aUserToken)
        {
            var vUserKey = new UserKey();

            //The following body of code is commented out as this is a public system. Once PublicInterface is built
            //we will return to a regular broadcast.

            var vUser = new User()
            {
                UsrID = aUserToken.UserID
            };

            UserBusiness.LoadByID(vUserKey, vUser);
            if (String.Compare(vUser.UsrPassword, aUserToken.Password, false) != 0)
            {
                throw new Exception("User Authentication Exception");
            }
            vUserKey.UsrKey = vUser.UsrKey;

            return(vUserKey);
        }