示例#1
0
        public static TransactionStatus userLogon(User aUser)
        {
            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            TransactionStatus vTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            try
            {
                ServerSession.Logon(HttpContext.Current.Session, aUser);
                vTransactionStatus.TransactionResult = TransactionResult.OK;
                vTransactionStatus.Message = "Login succesful";
                vTransactionStatus.TargetUrl = "/userdashboard.aspx";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vTransactionStatus);
            }
            catch (TransactionStatusException tx)
            {

                vTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vTransactionStatus;
            }
            catch (Exception ex)
            {
                vTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vTransactionStatus.Message = "Login Unsuccesful - please check your username and password are correct" + ex.Message;
                vTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vTransactionStatus;
            }

            return vTransactionStatus;
        }
示例#2
0
 /// <summary>
 ///   Insert a <see cref="User"/> passed as an argument via Stored Procedure that returns the newly inserted User Key 
 /// </summary>
 /// <param name="aUser">A <see cref="User"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aUser</c> argument is <c>null</c>.</exception>
 public static void Insert(User aUser)
 {
     if (aUser == null)
     {
         throw new ArgumentNullException("aUser");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into USR_User");
         vStringBuilder.AppendLine("       (USR_ID, USR_Password, USR_Name, USR_Surname, USR_Email,");
         vStringBuilder.AppendLine("        USR_Mobile, USR_Phone, USR_Fax, USR_WebContact, USR_WebTitle, USR_Avatar)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@USRID, @USRPassword, @USRName, @USRSurname, @USREmail,");
         vStringBuilder.AppendLine("        @USRMobile, @USRPhone, @USRFax, @USRWebContact, @USRWebTitle, @USRAvatar)");
         vStringBuilder.AppendLine(";");
         vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
         ObjectToData(vSqlCommand, aUser);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aUser.UsrKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
         vSqlCommand.Connection.Close();
     }
 }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="UserCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is UserCollection))
            {
                throw new ArgumentException("Invalid assignment source", "UserCollection");
            }

            _isFiltered = (aSource as UserCollection)._isFiltered;

            _userList.Clear();
            foreach (User vUserSource in (aSource as UserCollection)._userList)
            {
                User vUserTarget = new User();
                vUserTarget.AssignFromSource(vUserSource);
                _userList.Add(vUserTarget);
            }
        }
示例#6
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;
        }
示例#7
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="User"/> object.
 /// </summary>
 /// <param name="aUser">A <see cref="User"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(User aUser, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aUser.UsrKey = Convert.ToInt32(aSqlDataReader["USR_Key"]);
     aUser.UsrID = Convert.ToString(aSqlDataReader["USR_ID"]);
     aUser.UsrPassword = Convert.ToString(aSqlDataReader["USR_Password"]);
     aUser.UsrName = Convert.ToString(aSqlDataReader["USR_Name"]);
     aUser.UsrSurname = Convert.ToString(aSqlDataReader["USR_Surname"]);
     aUser.UsrEmail = Convert.ToString(aSqlDataReader["USR_Email"]);
     aUser.UsrMobile = Convert.ToString(aSqlDataReader["USR_Mobile"]);
     aUser.UsrPhone = Convert.ToString(aSqlDataReader["USR_Phone"]);
     aUser.UsrFax = Convert.ToString(aSqlDataReader["USR_Fax"]);
     aUser.UsrWebContact = Convert.ToString(aSqlDataReader["USR_WebContact"]) == "Y";
     aUser.UsrWebTitle = Convert.ToString(aSqlDataReader["USR_WebTitle"]);
     if (aIncludeAvatar)
     {
         aUser.UsrAvatar = CommonUtils.DbValueTo<byte[]>(aSqlDataReader["USR_Avatar"], null);
     }
 }
