/// <summary> /// Exports the players joined db reading them from the import directory /// </summary> /// <returns><c>true</c>, if players joined db was exported, <c>false</c> otherwise.</returns> /// <param name="errorString">Error string.</param> public bool ExportPlayersJoinedDb(out string errorString) { // Load all the databases we can find and get the player UUIDs var allUUIDs = new List <string>(); var filePaths = GetImportFilePaths(); if (filePaths != null) { foreach (var filePath in filePaths) { // Check whether that is a DB and load it if (IsValidDatabasePath(filePath)) { var importDbService = DBService.OpenFromFilePath(false, filePath); var playerProfileData = importDbService.GetPlayerProfileData(); if (playerProfileData == null) { // skip no-player DBs, they are wrong continue; } allUUIDs.Add(playerProfileData.Uuid); importDbService.CloseConnection(); } } } else { errorString = "Could not find the import folder: " + AppConfig.DbImportFolder; Debug.LogError(errorString); return(false); } // Create the joined DB var joinedDbService = DBService.OpenFromDirectoryAndFilename(true, AppConfig.GetJoinedDatabaseFilename(), AppConfig.DbJoinedFolder); InjectStaticData(joinedDbService); InjectEnums(joinedDbService); // Export and inject all the DBs foreach (var uuid in allUUIDs) { // Export var exportDbService = DBService.ExportFromPlayerUUIDAndReopen(uuid, dirName: AppConfig.DbImportFolder); InjectUUID(uuid, exportDbService); // Inject InjectExportedDB(uuid, exportDbService, joinedDbService); exportDbService.CloseConnection(); exportDbService.ForceFileDeletion(); } joinedDbService.CloseConnection(); errorString = ""; return(true); }
public bool ExportPlayerDb(string playerUuid) { // Create a new service for the copied database // This will copy the current database var exportDbService = DBService.ExportFromPlayerUUIDAndReopen(playerUuid); InjectUUID(playerUuid, exportDbService); InjectStaticData(exportDbService); InjectEnums(exportDbService); exportDbService.CloseConnection(); return(true); }