package CoreFS.SB04;

import CoreFS.SA01.CoreGlobalConstants;
import CoreFS.SA06.CoreReturnObject;

/**
 * @desc 提供对客户端对设计管理的操作服务
 * @create 091214
 * @modify 091214
 * @author sunjiawang
 * 
 */
public class CoreDesignManager implements CoreIDesignManager {
	private static CoreXmlDesignBean xmlbean = new CoreXmlDesignBean();

	/**
	 * @desc 获取xmlbean
	 * @param xmlbean
	 */
	public CoreXmlDesignBean getXmlbean() {
		if (xmlbean == null) {
			xmlbean = new CoreXmlDesignBean();
		}
		return xmlbean;
	}

	public CoreReturnObject add(CoreDesignBean bean) {
		CoreReturnObject crb = new CoreReturnObject();
		String err = "";
		try {
			err = this.getXmlbean().add(
					CoreGlobalConstants.DESIGNBEAN_REMOTEXMLCONFIGPATH, bean);

			if (err != "") {
				crb.setV_errCode(-1);
				crb.setV_errMsg(err);
			}
		} catch (Exception ex) {
			crb.setResult(null);
			crb.setV_errCode(-1);
			crb.setV_errMsg(ex.getMessage());
		}
		return crb;
	}

	/**
	 * @desc 删除用户
	 */
	public CoreReturnObject delete(String did) {
		CoreReturnObject crb = new CoreReturnObject();
		String err = "";
		try {
			this.getXmlbean().delete(
					CoreGlobalConstants.DESIGNBEAN_REMOTEXMLCONFIGPATH, did);

			if (err != "") {
				crb.setV_errCode(-1);

			}
		} catch (Exception ex) {
			crb.setResult(null);
			crb.setV_errCode(-1);
			crb.setV_errMsg(ex.getMessage());
		}
		return crb;

	}

	/**
	 * @desc 修改用户
	 */
	public CoreReturnObject update(CoreDesignBean bean) {
		CoreReturnObject crb = new CoreReturnObject();
		String err = "";
		try {
			this.getXmlbean().update(
					CoreGlobalConstants.DESIGNBEAN_REMOTEXMLCONFIGPATH, bean);

			if (err != "") {
				crb.setV_errCode(-1);

			}
		} catch (Exception ex) {
			crb.setResult(null);
			crb.setV_errCode(-1);
			crb.setV_errMsg(ex.getMessage());
		}
		return crb;

	}

	/**
	 * 查询所有用户
	 */
	public CoreReturnObject findByParams(String id, String caption) {
		int likeflag = 0;
		String err = "";
		CoreReturnObject crb = new CoreReturnObject();
		try {
			crb.setResult(this.getXmlbean().findByParamsMap(
					CoreGlobalConstants.DESIGNBEAN_REMOTEXMLCONFIGPATH, id,
					caption));

			if (err != "") {
				crb.setV_errCode(-1);

			}
		} catch (Exception ex) {
			crb.setResult(null);
			crb.setV_errCode(-1);
			crb.setV_errMsg(ex.getMessage());
		}
		return crb;
	}
	
	
}
