Example #1
0
        /// <summary>
        /// The create user.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="username">
        /// The username.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        /// <param name="passwordSalt">
        /// The password salt.
        /// </param>
        /// <param name="passwordFormat">
        /// The password format.
        /// </param>
        /// <param name="email">
        /// The email.
        /// </param>
        /// <param name="passwordQuestion">
        /// The password question.
        /// </param>
        /// <param name="passwordAnswer">
        /// The password answer.
        /// </param>
        /// <param name="isApproved">
        /// The is approved.
        /// </param>
        /// <param name="providerUserKey">
        /// The provider user key.
        /// </param>
        public void CreateUser([NotNull] string appName, [NotNull] string username, [NotNull] string password, [NotNull] string passwordSalt,
                               int passwordFormat, [NotNull] string email, [NotNull] string passwordQuestion, [NotNull] string passwordAnswer,
                               bool isApproved, [NotNull] object providerUserKey)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_createuser")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Input Parameters
                cmd.Parameters.AddWithValue("Username", username);
                cmd.Parameters.AddWithValue("Password", password);
                cmd.Parameters.AddWithValue("PasswordSalt", passwordSalt);
                cmd.Parameters.AddWithValue("PasswordFormat", passwordFormat);
                cmd.Parameters.AddWithValue("Email", email);
                cmd.Parameters.AddWithValue("PasswordQuestion", passwordQuestion);
                cmd.Parameters.AddWithValue("PasswordAnswer", passwordAnswer);
                cmd.Parameters.AddWithValue("IsApproved", isApproved);
                cmd.Parameters.AddWithValue("@UTCTIMESTAMP", DateTime.UtcNow);

                // Input Output Parameters
                var paramUserKey = new SqlParameter("UserKey", SqlDbType.UniqueIdentifier);
                paramUserKey.Direction = ParameterDirection.InputOutput;
                paramUserKey.Value     = providerUserKey;
                cmd.Parameters.Add(paramUserKey);

                // Execute
                this._msSqlDbAccess.ExecuteNonQuery(cmd);

                // Retrieve Output Parameters
                providerUserKey = paramUserKey.Value;
            }
        }
Example #2
0
        /// <summary>
        /// The get user.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="providerUserKey">
        /// The provider user key.
        /// </param>
        /// <param name="userName">
        /// The user name.
        /// </param>
        /// <param name="userIsOnline">
        /// The user is online.
        /// </param>
        /// <returns>
        /// </returns>
        public DataRow GetUser([NotNull] string appName, [NotNull] object providerUserKey, [NotNull] string userName, bool userIsOnline)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_getuser")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@UserName", userName);
                cmd.Parameters.AddWithValue("@UserKey", providerUserKey);
                cmd.Parameters.AddWithValue("@UserIsOnline", userIsOnline);
                cmd.Parameters.AddWithValue("@UTCTIMESTAMP", DateTime.UtcNow);
                using (DataTable dt = this._msSqlDbAccess.GetData(cmd))
                {
                    if (dt.Rows.Count > 0)
                    {
                        return(dt.Rows[0]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// The update user.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="requiresUniqueEmail">
        /// The requires unique email.
        /// </param>
        /// <returns>
        /// The update user.
        /// </returns>
        public int UpdateUser([NotNull] object appName, [NotNull] MembershipUser user, bool requiresUniqueEmail)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_updateuser")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("UserKey", user.ProviderUserKey);
                cmd.Parameters.AddWithValue("UserName", user.UserName);
                cmd.Parameters.AddWithValue("Email", user.Email);
                cmd.Parameters.AddWithValue("Comment", user.Comment);
                cmd.Parameters.AddWithValue("IsApproved", user.IsApproved);
                cmd.Parameters.AddWithValue("LastLogin", user.LastLoginDate);
                cmd.Parameters.AddWithValue("LastActivity", user.LastActivityDate.ToUniversalTime());
                cmd.Parameters.AddWithValue("UniqueEmail", requiresUniqueEmail);

                // Add Return Value
                var p = new SqlParameter("ReturnValue", SqlDbType.Int);
                p.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(p);

                this._msSqlDbAccess.ExecuteNonQuery(cmd); // Execute Non SQL Query
                return(Convert.ToInt32(p.Value));         // Return
            }
        }
Example #4
0
 /// <summary>
 /// Database Action - Get Role Exists
 /// </summary>
 /// <param name="appName">
 /// Application Name
 /// </param>
 /// <param name="roleName">
 /// Role Name
 /// </param>
 /// <returns>
 /// Database containing Role Information
 /// </returns>
 public object GetRoleExists(object appName, object roleName)
 {
     using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_role_exists")))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("RoleName", roleName);
         return(this._msSqlDbAccess.ExecuteScalar(cmd));
     }
 }
Example #5
0
        /// <summary>
        /// The get profile structure.
        /// </summary>
        /// <returns>
        /// </returns>
        public DataTable GetProfileStructure()
        {
            string sql = @"SELECT TOP 1 * FROM {0}".FormatWith(MsSqlDbAccess.GetObjectName("prov_Profile"));

            using (var cmd = new SqlCommand(sql))
            {
                cmd.CommandType = CommandType.Text;
                return(this._msSqlDbAccess.GetData(cmd));
            }
        }
Example #6
0
 /// <summary>
 /// The delete profiles.
 /// </summary>
 /// <param name="appName">
 /// The app name.
 /// </param>
 /// <param name="userNames">
 /// The user names.
 /// </param>
 /// <returns>
 /// The delete profiles.
 /// </returns>
 public int DeleteProfiles([NotNull] object appName, [NotNull] object userNames)
 {
     using (SqlCommand cmd = MsSqlDbAccess.GetCommand("prov_profile_deleteprofiles"))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("UserNames", userNames);
         return(Convert.ToInt32(this._msSqlDbAccess.ExecuteScalar(cmd)));
     }
 }
Example #7
0
 /// <summary>
 /// Database Action - Get Roles
 /// </summary>
 /// <param name="appName">
 /// Application Name
 /// </param>
 /// <param name="username">
 /// The username.
 /// </param>
 /// <returns>
 /// Database containing Role Information
 /// </returns>
 public DataTable GetRoles(object appName, object username)
 {
     using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_role_getroles")))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("Username", username);
         return(this._msSqlDbAccess.GetData(cmd));
     }
 }
Example #8
0
 /// <summary>
 /// Database Action - Create Role
 /// </summary>
 /// <param name="appName">
 /// Application Name
 /// </param>
 /// <param name="roleName">
 /// Role Name
 /// </param>
 public void CreateRole(object appName, object roleName)
 {
     using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_role_createrole")))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("RoleName", roleName);
         this._msSqlDbAccess.ExecuteNonQuery(cmd);
     }
 }
Example #9
0
 /// <summary>
 /// Database Action - Find Users in Role
 /// </summary>
 /// <param name="appName">
 /// Application Name
 /// </param>
 /// <param name="roleName">
 /// Role Name
 /// </param>
 /// <returns>
 /// Datatable containing User Information
 /// </returns>
 public DataTable FindUsersInRole(object appName, object roleName)
 {
     using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_role_findusersinrole")))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("RoleName", roleName);
         return(this._msSqlDbAccess.GetData(cmd));
     }
 }
Example #10
0
 /// <summary>
 /// The get number inactive profiles.
 /// </summary>
 /// <param name="appName">
 /// The app name.
 /// </param>
 /// <param name="inactiveSinceDate">
 /// The inactive since date.
 /// </param>
 /// <returns>
 /// The get number inactive profiles.
 /// </returns>
 public int GetNumberInactiveProfiles([NotNull] object appName, [NotNull] object inactiveSinceDate)
 {
     using (SqlCommand cmd = MsSqlDbAccess.GetCommand("prov_profile_getnumberinactiveprofiles"))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("InactiveSinceDate", inactiveSinceDate);
         return(Convert.ToInt32(this._msSqlDbAccess.ExecuteScalar(cmd)));
     }
 }
Example #11
0
 /// <summary>
 /// Database Action - Remove User From Role
 /// </summary>
 /// <param name="appName">
 /// Application Name
 /// </param>
 /// <param name="userName">
 /// User Name
 /// </param>
 /// <param name="roleName">
 /// Role Name
 /// </param>
 public void RemoveUserFromRole(object appName, string userName, string roleName)
 {
     using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_role_removeuserfromrole")))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("Username", userName);
         cmd.Parameters.AddWithValue("RoleName", roleName);
         this._msSqlDbAccess.ExecuteNonQuery(cmd);
     }
 }
Example #12
0
        protected BaseProviderDb(string connectionStringAppKeyName)
        {
            this._dbAccess = new Lazy <IDbAccess>(() =>
            {
                var access = new MsSqlDbAccess(DbProviderFactories.GetFactory, new QueryProfile());
                var old    = access.Information.ConnectionString;
                access.Information.ConnectionString = () => ProviderConnectionStrings.TryGetValue(connectionStringAppKeyName, out var connStr) ? connStr : old();

                return(access);
            });
        }
