| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package xin.glue.ui.common.component;
- import java.util.List;
- import javax.servlet.http.Cookie;
- import javax.servlet.http.HttpServletRequest;
- import com.posdata.glue.context.PosContext;
- import com.posdata.glue.dao.PosGenericDao;
- import com.posdata.glue.dao.manager.PosQueryDefinition;
- import com.posdata.glue.dao.manager.PosQueryManagerImpl;
- import com.posdata.glue.dao.vo.PosParameter;
- public class PosSiteLog {
- public static boolean writeLog(PosContext ctx, PosGenericDao dao, String queryId, List params) {
- if (!PosSiteConfig.isWriteLog())
- return true;
- try {
- PosParameter param = new PosParameter();
- PosQueryManagerImpl queryManager = (PosQueryManagerImpl)PosContext.getBeanFactory().getBeanObject("queryManager");
- PosQueryDefinition query = queryManager.getQueryDefinition(queryId);
- if (query == null) {
- param.setValueParamter(0, "程序内嵌语句");
- param.setValueParamter(1, queryId);
- } else {
- param.setValueParamter(0, queryId);
- param.setValueParamter(1, query.getQueryStatement().replaceAll("&", "&"));
- }
- String paramValue = "";
- int count = params.size();
- for (int i=0; i<count; i++)
- paramValue += "parameter " + i + ": " + params.get(i) + "\n";
- param.setValueParamter(2, paramValue);
- HttpServletRequest request = (HttpServletRequest)ctx.findRequestAttr("HttpServletRequest");
- Cookie[] cookies = request.getCookies();
- param.setValueParamter(3, cookies[2].getValue());
- param.setValueParamter(4, cookies[1].getValue());
- String[] address = cookies[0].getValue().split("\\|");
- param.setValueParamter(5, "外网IP:\n" + address[0] + "\n\n内网IP:\n" + address[1].replace(',', '\n'));
- dao.insert("site.log.insert", param);
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
- }
|