using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using Swarmops.Common; using Swarmops.Basic.Types; using Swarmops.Basic.Types.System; namespace Swarmops.Database { public partial class SwarmDb { public int CreatePWLogEntry (DateTime dateTimeUtc, int actingPersonId, string affectedItemType, int affectedItemId, string actionType, string actionDescription, string changedField, string valueBefore, string valueAfter, string comment, string ipAddress) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand ("CreatePWLogEntry2", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName (command, "dateTimeUtc", dateTimeUtc); AddParameterWithName (command, "actingPersonId", actingPersonId); AddParameterWithName (command, "affectedItemType", affectedItemType); AddParameterWithName (command, "affectedItemId", affectedItemId); AddParameterWithName (command, "actionType", actionType); AddParameterWithName (command, "actionDescription", actionDescription); AddParameterWithName (command, "changedField", changedField); AddParameterWithName (command, "valueBefore", valueBefore); AddParameterWithName (command, "valueAfter", valueAfter); AddParameterWithName (command, "comment", comment); AddParameterWithName (command, "ipAddress", ipAddress); int logEntryId = Convert.ToInt32 (command.ExecuteScalar()); return logEntryId; } } public DateTime CheckLogEntry (string affectedItemType, int affectedItemId, string actionType) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand ( "SELECT Max(DateTimeUtc) from PWLog WHERE AffectedItemId=" + affectedItemId + " AND AffectedItemType='" + affectedItemType + "' AND ActionType='" + actionType + "'", connection); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { if (!reader.IsDBNull (0)) { return reader.GetDateTime (0); } } return Constants.DateTimeLow; } } } public BasicPWLog[] GetLatestEvents (string affectedItemType, DateTime beforeDate, int[] affectedIds, string[] actionTypes) { List retlist = new List(); using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand ("SELECT DateTimeUtc, ActingPersonId, AffectedItemType, AffectedItemId, ActionType, " + " ActionDescription, ChangedField, ValueBefore, ValueAfter, Comment, IpAddress " + " FROM PWLog " +