private void LoadLoginData()
        {
            LoginStatisticService service = (LoginStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(LoginStatisticService));
            LoginStatisticData    data    = service.GetData(Context);

            List <LoginEntry> entries = new List <LoginEntry>();

            foreach (LoginStatisticData.TLoginRow row in data.TLogin.Rows)
            {
                Portal.API.Users.UserRow user = UserManagement.Users.FindById(row.UserId);
                LoginEntry entry = new LoginEntry();
                if (null != user)
                {
                    // User was found, so use the actual user infos to show.
                    entry.Login     = user.login;
                    entry.FirstName = user.SafeFirstName;
                    entry.LastName  = user.SafeSurName;
                }
                else
                {
                    // User was deleted, so use cached infos.
                    entry.Login     = row.Login;
                    entry.FirstName = row.FirstName;
                    entry.LastName  = row.LastName;
                }
                entry.LoginCount = row.LoginCount;
                entry.LastLogin  = row.LastLogin;
                entries.Add(entry);
            }

            repeaterLogin.DataSource = entries;
            repeaterLogin.DataBind();
        }
        /// <summary>
        /// Increases the users loggin count and actualizes his latest login date.
        /// </summary>
        public void AddLogin()
        {
            lock (lockObject)
            {
                try
                {
                    LoginStatisticData data = service.GetData(context);

                    // Find the user.
                    if (null == System.Web.HttpContext.Current)
                    {
                        System.Web.HttpContext.Current = context;
                    }
                    Portal.API.Users.UserRow user = UserManagement.Users.FindById(userId);

                    // Search the row for the current user.
                    // If there is now row for the current user, create a new one.
                    LoginStatisticData.TLoginRow[] rows = (LoginStatisticData.TLoginRow[])data.TLogin.Select("UserId = '" + userId.ToString() + "'");
                    LoginStatisticData.TLoginRow   row;
                    if (rows.Length == 0)
                    {
                        row            = data.TLogin.NewTLoginRow();
                        row.UserId     = userId;
                        row.Login      = user.login;
                        row.FirstName  = user.SafeFirstName;
                        row.LastName   = user.SafeSurName;
                        row.LoginCount = 0;
                        row.LoginCount = row.LoginCount + 1;
                        row.LastLogin  = this.lastLogin;
                        data.TLogin.AddTLoginRow(row);
                    }
                    else
                    {
                        row            = rows[0];
                        row.Login      = user.login;
                        row.FirstName  = user.SafeFirstName;
                        row.LastName   = user.SafeSurName;
                        row.LoginCount = row.LoginCount + 1;
                        row.LastLogin  = this.lastLogin;
                    }

                    service.SaveData(context, data);
                }
                catch (Exception ex)
                {
                    HandleException("Unexpected error while adding a login to the login statistics.", ex);
                }
            }
        }