IDEMPIERE-2516 iDempiere monitor shows inactive clients (maintenance mode / active sessions) / thanks to Nicolas Micoud (nmicoud)
This commit is contained in:
parent
d3d194f80d
commit
e8723e62e0
|
@ -56,7 +56,7 @@ public class MClient extends X_AD_Client
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4479164806149932775L;
|
private static final long serialVersionUID = -4420908648355523008L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get client
|
* Get client
|
||||||
|
@ -82,7 +82,19 @@ public class MClient extends X_AD_Client
|
||||||
*/
|
*/
|
||||||
public static MClient[] getAll (Properties ctx)
|
public static MClient[] getAll (Properties ctx)
|
||||||
{
|
{
|
||||||
|
return getAll(ctx, "");
|
||||||
|
} // getAll
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all clients
|
||||||
|
* @param ctx context
|
||||||
|
* @param order by clause
|
||||||
|
* @return clients
|
||||||
|
*/
|
||||||
|
public static MClient[] getAll (Properties ctx, String orderBy)
|
||||||
|
{
|
||||||
List<MClient> list = new Query(ctx,I_AD_Client.Table_Name,null,null)
|
List<MClient> list = new Query(ctx,I_AD_Client.Table_Name,null,null)
|
||||||
|
.setOrderBy(orderBy)
|
||||||
.list();
|
.list();
|
||||||
for(MClient client:list ){
|
for(MClient client:list ){
|
||||||
s_cache.put (new Integer (client.getAD_Client_ID()), client);
|
s_cache.put (new Integer (client.getAD_Client_ID()), client);
|
||||||
|
|
|
@ -771,7 +771,9 @@ public class Login
|
||||||
|
|
||||||
// IDEMPIERE-1717 Maintenance mode
|
// IDEMPIERE-1717 Maintenance mode
|
||||||
if (! MRole.get(m_ctx, AD_Role_ID).isAccessAdvanced()) {
|
if (! MRole.get(m_ctx, AD_Role_ID).isAccessAdvanced()) {
|
||||||
if (MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, AD_Client_ID))
|
if (MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, 0))
|
||||||
|
return Msg.getMsg(m_ctx, "SystemInMaintenance");
|
||||||
|
if (AD_Client_ID != 0 && MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, AD_Client_ID))
|
||||||
return Msg.getMsg(m_ctx, "SystemInMaintenance");
|
return Msg.getMsg(m_ctx, "SystemInMaintenance");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ import org.compiere.model.AdempiereProcessorLog;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MSession;
|
import org.compiere.model.MSession;
|
||||||
import org.compiere.model.MStore;
|
import org.compiere.model.MStore;
|
||||||
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.model.MSystem;
|
import org.compiere.model.MSystem;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.server.AdempiereServerGroup;
|
import org.compiere.server.AdempiereServerGroup;
|
||||||
|
@ -95,7 +96,8 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -387582087015910664L;
|
private static final long serialVersionUID = -7455613826465213838L;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger(AdempiereMonitor.class);
|
private static CLogger log = CLogger.getCLogger(AdempiereMonitor.class);
|
||||||
/** The Server */
|
/** The Server */
|
||||||
|
@ -1005,7 +1007,7 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
table.setCellPadding(2);
|
table.setCellPadding(2);
|
||||||
//
|
//
|
||||||
line = new tr();
|
line = new tr();
|
||||||
MClient[] clients = MClient.getAll(ctx);
|
MClient[] clients = MClient.getAll(ctx, "AD_Client_ID");
|
||||||
line.addElement(new th().addElement("Client #" + clients.length + " - EMail Test:"));
|
line.addElement(new th().addElement("Client #" + clients.length + " - EMail Test:"));
|
||||||
p = new p();
|
p = new p();
|
||||||
for (int i = 0; i < clients.length; i++)
|
for (int i = 0; i < clients.length; i++)
|
||||||
|
@ -1044,6 +1046,8 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
p = new p();
|
p = new p();
|
||||||
for (int i = 0; i < clients.length; i++) {
|
for (int i = 0; i < clients.length; i++) {
|
||||||
MClient client = clients[i];
|
MClient client = clients[i];
|
||||||
|
if (!client.isActive())
|
||||||
|
continue;
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
p.addElement(" - ");
|
p.addElement(" - ");
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1059,20 +1063,34 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
//
|
//
|
||||||
line = new tr();
|
line = new tr();
|
||||||
int inMaintenanceClients[] = DB.getIDsEx(null, "SELECT AD_Client_ID FROM AD_SysConfig WHERE Name = 'SYSTEM_IN_MAINTENANCE_MODE' AND Value = 'Y'");
|
|
||||||
line.addElement(new th().addElement("Maintenance Mode #"+inMaintenanceClients.length));
|
boolean isSystemInMaintenance = MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, 0);
|
||||||
|
List<Integer> inMaintenanceClients = new ArrayList<Integer>();
|
||||||
|
if (isSystemInMaintenance)
|
||||||
|
line.addElement(new th().addElement("Maintenance Mode"));
|
||||||
|
else {
|
||||||
|
int possiblyInMaintenanceClients[] = DB.getIDsEx(null, "SELECT AD_Client_ID FROM AD_SysConfig WHERE AD_Client_ID!=0 AND IsActive='Y' AND Name=?", MSysConfig.SYSTEM_IN_MAINTENANCE_MODE);
|
||||||
|
for (int clientId : possiblyInMaintenanceClients) {
|
||||||
|
boolean isTenantInMaintenance = MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, clientId);
|
||||||
|
if (isTenantInMaintenance)
|
||||||
|
inMaintenanceClients.add(clientId);
|
||||||
|
}
|
||||||
|
line.addElement(new th().addElement("Maintenance Mode #"+inMaintenanceClients.size()));
|
||||||
|
}
|
||||||
|
|
||||||
p = new p();
|
p = new p();
|
||||||
if (inMaintenanceClients.length > 0) {
|
if (isSystemInMaintenance)
|
||||||
for (int i = 0; i < clients.length; i++) {
|
p.addElement("All clients are in maintenance mode");
|
||||||
MClient client = clients[i];
|
else if (inMaintenanceClients.size() > 0) {
|
||||||
if (i > 0)
|
boolean first = true;
|
||||||
|
for (int clientID : inMaintenanceClients) {
|
||||||
|
MClient client = MClient.get(ctx, clientID);
|
||||||
|
if (!client.isActive())
|
||||||
|
continue;
|
||||||
|
if (!first)
|
||||||
p.addElement(" - ");
|
p.addElement(" - ");
|
||||||
for (int clientID : inMaintenanceClients) {
|
p.addElement(client.getName());
|
||||||
if (client.getAD_Client_ID() == clientID)
|
first = false;
|
||||||
p.addElement(client.getName() + " : Yes");
|
|
||||||
else
|
|
||||||
p.addElement(client.getName() + " : No");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue