Search in sources :

Example 11 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit in project ExciteBot by TheGameCommunity.

the class DiscoveryAudit method addProfileDiscovery.

@SuppressWarnings("rawtypes")
public static DiscoveryAudit addProfileDiscovery(MessageContext context, boolean automatic, Player player) {
    Audit parent = Audit.addAudit(context, AuditType.DISCOVERY_AUDIT, getMessage(context, automatic, player));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_PROFILE_DISCOVERIES).setColumns(AUDIT_ID, PLAYER_ID).to(parent.getID(), player.getID()).prepare(context, true);
        st.execute();
        DiscoveryAudit ret = getProfileDiscoveryByDiscoveredID(ConsoleContext.INSTANCE, player.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 12 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit in project ExciteBot by TheGameCommunity.

the class MailAudit method addMailAudit.

@SuppressWarnings("rawtypes")
public static MailAudit addMailAudit(MessageContext context, MimeMessage message, boolean incoming, File file) throws AddressException, MessagingException {
    ElectronicAddress from = new EmailAddress(message.getFrom()[0]);
    ElectronicAddress to = new EmailAddress(new InternetAddress(message.getHeader("To")[0]));
    String description = from.getEmail() + " sent mail to " + to.getEmail();
    String[] appIDHeader = message.getHeader(Mailbox.APP_ID_HEADER);
    String mailType = "GENERIC";
    if (appIDHeader != null) {
        switch(appIDHeader[0]) {
            case Mailbox.FRIEND_REQUEST:
                description = from + " sent a friend request to " + to;
                mailType = "FRIEND_REQUEST";
                break;
            case Mailbox.EXCITEBOTS:
                description = from + " sent a challenge to " + to;
                mailType = "CHALLENGE";
                break;
        }
    }
    Audit parent = Audit.addAudit(context, AuditType.MAIL_AUDIT, description);
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.MAIL).setColumns(AUDIT_ID, SENDER, RECIPIENT, INCOMING, MAIL_TYPE, FILE).to(parent.getID(), from.getEmail(), to.getEmail(), incoming, mailType, file.getAbsolutePath()).prepare(context, true);
        st.execute();
        MailAudit ret = getMailAuditByAuditID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) SQLException(java.sql.SQLException) IOError(java.io.IOError) ElectronicAddress(com.gamebuster19901.excite.bot.mail.ElectronicAddress) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement) EmailAddress(com.gamebuster19901.excite.bot.mail.EmailAddress)

Example 13 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit in project ExciteBot by TheGameCommunity.

the class NameChangeAudit method addNameChange.

@SuppressWarnings("rawtypes")
public static NameChangeAudit addNameChange(MessageContext context, Player player, String newName) {
    Audit parent = Audit.addAudit(ConsoleContext.INSTANCE, context, AuditType.NAME_CHANGE_AUDIT, getMessage(context, newName));
    String name = player.getName();
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_NAME_CHANGES).setColumns(AUDIT_ID, OLD_PLAYER_NAME, NEW_PLAYER_NAME, PLAYER_ID, FRIEND_CODE).to(parent.getID(), name, newName, player.getID(), player.getFriendCode()).prepare(ConsoleContext.INSTANCE, true);
        st.execute();
        NameChangeAudit ret = getNameChangeByAuditID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 14 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit in project ExciteBot by TheGameCommunity.

the class RankChangeAudit method addRankChange.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static RankChangeAudit addRankChange(MessageContext context, DiscordUser promotee, String rank, boolean added) {
    Audit parent = Audit.addAudit(ConsoleContext.INSTANCE, context, AuditType.RANK_CHANGE_AUDIT, getMessage(context, new MessageContext(promotee), rank, added));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(AUDIT_RANK_CHANGES).setColumns(AUDIT_ID, PROMOTEE, PROMOTEE_ID).to(parent.getID(), promotee, promotee.getID()).prepare(ConsoleContext.INSTANCE, true);
        st.execute();
        RankChangeAudit ret = getRankChangeAuditByID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement) MessageContext(com.gamebuster19901.excite.bot.command.MessageContext)

Example 15 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit in project ExciteBot by TheGameCommunity.

the class TransactionAudit method addTransactionAudit.

public static TransactionAudit addTransactionAudit(MessageContext context, Transaction transaction) {
    Audit parent = Audit.addAudit(context, AuditType.TRANSACTION_AUDIT, getMessage(context, transaction));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(AUDIT_TRANSACTIONS).setColumns(AUDIT_ID, RECIPIENT, TRANSACTION_TYPE, AMOUNT, CURRENCY, WALLET).to(parent.getID(), transaction.getBalanceHolder(), transaction.getTransactionType(), transaction.getAmount(), transaction.getCurrency(), transaction.getWallet()).prepare(context, true);
        st.execute();
        TransactionAudit ret = getTransactionAuditByAuditID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Aggregations

PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)14 IOError (java.io.IOError)14 SQLException (java.sql.SQLException)14 Audit (com.gamebuster19901.excite.bot.audit.Audit)2 MessageContext (com.gamebuster19901.excite.bot.command.MessageContext)2 Comparison (com.gamebuster19901.excite.bot.database.Comparison)2 Row (com.gamebuster19901.excite.bot.database.Row)2 ElectronicAddress (com.gamebuster19901.excite.bot.mail.ElectronicAddress)2 Nullable (javax.annotation.Nullable)2 AuditType (com.gamebuster19901.excite.bot.audit.AuditType)1 Result (com.gamebuster19901.excite.bot.database.Result)1 ResultSet (com.gamebuster19901.excite.bot.database.sql.ResultSet)1 AddFriendResponse (com.gamebuster19901.excite.bot.mail.AddFriendResponse)1 EmailAddress (com.gamebuster19901.excite.bot.mail.EmailAddress)1 RefundResponse (com.gamebuster19901.excite.bot.mail.RefundResponse)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InternetAddress (javax.mail.internet.InternetAddress)1