public override string ToString() { ConsoleWrite.Write("Subject: "); ConsoleWrite.Write($"{this.Subject.ToString()}", ConsoleColor.Cyan); Console.WriteLine(); ConsoleWrite.Write("Presentation URL: "); ConsoleWrite.Write($"{this.PresentationUrl.ToString()}", ConsoleColor.Cyan); Console.WriteLine(); ConsoleWrite.Write($"Speaker: "); ConsoleWrite.Write($"{this.Speaker.Name}", ConsoleColor.Cyan); Console.WriteLine(); ConsoleWrite.Write("Company: "); ConsoleWrite.Write($"{this.Speaker.Company.Name}", ConsoleColor.Cyan); Console.WriteLine(); ConsoleWrite.Write("Role: "); ConsoleWrite.Write($"{this.Speaker.Company.Role}", ConsoleColor.Cyan); Console.WriteLine(); ConsoleWrite.WriteLine($"Contacts:"); ConsoleWrite.WriteLine($"- LinkedIn: {this.Speaker.Linkedin}", ConsoleColor.Cyan); ConsoleWrite.WriteLine($"- GitHub: {this.Speaker.GitHub}", ConsoleColor.Cyan); return(base.ToString()); }
public DatabaseUpgradeResult Upgrade(string companyId = "1", IJournal journal = null, bool withFileListConfirmation = false) { ConsoleWrite.WriteLine("Start", ConsoleColor.Green); Stopwatch sw = new Stopwatch(); sw.Start(); var scripts = Manifest.GetScripts().Select(s => new SqlScript(s.Name, s.Contents)); var engine = DeployChanges.To.SqlDatabase(ConnectionString) .WithScripts(scripts) .LogToConsole(); engine.Configure(c => { c.Variables.Add("CompanyId", companyId); foreach (var entry in Variables) { c.Variables.Add(entry.Key, entry.Value); } }); if (journal != null) { engine.JournalTo(journal); } engine.Configure(c => { c.ConnectionManager.TransactionMode = TransactionMode.NoTransaction; c.ScriptExecutor.ExecutionTimeoutSeconds = 30 * 60; // 30 minutes in seconds }); var build = engine.Build(); if (withFileListConfirmation) { var scriptsToExecute = build.GetScriptsToExecute(); for (int i = 0; i < scriptsToExecute.Count; i++) { ConsoleWrite.WriteLine((i + 1) + ". " + scriptsToExecute[i].Name, ConsoleColor.White); } ConsoleWrite.WriteLine("> Countinue ? (y/n)", ConsoleColor.Green); var key = Console.ReadKey(); if (key.Key != ConsoleKey.Y) { ConsoleWrite.WriteLine("> Upgrade terminated", ConsoleColor.White); return(null); } } var result = build.PerformUpgrade(); sw.Stop(); if (result.Successful && result.Scripts.Any()) { ConsoleWrite.WriteLine("> Database Upgrade completed successfuly: ", ConsoleColor.Green); ConsoleWrite.Write("> Number of executed scripts: ", ConsoleColor.White); ConsoleWrite.WriteLine(result.Scripts.Count().ToString(), ConsoleColor.Green); ConsoleWrite.Write("> Time: ", ConsoleColor.White); ConsoleWrite.WriteLine(sw.Elapsed.Seconds + " sec.", ConsoleColor.Green); ConsoleWrite.WriteLine("> Refresing modules..", ConsoleColor.White); engine.RefreshModules(); ConsoleWrite.WriteLine("> Modules refreshed", ConsoleColor.Green); } else if (!result.Successful) { ConsoleWrite.WriteLine("> Upgrade failed", ConsoleColor.Red); } else { ConsoleWrite.WriteLine("> Nothing to do, all is up to date", ConsoleColor.Green); } return(result); }