예제 #1
0
        /// <summary>
        /// Deletes the record of a user in the EJS
        /// </summary>
        internal static int DeleteUserData(SqlConnection dBconnection,
                                           ejsSessionToken sessionToken, ejsUserInfo userInfo)
        {
            SqlCommand command = new SqlCommand();

            command.CommandTimeout = 60;

            try
            {
                command.Connection  = dBconnection;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "DeleteUser";

                command.Parameters.Add("OperatorId", SqlDbType.UniqueIdentifier).Value = sessionToken.UserId;
                command.Parameters.Add("UserId", SqlDbType.UniqueIdentifier).Value     = new Guid(userInfo.Id);

                SqlParameter returnValue = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
                returnValue.Direction = ParameterDirection.ReturnValue;
                command.Parameters.Add(returnValue);

                command.ExecuteNonQuery();
                int resultCode = (int)returnValue.Value;
                return(resultCode);
            }
            finally
            {
                command.Dispose();
            }
        }
예제 #2
0
        internal static int RegisterNewUser(SqlConnection dBconnection,
                                            ejsUserInfo newUser, string userName, string password,
                                            bool isAccountActive, int userGroupId)
        {
            SqlCommand command = new SqlCommand();

            command.CommandTimeout = 60;

            try
            {
                command.Connection  = dBconnection;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "RegisterNewUser";

                command.Parameters.Add("UserName", SqlDbType.VarChar, 50);
                command.Parameters.Add("Password", SqlDbType.VarChar, 512);
                command.Parameters.Add("FirstName", SqlDbType.NVarChar, 100);
                command.Parameters.Add("LastName", SqlDbType.NVarChar, 100);
                command.Parameters.Add("Email", SqlDbType.VarChar, 128);
                command.Parameters.Add("DBName", SqlDbType.VarChar, 128);
                command.Parameters.Add("IsAccountActive", SqlDbType.Bit);
                command.Parameters.Add("UserGroupId", SqlDbType.Int);
                command.Parameters.Add("UserId", SqlDbType.UniqueIdentifier);

                command.Parameters[0].Value = userName;
                command.Parameters[1].Value = password;
                command.Parameters[2].Value = newUser.FirstName;
                command.Parameters[3].Value = newUser.LastName;
                command.Parameters[4].Value = newUser.Email;
                command.Parameters[5].Value = "meetF_" + newUser.Id.ToString();
                command.Parameters[6].Value = true;
                command.Parameters[7].Value = userGroupId;
                command.Parameters[8].Value = new Guid(newUser.Id);

                SqlParameter returnValue = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
                returnValue.Direction = ParameterDirection.ReturnValue;
                command.Parameters.Add(returnValue);

                command.ExecuteNonQuery();
                int resultCode = (int)returnValue.Value;
                return(resultCode);
            }
            finally
            {
                command.Dispose();
            }
        }
예제 #3
0
        /// <summary>
        /// Updates the record for a user in the EJS
        /// </summary>
        /// <param name="operatorId">ID of the person performing the update</param>
        /// <param name="password">Send 'NoChange' for no update.</param>
        internal static int UpdateUserData(SqlConnection dBconnection,
                                           ejsSessionToken sessionToken, ejsUserInfo userInfo, string password)
        {
            SqlCommand command = new SqlCommand();

            command.CommandTimeout = 60;

            try
            {
                command.Connection  = dBconnection;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "UpdateUser";

                command.Parameters.Add("OperatorId", SqlDbType.UniqueIdentifier).Value = sessionToken.UserId;
                command.Parameters.Add("UserName", SqlDbType.VarChar, 50).Value        = userInfo.UserName;
                command.Parameters.Add("FirstName", SqlDbType.NVarChar, 100).Value     = userInfo.FirstName;
                command.Parameters.Add("LastName", SqlDbType.NVarChar, 100).Value      = userInfo.LastName;
                command.Parameters.Add("IsAccountActive", SqlDbType.Bit).Value         = userInfo.IsAccountActive;
                command.Parameters.Add("UserId", SqlDbType.UniqueIdentifier).Value     = new Guid(userInfo.Id);
                command.Parameters.Add("Email", SqlDbType.VarChar, 128).Value          = userInfo.Email;
                command.Parameters.Add("NewUserGroupId", SqlDbType.Int).Value          = userInfo.UserGroupId;

                if (password != "")
                {
                    command.Parameters.Add("Password", SqlDbType.VarChar, 512).Value = password;
                }
                else
                {
                    command.Parameters.Add("Password", SqlDbType.VarChar, 512).Value = "NoChange";
                }

                SqlParameter returnValue = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
                returnValue.Direction = ParameterDirection.ReturnValue;
                command.Parameters.Add(returnValue);

                command.ExecuteNonQuery();
                int resultCode = (int)returnValue.Value;
                return(resultCode);
            }
            finally
            {
                command.Dispose();
            }
        }