public void Run_WithSimpleOrFullModeRecovery_CreatesScriptForIt(RecoveryMode recoveryMode, string expectedFileName) { var sut = MakeTestableRoundhouseMigrationRunner(false, true); sut.fakeConfiguration.RecoveryMode = recoveryMode; sut.run(); StringAssert.IsMatch(expectedFileName, sut.CheckFilesCopied.ToString()); }
public void Run_WithDryRun_WillCallRecoveryMode(RecoveryMode recoveryMode, string expected) { var sut = MakeTestableRoundhouseMigrationRunner(true, false); sut.fakeConfiguration.RecoveryMode = recoveryMode; sut.run(); StringAssert.Contains(expected, sut.CheckLogWritten.ToString()); A.CallTo(() => sut.database_migrator.set_recovery_mode(recoveryMode == RecoveryMode.Simple)).MustHaveHappened(); }
public void Run_WithoutDryRun_WillSetRecoveryMode(RecoveryMode recoveryMode) { var sut = MakeTestableRoundhouseMigrationRunner(false, false); sut.fakeConfiguration.RecoveryMode = recoveryMode; sut.run(); A.CallTo(() => sut.database_migrator.open_connection(true)).WithAnyArguments().MustHaveHappened(); A.CallTo(() => sut.database_migrator.set_recovery_mode(recoveryMode == RecoveryMode.Simple)).MustHaveHappened(); }
public SqlServerDatabaseDefinition( string databaseName, DatabaseType databaseType, RecoveryMode recoveryMode, string dataFileLogicalName, string dataFilePath, long dataFileCurrentSizeInKb, long dataFileMaxSizeInKb, long dataFileGrowthSizeInKb, string logFileLogicalName, string logFilePath, long logFileCurrentSizeInKb, long logFileMaxSizeInKb, long logFileGrowthSizeInKb) { databaseName.MustForArg(nameof(databaseName)).NotBeNullNorWhiteSpace().And().BeAlphanumeric(DatabaseNameAlphanumericOtherAllowedCharacters); if (!string.IsNullOrWhiteSpace(dataFileLogicalName)) { dataFileLogicalName.MustForArg(nameof(dataFileLogicalName)).BeAlphanumeric(DatabaseLogicalFileNameAlphanumericOtherAllowedCharacters); } if (!string.IsNullOrWhiteSpace(dataFilePath)) { SqlInjectorChecker.ThrowIfNotValidPath(dataFilePath, nameof(dataFilePath)); } if (!string.IsNullOrWhiteSpace(logFileLogicalName)) { logFileLogicalName.MustForArg(nameof(logFileLogicalName)).BeAlphanumeric(DatabaseLogicalFileNameAlphanumericOtherAllowedCharacters); } if (!string.IsNullOrWhiteSpace(logFilePath)) { SqlInjectorChecker.ThrowIfNotValidPath(logFilePath, nameof(logFilePath)); } this.DatabaseName = databaseName; this.DatabaseType = databaseType; this.RecoveryMode = recoveryMode; this.DataFileLogicalName = dataFileLogicalName; this.DataFilePath = dataFilePath; this.LogFilePath = logFilePath; this.DataFileCurrentSizeInKb = dataFileCurrentSizeInKb; this.DataFileMaxSizeInKb = dataFileMaxSizeInKb; this.DataFileGrowthSizeInKb = dataFileGrowthSizeInKb; this.LogFileLogicalName = logFileLogicalName; this.LogFileCurrentSizeInKb = logFileCurrentSizeInKb; this.LogFileMaxSizeInKb = logFileMaxSizeInKb; this.LogFileGrowthSizeInKb = logFileGrowthSizeInKb; }
internal static string ToSerializedValue(this RecoveryMode value) { switch (value) { case RecoveryMode.None: return("None"); case RecoveryMode.OverProvision: return("OverProvision"); case RecoveryMode.Reprovision: return("Reprovision"); } return(null); }
public SqlServerDatabaseDefinition DeepCloneWithRecoveryMode(RecoveryMode recoveryMode) { var result = new SqlServerDatabaseDefinition( this.DatabaseName?.DeepClone(), this.DatabaseType.DeepClone(), recoveryMode, this.DataFileLogicalName?.DeepClone(), this.DataFilePath?.DeepClone(), this.DataFileCurrentSizeInKb.DeepClone(), this.DataFileMaxSizeInKb.DeepClone(), this.DataFileGrowthSizeInKb.DeepClone(), this.LogFileLogicalName?.DeepClone(), this.LogFilePath?.DeepClone(), this.LogFileCurrentSizeInKb.DeepClone(), this.LogFileMaxSizeInKb.DeepClone(), this.LogFileGrowthSizeInKb.DeepClone()); return(result); }
public static SqlServerDatabaseDefinition BuildDatabaseConfigurationUsingDefaultsAsNecessary( string databaseName, string dataDirectory, DatabaseType databaseType = DatabaseType.User, string logDirectory = null, RecoveryMode recoveryMode = RecoveryMode.Simple, string dataFileLogicalName = null, string dataFileNameOnDisk = null, long?dataFileCurrentSizeInKb = null, long?dataFileMaxSizeInKb = null, long?dataFileGrowthSizeInKb = null, string logFileLogicalName = null, string logFileNameOnDisk = null, long?logFileCurrentSizeInKb = null, long?logFileMaxSizeInKb = null, long?logFileGrowthSizeInKb = null) { databaseName.MustForArg(nameof(databaseName)).NotBeNullNorWhiteSpace(); var databaseConfiguration = new SqlServerDatabaseDefinition( databaseName, databaseType, recoveryMode, dataFileLogicalName ?? Invariant($"{databaseName}Data"), Path.Combine( dataDirectory, dataFileNameOnDisk ?? Invariant($"{databaseName}Data.{MicrosoftSqlDataFileExtension}")), dataFileCurrentSizeInKb ?? MicrosoftSqlDefaultCurrentFileSizeInKb, dataFileMaxSizeInKb ?? InfinityMaxSize, dataFileGrowthSizeInKb ?? MicrosoftSqlDefaultFileGrowthSizeInKb, logFileLogicalName ?? Invariant($"{databaseName}Log"), Path.Combine( logDirectory ?? dataDirectory, logFileNameOnDisk ?? Invariant($"{databaseName}Log.{MicrosoftSqlLogFileExtension}")), logFileCurrentSizeInKb ?? MicrosoftSqlDefaultCurrentFileSizeInKb, logFileMaxSizeInKb ?? InfinityMaxSize, logFileGrowthSizeInKb ?? MicrosoftSqlDefaultFileGrowthSizeInKb); return(databaseConfiguration); }
public IDictionary <string, string> to_token_dictionary() { var tokens = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { { nameof(AccessToken), AccessToken.to_string() }, { nameof(AfterMigrationFolderName), AfterMigrationFolderName.to_string() }, { nameof(AlterDatabaseFolderName), AlterDatabaseFolderName.to_string() }, { nameof(Baseline), Baseline.to_string() }, { nameof(BeforeMigrationFolderName), BeforeMigrationFolderName.to_string() }, { nameof(CommandTimeout), CommandTimeout.to_string() }, { nameof(CommandTimeoutAdmin), CommandTimeoutAdmin.to_string() }, { nameof(ConfigurationFile), ConfigurationFile.to_string() }, { nameof(ConnectionString), ConnectionString.to_string() }, { nameof(ConnectionStringAdmin), ConnectionStringAdmin.to_string() }, { nameof(CreateDatabaseCustomScript), CreateDatabaseCustomScript.to_string() }, { nameof(DatabaseName), DatabaseName.to_string() }, { nameof(DatabaseType), DatabaseType.to_string() }, { nameof(Debug), Debug.to_string() }, { nameof(DisableOutput), DisableOutput.to_string() }, { nameof(DisableTokenReplacement), DisableTokenReplacement.to_string() }, { nameof(DoNotAlterDatabase), DoNotAlterDatabase.to_string() }, { nameof(DoNotCreateDatabase), DoNotCreateDatabase.to_string() }, { nameof(DoNotStoreScriptsRunText), DoNotStoreScriptsRunText.to_string() }, { nameof(DownFolderName), DownFolderName.to_string() }, { nameof(Drop), Drop.to_string() }, { nameof(DryRun), DryRun.to_string() }, #pragma warning disable 618 { nameof(EnvironmentName), string.Join(",", EnvironmentNames) }, #pragma warning restore 618 { nameof(EnvironmentNames), string.Join(",", EnvironmentNames) }, { nameof(FunctionsFolderName), FunctionsFolderName.to_string() }, { nameof(IndexesFolderName), IndexesFolderName.to_string() }, { nameof(Initialize), Initialize.to_string() }, { nameof(OutputPath), OutputPath.to_string() }, { nameof(PermissionsFolderName), PermissionsFolderName.to_string() }, { nameof(RecoveryMode), RecoveryMode.to_string() }, { nameof(RepositoryPath), RepositoryPath.to_string() }, { nameof(Restore), Restore.to_string() }, { nameof(RestoreCustomOptions), RestoreCustomOptions.to_string() }, { nameof(RestoreFromPath), RestoreFromPath.to_string() }, { nameof(RestoreTimeout), RestoreTimeout.to_string() }, { nameof(RunAfterCreateDatabaseFolderName), RunAfterCreateDatabaseFolderName.to_string() }, { nameof(RunAfterOtherAnyTimeScriptsFolderName), RunAfterOtherAnyTimeScriptsFolderName.to_string() }, { nameof(RunAllAnyTimeScripts), RunAllAnyTimeScripts.to_string() }, { nameof(RunBeforeUpFolderName), RunBeforeUpFolderName.to_string() }, { nameof(RunFirstAfterUpFolderName), RunFirstAfterUpFolderName.to_string() }, { nameof(SchemaName), SchemaName.to_string() }, { nameof(ScriptsRunErrorsTableName), ScriptsRunErrorsTableName.to_string() }, { nameof(ScriptsRunTableName), ScriptsRunTableName.to_string() }, { nameof(SearchAllSubdirectoriesInsteadOfTraverse), SearchAllSubdirectoriesInsteadOfTraverse.to_string() }, { nameof(ServerName), ServerName.to_string() }, { nameof(Silent), Silent.to_string() }, { nameof(SprocsFolderName), SprocsFolderName.to_string() }, { nameof(SqlFilesDirectory), SqlFilesDirectory.to_string() }, { nameof(TriggersFolderName), TriggersFolderName.to_string() }, { nameof(UpFolderName), UpFolderName.to_string() }, { nameof(Version), Version.to_string() }, { nameof(VersionFile), VersionFile.to_string() }, { nameof(VersionTableName), VersionTableName.to_string() }, { nameof(VersionXPath), VersionXPath.to_string() }, { nameof(ViewsFolderName), ViewsFolderName.to_string() }, { nameof(WarnAndIgnoreOnOneTimeScriptChanges), WarnAndIgnoreOnOneTimeScriptChanges.to_string() }, { nameof(WarnOnOneTimeScriptChanges), WarnOnOneTimeScriptChanges.to_string() }, { nameof(WithTransaction), WithTransaction.to_string() }, }; if (UserTokens != null) { foreach (var t in UserTokens) { tokens[t.Key] = t.Value; } } return(tokens); }
public IDictionary <string, string> to_token_dictionary() { var tokens = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); tokens["AfterMigrationFolderName"] = AfterMigrationFolderName.to_string(); tokens["AlterDatabaseFolderName"] = AlterDatabaseFolderName.to_string(); tokens["Baseline"] = Baseline.to_string(); tokens["BeforeMigrationFolderName"] = BeforeMigrationFolderName.to_string(); tokens["CommandTimeout"] = CommandTimeout.to_string(); tokens["CommandTimeoutAdmin"] = CommandTimeoutAdmin.to_string(); tokens["ConfigurationFile"] = ConfigurationFile.to_string(); tokens["ConnectionString"] = ConnectionString.to_string(); tokens["ConnectionStringAdmin"] = ConnectionStringAdmin.to_string(); tokens["CreateDatabaseCustomScript"] = CreateDatabaseCustomScript.to_string(); tokens["DatabaseName"] = DatabaseName.to_string(); tokens["DatabaseType"] = DatabaseType.to_string(); tokens["Debug"] = Debug.to_string(); tokens["DisableOutput"] = DisableOutput.to_string(); tokens["DisableTokenReplacement"] = DisableTokenReplacement.to_string(); tokens["DoNotAlterDatabase"] = DoNotAlterDatabase.to_string(); tokens["DoNotCreateDatabase"] = DoNotCreateDatabase.to_string(); tokens["DoNotStoreScriptsRunText"] = DoNotStoreScriptsRunText.to_string(); tokens["DownFolderName"] = DownFolderName.to_string(); tokens["Drop"] = Drop.to_string(); tokens["DryRun"] = DryRun.to_string(); tokens["EnvironmentName"] = string.Join(",", EnvironmentNames); tokens["EnvironmentNames"] = string.Join(",", EnvironmentNames); tokens["FunctionsFolderName"] = FunctionsFolderName.to_string(); tokens["IndexesFolderName"] = IndexesFolderName.to_string(); tokens["Initialize"] = Initialize.to_string(); tokens["OutputPath"] = OutputPath.to_string(); tokens["PermissionsFolderName"] = PermissionsFolderName.to_string(); tokens["RecoveryMode"] = RecoveryMode.to_string(); tokens["RepositoryPath"] = RepositoryPath.to_string(); tokens["Restore"] = Restore.to_string(); tokens["RestoreCustomOptions"] = RestoreCustomOptions.to_string(); tokens["RestoreFromPath"] = RestoreFromPath.to_string(); tokens["RestoreTimeout"] = RestoreTimeout.to_string(); tokens["RunAfterCreateDatabaseFolderName"] = RunAfterCreateDatabaseFolderName.to_string(); tokens["RunAfterOtherAnyTimeScriptsFolderName"] = RunAfterOtherAnyTimeScriptsFolderName.to_string(); tokens["RunAllAnyTimeScripts"] = RunAllAnyTimeScripts.to_string(); tokens["RunBeforeUpFolderName"] = RunBeforeUpFolderName.to_string(); tokens["RunFirstAfterUpFolderName"] = RunFirstAfterUpFolderName.to_string(); tokens["SchemaName"] = SchemaName.to_string(); tokens["ScriptsRunErrorsTableName"] = ScriptsRunErrorsTableName.to_string(); tokens["ScriptsRunTableName"] = ScriptsRunTableName.to_string(); tokens["SearchAllSubdirectoriesInsteadOfTraverse"] = SearchAllSubdirectoriesInsteadOfTraverse.to_string(); tokens["ServerName"] = ServerName.to_string(); tokens["Silent"] = Silent.to_string(); tokens["SprocsFolderName"] = SprocsFolderName.to_string(); tokens["SqlFilesDirectory"] = SqlFilesDirectory.to_string(); tokens["TriggersFolderName"] = TriggersFolderName.to_string(); tokens["UpFolderName"] = UpFolderName.to_string(); tokens["Version"] = Version.to_string(); tokens["VersionFile"] = VersionFile.to_string(); tokens["VersionTableName"] = VersionTableName.to_string(); tokens["VersionXPath"] = VersionXPath.to_string(); tokens["ViewsFolderName"] = ViewsFolderName.to_string(); tokens["WarnAndIgnoreOnOneTimeScriptChanges"] = WarnAndIgnoreOnOneTimeScriptChanges.to_string(); tokens["WarnOnOneTimeScriptChanges"] = WarnOnOneTimeScriptChanges.to_string(); tokens["WithTransaction"] = WithTransaction.to_string(); if (UserTokens != null) { foreach (var t in UserTokens) { tokens[t.Key] = t.Value; } } return(tokens); }
private void RecoverQueue(int queueId, int messageId, RecoveryMode recoveryMode) { using (var transaction = Repository.CreateProcessingTransaction(TransactionIsolationLevel.ReadCommitted, TimeSpan.FromMinutes(1))) { switch (recoveryMode) { case RecoveryMode.MakeLast: Repository.MoveMessageToEnd(messageId, transaction); break; case RecoveryMode.MarkAsFailed: Repository.CopyMessageToFailed(messageId, transaction); Repository.RemoveMessage(new [] {messageId}, transaction); break; case RecoveryMode.Remove: Repository.RemoveMessage(new[] { messageId }, transaction); break; default: // should not happen throw new NotImplementedException(); } Repository.ReleaseQueue(queueId, transaction); transaction.Complete(); } }
private void DrawProject() { GUILayout.Space(5F); EditorGUILayout.BeginVertical("ButtonLeft"); { this.openAutoRecovery = EditorGUILayout.Foldout(this.openAutoRecovery, "Recovery Settings (" + Enum.GetName(typeof(RecoveryMode), this.recoveryMode) + ")"); if (this.openAutoRecovery == true) { this.recoveryMode = (RecoveryMode)EditorGUILayout.EnumPopup("Recovery Mode", this.recoveryMode); if (this.recoveryMode == RecoveryMode.Automatic) { this.promptOnPause = EditorGUILayout.Toggle(this.promptOnPauseContent, this.promptOnPause); this.useCache = EditorGUILayout.Toggle(this.useCacheContent, this.useCache); this.supaFast = EditorGUILayout.Toggle(supaFastContent, this.supaFast); this.recoveryLogFilePath = NGEditorGUILayout.SaveFileField("Recovery Log File", this.recoveryLogFilePath); } GUILayout.Space(5F); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button("Scan", GeneralStyles.BigButton) == true) { string[] assets = AssetDatabase.GetAllAssetPaths(); this.hasResult = true; this.selectedMissing = -1; this.missings.Clear(); try { for (int i = 0; i < assets.Length; i++) { if (assets[i].EndsWith(".prefab") == false) { continue; } if (EditorUtility.DisplayCancelableProgressBar(NGMissingScriptRecoveryWindow.NormalTitle, "Scanning " + assets[i], (float)i / (float)assets.Length) == true) { break; } Object[] content = AssetDatabase.LoadAllAssetsAtPath(assets[i]); for (int j = 0; j < content.Length; j++) { GameObject go = content[j] as GameObject; if (go != null) { Component[] components = go.GetComponents <Component>(); for (int k = 0; k < components.Length; k++) { if (components[k] == null) { this.missings.Add(new MissingGameObject(go)); break; } } } } } } finally { EditorUtility.ClearProgressBar(); } return; } } GUILayout.FlexibleSpace(); if (this.cachedComponentFixes.Count > 0) { if (GUILayout.Button("Clear Recovery Cache (" + this.cachedComponentFixes.Count + " elements)", GeneralStyles.BigButton) == true) { this.cachedComponentFixes.Clear(); } } } EditorGUILayout.EndHorizontal(); if (this.hasResult == true) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Result"); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true) { this.hasResult = false; } } EditorGUILayout.EndHorizontal(); if (this.missings.Count == 0) { GUILayout.Label("No missing script found."); } else { this.scrollPositionResult = EditorGUILayout.BeginScrollView(this.scrollPositionResult); { for (int i = 0; i < this.missings.Count; i++) { EditorGUILayout.BeginHorizontal(); { NGEditorGUILayout.PingObject(this.missings[i].path, this.missings[i].gameObject, GeneralStyles.LeftButton); if (GUILayout.Button("Fix", GUILayoutOptionPool.Width(75F)) == true) { this.selectedMissing = i; this.tab = 0; this.Diagnose(this.missings[i].gameObject); } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (this.recoveryMode == RecoveryMode.Automatic) { EditorGUILayout.HelpBox("Backup your project before\ndoing any automatic recovery.", MessageType.Warning); } using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { if (GUILayout.Button("Start Recovery", GeneralStyles.BigButton) == true) { Utility.StartBackgroundTask(this.RecoveryTask()); } } } EditorGUILayout.EndHorizontal(); } } }