Schedules | Script to mass check and clean old schedule entries
Disable Schedule Entries
During the testing or development of your project, you may have created schedules that were never executed. They could be stuck in the past in a "Manual Pending" state, for example.
Use the following script to check and disable schedule entries in the past.
Clean schedule entries
|
def cleanSchedules(startDate, endDate, debugMode): f = system.mes.object.filter.createFilter() f.setMESObjectTypeName("OperationsRequest") objs = system.mes.loadMESObjects(f) faultList = system.mes.object.list.createList() for obj in objs: if "Pending" in obj.getSegmentScheduleState() and obj.getBeginDateTime().before(endDate) and obj.getBeginDateTime().after(startDate): print "Sched [%s] [%s] BeginDateTime [%s]" % (obj.getName(), obj.getSegmentScheduleState(), obj.getBeginDateTime()) if not debugMode: obj.setSegmentScheduleState("Failed") faultList.add(obj) system.mes.saveMESObjects(faultList)
startDate = system.date.getDate(2024, 0, 1) endDate = system.date.getDate(2024, 11, 31) print "From ", startDate, " To ", endDate debugMode = True
cleanSchedules(startDate, endDate, debugMode) |