package weaver.interfaces.htsc.comInfo;

import com.weaver.general.Util;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.StaticObj;


public class PropNewComInfo {

    private StaticObj staticobj = null;

    public PropNewComInfo() {
        BaseBean bb = new BaseBean();
        //bb.writeLog("PropNewComInfo");
        this.staticobj = StaticObj.getInstance();
        if (this.staticobj.getObject("PropNewComInfo") == null)
        {
            bb.writeLog("PropNewComInfo----init");
            RecordSet rs = new RecordSet();
            String sql = "select pkey,pvalue from uf_prop " ;
            rs.writeLog("sql:"+sql);
            rs.execute(sql);
            while (rs.next()) {
                String pkey = Util.null2String(rs.getString("pkey"));
                String pvalue = Util.null2String(rs.getString("pvalue"));
                this.staticobj.putRecordToObj("PropNewComInfo", pkey, pvalue);
            }
        }
    }

    public void remove() {
        this.staticobj.removeObject("PropNewComInfo");
    }

    public String getPropNewName(String pkey) {
        BaseBean bb = new BaseBean();
        bb.writeLog("getPropNewName");
        return (String)this.staticobj.getRecordFromObj("PropNewComInfo", pkey);
    }

    public void addPropNewComInfo(String pkey,String pvalue)
    {
        this.staticobj.putRecordToObj("PropNewComInfo", pkey,pvalue);
    }

    /***
     *
     * @param pkey
     * @return
     */
    public String getPropNewNameByDb(String pkey){
        BaseBean bb = new BaseBean();
        bb.writeLog("getPropNewNameByDb");

        String pvalue = "";
        if("".equals(pkey)){
            return "";
        }
        try{
            RecordSet rs = new RecordSet();
            String sql = "select pvalue from uf_prop where pkey = '" + pkey+"'";
            rs.execute(sql);
            if(rs.next()){
                pvalue = weaver.general.Util.null2String(rs.getString("pvalue"));
            }
            if(!"".equals(pvalue))
            {
                addPropNewComInfo(pkey,pvalue);
            }
        }catch (Exception e){

        }
        return pvalue;
    }

}