Example #13
0
        /// <summary>
        /// The unlock user.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="userName">
        /// The user name.
        /// </param>
        public void UnlockUser([NotNull] string appName, [NotNull] string userName)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_unlockuser")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@UserName", userName);
                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #14
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            using (DataSet ds = LegacyDb.ds_forumadmin(this.PageContext.PageBoardID))
            {
                this.CategoryList.DataSource = ds.Tables[MsSqlDbAccess.GetObjectName("Category")];
            }

            // Hide the New Forum Button if there are no Categories.
            this.NewForum.Visible = this.CategoryList.Items.Count < 1;

            this.DataBind();
        }
Example #15
0
        /// <summary>
        /// The get user name by email.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="email">
        /// The email.
        /// </param>
        /// <returns>
        /// </returns>
        public DataTable GetUserNameByEmail([NotNull] string appName, [NotNull] string email)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_getusernamebyemail")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@Email", email);
                return(this._msSqlDbAccess.GetData(cmd));
            }
        }
Example #16
0
        /// <summary>
        /// The upgrade membership.
        /// </summary>
        /// <param name="previousVersion">
        /// The previous version.
        /// </param>
        /// <param name="newVersion">
        /// The new version.
        /// </param>
        public void UpgradeMembership(int previousVersion, int newVersion)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_upgrade")))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                // Nonstandard args
                cmd.Parameters.AddWithValue("@PreviousVersion", previousVersion);
                cmd.Parameters.AddWithValue("@NewVersion", newVersion);
                cmd.Parameters.AddWithValue("@UTCTIMESTAMP", DateTime.UtcNow);
                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #17
0
        /// <summary>
        /// The get all users.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="pageIndex">
        /// The page index.
        /// </param>
        /// <param name="pageSize">
        /// The page size.
        /// </param>
        /// <returns>
        /// </returns>
        public DataTable GetAllUsers([NotNull] string appName, int pageIndex, int pageSize)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_getallusers")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
                cmd.Parameters.AddWithValue("@PageSize", pageSize);
                return(this._msSqlDbAccess.GetData(cmd));
            }
        }
Example #18
0
        /// <summary>
        /// The delete user.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="username">
        /// The username.
        /// </param>
        /// <param name="deleteAllRelatedData">
        /// The delete all related data.
        /// </param>
        public void DeleteUser([NotNull] string appName, [NotNull] string username, bool deleteAllRelatedData)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_deleteuser")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@Username", username);
                cmd.Parameters.AddWithValue("@DeleteAllRelated", deleteAllRelatedData);
                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #19
0
 /// <summary>
 /// The get profiles.
 /// </summary>
 /// <param name="appName">
 /// The app name.
 /// </param>
 /// <param name="pageIndex">
 /// The page index.
 /// </param>
 /// <param name="pageSize">
 /// The page size.
 /// </param>
 /// <param name="userNameToMatch">
 /// The user name to match.
 /// </param>
 /// <param name="inactiveSinceDate">
 /// The inactive since date.
 /// </param>
 /// <returns>
 /// </returns>
 public DataSet GetProfiles([NotNull] object appName, [NotNull] object pageIndex, [NotNull] object pageSize, [NotNull] object userNameToMatch, [NotNull] object inactiveSinceDate)
 {
     using (SqlCommand cmd = MsSqlDbAccess.GetCommand("prov_profile_getprofiles"))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ApplicationName", appName);
         cmd.Parameters.AddWithValue("PageIndex", pageIndex);
         cmd.Parameters.AddWithValue("PageSize", pageSize);
         cmd.Parameters.AddWithValue("UserNameToMatch", userNameToMatch);
         cmd.Parameters.AddWithValue("InactiveSinceDate", inactiveSinceDate);
         return(this._msSqlDbAccess.GetDataset(cmd));
     }
 }
Example #20
0
        /// <summary>
        /// The change password question and answer.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="username">
        /// The username.
        /// </param>
        /// <param name="passwordQuestion">
        /// The password question.
        /// </param>
        /// <param name="passwordAnswer">
        /// The password answer.
        /// </param>
        public void ChangePasswordQuestionAndAnswer([NotNull] string appName, [NotNull] string username, [NotNull] string passwordQuestion, [NotNull] string passwordAnswer)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_changepasswordquestionandanswer")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@Username", username);
                cmd.Parameters.AddWithValue("@PasswordQuestion", passwordQuestion);
                cmd.Parameters.AddWithValue("@PasswordAnswer", passwordAnswer);
                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #21