示例#8
0
 /// <summary>
 ///   Delete a <see cref="User"/> object passed as an argument.
 /// </summary>
 /// <param name="aUser">The <see cref="User"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aUser</c> argument is <c>null</c>.</exception>
 public static void Delete(User aUser)
 {
     if (aUser == null)
     {
         throw new ArgumentNullException("aUser");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete USR_User");
         vStringBuilder.AppendLine("where  USR_Key = @USRKey");
         vSqlCommand.Parameters.AddWithValue("@USRKey", aUser.UsrKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
示例#9
0
 /// <summary>
 /// Call the WebService with a request to return a User with a specified UserID
 /// </summary>
 /// <param name="aUser">The User object to return</param>
 /// <param name="aUserToken">A user token.</param>
 public static void GetUserByID(UserToken aUserToken, User aUser)
 {
     UserCallHandler.ServiceCall<User>(aUserToken, "GetUserByID", aUser);
 }
示例#10
0
 /// <summary>
 ///   Update a <see cref="User"/> passed as an argument .
 /// </summary>
 /// <param name="aUser">A <see cref="User"/>.</param>
 public static void Update(User aUser)
 {
     if (aUser == null)
     {
         throw new ArgumentNullException("aUser");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update USR_User");
         vStringBuilder.AppendLine("set    USR_ID = @USRID,");
         vStringBuilder.AppendLine("       USR_Password = @USRPassword,");
         vStringBuilder.AppendLine("       USR_Name = @USRName,");
         vStringBuilder.AppendLine("       USR_Surname = @USRSurname,");
         vStringBuilder.AppendLine("       USR_Email = @USREmail,");
         vStringBuilder.AppendLine("       USR_Mobile = @USRMobile,");
         vStringBuilder.AppendLine("       USR_Phone = @USRPhone,");
         vStringBuilder.AppendLine("       USR_Fax = @USRFax,");
         vStringBuilder.AppendLine("       USR_WebContact = @USRWebContact,");
         vStringBuilder.AppendLine("       USR_WebTitle = @USRWebTitle,");
         vStringBuilder.AppendLine("       USR_Avatar = @USRAvatar");
         vStringBuilder.AppendLine("where  USR_Key = @USRKey");
         ObjectToData(vSqlCommand, aUser);
         vSqlCommand.Parameters.AddWithValue("@USRKey", aUser.UsrKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
示例#11
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="User"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aUser">A <see cref="User"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, User aUser)
 {
     aSqlCommand.Parameters.AddWithValue("@USRID", aUser.UsrID);
     aSqlCommand.Parameters.AddWithValue("@USRPassword", aUser.UsrPassword);
     aSqlCommand.Parameters.AddWithValue("@USRName", aUser.UsrName);
     aSqlCommand.Parameters.AddWithValue("@USRSurname", aUser.UsrSurname);
     aSqlCommand.Parameters.AddWithValue("@USREmail", aUser.UsrEmail);
     aSqlCommand.Parameters.AddWithValue("@USRMobile", aUser.UsrMobile);
     aSqlCommand.Parameters.AddWithValue("@USRPhone", aUser.UsrPhone);
     aSqlCommand.Parameters.AddWithValue("@USRFax", aUser.UsrFax);
     aSqlCommand.Parameters.AddWithValue("@USRWebContact", aUser.UsrWebContact ? "Y" : "N");
     aSqlCommand.Parameters.AddWithValue("@USRWebTitle", aUser.UsrWebTitle);
     if (aUser.UsrAvatar == null)
     {
         aSqlCommand.Parameters.Add("@USRAvatar", SqlDbType.Image).Value = DBNull.Value;
     }
     else
     {
         aSqlCommand.Parameters.AddWithValue("@USRAvatar", aUser.UsrAvatar);
     }
 }
示例#12
0
 /// <summary>
 /// Loads the User by the UsrID of the argument User.
 /// </summary>
 /// <param name="aUser">A user.</param>
 public static void LoadById(User aUser)
 {
     if (aUser == null)
     {
         throw new ArgumentNullException("aUser");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(true);
         vStringBuilder.AppendLine("where USR_ID = @USRID");
         vSqlCommand.Parameters.AddWithValue("@USRID", aUser.UsrID);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!(vSqlDataReader.HasRows))
             {
                 throw new Exception(String.Format("Expected User not found: USR_ID = {0}", aUser.UsrID));
             }
             vSqlDataReader.Read();
             DataToObject(aUser, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
示例#13
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>UserList</c> property a <see cref="UserCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="User"/>, filtered by the filter properties of the passed <see cref="UserCollection"/>.
 /// </summary>
 /// <param name="aUserCollection">The <see cref="UserCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="UserCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aUserCollection</c> argument is <c>null</c>.</exception>
 public static void Load(UserCollection aUserCollection)
 {
     if (aUserCollection == null)
     {
         throw new ArgumentNullException("aUserCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(false);
         if (aUserCollection.IsFiltered)
         {
             vStringBuilder.AppendLine("where t1.USR_WebContact = 'Y'");
         }
         vStringBuilder.AppendLine("order by t1.USR_ID");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vUser = new User();
                 DataToObject(vUser, vSqlDataReader, false);
                 aUserCollection.UserList.Add(vUser);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
示例#14
0
 /// <summary>
 ///   The <c>AddUser</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="User"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="UserBusiness"/> with the newly deserialized <see cref="User"/> object.
 ///   Finally, it returns the inserted object (now with an assigned User Key) as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">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 AddUser(UserKey aUserKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of AddUser");
     }
     User vUser = new User();
     vUser = XmlUtils.Deserialize<User>(aXmlArgument);
     UserBusiness.Insert(aUserKey, vUser);
     return XmlUtils.Serialize<User>(vUser, true);
 }
示例#15
0
 /// <summary>
 ///   Gets the <see cref="User"/> by UserID.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns>User as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetUserByID(UserKey aUserKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetUserByID");
     }
     User vUser = new User();
     vUser = XmlUtils.Deserialize<User>(aXmlArgument);
     UserBusiness.LoadByID(vUser, vUser);
     return XmlUtils.Serialize<User>(vUser, true);
 }
示例#16
0
 /// <summary>
 /// Call the WebService with a request to Delete a User
 /// </summary>
 /// <param name="aUser">The User object to Delete</param>
 /// <param name="aUserToken">A user token.</param>
 public static void DeleteUser(UserToken aUserToken, User aUser)
 {
     UserCallHandler.ServiceCall<User>(aUserToken, "DeleteUser", aUser);
 }
示例#17
0
 /// <summary>
 /// Call the WebService with a request to Edit a User
 /// </summary>
 /// <param name="aUser">The User object to Edit</param>
 /// <param name="aUserToken">A user token.</param>
 public static void EditUser(UserToken aUserToken, User aUser)
 {
     UserCallHandler.ServiceCall<User>(aUserToken, "EditUser", aUser);
 }
示例#18
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);
        }