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

KMPRUTL1.m

Go to the documentation of this file.
  1. KMPRUTL1 ;OAK/KAK/RAK - Resource Usage Monitor Utility ;1/30/13 08:32
  1. ;;2.0;CAPACITY MANAGEMENT - RUM;**1,2**;May 28, 2003;Build 12
  1. ;
  1. DATERNG(KMPUY,KMPUSTR,KMPUEND) ;-- date range
  1. ;---------------------------------------------------------------------
  1. ; KMPUY..... Value returned in four pieces:
  1. ; fmstartdate^fmenddate^ouputstartdate^outputenddate
  1. ;
  1. ; Piece one and two are the date ranges in fileman format.
  1. ; Piece three and four are the same dates in output format:
  1. ; dy-Mon-yr
  1. ;
  1. ; ********
  1. ; * NOTE *
  1. ; ********
  1. ; - The first piece will always be the earliest date entered.
  1. ;
  1. ; Optional Parameters:
  1. ;
  1. ; KMPUSTR... If defined, the earliest date that may be selected.
  1. ; (must be in fileman format)
  1. ;
  1. ; KMPUEND... If defined, the latest date that may be selected.
  1. ; (must be in fileman format)
  1. ;-----------------------------------------------------------------------
  1. ;
  1. N DATE1,DATE2,DIR,DIRUT,LINE,X,Y
  1. ;
  1. S KMPUY="",KMPUSTR=$G(KMPUSTR),KMPUEND=$G(KMPUEND)
  1. ;
  1. RANGE ;-- Ask date ranges
  1. S DIR(0)="DOA^"_$S(KMPUSTR:KMPUSTR,1:"")_":"_$S(KMPUEND:KMPUEND,1:"")_":E"
  1. S DIR("A")="Start with Date: "
  1. S:KMPUSTR DIR("B")=$$FMTE^XLFDT(KMPUSTR,2)
  1. S DIR("?")=" "
  1. S DIR("?",1)="Enter the starting date.",LINE=2
  1. ; if starting date.
  1. I KMPUSTR D
  1. .S DIR("?",LINE)="Date must not precede "_$$FMTE^XLFDT(KMPUSTR)
  1. .S LINE=LINE+1
  1. ; if ending date.
  1. I KMPUEND S DIR("?",LINE)="Date must not follow "_$$FMTE^XLFDT(KMPUEND)
  1. W ! D ^DIR I $D(DIRUT) S KMPUY="" Q
  1. S DATE1=Y
  1. S DIR("A")=" End with Date: "
  1. S:KMPUEND DIR("B")=$$FMTE^XLFDT(KMPUEND,2)
  1. S DIR("?",1)="Enter the ending date."
  1. D ^DIR G:Y="" RANGE I Y="^" S KMPUY="" Q
  1. S DATE2=Y
  1. ; Set earliest date into first piece.
  1. S KMPUY=$S(DATE2<DATE1:DATE2,1:DATE1)_U_$S(DATE2>DATE1:DATE2,1:DATE1)
  1. S $P(KMPUY,U,3)=$$FMTE^XLFDT($P(KMPUY,U))
  1. S $P(KMPUY,U,4)=$$FMTE^XLFDT($P(KMPUY,U,2))
  1. ;
  1. Q
  1. ;
  1. ENVCHECK(KMPRENV,KMPRQIET) ;-- environment check.
  1. ;-----------------------------------------------------------------------
  1. ; KMPRENV... Result of environment check in format:
  1. ; KMPRENV=Number^Text
  1. ; 1-99: system status (not an error condition).
  1. ; 0 - RUM turned on and background job queued
  1. ; 1 - RUM is not turned on
  1. ; 2 - 'KMPR BACKGROUND' job has been queued to run
  1. ;
  1. ; 100>: error condition.
  1. ; 100 - RUM not available for 'OS' at this time
  1. ; 200 - RUM is on but the option 'KMPR BACKGROUND DRIVER'
  1. ; is not scheduled to run."
  1. ; 201 - The RUM background driver option [KMPR BACKGROUND
  1. ; DRIVER] is missing
  1. ;
  1. ; KMPRQIET.. Output message: 0 - output message (not quiet).
  1. ; 1 - do not output message (quiet).
  1. ;-----------------------------------------------------------------------
  1. ;
  1. K KMPRENV
  1. S KMPRENV="0^RUM turned on and background job queued"
  1. S KMPRQIET=+$G(KMPRQIET)
  1. ;
  1. N IEN,IEN1,TEXT
  1. ;
  1. ; check for operating system availability.
  1. S TEXT=$P($G(^%ZOSF("OS")),U)
  1. I TEXT'["DSM"&(TEXT'["OpenM") D Q
  1. .S KMPRENV="100^RUM not available for '"_TEXT_"' at this time"
  1. .D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
  1. ;
  1. ; if rum not started quit.
  1. I '$G(^%ZTSCH("LOGRSRC")) D Q
  1. .S KMPRENV="1^RUM is not turned on"
  1. .D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
  1. ;
  1. S TEXT="KMPR BACKGROUND DRIVER"
  1. S IEN=$O(^DIC(19,"B",TEXT,0))
  1. I 'IEN D Q
  1. .S KMPRENV="201^The RUM background driver option [KMPR BACKGROUND DRIVER] is missing"
  1. .D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
  1. ;
  1. S IEN1=$O(^DIC(19.2,"B",IEN,0))
  1. I 'IEN1!($P($G(^DIC(19.2,+IEN1,1)),U)']"") D
  1. .S KMPRENV="200^RUM is on but the option '"_TEXT_"' is not scheduled to run"
  1. ;
  1. Q:KMPRQIET
  1. D ENVOUTPT(KMPRENV,1,1) I +KMPRENV<100 Q
  1. ;
  1. K DIR S DIR(0)="YO",DIR("B")="YES"
  1. S DIR("A")="Do you want me to queue this option to run every night at 1 a.m."
  1. W ! D ^DIR Q:'Y
  1. ;
  1. D QUEBKG
  1. ;
  1. W !
  1. S KMPRENV="0^RUM turned on and background job queued"
  1. ;
  1. Q
  1. ;
  1. ENVOUTPT(KMPRENV,KMPRHILT,KMPRCNTR) ;-- environment check output.
  1. ;-----------------------------------------------------------------------
  1. ; KMPRENV... Environment output (see ENVCHECK).
  1. ; KMPRHILT.. Highlight text: 0 - do not highlight.
  1. ; 1 - highlight text.
  1. ; KMPRCNTR.. Center text: 0 - do not center text.
  1. ; 1 - center text.
  1. ;-----------------------------------------------------------------------
  1. ;
  1. S KMPRENV=$G(KMPRENV),KMPRHILT=+$G(KMPRHILT),KMPRCNTR=+$G(KMPRCNTR)
  1. Q:KMPRENV=""
  1. ;
  1. N INDENT,IORVOFF,IORVON,TEXT
  1. S X="IORVOFF;IORVON" D ENDR^%ZISS
  1. S KMPRENV=$P(KMPRENV,U,2)
  1. S:KMPRHILT KMPRENV=IORVON_" "_KMPRENV_" "_IORVOFF
  1. S TEXT(1)=KMPRENV
  1. I KMPRCNTR S INDENT=80-$L(TEXT(1))\2,TEXT(1,"F")="!?"_INDENT
  1. D EN^DDIOL(.TEXT)
  1. ;
  1. Q
  1. ;
  1. PKG(PACKAGE) ; Select Package(s)
  1. ; Output Variable:
  1. ; PACKAGE = Contains array of package names
  1. ; = PACKAGE("^") if DTOUT or DUOUT
  1. ;
  1. N DIR,DTOUT,DUOUT,Y
  1. S DIR(0)="FO^1:999:0"
  1. F D Q:$D(DTOUT)!$D(DUOUT)!(Y="")
  1. .S DIR("A")="Select Package Namespace" D ^DIR I Y'="" S PACKAGE(Y)=""
  1. .I Y=" " W !,*7,"Please enter a valid package namespace.",!
  1. S:$D(DTOUT)!$D(DUOUT)!('$D(PACKAGE)) PACKAGE("^")=""
  1. W !
  1. Q
  1. ;
  1. QUEBKG ;-- queue background job KMPR BACKGROUND DRIVER
  1. N DA,DIK,FDA,ERROR,IEN,IEN1,IENZ,TEXT,X,Y,Z
  1. S:'$G(DT) DT=$$DT^XLFDT
  1. S TEXT="KMPR BACKGROUND DRIVER"
  1. S IEN=$O(^DIC(19,"B",TEXT,0)) Q:'IEN
  1. S IEN1=$O(^DIC(19.2,"B",IEN,0))
  1. ; if already in file 19.2 then kill.
  1. I IEN1 S DIK="^DIC(19.2,",DA=IEN1 D ^DIK
  1. ; schedule for tomorrow@1am.
  1. S FDA($J,19.2,"+1,",.01)=IEN
  1. ; queued to run at what time - set to tomorrow@1am
  1. S FDA($J,19.2,"+1,",2)=$$FMADD^XLFDT(DT,1)_".01"
  1. ; rescheduling frequency.
  1. S FDA($J,19.2,"+1,",6)="1D"
  1. D UPDATE^DIE("","FDA($J)",.IENZ,"ERROR")
  1. I $D(ERROR) D MSG^DIALOG("W","",60,10,"ERROR")
  1. Q