public static void draw() { //Draw Command Window ConsoleGui.WriteLine("|| - Commands"); ConsoleGui.Write("|| "); ConsoleGui.Write("|{0}Clear | ", clearSelected ? " *" : " "); ConsoleGui.Write("|{0}Exit |", exitSelected ? " *" : " "); ConsoleGui.WriteLine(); ConsoleGui.Write("|{0}Enter |", enterSelected ? " *" : " "); ConsoleGui.Write("|{0}", inputString); ConsoleGui.WriteLine("\n|| ---------"); //Draw Message Window ConsoleGui.WriteLine("------------"); ConsoleGui.WriteLine("|| - Messages"); if (messages.Count > MSG_COUNT) { //display last MSG_COUNT number of messages for (int i = messages.Count - 1; i >= messages.Count - MSG_COUNT; i--) { ConsoleGui.WriteLine("{0} - {1}", i, messages[i]); } } else { //display messages for (int i = messages.Count - 1; i >= 0; i--) { ConsoleGui.WriteLine("{0} - {1}", i, messages[i]); } } ConsoleGui.WriteLine("|| ---------"); }
static void Main(string[] args) { ConsoleGui.WriteGui(); var apexProduct = ApexProduct.Unknown; var apexPath = string.Empty; ConsoleGui.WriteLine("1. ApexSQL Log"); ConsoleGui.WriteLine("2. ApexSQL Recover"); ConsoleGui.WriteLine(); ConsoleGui.Write("请输入产品序号:"); var keyInfo = Console.ReadKey(); ConsoleGui.WriteLine(); ConsoleGui.Write("请输入产品路径:"); switch (keyInfo.KeyChar) { case '1': { apexProduct = ApexProduct.ApexLog; apexPath = Console.ReadLine(); } break; case '2': { apexProduct = ApexProduct.ApexRecover; apexPath = Console.ReadLine(); } break; } ConsoleGui.WriteLine(); if (apexProduct != ApexProduct.Unknown) { try { var dirInfo = new DirectoryInfo(apexPath); if (dirInfo.Exists) { if (apexProduct == ApexProduct.ApexLog || apexProduct == ApexProduct.ApexRecover) { var files = dirInfo.GetFiles("ApexSQL.Engine.Communication.dll", SearchOption.TopDirectoryOnly); if (files != null && files.Any()) { var filePath = files.First().FullName; var filePathBak = $"{filePath}.bak"; if (File.Exists(filePathBak)) { File.Delete(filePathBak); } files.First().MoveTo($"{filePath}.bak"); ReleasePatchFile(filePath); ConsoleGui.Write("成功"); } } } } catch { return; } } Console.ReadKey(); }
public static void WriteLine(string format, params object[] args) { string s = String.Format(format, args); ConsoleGui.WriteLine(s); }