package nc.pub.util;

import nc.bcmanage.bs.IBusiCenterManageService;
import nc.bcmanage.vo.BusiCenterVO;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.log.NcLog;
import nc.vo.pub.BusinessException;

public class DataSourceUtil {
	
	
	
	/**
	 * 
	 * 设置NC数据源
	 * 
	 */
	public static void setDataSource() throws BusinessException{
	   BusiCenterVO[] centerVOs = getBusiCenterVOs();
	   if (centerVOs != null && centerVOs.length > 0) {
	   // 设置数据源，默认只有一个账套
	  InvocationInfoProxy.getInstance().setUserDataSource(
	  centerVOs[0].getDataSourceName());//设置数据源----第一条数据

     }
   }
	
	

	/**
	 * 
	 * 获取当前所有数据源
	 * 
	 */
	
	  private static BusiCenterVO[] getBusiCenterVOs() throws BusinessException{
          IBusiCenterManageService service = NCLocator.getInstance().lookup(
                      IBusiCenterManageService.class);
       
          BusiCenterVO[]   centerVOs = service.getBusiCenterVOs();
       
          return centerVOs;
	  }

}
