/// <summary> /// Handle request to get backup configuration info /// </summary> /// <param name="optionsParams"></param> /// <param name="requestContext"></param> /// <returns></returns> internal async Task HandleBackupConfigInfoRequest( DefaultDatabaseInfoParams optionsParams, RequestContext <BackupConfigInfoResponse> requestContext) { try { var response = new BackupConfigInfoResponse(); ConnectionInfo connInfo; DisasterRecoveryService.ConnectionServiceInstance.TryFindConnection( optionsParams.OwnerUri, out connInfo); if (connInfo != null) { using (DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(connInfo, databaseExists: true)) { using (SqlConnection sqlConn = ConnectionService.OpenSqlConnection(connInfo, "Backup")) { if (sqlConn != null && !connInfo.IsCloud) { BackupConfigInfo backupConfigInfo = this.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); response.BackupConfigInfo = backupConfigInfo; } } } } await requestContext.SendResult(response); } catch (Exception ex) { await requestContext.SendError(ex.ToString()); } }
/// <summary> /// Handle request to get backup configuration info /// </summary> /// <param name="optionsParams"></param> /// <param name="requestContext"></param> /// <returns></returns> public static async Task HandleBackupConfigInfoRequest( DefaultDatabaseInfoParams optionsParams, RequestContext <BackupConfigInfoResponse> requestContext) { try { var response = new BackupConfigInfoResponse(); ConnectionInfo connInfo; DisasterRecoveryService.ConnectionServiceInstance.TryFindConnection( optionsParams.OwnerUri, out connInfo); if (connInfo != null) { DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(connInfo, databaseExists: true); SqlConnection sqlConn = GetSqlConnection(connInfo); if ((sqlConn != null) && !connInfo.IsSqlDW && !connInfo.IsAzure) { BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); backupConfigInfo.DatabaseInfo = AdminService.GetDatabaseInfo(connInfo); response.BackupConfigInfo = backupConfigInfo; } } await requestContext.SendResult(response); } catch (Exception ex) { await requestContext.SendError(ex.ToString()); } }
private string GetDefaultBackupFolderPath(CDataContainer dataContainer, SqlConnection sqlConn) { DisasterRecoveryService service = new DisasterRecoveryService(); BackupConfigInfo backupConfigInfo = service.GetBackupConfigInfo(dataContainer, sqlConn, sqlConn.Database); return(backupConfigInfo.DefaultBackupFolder); }
/// <summary> /// Return backup configuration data /// </summary> /// <param name="databaseName"></param> /// <returns></returns> public BackupConfigInfo CreateBackupConfigInfo(string databaseName) { BackupConfigInfo configInfo = new BackupConfigInfo(); configInfo.RecoveryModel = GetRecoveryModel(databaseName); configInfo.DefaultBackupFolder = CommonUtilities.GetDefaultBackupFolder(this.serverConnection); configInfo.BackupEncryptors = GetBackupEncryptors(); return(configInfo); }
/// <summary> /// Return backup configuration data /// </summary> /// <param name="databaseName"></param> /// <returns></returns> public BackupConfigInfo CreateBackupConfigInfo(string databaseName) { BackupConfigInfo configInfo = new BackupConfigInfo(); configInfo.RecoveryModel = GetRecoveryModel(databaseName); configInfo.DefaultBackupFolder = GetDefaultBackupFolder(); configInfo.LatestBackups = GetLatestBackupLocations(databaseName); configInfo.BackupEncryptors = GetBackupEncryptors(); return(configInfo); }
/// Test is failing in code coverage runs. Reenable when stable. ///[Fact] public void CreateBackupTest() { string databaseName = "testbackup_" + new Random().Next(10000000, 99999999); SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName); var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName); // Initialize backup service DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true); SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo); // Get default backup path BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); string backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + ".bak"); BackupInfo backupInfo = CreateBackupInfo(databaseName, BackupType.Full, new List <string>() { backupPath }, new Dictionary <string, int>() { { backupPath, (int)DeviceType.File } }); var backupParams = new BackupParams { OwnerUri = liveConnection.ConnectionInfo.OwnerUri, BackupInfo = backupInfo }; // Backup the database BackupOperation backupOperation = DisasterRecoveryService.Instance.SetBackupInput(helper.DataContainer, sqlConn, backupParams.BackupInfo); DisasterRecoveryService.Instance.PerformBackup(backupOperation); // Remove the backup file if (File.Exists(backupPath)) { File.Delete(backupPath); } // Clean up the database testDb.Cleanup(); }
public async Task <string> CreateBackupFile() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { SqlTestDb testDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, null, "RestoreTest"); var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(testDb.DatabaseName, queryTempFile.FilePath); // Initialize backup service DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true); SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo); // Get default backup pathS BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); string backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, testDb.DatabaseName + ".bak"); BackupInfo backupInfo = CreateBackupInfo(testDb.DatabaseName, BackupType.Full, new List <string>() { backupPath }, new Dictionary <string, int>() { { backupPath, (int)DeviceType.File } }); var backupParams = new BackupParams { OwnerUri = liveConnection.ConnectionInfo.OwnerUri, BackupInfo = backupInfo, TaskExecutionMode = TaskExecutionMode.Execute }; // Backup the database BackupOperation backupOperation = DisasterRecoveryService.Instance.CreateBackupOperation(helper.DataContainer, sqlConn, backupParams.BackupInfo); DisasterRecoveryService.Instance.PerformBackup(backupOperation); // Clean up the database testDb.Cleanup(); return(backupPath); } }
private void CreateProjectForm_Load(object sender, EventArgs e) { TribeLogConfig = new TribeLogConfigInfo(); TravelDataConfig = new BackupConfigInfo(); SharedLogConfig = new SharedLogConfigInfo(); //Load edit data if (editedProject != null) { if (editedProject.TribeLogConfig != null) { TribeLogConfig.CopyFrom(editedProject.TribeLogConfig); } if (editedProject.TravelDataConfig != null) { TravelDataConfig.CopyFrom(editedProject.TravelDataConfig); } if (editedProject.SharedLogConfig != null) { SharedLogConfig.CopyFrom(editedProject.SharedLogConfig); } worldFriendlyNameTxtBox.Text = editedProject.WorldFriendlyName; worldAtlasPasswordTxtBox.Text = editedProject.WorldAtlasPassword; worldAtlasIdTxtBox.Text = editedProject.WorldAtlasId; mapImageURLTxtBox.Text = editedProject.MapImageURL; metaWorldURLTxtBox.Text = editedProject.MetaWorldURL; authListURLTxtBox.Text = editedProject.AuthListURL; baseServerArgsTxtBox.Text = editedProject.BaseServerArgs; if (worldAtlasIdTxtBox.Text.Length == 0) { Random rand = new Random(); worldAtlasIdTxtBox.Text = rand.Next().ToString(); } gridSizeTxtBox.Text = "" + editedProject.cellSize; columnUTCOffsetTxtBox.Text = "" + editedProject.columnUTCOffset.ToString("0.0#######"); sizeXTxtBox.Text = "" + editedProject.numOfCellsX; sizeYTxtBox.Text = "" + editedProject.numOfCellsY; modIdTxtBox.Text = editedProject.ModIDs; S3localURLTxtBx.Text = editedProject.LocalS3URL; S3localAccesKeyIdTxtBx.Text = editedProject.LocalS3AccessKeyId; S3localSecretKeyTxtBx.Text = editedProject.LocalS3SecretKey; S3localBucketNameTxtBx.Text = editedProject.LocalS3BucketName; S3localRegionTxtBx.Text = editedProject.LocalS3Region; globalGameplaySetupTxtBox.Text = editedProject.globalGameplaySetup; useUTCTimeCheckbox.Checked = editedProject.bUseUTCTime; globalTransitionZTxtBox.Text = editedProject.globalTransitionMinZ.ToString(); additionalCmdLineParamsTxtBox.Text = editedProject.AdditionalCmdLineParams; BindingList <ConfigKeyValueEntry> pairs = new BindingList <ConfigKeyValueEntry>(); pairs.AddingNew += (s, a) => { a.NewObject = new ConfigKeyValueEntry("", ""); }; if (editedProject.OverrideShooterGameModeDefaultGameIni != null) { foreach (KeyValuePair <string, string> DicPair in editedProject.OverrideShooterGameModeDefaultGameIni) { pairs.Add(new ConfigKeyValueEntry(DicPair.Key, DicPair.Value)); } } overrideShooterGameModeDefaultGameIniDataGridView.DataSource = pairs; DateTime Day0; if (DateTime.TryParse(editedProject.Day0, out Day0)) { day0DateTimePicker.Value = Day0; } else { day0DateTimePicker.Value = DateTime.UtcNow; } if (editedProject.DatabaseConnections != null) { if (editedProject.DatabaseConnections.Count > 0) { DBEntry1_NameTxtBx.Text = editedProject.DatabaseConnections[0].Name; DBEntry1_URLTxtBx.Text = editedProject.DatabaseConnections[0].URL; DBEntry1_PortTxtBx.Text = editedProject.DatabaseConnections[0].Port.ToString(); DBEntry1_PasswordTxtBx.Text = editedProject.DatabaseConnections[0].Password; } if (editedProject.DatabaseConnections.Count > 1) { DBEntry2_NameTxtBx.Text = editedProject.DatabaseConnections[1].Name; DBEntry2_URLTxtBx.Text = editedProject.DatabaseConnections[1].URL; DBEntry2_PortTxtBx.Text = editedProject.DatabaseConnections[1].Port.ToString(); DBEntry2_PasswordTxtBx.Text = editedProject.DatabaseConnections[1].Password; } if (editedProject.DatabaseConnections.Count > 2) { DBEntry3_NameTxtBx.Text = editedProject.DatabaseConnections[2].Name; DBEntry3_URLTxtBx.Text = editedProject.DatabaseConnections[2].URL; DBEntry3_PortTxtBx.Text = editedProject.DatabaseConnections[2].Port.ToString(); DBEntry3_PasswordTxtBx.Text = editedProject.DatabaseConnections[2].Password; } if (editedProject.DatabaseConnections.Count > 3) { DBEntry4_NameTxtBx.Text = editedProject.DatabaseConnections[3].Name; DBEntry4_URLTxtBx.Text = editedProject.DatabaseConnections[3].URL; DBEntry4_PortTxtBx.Text = editedProject.DatabaseConnections[3].Port.ToString(); DBEntry4_PasswordTxtBx.Text = editedProject.DatabaseConnections[3].Password; } if (editedProject.DatabaseConnections.Count > 4) { DBEntry5_NameTxtBx.Text = editedProject.DatabaseConnections[4].Name; DBEntry5_URLTxtBx.Text = editedProject.DatabaseConnections[4].URL; DBEntry5_PortTxtBx.Text = editedProject.DatabaseConnections[4].Port.ToString(); DBEntry5_PasswordTxtBx.Text = editedProject.DatabaseConnections[4].Password; } } this.Text = "Edit project"; createBtn.Text = "Edit"; } else { Random rand = new Random(); worldAtlasIdTxtBox.Text = rand.Next().ToString(); } }
public async Task <string[]> CreateBackupSetsToRecoverDatabase() { List <string> backupFiles = new List <string>(); using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { string query = $"CREATE SCHEMA [test]"; SqlTestDb testDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, query, "RestoreTest"); string databaseName = testDb.DatabaseName; // Initialize backup service var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName, queryTempFile.FilePath); DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true); using (SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo)) { BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); query = $"create table [test].[{tableNames[0]}] (c1 int)"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, databaseName, query); string backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + "_full.bak"); query = $"BACKUP DATABASE [{databaseName}] TO DISK = N'{backupPath}' WITH NOFORMAT, NOINIT, NAME = N'{databaseName}-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, "master", query); backupFiles.Add(backupPath); query = $"create table [test].[{tableNames[1]}] (c1 int)"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, databaseName, query); backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + "_diff.bak"); query = $"BACKUP DATABASE [{databaseName}] TO DISK = N'{backupPath}' WITH DIFFERENTIAL, NOFORMAT, NOINIT, NAME = N'{databaseName}-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, "master", query); backupFiles.Add(backupPath); query = $"create table [test].[{tableNames[2]}] (c1 int)"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, databaseName, query); backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + "_log1.bak"); query = $"BACKUP Log [{databaseName}] TO DISK = N'{backupPath}' WITH NOFORMAT, NOINIT, NAME = N'{databaseName}-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, "master", query); backupFiles.Add(backupPath); query = $"create table [test].[{tableNames[3]}] (c1 int)"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, databaseName, query); backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + "_log2.bak"); query = $"BACKUP Log [{databaseName}] TO DISK = N'{backupPath}' WITH NOFORMAT, NOINIT, NAME = N'{databaseName}-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, "master", query); backupFiles.Add(backupPath); query = $"create table [test].[{tableNames[4]}] (c1 int)"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, databaseName, query); backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + "_log3.bak"); query = $"BACKUP Log [{databaseName}] TO DISK = N'{backupPath}' WITH NOFORMAT, NOINIT, NAME = N'{databaseName}-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, "master", query); backupFiles.Add(backupPath); databaseNameToRestoreFrom = testDb.DatabaseName; // Clean up the database testDb.Cleanup(); } } return(backupFiles.ToArray()); }
private string GetDefaultBackupFullPath(DisasterRecoveryService service, string databaseName, CDataContainer dataContainer, SqlConnection sqlConn) { BackupConfigInfo backupConfigInfo = service.GetBackupConfigInfo(dataContainer, sqlConn, sqlConn.Database); return(Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + ".bak")); }
//[Fact] public async void BackupFileBrowserTest() { string databaseName = "testfilebrowser_" + new Random().Next(10000000, 99999999); SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName); // Initialize backup service var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName); DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true); SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo); DisasterRecoveryService disasterRecoveryService = new DisasterRecoveryService(); BackupConfigInfo backupConfigInfo = disasterRecoveryService.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); // Create backup file string backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + ".bak"); string query = $"BACKUP DATABASE [{databaseName}] TO DISK = N'{backupPath}' WITH NOFORMAT, NOINIT, NAME = N'{databaseName}-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; await TestServiceProvider.Instance.RunQueryAsync(TestServerType.OnPrem, "master", query); FileBrowserService service = new FileBrowserService(); string[] backupFilters = new string[2] { "*.bak", "*.trn" }; var openParams = new FileBrowserOpenParams { OwnerUri = liveConnection.ConnectionInfo.OwnerUri, ExpandPath = backupConfigInfo.DefaultBackupFolder, FileFilters = backupFilters }; var openBrowserEventFlowValidator = new EventFlowValidator <bool>() .AddEventValidation(FileBrowserOpenedNotification.Type, eventParams => { Assert.True(eventParams.Succeeded); Assert.NotNull(eventParams.FileTree); Assert.NotNull(eventParams.FileTree.RootNode); Assert.NotNull(eventParams.FileTree.RootNode.Children); Assert.True(eventParams.FileTree.RootNode.Children.Count > 0); Assert.True(ContainsFileInTheFolder(eventParams.FileTree.SelectedNode, backupPath)); }) .Complete(); await service.RunFileBrowserOpenTask(openParams, openBrowserEventFlowValidator.Object); // Verify complete notification event was fired and the result openBrowserEventFlowValidator.Validate(); var expandParams = new FileBrowserExpandParams { OwnerUri = liveConnection.ConnectionInfo.OwnerUri, ExpandPath = backupConfigInfo.DefaultBackupFolder }; var expandEventFlowValidator = new EventFlowValidator <bool>() .AddEventValidation(FileBrowserExpandedNotification.Type, eventParams => { Assert.True(eventParams.Succeeded); Assert.NotNull(eventParams.Children); Assert.True(eventParams.Children.Length > 0); }) .Complete(); // Expand the node in file browser await service.RunFileBrowserExpandTask(expandParams, expandEventFlowValidator.Object); // Verify result expandEventFlowValidator.Validate(); var validateParams = new FileBrowserValidateParams { OwnerUri = liveConnection.ConnectionInfo.OwnerUri, ServiceType = FileValidationServiceConstants.Backup, SelectedFiles = new[] { backupPath } }; var validateEventFlowValidator = new EventFlowValidator <bool>() .AddEventValidation(FileBrowserValidatedNotification.Type, eventParams => Assert.True(eventParams.Succeeded)) .Complete(); // Validate selected files in the browser await service.RunFileBrowserValidateTask(validateParams, validateEventFlowValidator.Object); // Verify complete notification event was fired and the result validateEventFlowValidator.Validate(); // Remove the backup file if (File.Exists(backupPath)) { File.Delete(backupPath); } }
public void Deserialize(string json, MainForm mainForm) { try { AtlasGridData deserializedProject = JsonConvert.DeserializeObject <AtlasGridData>(json, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Ignore }); if (deserializedProject.TribeLogConfig == null) { deserializedProject.TribeLogConfig = new TribeLogConfigInfo(); } if (deserializedProject.SharedLogConfig == null) { deserializedProject.SharedLogConfig = new SharedLogConfigInfo(); } if (deserializedProject.TravelDataConfig == null) { deserializedProject.TravelDataConfig = new BackupConfigInfo(); } this.cellSize = deserializedProject.gridSize; idGenerator = deserializedProject.idGenerator; regionsIdGenerator = deserializedProject.regionsIdGenerator; int maxX = 0, maxY = 0; List <ServerData> targetServerList = /*deserializedProject.originalServers != null ? deserializedProject.originalServers : */ deserializedProject.servers; foreach (ServerData deserializedServer in targetServerList) { if (deserializedServer.gridX > maxX) { maxX = deserializedServer.gridX; } if (deserializedServer.gridY > maxY) { maxY = deserializedServer.gridY; } Server s = new Server(deserializedServer.gridX, deserializedServer.gridY); s.MachineIdTag = deserializedServer.MachineIdTag; s.ip = deserializedServer.ip; s.port = deserializedServer.port; s.gamePort = deserializedServer.gamePort; s.seamlessDataPort = deserializedServer.seamlessDataPort; s.isHomeServer = deserializedServer.isHomeServer; s.AdditionalCmdLineParams = deserializedServer.AdditionalCmdLineParams; s.OverrideShooterGameModeDefaultGameIni = deserializedServer.OverrideShooterGameModeDefaultGameIni; s.name = deserializedServer.name; s.floorZDist = deserializedServer.floorZDist; s.transitionMinZ = deserializedServer.transitionMinZ; s.utcOffset = deserializedServer.utcOffset; s.GlobalBiomeSeamlessServerGridPreOffsetValues = deserializedServer.GlobalBiomeSeamlessServerGridPreOffsetValues; s.GlobalBiomeSeamlessServerGridPreOffsetValuesOceanWater = deserializedServer.GlobalBiomeSeamlessServerGridPreOffsetValuesOceanWater; s.OceanDinoDepthEntriesOverride = deserializedServer.OceanDinoDepthEntriesOverride; s.OceanEpicSpawnEntriesOverrideValues = deserializedServer.OceanEpicSpawnEntriesOverrideValues; s.oceanEpicSpawnEntriesOverrideTemplateName = deserializedServer.oceanEpicSpawnEntriesOverrideTemplateName; s.NPCShipSpawnEntriesOverrideTemplateName = deserializedServer.NPCShipSpawnEntriesOverrideTemplateName; s.regionOverrides = deserializedServer.regionOverrides; s.waterColorR = deserializedServer.waterColorR; s.waterColorG = deserializedServer.waterColorG; s.waterColorB = deserializedServer.waterColorB; s.skyStyleIndex = deserializedServer.skyStyleIndex; s.serverIslandPointsMultiplier = deserializedServer.serverIslandPointsMultiplier; s.ServerCustomDatas1 = deserializedServer.ServerCustomDatas1; s.ServerCustomDatas2 = deserializedServer.ServerCustomDatas2; s.ClientCustomDatas1 = deserializedServer.ClientCustomDatas1; s.ClientCustomDatas2 = deserializedServer.ClientCustomDatas2; s.oceanFloatsamCratesOverride = deserializedServer.oceanFloatsamCratesOverride; s.treasureMapLootTablesOverride = deserializedServer.treasureMapLootTablesOverride; s.lastModifiedUTC = deserializedServer.lastModified; s.lastImageOverrideUTC = deserializedServer.lastImageOverride; s.serverTemplateName = deserializedServer.serverTemplateName; if (s.serverTemplateName == null) { s.serverTemplateName = ""; } if (s.floorZDist <= 0) { s.floorZDist = 0; } s.islandLocked = deserializedServer.islandLocked; s.discoLocked = deserializedServer.discoLocked; s.pathsLocked = deserializedServer.pathsLocked; s.extraSublevels = deserializedServer.extraSublevels; servers.Add(s); foreach (IslandInstanceData deserializedIslandInstance in deserializedServer.islandInstances) { if (!mainForm.islands.ContainsKey(deserializedIslandInstance.name)) { continue; } //PointF worldPoint = s.RelativeToWorldPoint(cellSize, new PointF(deserializedIsland.additionalTranslationX, deserializedIsland.additionalTranslationY)); //islandInstances.Add(new IslandInstance(deserializedIsland.name, worldPoint.X, worldPoint.Y, deserializedIsland.additionalRotationYaw)); bool bRepeatedId = false; foreach (IslandInstanceData prevIslands in islandInstances) { if (prevIslands.id == deserializedIslandInstance.id) { bRepeatedId = true; break; } } if (deserializedIslandInstance.id == 0 || bRepeatedId) { deserializedIslandInstance.id = GenerateNewId(); } deserializedIslandInstance.SyncOverridesWithTemplates(mainForm); deserializedIslandInstance.maxTreasureQuality = deserializedIslandInstance.minTreasureQuality = -1; deserializedIslandInstance.useNpcVolumesForTreasures = false; deserializedIslandInstance.islandTreasureBottleSupplyCrateOverrides = ""; deserializedIslandInstance.islandPoints = 1; //deserializedIslandInstance.spawnPointRegionOverride = -1; islandInstances.Add(deserializedIslandInstance); } foreach (DiscoveryZoneData deserializedDiscoZone in deserializedServer.discoZones) { bool bRepeatedId = false; foreach (DiscoveryZoneData prevDiscoZones in discoZones) { if (prevDiscoZones.id == deserializedDiscoZone.id) { bRepeatedId = true; break; } } if (deserializedDiscoZone.id == 0 || bRepeatedId) { deserializedDiscoZone.id = GenerateUniqueDiscoZoneId(); } discoZones.Add(deserializedDiscoZone); } foreach (SpawnRegionData spawnRegion in deserializedServer.spawnRegions) { spawnRegion.X = deserializedServer.gridX; spawnRegion.Y = deserializedServer.gridY; spawnRegions.Add(spawnRegion); } } numOfCellsX = maxX + 1; numOfCellsY = maxY + 1; WorldFriendlyName = deserializedProject.WorldFriendlyName; WorldAtlasId = deserializedProject.WorldAtlasId; AuthListURL = deserializedProject.AuthListURL; MetaWorldURL = deserializedProject.MetaWorldURL; coordsScaling = deserializedProject.coordsScaling; showServerInfo = deserializedProject.showServerInfo; showDiscoZoneInfo = deserializedProject.showDiscoZoneInfo; showIslandNames = deserializedProject.showIslandNames; showShipPathsInfo = deserializedProject.showShipPathsInfo; showLines = deserializedProject.showLines; alphaBackground = deserializedProject.alphaBackground; showBackground = deserializedProject.showBackground; showForeground = deserializedProject.showForeground; backgroundImgPath = deserializedProject.backgroundImgPath; foregroundImgPath = deserializedProject.foregroundImgPath; discoZonesImagePath = deserializedProject.discoZonesImagePath; ModIDs = deserializedProject.ModIDs; MapImageURL = deserializedProject.MapImageURL; BaseServerArgs = deserializedProject.BaseServerArgs; LocalS3URL = deserializedProject.LocalS3URL; LocalS3AccessKeyId = deserializedProject.LocalS3AccessKeyId; LocalS3SecretKey = deserializedProject.LocalS3SecretKey; LocalS3BucketName = deserializedProject.LocalS3BucketName; LocalS3Region = deserializedProject.LocalS3Region; globalGameplaySetup = deserializedProject.globalGameplaySetup; TribeLogConfig = deserializedProject.TribeLogConfig; TravelDataConfig = deserializedProject.TravelDataConfig; SharedLogConfig = deserializedProject.SharedLogConfig; DatabaseConnections = deserializedProject.DatabaseConnections; bUseUTCTime = deserializedProject.bUseUTCTime; columnUTCOffset = deserializedProject.columnUTCOffset; globalTransitionMinZ = deserializedProject.globalTransitionMinZ; AdditionalCmdLineParams = deserializedProject.AdditionalCmdLineParams; OverrideShooterGameModeDefaultGameIni = deserializedProject.OverrideShooterGameModeDefaultGameIni; Day0 = deserializedProject.Day0; LastImageOverrideUTC = deserializedProject.lastImageOverride; WorldAtlasPassword = deserializedProject.WorldAtlasPassword; if (deserializedProject.shipPaths != null) { shipPaths = deserializedProject.shipPaths; foreach (ShipPathData shipPath in shipPaths) { foreach (BezierNodeData bezierNode in shipPath.Nodes) { bezierNode.shipPath = shipPath; } } } shipPathsIdGenerator = deserializedProject.shipPathsIdGenerator; serverTemplates = deserializedProject.serverTemplates; if (serverTemplates == null) { serverTemplates = new List <ServerTemplateData>(); } successfullyLoaded = true; } catch (Exception e) { MessageBox.Show("Failed to parse project json, Message: " + e.Message, "Error"); } }
public void CreateBackupWithAdvancedOptionsTest() { string databaseName = "testbackup_" + new Random().Next(10000000, 99999999); SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName); string certificateName = "backupcertificate" + new Random().Next(10000000, 99999999); string masterkeyPassword = Guid.NewGuid().ToString(); string createCertificateQuery = string.Format(CreateCertificateQueryFormat, masterkeyPassword, certificateName); string cleanupCertificateQuery = string.Format(CleanupCertificateQueryFormat, certificateName); // create master key and certificate Console.WriteLine("Create master key and certificate.."); testDb.RunQuery(createCertificateQuery); var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName); // Initialize backup service DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true); SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo); // Get default backup path Console.WriteLine("Get default backup path.."); BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); string backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, databaseName + ".bak"); BackupInfo backupInfo = CreateBackupInfo(databaseName, BackupType.Full, new List <string>() { backupPath }, new Dictionary <string, int>() { { backupPath, (int)DeviceType.File } }); // Set advanced options backupInfo.ContinueAfterError = true; backupInfo.FormatMedia = true; backupInfo.SkipTapeHeader = true; backupInfo.Initialize = true; backupInfo.MediaName = "backup test media"; backupInfo.MediaDescription = "backup test"; backupInfo.RetainDays = 90; backupInfo.CompressionOption = (int)BackupCompressionOptions.On; // Set encryption backupInfo.EncryptionAlgorithm = (int)BackupEncryptionAlgorithm.Aes128; backupInfo.EncryptorType = (int)BackupEncryptorType.ServerCertificate; backupInfo.EncryptorName = certificateName; var backupParams = new BackupParams { OwnerUri = liveConnection.ConnectionInfo.OwnerUri, BackupInfo = backupInfo }; // Backup the database Console.WriteLine("Perform backup operation.."); BackupOperation backupOperation = DisasterRecoveryService.Instance.SetBackupInput(helper.DataContainer, sqlConn, backupParams.BackupInfo); DisasterRecoveryService.Instance.PerformBackup(backupOperation); // Verify backup file is created Assert.True(File.Exists(backupPath)); // Remove the backup file Console.WriteLine("Remove backup file.."); if (File.Exists(backupPath)) { File.Delete(backupPath); } // Delete certificate and master key Console.WriteLine("Remove certificate and master key.."); testDb.RunQuery(cleanupCertificateQuery); // Clean up the database Console.WriteLine("Clean up database.."); testDb.Cleanup(); }