package nccloud.web.hrhi.psndoc.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Map;
import nc.hr.utils.HRFileUtils;
import nccloud.base.exception.ExceptionUtils;
import nccloud.commons.lang.ArrayUtils;
import nccloud.framework.core.io.WebFile;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.container.SessionContext;
import nccloud.web.hrwa.helper.DeleteFileUtil;

public class TrainExportErrorAction implements ICommonAction {

	@Override
	public Object doAction(IRequest request) {
	    Map<String, String[]> readParameters = request.readParameters();
	    
	    String errorFile = ArrayUtils.isEmpty((Object[])readParameters.get("errorFile")) ? null : (String)readParameters.get("errorFile")[0];
	    String pk_loginUser = SessionContext.getInstance().getClientInfo().getUserid();
	    
	    File file = new File(HRFileUtils.getExportPath() + "/hrhifile/psndoc/errorfile/" + pk_loginUser + "/" + errorFile);
	    if (!file.exists()) {
	      ExceptionUtils.wrapBusinessException("²ÎÊýÎÞÐ§");
	    }
	    
	    WebFile webfile = null;
	    try {
	      webfile = new WebFile(errorFile, new FileInputStream(file));
	    } catch (FileNotFoundException e) {
	      ExceptionUtils.wrapBusinessException(e.getMessage());
	    } 
	    return webfile;
	  }

}
