public DatabaseEvent(DatabaseEventExecutionContext context, int eventClass, string databaseName, int spid, string text, DateTime?startTime, DateTime?endTime, long eventSequence) { Context = context; EventType = eventClass; Text = text; StartTime = startTime; EndTime = endTime; Spid = spid; DatabaseName = databaseName; EventSequence = eventSequence; }
public ExistingConnectionEvent(DatabaseEventExecutionContext context, int spid, string text, DateTime?startTime, long eventSequence) : base(context, EXISTING_CONNECTION, "", spid, text, startTime, null, eventSequence) { }
public NonQueryEvent(DatabaseEventExecutionContext context, int spid, string text, string databaseName, DateTime?startTime, long eventSequence) : base(context, NONQUERY, databaseName, spid, text, startTime, null, eventSequence) { }
public LoginEvent(DatabaseEventExecutionContext context, int spid, string text, DateTime?startTime, long eventSequence) : base(context, AUDIT_LOGIN, "", spid, text, startTime, null, eventSequence) { }
public static void Build(DatabaseEventExecutionContext context, DataTable traceTable) { IList <DatabaseEvent> list = context.Events; for (int i = 0; i < traceTable.Rows.Count; i++) { string text = traceTable.Rows[i]["TextData"].ToString(); DateTime?startTime = null; object obj = traceTable.Rows[i]["StartTime"]; if (!(obj is DBNull)) { startTime = (DateTime)obj; } DateTime?endTime = null; obj = traceTable.Rows[i]["EndTime"]; if (!(obj is DBNull)) { endTime = (DateTime)obj; } string databaseName = ""; obj = traceTable.Rows[i]["DatabaseName"]; if (!(obj is DBNull)) { databaseName = (string)obj; } int spid = (int)traceTable.Rows[i]["SPID"]; int eventClass = (int)traceTable.Rows[i]["EventClass"]; long eventSequence = (long)traceTable.Rows[i]["EventSequence"]; DatabaseEvent e = null; switch (eventClass) { case AUDIT_LOGIN: e = new LoginEvent(context, spid, text, startTime, eventSequence); break; case AUDIT_LOGOUT: e = new LogoutEvent(context, spid, text, startTime, eventSequence); break; case EXISTING_CONNECTION: e = new ExistingConnectionEvent(context, spid, text, startTime, eventSequence); break; case SQL_BATCH_STARTING: if (text.Substring(0, 6).ToLower().Equals("select")) { e = new QueryEvent(context, spid, text, databaseName, startTime, eventSequence); } else { e = new NonQueryEvent(context, spid, text, databaseName, startTime, eventSequence); } break; case RPC_STARTING: e = new NonQueryEvent(context, spid, text, databaseName, startTime, eventSequence); break; default: break; } list.Add(e); } }