/// <summary> /// Is the information logged? /// </summary> /// <param name="AD_Table_ID"> table id</param> /// <param name="tableName">table name</param> /// <param name="type">change type</param> /// <returns> true if table is logged</returns> public Boolean IsLogged(int AD_Table_ID, String tableName, String type) { // No Log if (MChangeLog.IsNotLogged(AD_Table_ID, tableName, 0, type)) { return(false); } // Role Logging MRole role = MRole.GetDefault(GetCtx(), false); // Do we need to log if (IsWebStoreSession() || // log if WebStore MChangeLog.IsLogged(AD_Table_ID, type) || // im/explicit log role != null && role.IsChangeLog()) // Role Logging { return(true); } // return(false); }
/// <summary> /// Create Change Log only if table is logged /// </summary> /// <param name="TrxName">transaction name</param> /// <param name="AD_ChangeLog_ID">0 for new change log</param> /// <param name="AD_Table_ID">table</param> /// <param name="AD_Column_ID">column</param> /// <param name="keyInfo">key value(s)</param> /// <param name="AD_Client_ID">client</param> /// <param name="AD_Org_ID">org</param> /// <param name="OldValue">old</param> /// <param name="NewValue">new</param> /// <param name="tableName"></param> /// <param name="type"></param> /// <returns>change log or null</returns> public MChangeLog ChangeLog(Trx trx, int AD_ChangeLog_ID, int AD_Table_ID, int AD_Column_ID, Object keyInfo, int AD_Client_ID, int AD_Org_ID, Object oldValue, Object newValue, String tableName, String type) { // Null handling if (oldValue == null && newValue == null) { return(null); } // Equal Value if (oldValue != null && newValue != null && oldValue.Equals(newValue)) { return(null); } // No Log if (MChangeLog.IsNotLogged(AD_Table_ID, tableName, AD_Column_ID, type)) { return(null); } // Role Logging MRole role = MRole.GetDefault(GetCtx(), false); // Do we need to log if (_webStoreSession || // log if WebStore MChangeLog.IsLogged(AD_Table_ID, type) || // im/explicit log (role != null && role.IsChangeLog())) // Role Logging { ; } else { return(null); } // log.Finest("AD_ChangeLog_ID=" + AD_ChangeLog_ID + ", AD_Session_ID=" + GetAD_Session_ID() + ", AD_Table_ID=" + AD_Table_ID + ", AD_Column_ID=" + AD_Column_ID + ": " + oldValue + " -> " + newValue); //Boolean success = false; try { String trxName = null; if (trx != null) { trxName = trx.GetTrxName(); } MChangeLog cl = new MChangeLog(GetCtx(), AD_ChangeLog_ID, trxName, GetAD_Session_ID(), AD_Table_ID, AD_Column_ID, keyInfo, AD_Client_ID, AD_Org_ID, oldValue, newValue); if (cl.Save()) { return(cl); } } catch (Exception e) { log.Log(Level.SEVERE, "AD_ChangeLog_ID=" + AD_ChangeLog_ID + ", AD_Session_ID=" + GetAD_Session_ID() + ", AD_Table_ID=" + AD_Table_ID + ", AD_Column_ID=" + AD_Column_ID, e); return(null); } log.Log(Level.SEVERE, "AD_ChangeLog_ID=" + AD_ChangeLog_ID + ", AD_Session_ID=" + GetAD_Session_ID() + ", AD_Table_ID=" + AD_Table_ID + ", AD_Column_ID=" + AD_Column_ID); return(null); }