예제 #1
0
        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());
        }
예제 #2
0
        public ISqlScript[] GetScripts()
        {
            var files   = new List <ISqlScript>();
            var baseDir = BaseFolder;

            var filteredFolders = Folders.ToList();

            foreach (var folder in filteredFolders)
            {
                var fullPath = Path.Combine(baseDir, folder.Path.Trim('\\'));
                if (!Directory.Exists(fullPath))
                {
                    ConsoleWrite.WriteLine("> Folder not found (ignored): " + fullPath, ConsoleColor.Yellow);
                    continue;
                }

                foreach (var filePath in Directory.GetFiles(fullPath, "*.sql", SearchOption.AllDirectories))
                {
                    var content = File.ReadAllText(filePath);
                    var name    = filePath.Replace(baseDir, "");
                    if (files.All(x => x.Name != name))
                    {
                        files.Add(new SqlScript(name, content));
                    }
                }
            }

            return(files.ToArray());
        }
예제 #3
0
        public void WriteLine_ConsoleWrite_Input()
        {
            string message = "Console Write Test"; //bruges til test input

            _uut.WriteLine(message);               //input (det er det her som er console write)
            Assert.That(message, Is.EqualTo(message));
        }
예제 #4
0
 public Topic(string name)
 {
     ConsoleWrite.WriteLine($"{new String('-', 10)} {name}", ConsoleColor.Green);
     this.Name = name;
 }
예제 #5
0
        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);
        }