0
        /// <summary>
        /// The get user password info.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="username">
        /// The username.
        /// </param>
        /// <param name="updateUser">
        /// The update user.
        /// </param>
        /// <returns>
        /// </returns>
        public DataTable GetUserPasswordInfo([NotNull] string appName, [NotNull] string username, bool updateUser)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_getuser")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@Username", username);
                cmd.Parameters.AddWithValue("@UserIsOnline", updateUser);
                cmd.Parameters.AddWithValue("@UTCTIMESTAMP", DateTime.UtcNow);
                return(this._msSqlDbAccess.GetData(cmd));
            }
        }
Example #22
0
        /// <summary>
        /// The find users by name.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="usernameToMatch">
        /// The username to match.
        /// </param>
        /// <param name="pageIndex">
        /// The page index.
        /// </param>
        /// <param name="pageSize">
        /// The page size.
        /// </param>
        /// <returns>
        /// </returns>
        public DataTable FindUsersByName([NotNull] string appName, [NotNull] string usernameToMatch, int pageIndex, int pageSize)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_findusersbyname")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@Username", usernameToMatch);
                cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
                cmd.Parameters.AddWithValue("@PageSize", pageSize);
                return(this._msSqlDbAccess.GetData(cmd));
            }
        }
Example #23
0
        /// <summary>
        /// Bind data for this control.
        /// </summary>
        private void BindData()
        {
            // get list of forums and their moderating data
            using (DataSet ds = LegacyDb.forum_moderatelist(this.PageContext.PageUserID, this.PageContext.PageBoardID))
            {
                this.CategoryList.DataSource = ds.Tables[MsSqlDbAccess.GetObjectName("Category")];
            }

            // bind data to controls
            this.DataBind();

            if (this.CategoryList.Items.Count.Equals(0))
            {
                this.InfoPlaceHolder.Visible = true;
            }
        }
Example #24
0
        /// <summary>
        /// The change password.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="username">
        /// The username.
        /// </param>
        /// <param name="newPassword">
        /// The new password.
        /// </param>
        /// <param name="newSalt">
        /// The new salt.
        /// </param>
        /// <param name="passwordFormat">
        /// The password format.
        /// </param>
        /// <param name="newPasswordAnswer">
        /// The new password answer.
        /// </param>
        public void ChangePassword([NotNull] string appName, [NotNull] string username, [NotNull] string newPassword, [NotNull] string newSalt, int passwordFormat, [NotNull] string newPasswordAnswer)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_changepassword")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@Username", username);
                cmd.Parameters.AddWithValue("@Password", newPassword);
                cmd.Parameters.AddWithValue("@PasswordSalt", newSalt);
                cmd.Parameters.AddWithValue("@PasswordFormat", passwordFormat);
                cmd.Parameters.AddWithValue("@PasswordAnswer", newPasswordAnswer);

                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #25
0
        /// <summary>
        /// The get number of users online.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="timeWindow">
        /// The time window.
        /// </param>
        /// <returns>
        /// The get number of users online.
        /// </returns>
        public int GetNumberOfUsersOnline([NotNull] string appName, int timeWindow)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_getnumberofusersonline")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@TimeWindow", timeWindow);
                cmd.Parameters.AddWithValue("@CurrentTimeUtc", DateTime.UtcNow);
                var p = new SqlParameter("ReturnValue", SqlDbType.Int);
                p.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(p);
                this._msSqlDbAccess.ExecuteNonQuery(cmd);
                return(Convert.ToInt32(cmd.Parameters["ReturnValue"].Value));
            }
        }
Example #26
0
        /// <summary>
        /// Database Action - Delete Role
        /// </summary>
        /// <param name="appName">
        /// Application Name
        /// </param>
        /// <param name="roleName">
        /// Role Name
        /// </param>
        /// <param name="deleteOnlyIfRoleIsEmpty">
        /// The delete Only If Role Is Empty.
        /// </param>
        /// <returns>
        /// Status as integer
        /// </returns>
        public int DeleteRole(object appName, object roleName, object deleteOnlyIfRoleIsEmpty)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_role_deleterole")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("ApplicationName", appName);
                cmd.Parameters.AddWithValue("RoleName", roleName);
                cmd.Parameters.AddWithValue("DeleteOnlyIfRoleIsEmpty", deleteOnlyIfRoleIsEmpty);

                var p = new SqlParameter("ReturnValue", SqlDbType.Int);
                p.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(p);

                this._msSqlDbAccess.ExecuteNonQuery(cmd);

                return(Convert.ToInt32(cmd.Parameters["ReturnValue"].Value));
            }
        }
