public Collections GetPlayersCollections(CollectionGeneratorConfiguration cfg, LogCollectionGeneration logger) { int totalUsernames = cfg.Usernames.Count; int processedCounter = 0; var c = new Collections(); _osuApi.ApiKey = cfg.ApiKey; _logger = logger; _logger?.Invoke(StartingProcessing, 0d); _collectionManager.EditCollection(CollectionEditArgs.ClearCollections()); try { foreach (var username in cfg.Usernames) { var collections = GetPlayerCollections(username, cfg.CollectionNameSavePattern, cfg.ScoreSaveConditions); Log(username, ParsingFinished, ++processedCounter / (double)totalUsernames * 100); _collectionManager.EditCollection(CollectionEditArgs.AddOrMergeCollections(collections)); } c.AddRange(_collectionManager.LoadedCollections); _logger?.Invoke(string.Format(ParsingFinished, cfg.Usernames.Count), 100); _logger = null; return(c); } catch (ThreadAbortException) { _logger?.Invoke(Aborted, -1d); return(c); } }
public void GenerateCollection(CollectionGeneratorConfiguration configuration) { if (_userTopGenerator == null) { _userTopGenerator = new UserTopGenerator(configuration.ApiKey, _loadedBeatmaps); } if (_processingThread == null || !_processingThread.IsAlive) { _processingThread = new Thread(() => { Collections = _userTopGenerator.GetPlayersCollections(configuration, Log); }); _processingThread.Start(); } }