package nc.message.bs;

import nc.bs.businessevent.BusinessEvent;
import nc.bs.businessevent.IBusinessEvent;
import nc.bs.businessevent.IBusinessListener;
import nc.message.msgcenter.event.MessageStatesChangeContext;
import nc.vo.pub.BusinessException;

public class MessageSendListener implements IBusinessListener {

	public void doAction(IBusinessEvent event) throws BusinessException {
		// TODO Auto-generated method stub
		BusinessEvent.BusinessUserObj busiObj=(BusinessEvent.BusinessUserObj)event.getUserObject();
		
		MessageStatesChangeContext context = (MessageStatesChangeContext)busiObj.getUserObj();
		
		if(context != null) {
			String  eventStatus= context.getEventStates();
			if(context.getMessage()!=null && !"add".equals(eventStatus) && !"update".equals(eventStatus)) {
				String[] handelpks = context.getHandlepks();
				if(handelpks !=null) {
					/*
					 * for(int i=0;i<handelpks.length;i++) {
					 * 
					 * IdeldbMessage mes = null; if (!com.yonyou.cloud.ncc.NCCEnv.isMerged()) { mes
					 * = IrisNCLocator.getInstance().lookup(IdeldbMessage.class); }else { mes =
					 * NCLocator.getInstance().lookup(IdeldbMessage.class); }
					 * mes.deleteTodo("("+stringArray2Strin(handelpks)+")"); }
					 */
				}
			}
		}
	}
	
	public static String stringArray2Strin(String[] str) { 
		 
		StringBuffer sb = new StringBuffer(); 
		for (int i = 0; i < str.length; i++) { 
			sb.append("'").append(str[i]).append("'").append(","); 
		} 
		return sb.toString().substring(0, sb.length() - 1); 
	}

}
