1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System.Timers;
- namespace OpenSim.Framework.Statistics
- {
-
-
-
- public class UserStatsCollector : BaseStatsCollector
- {
- private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000);
- private int successfulLoginsToday;
- public int SuccessfulLoginsToday { get { return successfulLoginsToday; } }
- private int successfulLoginsYesterday;
- public int SuccessfulLoginsYesterday { get { return successfulLoginsYesterday; } }
- private int successfulLogins;
- public int SuccessfulLogins { get { return successfulLogins; } }
- private int logouts;
- public int Logouts { get { return logouts; } }
- public UserStatsCollector()
- {
- ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing);
- ageStatsTimer.Enabled = true;
- }
- private void OnAgeing(object source, ElapsedEventArgs e)
- {
- successfulLoginsYesterday = successfulLoginsToday;
-
-
- successfulLoginsToday = 0;
- }
-
-
-
- public void AddSuccessfulLogin()
- {
- successfulLogins++;
- successfulLoginsToday++;
- }
- public void AddLogout()
- {
- logouts++;
- }
-
-
-
-
- override public string Report()
- {
- return string.Format(
- @"Successful logins total : {0}, today : {1}, yesterday : {2}
- Logouts total : {3}",
- SuccessfulLogins, SuccessfulLoginsToday, SuccessfulLoginsYesterday, Logouts);
- }
- }
- }
|