Example #27
0
        /// <summary>
        /// The add profile column.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="columnType">
        /// The column type.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        public void AddProfileColumn([NotNull] string name, SqlDbType columnType, int size)
        {
            // get column type...
            string type = columnType.ToString();

            if (size > 0)
            {
                type += "(" + size + ")";
            }

            string sql = "ALTER TABLE {0} ADD [{1}] {2} NULL".FormatWith(
                MsSqlDbAccess.GetObjectName("prov_Profile"), name, type);

            using (var cmd = new SqlCommand(sql))
            {
                cmd.CommandType = CommandType.Text;
                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #28
0
        public static DataTable post_list(
            object topicId,
            object authorUserID,
            object updateViewCount,
            bool showDeleted,
            bool styledNicks,
            DateTime sincePostedDate,
            DateTime toPostedDate,
            DateTime sinceEditedDate,
            DateTime toEditedDate,
            int pageIndex,
            int pageSize,
            int sortPosted,
            int sortEdited,
            int sortPosition,
            bool showThanks,
            int messagePosition)
        {
            using (var cmd = MsSqlDbAccess.GetCommand("sueetie_post_list"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("TopicID", topicId);
                cmd.Parameters.AddWithValue("AuthorUserID", authorUserID);
                cmd.Parameters.AddWithValue("UpdateViewCount", updateViewCount);
                cmd.Parameters.AddWithValue("ShowDeleted", showDeleted);
                cmd.Parameters.AddWithValue("StyledNicks", styledNicks);
                cmd.Parameters.AddWithValue("SincePostedDate", sincePostedDate);
                cmd.Parameters.AddWithValue("ToPostedDate", toPostedDate);
                cmd.Parameters.AddWithValue("SinceEditedDate", sinceEditedDate);
                cmd.Parameters.AddWithValue("ToEditedDate", toEditedDate);
                cmd.Parameters.AddWithValue("PageIndex", pageIndex);
                cmd.Parameters.AddWithValue("PageSize", pageSize);
                cmd.Parameters.AddWithValue("SortPosted", sortPosted);
                cmd.Parameters.AddWithValue("SortEdited", sortEdited);
                cmd.Parameters.AddWithValue("SortPosition", sortPosition);
                cmd.Parameters.AddWithValue("ShowThanks", showThanks);
                cmd.Parameters.AddWithValue("MessagePosition", messagePosition);

                return(MsSqlDbAccess.Current.GetData(cmd));
            }
        }
Example #29
0
        /// <summary>
        /// The reset password.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="userName">
        /// The user name.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        /// <param name="passwordSalt">
        /// The password salt.
        /// </param>
        /// <param name="passwordFormat">
        /// The password format.
        /// </param>
        /// <param name="maxInvalidPasswordAttempts">
        /// The max invalid password attempts.
        /// </param>
        /// <param name="passwordAttemptWindow">
        /// The password attempt window.
        /// </param>
        public void ResetPassword([NotNull] string appName, [NotNull] string userName, [NotNull] string password, [NotNull] string passwordSalt,
                                  int passwordFormat,
                                  int maxInvalidPasswordAttempts,
                                  int passwordAttemptWindow)
        {
            using (var cmd = new SqlCommand(MsSqlDbAccess.GetObjectName("prov_resetpassword")))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ApplicationName", appName);

                // Nonstandard args
                cmd.Parameters.AddWithValue("@UserName", userName);
                cmd.Parameters.AddWithValue("@Password", password);
                cmd.Parameters.AddWithValue("@PasswordSalt", passwordSalt);
                cmd.Parameters.AddWithValue("@PasswordFormat", passwordFormat);
                cmd.Parameters.AddWithValue("@MaxInvalidAttempts", maxInvalidPasswordAttempts);
                cmd.Parameters.AddWithValue("@PasswordAttemptWindow", passwordAttemptWindow);
                cmd.Parameters.AddWithValue("@CurrentTimeUtc", DateTime.UtcNow);

                this._msSqlDbAccess.ExecuteNonQuery(cmd);
            }
        }
 /// <summary>
 /// Tests database connection. Can probably be moved to DB class.
 /// </summary>
 /// <param name="exceptionMessage">
 /// The exception message.
 /// </param>
 /// <returns>
 /// The test database connection.
 /// </returns>
 public bool TestDatabaseConnection([NotNull] out string exceptionMessage)
 {
     return(MsSqlDbAccess.TestConnection(out exceptionMessage));
 }