private EntryXml GetEntry(string categoryName, string exerciseName, string userId)
        {
            ExerciseXml exercise = GetExercise(categoryName, exerciseName);

            if (exercise.Entries == null)
            {
                exercise.Entries    = new EntryXml[1];
                exercise.Entries[0] = new EntryXml(userId);
                return(exercise.Entries[0]);
            }

            foreach (EntryXml entry in exercise.Entries)
            {
                if (entry.UID == userId)
                {
                    return(entry);
                }
            }

            EntryXml appendedEntry = new EntryXml(userId);

            EntryXml[] entries = new EntryXml[exercise.Entries.Length + 1];
            entries[entries.Length - 1] = appendedEntry;
            exercise.Entries.CopyTo(entries, 0);
            exercise.Entries = entries;

            return(appendedEntry);
        }
        private void UpdateExerciseInformation(string category, string exercise, string username, string userid, float score)
        {
            try
            {
                if (_Disposed)
                {
                    return;
                }

                if (_Database == null)
                {
                    return;
                }

                LOG.Info("Update Exercise: category:" + category + " exercise:" + exercise + " username:"******" userid:" + userid + " score:" + score);

                lock (_Database)
                {
                    // Sicher stellen, dass dieser Eintrag auch wirklich gültig ist. Wenn wir ihn einmal suchen, wird er auch erzeugt.
                    if (score <= 1)
                    {
                        return;
                    }
                    if ((string.IsNullOrWhiteSpace(userid)) || (userid.Length < 5))
                    {
                        return;
                    }
                    if (string.IsNullOrWhiteSpace(username))
                    {
                        return;
                    }
                    if (string.IsNullOrWhiteSpace(category))
                    {
                        return;
                    }
                    if (string.IsNullOrWhiteSpace(exercise))
                    {
                        return;
                    }

                    // Eintrag suchen/erstellen
                    EntryXml entry = GetEntry(category, exercise, userid); // Never null

                    // Eintrag anpassen
                    if (entry.Score < score)
                    {
                        LOG.Info("New highscore!");
                        entry.Name  = username;
                        entry.Score = score;
                        entry.SetDate(DateTime.Now);

                        _Database.LastUpdate = DateTime.Now;
                        _Database.Save();
                        _FtpManager.UploadFtp(_Configuration.DatabaseFilename);
                    }
                    else
                    {
                        LOG.Info("No highscore!");
                    }
                }
            }
            catch (Exception ex)
            {
                LOG.Error(ex);
            }
        }