📄 mscheduler.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.util.*;
/**
* Scheduler Model
*
* @author Jorg Janke
* @version $Id: MScheduler.java,v 1.8 2005/11/14 02:10:52 jjanke Exp $
*/
public class MScheduler extends X_AD_Scheduler
implements CompiereProcessor
{
/**
* Get Active
* @param ctx context
* @return active processors
*/
public static MScheduler[] getActive (Properties ctx)
{
ArrayList<MScheduler> list = new ArrayList<MScheduler>();
String sql = "SELECT * FROM AD_Scheduler WHERE IsActive='Y'";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MScheduler (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MScheduler[] retValue = new MScheduler[list.size ()];
list.toArray (retValue);
return retValue;
} // getActive
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MScheduler.class);
/**
* Standard Constructor
* @param ctx context
* @param AD_Scheduler_ID id
*/
public MScheduler (Properties ctx, int AD_Scheduler_ID, String trxName)
{
super (ctx, AD_Scheduler_ID, trxName);
} // MScheduler
/**
* Load Constructor
* @param ctx context
* @param rs result set
*/
public MScheduler (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MScheduler
/**
* Get Server ID
* @return id
*/
public String getServerID ()
{
return "Scheduler" + get_ID();
} // getServerID
/**
* Get Date Next Run
* @param requery requery
* @return date next run
*/
public Timestamp getDateNextRun (boolean requery)
{
if (requery)
load(get_TrxName());
return getDateNextRun();
} // getDateNextRun
/**
* Get Logs
* @return logs
*/
public CompiereProcessorLog[] getLogs ()
{
ArrayList<MSchedulerLog> list = new ArrayList<MSchedulerLog>();
String sql = "SELECT * "
+ "FROM AD_SchedulerLog "
+ "WHERE AD_Scheduler_ID=? "
+ "ORDER BY Created DESC";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getAD_Scheduler_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MSchedulerLog (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MSchedulerLog[] retValue = new MSchedulerLog[list.size ()];
list.toArray (retValue);
return retValue;
} // getLogs
/**
* Delete old Request Log
* @return number of records
*/
public int deleteLog()
{
if (getKeepLogDays() < 1)
return 0;
String sql = "DELETE AD_SchedulerLog "
+ "WHERE AD_Scheduler_ID=" + getAD_Scheduler_ID()
+ " AND (Created+" + getKeepLogDays() + ") < SysDate";
int no = DB.executeUpdate(sql, get_TrxName());
return 0;
} // deleteLog
} // MScheduler
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -