25 namespace Ntp.Data.Log
34 public static void SqlExecute(
this LogBase log,
string sql, IDataParameterCollection parameters)
36 string query = $
"{sql} ";
37 foreach (IDataParameter parameter
in parameters)
39 query = query.Replace($
"{parameter.ParameterName} ", $
"{GetDbDataParameterValue(parameter)} ");
40 query = query.Replace($
"{parameter.ParameterName},", $
"{GetDbDataParameterValue(parameter)},");
41 query = query.Replace($
"{parameter.ParameterName};", $
"{GetDbDataParameterValue(parameter)};");
42 query = query.Replace($
"{parameter.ParameterName})", $
"{GetDbDataParameterValue(parameter)})");
45 log.WriteLine(query.Trim(),
Severity.Trace);
51 "Applying database changes...",
58 "Waiting for database link.",
62 $
"Database connection timeout is {connection.ConnectionTimeout} seconds.",
66 "DATABASE CONNECTION STRING COULD CONTAIN SENSITIVE INFORMATION.",
70 $
"DATABASE CONNECTION STRING IS [{connection.ConnectionString}]",
114 log.
WriteLine(
"Database version is -1. Did you set 'Create Yes' in configuration ?",
Severity.Notice);
118 $
"Application version is {application} but database version is {database}.",
121 if (database > application)
125 else if (database < application)
169 case DbType.AnsiString:
170 case DbType.AnsiStringFixedLength:
173 case DbType.StringFixedLength:
175 return $
"\'{p.Value.ToString().Replace("'", "''")}\'"; 177 return p.Value.ToString(); 179 case DbType.DateTime: 180 return $"\'{Convert.ToDateTime(p.Value).ToString("yyyy-MM-dd HH:mm:ss")}\'"; 181 case DbType.DateTime2: 182 case DbType.DateTimeOffset: 183 return p.Value.ToString(); 185 return p.Value.ToString(); 189 return Convert.ToBoolean(p.Value) ? "1" : "0"; 198 return p.Value.ToString(); 202 case DbType.Currency: 203 case DbType.VarNumeric: 204 return p.Value.ToString(); 206 return p.Value.ToString(); static void SchemaUpdated(this LogBase log, string version)
static void SchemaChangesApplied(this LogBase log, string version)
abstract void WriteLine(string text, Severity severity)
static void SchemaUpToDate(this LogBase log)
static void VersionTableParamError(this LogBase log)
static void AwaitingDbLink(this LogBase log, IDbConnection connection)
static void SchemaVersionError(this LogBase log, int database, int application)
static void VersionTableCreateError(this LogBase log, Exception e)
static void DbLinkUp(this LogBase log)
static void SchemaUpdateError(this LogBase log, Exception e)
static string GetDbDataParameterValue(IDataParameter p)
static void VersionTableUpdateError(this LogBase log, Exception e)
static void ApplySchemaChanges(this LogBase log)
static void SqlExecute(this LogBase log, string sql)
static void VersionTableInsertError(this LogBase log, Exception e)
static void VersionTableFetchError(this LogBase log, Exception e)
static void DbLinkError(this LogBase log, Exception e)
static void SqlExecute(this LogBase log, string sql, IDataParameterCollection parameters)
static void VersionTableCreated(this LogBase log)
static void DbLinkDown(this LogBase log)