private void SaveSchema <T>(string schema, FbSchemaBaseCollection <T> collection) where T : IFbSchemaItem { IFbSchemaItem item; string fileName = $"{_workPath}\\{schema}.log"; try { _log.MessageLn($"{strings.extractingSchema} {schema}..."); var table = GetShema(schema); using (StreamWriter sw = new StreamWriter(fileName, File.Exists(fileName))) { foreach (DataRow row in table.Rows) { item = collection.GetNewItem(); item.ProcessDataRow(row); foreach (DataColumn col in table.Columns) { sw.WriteLine("{0} = {1}", col.ColumnName, row[col]); } sw.WriteLine("============================"); } sw.Close(); } } catch (Exception e) { _log.ErrorLn($"{strings.error} {schema} - {e.Message}"); } }
private void DoRemove(DbObjects item) { int x = Console.CursorLeft; int y = Console.CursorTop; if (!item.Checked) { foreach (var depend in item.Dependencies) { DoRemove(depend); } Console.SetCursorPosition(x, y); _log.Message($" - {item.Name.Insert(item.Name.Length, C_EMPTY_TABLE_NAME)}"); try { item.ExecOrder = _log.GetExecOrder(); item.SQL = GetDeleteSQL(item); item.RevertSQL = GetRollbackSQL(item); _connection.Execute(item.SQL); item.Checked = true; Console.SetCursorPosition(x, y); } catch (Exception e) { _log.ErrorLn($"{strings.error}> {item.Name.Trim()} : {e.Message}"); x = Console.CursorLeft; y = Console.CursorTop; } } }
private bool ConnectDataBase() { _log.MessageLn(strings.connectingDataBase); try { var con = new FbConnection($@"User={_options.UserName};Password={_options.Password};Database={_options.DataBase};DataSource={_options.ServerName};"); con.Open(); dataBase = con; return(true); } catch (Exception e) { _log.ErrorLn(e.Message); return(false); } }
public void ErrorLn(string mens) { ColorConsole.WriteLine(mens.Red()); file.ErrorLn(mens); }