Question
· Apr 27, 2022

Maximum allowed System Tasks

Hi guys,

 

We have created a utility to allow users to create a System task for a list of items the same way it’s done via SMP (attached below), the problem is that there may items and those systems tasks will grow a maybe exceed a couple of thousands so :

  • First, what the maximum of scheduled system tasks we can have ?
  • Then, is there a better way we can do this without having a big list of system tasks ?
  • FYI, the system should be able to have a different scheduling times & intervals for each item

ClassMethod SetupTask(name As %String, descr As %String, code As %String, nspace As %String, dayfrq As %Integer, dayinc As %Integer, dayfrqtime As %Integer, sdate As %String, edate As %String, stime As %String, etime As %String, timeperiod As %Integer, tpday As %String, prior As %Integer) As %String
{
    s test=##class(%SYS.Task).FindId(name)
    i tpday=$c(0) s tpday=""
      s name=$e(name,1,16)
    s exists=##class(%Dictionary.ClassDefinition).%OpenId("ClientTask."_name)
    i exists="" d CreateTask^cvCreateTask(name,code)
    s Id=""
    if test="" {
        s x=##class(%SYS.Task).%New()
    } else {
        s x=##class(%SYS.Task).%OpenId(test)
    }
    s x.TaskClass="ClientTask."_name
    s x.Name = name
    s x.Description = descr
    s x.NameSpace = nspace
    s x.DailyFrequency = +dayfrq
    s x.DailyIncrement = +dayinc
    s x.DailyFrequencyTime = +dayfrqtime
    s:sdate=0 sdate=""
    s sd=$zdateh(sdate,2,,,,,,,"")
    i sd="" s sd=+$h
    s x.StartDate = sd
    s ed=0
    i edate'=0 s ed=$zdateh(edate,2,,,,,,,"")
    i '+ed s ed=""
    s x.EndDate = ed
    s st=$ztimeh(stime,2,"")
    s x.DailyStartTime = st       
    s et=$ztimeh(etime,2,"")
    s x.DailyEndTime = et
    i timeperiod'="" s x.TimePeriod = timeperiod
    s x.TimePeriodEvery = 1
    i tpday'="" s x.TimePeriodDay = tpday
    s x.Priority = prior
    s x.RescheduleOnStart=1
    s status=x.%Save()
   s Id=x.%Id()
    ;d x.%Close()
    q Id
    ;
}

cvCreateTask ;
 q ""
 
CreateTask(MyClassname,code)
   
  Set cdef = ##class(%Dictionary.ClassDefinition).%New("ClientTask."_MyClassname)
 Set cdef.Super = "%SYS.Task.Definition"
 Set pdef = ##class(%Dictionary.ParameterDefinition).%New(MyClassname_":TaskName")
 Do cdef.Parameters.Insert(pdef)
  Set pdef.Default=MyClassname
 Set mdef = ##class(%Dictionary.MethodDefinition).%New(MyClassname_":OnTask")
  d cdef.Methods.Insert(mdef)
  s mdef.ReturnType="%Status"
 s code=" "_code_$c(13,10)_" q 1"
 D mdef.Implementation.Write(code)
s status=cdef.%Save()
 w !,"cdef status=",status
  d cdef.%Close()
 d $SYSTEM.OBJ.Compile("ClientTask."_MyClassname)
 q

 

 

Thanks

Product version: Caché 2014.1
Discussion (1)1
Log in or sign up to continue