/**
 * @(#)file    GetEhrDataBiz.java
 * @(#)author  gyeongmo an
 * @(#)date    2014.6.30
 */

package kr.co.udapsoft.ebid.buyer.sycs.user.biz;

import java.sql.CallableStatement;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.util.ValueObject;

import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;


public class GetErpDataBiz extends Biz {

	public GetErpDataBiz(HandlerStorage storage) {
		super(storage);
	}

	public void doBiz() throws Exception {
		
        boolean success = false;

        if(storage.compareEvent("PROC")){
        	success = getErpData();
        }
        
        storage.setSuccess(success);
	}
	
	
	/**
	 * ERP에서 데이터가져오는 프로시져 실행
	 * @return
	 */
	public boolean getErpData() {

        try {
            conn.begin();
            
            if( !params.get("procName").equals("") ) {
        		CallableStatement cs 	= null;
        		String pssql			= "";
        		
            	pssql = "{call ETEC_ERPIF."+params.get("procName")+"()}";
            	cs = super.conn.getConnection().prepareCall(pssql);
            	cs.execute();
            	
            }

            return true;
        } catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getErpData() : " + e.getMessage());
            WAFLogger.error(e);
            conn.setRollback();
            storage.setMessage(e.toString());
            storage.setDetailMessage(e);
            return false;
        } finally {
            conn.end();
        }
    }
}
