/*
 * Created on 27-sep-2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.fenalco.utilities.fileloader;


import com.fenalco.utilities.database.ExecuteSQLException;
import com.fenalco.utilities.database.SQLUtilities;

/**
 * @author andres
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class Statistics implements EventListener
{
	private static final String tableName = "carga_archivos";

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.fenalco.utilities.fileloader.EventListener#processEvent(com.fenalco.utilities.fileloader.Event)
	 */
	public void processEvent(Event e)
	{
		int id = Math.abs(e.getFileName().hashCode() + e.getStatus().hashCode()
				+ e.getTime().hashCode());

		String sql = "INSERT INTO " + tableName
				+ " (carg_arch_id, carg_arch_nombre_archivo, carg_arch_estado, " 
				+ "carg_arch_fecha_hora) VALUES ("
				+ id + ", " + "\'" + e.getFileName() + "\', " + "\'"
				+ e.getStatus() + "\', " + "\'" + e.getTime() + "\');";

		try
		{
			SQLUtilities.execute(sql);
		} 
		catch( ExecuteSQLException e1 )
		{
			e1.printStackTrace();
		}

	}

}