private void DoAppend(LogEventInfo logEvent) { IDbCommand command = _activeConnection.CreateCommand(); command.CommandText = CommandTextLayout.GetFormattedMessage(logEvent); foreach (DatabaseParameterInfo par in Parameters) { IDbDataParameter p = command.CreateParameter(); p.Direction = ParameterDirection.Input; if (par.Name != null) { p.ParameterName = par.Name; } if (par.Size != 0) { p.Size = par.Size; } if (par.Precision != 0) { p.Precision = par.Precision; } if (par.Scale != 0) { p.Scale = par.Scale; } p.Value = par.CompiledLayout.GetFormattedMessage(logEvent); command.Parameters.Add(p); } command.ExecuteNonQuery(); }
/// <summary> /// Adds all layouts used by this target to the specified collection. /// </summary> /// <param name="layouts">The collection to add layouts to.</param> public override void PopulateLayouts(LayoutCollection layouts) { base.PopulateLayouts(layouts); if (DBHostLayout != null) { DBHostLayout.PopulateLayouts(layouts); } if (DBUserNameLayout != null) { DBUserNameLayout.PopulateLayouts(layouts); } if (DBDatabaseLayout != null) { DBDatabaseLayout.PopulateLayouts(layouts); } if (DBPasswordLayout != null) { DBPasswordLayout.PopulateLayouts(layouts); } if (CommandTextLayout != null) { CommandTextLayout.PopulateLayouts(layouts); } for (int i = 0; i < Parameters.Count; ++i) { if (Parameters[i].CompiledLayout != null) { Parameters[i].CompiledLayout.PopulateLayouts(layouts); } } }