public void Insert(ActionLog log) { string sql = string.Format(@"INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES (@{1},@{2},@{3},@{4},@{5}) SELECT SCOPE_IDENTITY()", ActionLog.TABLENAME, ActionLog.USERID, ActionLog.TARGETUSERID, ActionLog.ACTION, ActionLog.DETAIL, ActionLog.IPADDRESS); object id = base.ExecuteScalar(sql, new SqlParameter(ActionLog.USERID, log.UserId), new SqlParameter(ActionLog.TARGETUSERID, log.TargetUserId), new SqlParameter(ActionLog.ACTION, log.Action), new SqlParameter(ActionLog.DETAIL, log.Detail), new SqlParameter(ActionLog.IPADDRESS, log.IPAddress)); log.LogId = Convert.ToInt32(id); }
public static void Log(User user, User targetUser, string action, string detail) { var log = new ActionLog { UserId = user.UserId, TargetUserId=targetUser.UserId, Action = action, Detail = detail, IPAddress = IPHelper.IPAddress }; var daActionLog = GetLogDA(); daActionLog.Insert(log); }