Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: KMPDUTL1

KMPDUTL1.m

Go to the documentation of this file.
  1. KMPDUTL1 ;OAK/RAK,KAK,JML - CM TOOLS Utilities ;2/17/04
  1. ;;4.0;CAPACITY MANAGEMENT;;11/15/2017;Build 38
  1. ;
  1. CONT(KMPDEXT) ;-- function displays 'return to continue' message at bottom of page
  1. ;--------------------------------------------------------------------
  1. ; KMPDEXT 0 = do not show 'to exit' text
  1. ; 1 = show 'to exit' text
  1. ;
  1. ; Return: 0 = continue
  1. ; 1 = quit
  1. ;--------------------------------------------------------------------
  1. ;
  1. N DIR,X,Y
  1. ;
  1. S KMPDEXT=+$G(KMPDEXT)
  1. F Q:$Y>(IOSL-3) W !
  1. S DIR(0)="EA"
  1. S DIR("A")="Press RETURN to continue"_$S(KMPDEXT:" or '^' to exit: ",1:": ")
  1. D ^DIR
  1. Q +$G(Y)
  1. ;
  1. CURSTAT(STAT) ;-- current status
  1. ;---------------------------------------------------------------------
  1. ; input: STAT (optional) = data from $$TSKSTAT^KMPSUTL1
  1. ; output: See codes below
  1. ;---------------------------------------------------------------------
  1. ;
  1. N RESULT,SITNUM,STRTDT
  1. ;
  1. S RESULT="",SITNUM=^DD("SITE",1),STRTDT=$G(^XTMP("KMPS",SITNUM,0))
  1. ;
  1. I $D(^XTMP("KMPS","ERROR")) Q "6^ERRORS RECORDED"
  1. I $D(^XTMP("KMPS","STOP")) Q "7^STOPPING"
  1. I $D(^XTMP("KMPS","START")) L +^XTMP("KMPS"):0 I $T L -^XTMP("KMPS") Q "5^DID NOT COMPLETE"
  1. I +STRTDT I +$H-STRTDT>2 Q "5^DID NOT COMPLETE"
  1. I +STRTDT I +$H-STRTDT>1 Q "4^RUNNING TOO LONG"
  1. I $D(^XTMP("KMPS","START")) Q "0^RUNNING"
  1. I $D(STAT) Q $P(STAT,U,1,2)
  1. E Q "3^NOT RUNNING"
  1. Q "9^UNKNOWN"
  1. ;
  1. SYSINFO() ;-- returns system information
  1. ;---------------------------------------------------------------------
  1. ; Returns:
  1. ; "^" piece 1 - type of M platform
  1. ; "^" piece 2 - $ZV => name and version of M system
  1. ; "^" piece 3 - operating system version
  1. ;
  1. ;---------------------------------------------------------------------
  1. ;
  1. N MPLTF,OSVER,SYSINFO
  1. ;
  1. S MPLTF=$$MPLTF(),OSVER=$$OSVER(MPLTF)
  1. S SYSINFO=MPLTF_U_$ZV_U_OSVER
  1. Q SYSINFO
  1. ;
  1. MPLTF() ;-- returns the type of M platform
  1. ;---------------------------------------------------------------------
  1. ; Returns: DSM for DSM platform
  1. ; CVMS for Cache for OpenVMS platform
  1. ; CWINNT for Cache for Windows NT platform
  1. ;---------------------------------------------------------------------
  1. ;
  1. N MPLTF,ZV
  1. ;
  1. S ZV=$ZV
  1. S MPLTF=$S(ZV["DSM":"DSM",ZV["VMS":"CVMS",ZV["Windows":"CWINNT",1:"UNK")
  1. Q MPLTF
  1. ;
  1. OSVER(MPLTF) ;-- returns the operating system version
  1. ;---------------------------------------------------------------------
  1. ; input: MPLTF = type of M platform
  1. ;---------------------------------------------------------------------
  1. ;
  1. I $G(MPLTF)="" Q ""
  1. ;
  1. I MPLTF["DSM" Q $ZC(%GETSYI,"VERSION")
  1. I MPLTF["CVMS" Q $$CVMSVER^KMPDUTL5()
  1. I MPLTF["CWINNT" Q $$CWNTVER^KMPDUTL5()
  1. Q ""
  1. ;
  1. TSKSTAT(OPT) ;-- status of scheduled task option
  1. ;---------------------------------------------------------------------
  1. ; input OPT = option name
  1. ;
  1. ; output RTN = by "^" piece
  1. ; 1 - status code
  1. ; 2 - literal condition
  1. ; 3 - scheduled date@time (day)
  1. ; 4 - numeric day-of-week
  1. ; 5 - expanded scheduled frequency
  1. ; 6 - short form frequency
  1. ; 7 - task id
  1. ; 8 - queued by
  1. ; 9 - user status
  1. ;
  1. ; where status code^condition:
  1. ; = 0^SCHEDULED
  1. ; = 1^NOT SCHEDULED and 'scheduled date@time' will
  1. ; be UNKNOWN and 'numeric day of week' will be -1
  1. ; = 2^NOT RESCHEDULED
  1. ; = 3^MISSING when OPT does not exist
  1. ; = 9^UNKNOWN
  1. ; = ""^UNDEFINED
  1. ;
  1. ; where user status = ACTIVE or NOT ACTIVE
  1. ;---------------------------------------------------------------------
  1. ;
  1. Q:$G(OPT)="" "^UNDEFINED"
  1. ;
  1. N ACTV,DA,DAY,DOW,FREQ,RTN,TSK,TSKINFO,USER
  1. ;
  1. S (DOW,FREQ)=-1
  1. S RTN="9^UNKNOWN^NO DATE^-1^UNKNOWN^^^UNKNOWN^NOT ACTIVE"
  1. ;
  1. I '$D(^DIC(19,"B",OPT)) S $P(RTN,U,1,2)="3^MISSING" Q RTN
  1. S DA=$O(^DIC(19,"B",OPT,0)),DA=+$O(^DIC(19.2,"B",DA,0))
  1. S TSKINFO=$G(^DIC(19.2,DA,0)),(DOW,Y)=$P(TSKINFO,U,2),FREQ=$P(TSKINFO,U,6)
  1. S $P(TSKINFO,U,2)=$$FMTE^XLFDT($P(TSKINFO,U,2))
  1. I DOW'="" S DAY=$$DOW^XLFDT(DOW),DOW=$$DOW^XLFDT(DOW,1)
  1. K:$G(DAY)="day" DAY
  1. S TSK=+$G(^DIC(19.2,+DA,1))
  1. I (DOW="")!(TSK="") S $P(RTN,U,1,2)="1^NOT SCHEDULED"
  1. E D
  1. .S $P(RTN,U,1,2)="0^SCHEDULED"
  1. .I FREQ="" S $P(RTN,U,1,2)="2^NOT RESCHEDULED"
  1. .; queued to run at
  1. .S $P(RTN,U,3,4)=$S($P(TSKINFO,U,2)="":"NO DATE",1:$P(TSKINFO,U,2))_$S($D(DAY):" ("_DAY_")",1:"")_U_DOW
  1. ; rescheduling frequency
  1. I FREQ?1.3N1A D
  1. .S $P(RTN,U,5,6)=+FREQ_" "_$S(FREQ["D":"day",FREQ["M":"month",1:FREQ)_$S(+FREQ>1:"s",1:"")_U_FREQ
  1. E S $P(RTN,U,5,6)=$S(FREQ="":"UNKNOWN",1:FREQ)_U_FREQ
  1. ; task id
  1. S $P(RTN,U,7)=TSK
  1. ; find if the user is active
  1. I TSK D
  1. .S TSKINFO=$G(^%ZTSK(TSK,0))
  1. .S USER=+$P(TSKINFO,U,3)
  1. .S ACTV=+$$ACTIVE^XUSER(USER)
  1. .; queued by
  1. .S $P(RTN,U,8)=$P($G(^VA(200,USER,0)),U)
  1. I $G(ACTV) S $P(RTN,U,9)="ACTIVE"
  1. Q RTN
  1. ;
  1. VERPTCH(PKG,RTNARRY) ;-- returns current version and patch status of specified CM package
  1. ;---------------------------------------------------------------------
  1. ; input PKG = 'D' for CM TOOLS
  1. ; 'R' for RUM - DECOMMISSIONED
  1. ; 'S' for SAGG
  1. ; Return array (passed by reference) in format:
  1. ; output RTNARRY = -1 for error
  1. ; RTNARRY(0) = number of routines^total rtns ok^total rtns bad^total rtns missing
  1. ; RTNARRY(rtn name) = {0=good 1=bad 2=missing routine}^released version^released patch(es)^site version^site patch(es)
  1. ;
  1. ; This code will reference line tag PTCHINFO^KMP_pkg_UTL for the
  1. ; following patch information text starting at PTCHINFO+1:
  1. ;
  1. ; ;;routine name ^ current version ^ current patch(es)
  1. ;
  1. ; Example:
  1. ; PATCHINFO ;-- patch information
  1. ; ;;KMPSGE^1.8^**1,2**
  1. ; ;;KMPSUTL^1.8^**1,2**
  1. ; last line > ;;
  1. ;---------------------------------------------------------------------
  1. ;
  1. K RTNARRY
  1. ;
  1. N BAD,I,INFO,INFOSITE,OK,OUT,PTCH,PTCHSITE,RTN
  1. N TAG,TOTBAD,TOTMISS,TOTOK,TOTRTN,X,VER,VERSITE
  1. ;
  1. I $G(PKG)=""!("DS"'[$G(PKG))!($L(PKG)'=1) S RTNARRY=-1 Q
  1. S X="KMP"_PKG_"UTL"
  1. X ^%ZOSF("TEST") I '$T S RTNARRY=-1 Q
  1. ;
  1. S (OUT,TOTBAD,TOTMISS,TOTOK,TOTRTN)=0
  1. F I=1:1 D Q:OUT
  1. .S TAG="PTCHINFO+"_I_"^KMP"_PKG_"UTL"
  1. .S INFO=$P($T(@TAG),";;",2)
  1. .I INFO="" S OUT=1 Q
  1. .S RTN=$P(INFO,U),VER=$P(INFO,U,2),PTCH=$P(INFO,U,3)
  1. .; if routine is missing
  1. .I $T(@(RTN_"^"_RTN))="" D Q
  1. ..S TOTMISS=TOTMISS+1,TOTRTN=TOTRTN+1
  1. ..S RTNARRY(RTN)="2^"_VER_U_PTCH_"^^"
  1. .X "ZL @RTN S INFOSITE=$T(+2)"
  1. .S VERSITE=$P(INFOSITE,";",3),PTCHSITE=$P(INFOSITE,";",5)
  1. .I VERSITE'=VER!(PTCHSITE'=PTCH) S BAD=1,OK=0
  1. .E S BAD=0,OK=1
  1. .S TOTBAD=TOTBAD+BAD,TOTOK=TOTOK+OK,TOTRTN=TOTRTN+1
  1. .S RTNARRY(RTN)=BAD_U_VER_U_PTCH_U_VERSITE_U_PTCHSITE
  1. S RTNARRY(0)=TOTRTN_U_TOTOK_U_TOTBAD_U_TOTMISS
  1. Q