package com.caac.bean.utils;
import com.caac.sfxtgl.xtgl.service.SfxtglAMImpl;
import oracle.adf.share.ADFContext;
import oracle.adf.share.logging.ADFLogger;
import oracle.adf.share.security.SecurityContext;
import oracle.adf.share.security.identitymanagement.UserProfile;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.Date;
/**
* 日志操作类
* */
public class LogUtils {
public LogUtils() {
super();
}
/**
* 获取AM
*/
public static ApplicationModule getAm() {
String amDef = "com.caac.sfxtgl.xtgl.service.SfxtglAM";
String confi = "SfxtglAMLocal";
return Configuration.createRootApplicationModule(amDef, confi);
}
/**
* 释放AM
*/
public static void releaseAm(ApplicationModule am) {
if (am != null) {
Configuration.releaseRootApplicationModule(am, true);
}
}
/**
* 保存操作日志
* @param czmk 操作模块
* @param cznr 操作内容
*/
public static void saveLog(String czmk, String cznr) {
try {
ApplicationModule amModule = LogUtils.getAm();
SfxtglAMImpl am = (SfxtglAMImpl)amModule;
ViewObject vo = am.findViewObject("SfglRzView1");
Row row = vo.createRow();
row.setAttribute("Czsj", (Date)row.getAttribute("CreateTime"));
row.setAttribute("Czmk", czmk);
row.setAttribute("Cznr", cznr);
vo.insertRow(row);
am.getDBTransaction().commit();
LogUtils.releaseAm(am);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 当前用户登录名
*/
public static String loginUserName() {
ADFContext adfctx = ADFContext.getCurrent();
SecurityContext se = adfctx.getSecurityContext();
UserProfile up = se.getUserProfile();
return up.getName(); //用户名
}
}
--摘自收费管理,日志