// ********************************************************************* // GetAllRoles // /// <summary> /// All the roles that the system supports /// </summary> /// <returns>String array of roles</returns> // ***********************************************************************/ public static String[] GetAllRoles() { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetAllRoles()); }
// ********************************************************************* // CreateNewUser // /// <summary> /// Creates a new user. /// </summary> /// <param name="user">A User object containing information about the user to create. Only the /// Username and Email properties are used here.</param> /// <returns></returns> /// <remarks>This method chooses a random password for the user and emails the user his new Username/password. /// From that point on, the user can configure their settings.</remarks> /// // ********************************************************************/ public static CreateUserStatus CreateNewUser(User user, bool needToSendEmail) { // Make sure the username begins with an alpha character if (!Regex.IsMatch(user.Username, "^[A-Za-z].*")) { return(CreateUserStatus.InvalidFirstCharacter); } // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); // do we have a password? if (user.Password == String.Empty) { // assign a temporary password const int passwordLength = 10; user.Password = Globals.CreateTemporaryPassword(passwordLength); needToSendEmail = true; } CreateUserStatus status = dp.CreateNewUser(user); // create the user account if (status == CreateUserStatus.Created && needToSendEmail) { // send an email to the user with their new logon info Emails.SendEmail(user.Username, EmailTypeEnum.NewUserAccountCreated); } return(status); }
// ********************************************************************* // TotalNumberOfUserAccounts // /// <summary> /// Calculates and returns the total number of user accounts. /// </summary> /// <returns>The total number of user accounts created.</returns> /// // ********************************************************************/ public static int TotalNumberOfUserAccounts(string usernameBeginsWith, string usernameToFind) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.TotalNumberOfUserAccounts(usernameBeginsWith, usernameToFind)); }
// ********************************************************************* // GetForumsNotModeratedByUser // /// <summary> /// Returns a list of forums that are NOT moderated by the specified user. /// </summary> /// <param name="Username">The Username of the user whose list of non-moderated forums you /// are interested in.</param> /// <returns>A ModeratedForumColelction containing a listing of the forums NOT moderated by the /// specified user.</returns> /// // ********************************************************************/ public static ModeratedForumCollection GetForumsNotModeratedByUser(String Username) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetForumsNotModeratedByUser(Username)); }
// ********************************************************************* // RemoveModeratedForumForUser // /// <summary> /// Removes a forum from the user's list of moderated forums. /// </summary> /// <param name="forum">A ModeratedForum object specifying the forum to remove.</param> /// // ********************************************************************/ public static void RemoveModeratedForumForUser(ModeratedForum forum) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); dp.RemoveModeratedForumForUser(forum); }
// ********************************************************************* // FindUsersByName // /// <summary> /// Returns a user collection of users that match the string provided /// </summary> /// <param name="emailAddress">String to match on.</param> /// <returns>Username</returns> /// // ********************************************************************/ public static UserCollection FindUsersByName(int pageIndex, int pageSize, string usernameToMatch) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.FindUsersByName(pageIndex, pageSize, usernameToMatch)); }
// ********************************************************************* // GetUsersByFirstCharacter // /// <summary> /// Returns a list of users whose username starts with FirstCharacter. /// </summary> /// <param name="FirstCharacter">The starting letter of users you are interested in /// viewing.</param> /// <returns>A UserCollection populated with the users whose Username begins with FirstCharacter.</returns> /// // ********************************************************************/ public static UserCollection GetUsersByFirstCharacter(String FirstCharacter) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetUsersByFirstCharacter(FirstCharacter)); }
// ********************************************************************* // GetAllForumGroups // /// <summary> /// Returns a list of all forum groups /// </summary> /// <param name="displayForumGroupsNotApproved">If true returns all forum groups</param> /// <param name="allowFromCache">Whether or not the request can be satisfied from the Cache</param> /// // ********************************************************************/ public static ForumGroupCollection GetAllForumGroups(bool displayForumGroupsNotApproved, bool allowFromCache) { string cacheKey = "AllForumGroups-" + displayForumGroupsNotApproved + HttpContext.Current.User.Identity.Name; ForumGroupCollection forums; // This doesn't change a whole lot so we'll cache values if ((HttpContext.Current.Cache[cacheKey] != null) && (allowFromCache)) { forums = (ForumGroupCollection)HttpContext.Current.Cache[cacheKey]; } else { IDataProviderBase dp = DataProvider.Instance(); forums = dp.GetAllForumGroups(displayForumGroupsNotApproved, HttpContext.Current.User.Identity.Name); // Sort the forum groups forums.Sort(); HttpContext.Current.Cache.Insert(cacheKey, forums, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero); // Add all the forums to the cache as well foreach (ForumGroup f in forums) { HttpContext.Current.Cache.Insert("ForumGroup-" + f.ForumGroupID, f, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero); } } forums.Sort(); return(forums); }
// ********************************************************************* // UpdateForumGroup // /// <summary> /// Update a forum group name /// </summary> /// <param name="forumGroupName">new name value</param> /// <param name="forumGroupId">id of forum group to replace new name value with</param> // ********************************************************************/ public static void UpdateForumGroup(string forumGroupName, int forumGroupId) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); dp.UpdateForumGroup(forumGroupName, forumGroupId); }
public static Rating GetRatingForUser(string username, int parentID) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetRatingForUser(username, parentID)); }
public static void AddRating(Rating rating) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); dp.AddRating(rating); }
public static Rating GetRating(int postID) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetRating(postID)); }
// ********************************************************************* // GetUserRoles // /// <summary> /// All the roles that the named user belongs to /// </summary> /// <param name="username">Name of user to retrieve roles for</param> /// <returns>String array of roles</returns> // ***********************************************************************/ public static String[] GetUserRoles(string username) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetUserRoles(username)); }
// ********************************************************************* // GetForumRoles // /// <summary> /// Get all of the roles that a given forum belongs to /// </summary> /// <returns>String array of roles</returns> // ***********************************************************************/ public static String[] GetForumRoles(int forumID) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetForumRoles(forumID)); }
public void TestAtConstructorInitiererDataProviderBase() { using (IDataProviderBase <IDataReader, IDbCommand> sut = CreateSut()) { Assert.That(sut, Is.Not.Null); } }
// ********************************************************************* // AddForumGroup // /// <summary> /// Adds a new forum group /// </summary> /// <param name="forumGroupName">Name of new forum group to create.</param> /// // ********************************************************************/ public static void AddForumGroup(string forumGroupName) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); dp.AddForumGroup(forumGroupName); }
// ********************************************************************* // GetUsernameByEmail // /// <summary> /// Returns a username given a user's email address. /// </summary> /// <param name="emailAddress">Email address to look up username by.</param> /// <returns>Username</returns> /// // ********************************************************************/ public static string GetUsernameByEmail(string emailAddress) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetUsernameByEmail(emailAddress)); }
// ********************************************************************* // GetAllThreads // /// <summary> /// Returns a collection of threads based on the properties specified /// </summary> /// <param name="forumID">Id of the forum to retrieve posts from</param> /// <param name="username">Username asking for the threads</param> /// <param name="unreadThreadsOnly">Return unread threads</param> /// <returns>A collection of threads</returns> // ***********************************************************************/ public static ThreadCollection GetAllThreads(int forumID, string username, bool unreadThreadsOnly) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetAllThreads(forumID, username, unreadThreadsOnly)); }
// ********************************************************************* // UpdateUserInfo // /// <summary> /// Updates a user's personal information. /// </summary> /// <param name="user">The user to update. The Username indicates what user to update.</param> /// <param name="NewPassword">If the user is changing their password, the user's new password. /// Otherwise, this should be the user's existing password.</param> /// <returns>This method returns a boolean: it returns True if /// the update succeeds, false otherwise. (The update might fail if the user enters an /// incorrect password.)</returns> /// <remarks>For the user to update their information, they must supply their password. Therefore, /// the Password property of the user object passed in should be set to the user's existing password. /// The NewPassword parameter should contain the user's new password (if they are changing it) or /// existing password if they are not. From this method, only the user's personal information can /// be updated (the user's password, forum view settings, email address, etc.); to update the user's /// system-level settings (whether or not they are banned, their trusted status, etc.), use the /// UpdateUserInfoFromAdminPage method. <seealso cref="UpdateUserInfoFromAdminPage"/></remarks> /// // ********************************************************************/ public static bool UpdateUserProfile(User user) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); bool updatePasswordSucceded = false; // we need to strip the <script> tags from input forms user.Signature = StripScriptTagsFromInput(user.Signature); user.AolIM = Globals.HtmlEncode(user.AolIM); user.Email = Globals.HtmlEncode(user.Email); user.PublicEmail = Globals.HtmlEncode(user.PublicEmail); user.IcqIM = Globals.HtmlEncode(user.IcqIM); user.Interests = Globals.HtmlEncode(user.Interests); user.Location = Globals.HtmlEncode(user.Location); user.MsnIM = Globals.HtmlEncode(user.MsnIM); user.Occupation = Globals.HtmlEncode(user.Occupation); user.Url = Globals.HtmlEncode(user.Url); user.Username = StripScriptTagsFromInput(user.Username); user.YahooIM = Globals.HtmlEncode(user.YahooIM); // Call the underlying update updatePasswordSucceded = dp.UpdateUserProfile(user); // Remove from the cache if it exists HttpContext.Current.Cache.Remove("UserInfo-" + user.Username); return(updatePasswordSucceded); }
// ********************************************************************* // GetThreadsUserMostRecentlyParticipatedIn // /// <summary> /// Returns threads that the user has recently participated in. /// </summary> /// <param name="username">Username to get tracked posts for</param> /// <returns>Thread collection of threads</returns> // ***********************************************************************/ public static ThreadCollection GetThreadsUserMostRecentlyParticipatedIn(string username) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetThreadsUserMostRecentlyParticipatedIn(username)); }
// ********************************************************************* // UpdateUserInfoFromAdminPage // /// <summary> /// Updates a user's system-level information. /// </summary> /// <param name="user">A user object containing information to be updated. The Username /// property specifies what user should be updated.</param> /// <remarks>This method updates a user's system-level information: their approved status, their /// trusted status, etc. To update a user's personal information (such as their password, /// signature, homepage Url, etc.), use the UpdateUserInfo method. <seealso cref="UpdateUserInfo"/></remarks> /// // ********************************************************************/ public static void UpdateUserInfoFromAdminPage(User user) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); dp.UpdateUserInfoFromAdminPage(user); }
// ********************************************************************* // GetThreadsUserIsTracking // /// <summary> /// Returns threads that the user has email tracking enabled for. /// </summary> /// <param name="username">Username to get tracked posts for</param> /// <returns>Thread collection of threads being tracked</returns> // ***********************************************************************/ public static ThreadCollection GetThreadsUserIsTracking(string username) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetThreadsUserIsTracking(username)); }
// ********************************************************************* // ToggleOptions // /// <summary> /// Toggle various user options /// </summary> /// <param name="username">Name of user we're updating</param> /// <param name="hideReadThreads">Hide threads that the user has already read</param> /// <param name="viewOptions">How the user views posts</param> /// // ********************************************************************/ public static void ToggleOptions(string username, bool hideReadThreads, ViewOptions viewOptions) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); dp.ToggleOptions(username, hideReadThreads, viewOptions); }
// ********************************************************************* // GetAllThreads // /// <summary> /// Returns a collection of threads based on the properties specified /// </summary> /// <param name="forumID">Id of the forum to retrieve posts from</param> /// <param name="pageSize">Number of results to return</param> /// <param name="pageIndex">Location in results set to return</param> /// <param name="endDate">Results before this date</param> /// <param name="username">Username asking for the threads</param> /// <param name="unreadThreadsOnly">Return unread threads</param> /// <returns>A collection of threads</returns> // ***********************************************************************/ public static ThreadCollection GetAllThreads(int forumID, int pageSize, int pageIndex, DateTime endDate, string username, bool unreadThreadsOnly) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); ThreadCollection threads; // If the user is anonymous take some load off the db if (username == null) { if (HttpContext.Current.Cache["Thread-" + forumID + pageSize.ToString() + pageIndex.ToString() + endDate.ToString()] != null) { return((ThreadCollection)HttpContext.Current.Cache["Thread-" + forumID + pageSize.ToString() + pageIndex.ToString() + endDate.ToString()]); } } // Get the threads threads = dp.GetAllThreads(forumID, pageSize, pageIndex, endDate, username, unreadThreadsOnly); if (username == null) { HttpContext.Current.Cache.Insert("Thread-" + forumID + pageSize.ToString() + pageIndex.ToString() + endDate.ToString(), threads, null, DateTime.Now.AddMinutes(1), TimeSpan.Zero); } return(threads); }
// ********************************************************************* // ValidUser // /// <summary> /// Determines if the user is a valid user. /// </summary> /// <param name="user">The user to check. Note that the Username and Password properties of the /// User object must be set.</param> /// <returns>A boolean: true if the user's Username/password are valid; false if they are not, /// or if the user has been banned.</returns> /// // ********************************************************************/ public static bool ValidUser(User user) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.ValidUser(user)); }
// ********************************************************************* // GetPrevThreadID // /// <summary> /// Returns the id of the previous thread. /// </summary> /// <param name="postID">Current threadid is determined from postsid</param> // ***********************************************************************/ public static int GetPrevThreadID(int postID) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.GetPrevThreadID(postID)); }
// ********************************************************************* // TotalNumberOfUserAccounts // /// <summary> /// Calculates and returns the total number of user accounts. /// </summary> /// <returns>The total number of user accounts created.</returns> /// // ********************************************************************/ public static int TotalNumberOfUserAccounts() { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); return(dp.TotalNumberOfUserAccounts(null, null)); }
static async Task Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Initialize needed classes. dataProvider = InitializeDataprovider(); notificationService = InitializeNotification(); notificationConstants = new NotificationConstants(); tasksManager = InitializeTasksManager(dataProvider, notificationService, notificationConstants); // get all tasks. ITaskGroup tasks = tasksManager.GetAllTasks(); //Get current date and save if its new day. dayFollower = InitializeDayFollower(dataProvider); await dayFollower.SetNewDay(); //! Change var timer = new System.Threading.Timer( async e => await dayFollower.SetNewDay(), null, TimeSpan.Zero, TimeSpan.FromMinutes(30)); // start the check list view. Application.Run(new CheckListApp(tasksManager, tasks)); }
// ********************************************************************* // ChangePasswordForLoggedOnUser // /// <summary> /// Changes the password for the currently logged on user. /// </summary> /// <param name="password">User's current password.</param> /// <param name="newPassword">User's new password.</param> /// <returns>Indicates whether or not the password change succeeded</returns> // ***********************************************************************/ public static bool ChangePasswordForLoggedOnUser(string password, string newPassword) { User user; // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); // Get the current user user = Users.GetUserInfo(HttpContext.Current.User.Identity.Name, false); // Check to ensure the passwords match if (password != user.Password) { return(false); } else { dp.ChangePasswordForLoggedOnUser(user.Username, newPassword); } user.Password = newPassword; // Email the user their password Emails.SendEmail(user.Username, EmailTypeEnum.ChangedPassword); return(true); }
/// <summary> /// Deletes the bindings which bind a given household to all the household members who has membership. /// </summary> /// <param name="dataProvider">Implementation of the data provider used to access data.</param> /// <param name="householdProxy">Data proxy for the household on which to delete the bindings.</param> /// <returns>Affected household members.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataProvider"/> or <paramref name="householdProxy"/> is null.</exception> internal static IEnumerable <IHouseholdMemberProxy> DeleteMemberOfHouseholds(IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider, IHouseholdProxy householdProxy) { ArgumentNullGuard.NotNull(dataProvider, nameof(dataProvider)) .NotNull(householdProxy, nameof(householdProxy)); return(DeleteMemberOfHouseholds(dataProvider, () => GetMemberOfHouseholds(dataProvider, householdProxy).ToArray(), memberOfHouseholdProxy => memberOfHouseholdProxy.HouseholdMember as IHouseholdMemberProxy)); }