public Entities.LastLoginDetails GetLastLoginDetails(Guid guid) { LastLoginDetails loginDetails = null; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString)) { using (SqlCommand command = new SqlCommand("dbo.fr_LastLogin_Get", connection) { CommandType = CommandType.StoredProcedure }) { command.Parameters.Add("@MembershipId", SqlDbType.UniqueIdentifier).Value = guid; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { loginDetails = new LastLoginDetails(); loginDetails.EmailCountSent = Convert.ToInt32(reader["EmailCountSent"]); loginDetails.MembershipId = new Guid(Convert.ToString(reader["MembershipId"])); loginDetails.LastLogonDate = Convert.ToDateTime(reader["LastLogonDate"]); loginDetails.IgnoredUser = Convert.ToBoolean(reader["IgnoredUser"]); if (!Convert.IsDBNull(reader["FirstEmailSentAt"])) { loginDetails.FirstEmailSentAt = Convert.ToDateTime(reader["FirstEmailSentAt"]); } } } } } return(loginDetails); }
private void UpdateLoginDate(Guid contentId) { //In the event that exception occurs we do not want this to prevent authentication, it is not system critical try { var lastLoginData = Telligent.Evolution.Extensibility.Caching.Version1.CacheService.Get(LastLoginDetails.CacheKey(contentId), Telligent.Evolution.Extensibility.Caching.Version1.CacheScope.All) as LastLoginDetails; if (lastLoginData == null || lastLoginData.LastLogonDate < DateTime.Now.AddHours(-1)) { lastLoginData = UserHealth.GetLastLoginDetails(contentId) ?? new LastLoginDetails { MembershipId = contentId }; lastLoginData.LastLogonDate = DateTime.Now; lastLoginData.EmailCountSent = 0; lastLoginData.FirstEmailSentAt = null; UserHealth.CreateUpdateLastLoginDetails(lastLoginData); Telligent.Evolution.Extensibility.Caching.Version1.CacheService.Put(LastLoginDetails.CacheKey(contentId), lastLoginData, Telligent.Evolution.Extensibility.Caching.Version1.CacheScope.All); } } catch (Exception ex) { new CSException("Sentrus", string.Format("UpdateLoginDate failed for contentid:{0}", contentId), ex).Log(); } }
private void HideUsersOnClick(object sender, EventArgs eventArgs) { IUserHealth userHealth = Injector.Get <IUserHealth>(); EnumerateUsers(user => { if (user.ContentId != null) { var lastLoginData = userHealth.GetLastLoginDetails(user.ContentId); lastLoginData.IgnoredUser = true; userHealth.CreateUpdateLastLoginDetails(lastLoginData); Telligent.Evolution.Extensibility.Caching.Version1.CacheService.Remove(LastLoginDetails.CacheKey(user.ContentId), Telligent.Evolution.Extensibility.Caching.Version1.CacheScope.All); } }); //Set up the grid SetConfigurationPropertyValue(null); _repeater.DataSource = _configurationDataSource; _repeater.DataBind(); }