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

SCMCUT.m

Go to the documentation of this file.
  1. SCMCUT ;ALB/JLU;General utility routine;8/17/99@1515
  1. ;;5.3;Scheduling;**177,205,204,1015**;AUG 13, 1993;Build 21
  1. ;
  1. ;This is a general utility routine for the PCMM application. Any
  1. ;general purpose utility should be placed in this routine.
  1. ;
  1. ;
  1. CLNLST(SER,ARY,ACT) ;
  1. ;This API is a function that returns the list of clients that
  1. ;can run with the server that is passed in.
  1. ;
  1. ;INPUTs: SER --- This is the server to check for. It needs to be in
  1. ; a patch format Ex. SD*5.3*177
  1. ; ARY --- This is the array root the list will be returned in.
  1. ; If nothing is passed in a default will be used. This
  1. ; array must be clean before it is passed to this API.
  1. ; No kills will be issued.
  1. ; Ex. ^TMP("PCMM CLIENT LIST",$J,"1.2.0.0")=effective dt
  1. ; ^TMP("PCMM CLIENT LIST",$J,"1.3.0.0")=effective dt
  1. ; ACT --- This variable indicates whether to:
  1. ; 1 - return only active clients (default)
  1. ; 0 - return all clients
  1. ;
  1. ;OUTPUTS --- The output of this function call is the data in the array
  1. ; variable but also the function itself. It will either be
  1. ; 1 for a success or -1 with an error message.
  1. ; Ex. "-1^not a valid server name"
  1. ; "1"
  1. ;
  1. N RESULTS
  1. ;
  1. ;checking input parameters
  1. S SER=$G(SER)
  1. I SER']"" S RESULTS="-1^Server variable not defined." G CLNLSTQ
  1. S ARY=$G(ARY)
  1. I ARY']"" S ARY=$NA(^TMP("PCMM CLIENT LIST",$J))
  1. S ACT=$G(ACT,1)
  1. ;
  1. ;checking existance of server in PCMM SERVER PATCH file.
  1. I '$D(^SCTM(404.45,"B",SER)) S RESULTS="-1^This server is not in the PCMM SERVER PATCH file." G CLNLSTQ
  1. ;
  1. ;if ACT, checking if server is active
  1. I ACT,'$$ACTSER(SER) S RESULTS="-1^This server is not active." G CLNLSTQ
  1. ;
  1. ;loop through the server patches and build the list of clients.
  1. N CLT,SERIEN
  1. S CLT="",RESULTS="-1^No clients found for this Server."
  1. ;
  1. F S CLT=$O(^SCTM(404.45,"ASER",SER,CLT)) Q:CLT="" S SERIEN=$O(^SCTM(404.45,"ASER",SER,CLT,"")) Q:SERIEN="" DO
  1. .N NOD5,NOD6
  1. .S NOD5=$G(^SCTM(404.45,SERIEN,0))
  1. .Q:NOD5=""
  1. .S NOD6=$G(^SCTM(404.46,$P(NOD5,U,2),0))
  1. .Q:NOD6=""
  1. .I ACT,$P(NOD6,U,2),$D(^SCTM(404.45,"ACT",SER,SERIEN)) S @ARY@($P(NOD6,U,1))=$P(NOD6,U,2,3),RESULTS=1
  1. .I 'ACT S @ARY@($P(NOD6,U,1))=$P(NOD6,U,2,3),RESULTS=1
  1. .Q
  1. ;
  1. CLNLSTQ Q RESULTS
  1. ;
  1. ;
  1. ACTCLT(CLT) ;Is this client active?
  1. ;This function call returns whether the client passed in is active or
  1. ;not . It just tells the status of the client per its entry in PCMM
  1. ;CLIENT PATCH file. It does not relate in anyway to the PCMM SERVER
  1. ;PATCH file.
  1. ;
  1. ;INPUT: CLT - This is the External Client version number
  1. ;
  1. ;OUTPUT: 1 - ACTIVE
  1. ; 0 - NOT ACTIVE
  1. ; -1^ERROR DESCRIPTION
  1. ;
  1. N RESULTS
  1. S CLT=$G(CLT)
  1. I CLT']"" S RESULTS="-1^Client variable not defined." G ACTCLTQ
  1. ;
  1. N CLTIEN,ACT
  1. S CLTIEN=$O(^SCTM(404.46,"B",CLT,0))
  1. I CLTIEN="" S RESULTS="-1^Client not defined in PCMM CLIENT PATCH file." G ACTCLTQ
  1. S ACT=$P(^SCTM(404.46,CLTIEN,0),U,2)
  1. S RESULTS=$S(ACT:ACT,1:0) ;This was done so that a null would be zero
  1. ;
  1. ACTCLTQ Q RESULTS
  1. ;
  1. ;
  1. ACTSER(SER,ARY) ;
  1. ; This function call is used to return the status of a server
  1. ; or a list of active servers at the sight.
  1. ; It does not return the IENs or multiples of
  1. ; the same server value.
  1. ;
  1. ;INPUTS SER - [optional]: Test for a specific server version
  1. ; ARY - [optional]: This is the array root that the list
  1. ; is to be stored in, if SER is undefined.
  1. ; If nothing is passed then the default will be used.
  1. ; ^TMP("PCMM ACTIVE SERVERS",$J,SERVER NUMBER)=EFFECTIVE DT
  1. ;
  1. ;OUTPUTS 1 - a success
  1. ; 0 - none found.
  1. ;
  1. N RESULTS,LP,IEN
  1. S SER=$G(SER,"")
  1. I SER]"" S RESULTS=$D(^SCTM(404.45,"ACT",SER))>0 G ACTSERQ
  1. S ARY=$G(ARY,"^TMP(""PCMM ACTIVE SERVERS"",$J)")
  1. S RESULTS=0,LP=""
  1. ;
  1. I $O(^SCTM(404.45,"ACT",""))']"" G ACTSERQ
  1. ;
  1. F S LP=$O(^SCTM(404.45,"ACT",LP)) Q:LP="" S IEN=$O(^SCTM(404.45,"ACT",LP,"")) Q:IEN="" DO
  1. .S IEN=$G(^SCTM(404.45,IEN,0))
  1. .Q:IEN=""
  1. .S @ARY@(LP)=$P(IEN,U,3)
  1. .S RESULTS=1
  1. .Q
  1. I SER]"" S RESULTS=$D(@ARY@(SER))
  1. ;
  1. ACTSERQ Q RESULTS
  1. ;
  1. ;
  1. DISCLNTS() ;This function call is used to determine if all clients should
  1. ;be disabled.
  1. ;
  1. ;INPUTS -- NONE
  1. ;OUTPUTS -- 1 means YES disable all clients
  1. ; 0 means NO
  1. ;
  1. N IEN,RESULTS
  1. S RESULTS=0
  1. ;
  1. S IEN=+$O(^SCTM(404.44,0))
  1. I 'IEN G DISQ
  1. S IEN=$G(^SCTM(404.44,IEN,1))
  1. S RESULTS=$S('$P(IEN,U,2):0,1:1)
  1. ;
  1. DISQ Q RESULTS
  1. ;
  1. UPCLNLST(SCX) ;update 404.46/404.45 with new client/server pair (if enabled)
  1. ; input := SCX p1[required] : ServerPatch
  1. ; p2[required] : ^ClientVersion
  1. ; p3[optional] : ^EnabledOverride(1=bypass,0=no[default])
  1. ; p4[optional] : ^ActiveServer(1=yes[default],0=no)
  1. ; p5[optional] : ^ActiveClient(1=yes[default],0=no)
  1. ; output := SCRESULT : 1 = success
  1. ; : 0 = failure/not allowed
  1. ;
  1. N SCRESULT,SCSER,SCCLI,SCASER,SCACLI,SCBYPASS,SCIEN
  1. S SCRESULT=0
  1. ;
  1. ; parse
  1. S SCSER=$P(SCX,U)
  1. I SCSER']"" G UPCLNQ
  1. S SCCLI=$P(SCX,U,2)
  1. I SCCLI']"" G UPCLNQ
  1. S SCBYPASS=$P(SCX,U,3)
  1. S SCBYPASS=$S(SCBYPASS=1:1,1:0)
  1. S SCIEN=+$O(^SCTM(404.44,0))
  1. I 'SCIEN G UPCLNQ
  1. I 'SCBYPASS,$P($G(^SCTM(404.44,SCIEN,1)),U,3)=1 G UPCLNQ
  1. S SCASER=$P(SCX,U,4)
  1. S SCASER=$S(SCASER=0:0,1:1)
  1. S SCACLI=$P(SCX,U,5)
  1. S SCACLI=$S(SCACLI=0:0,1:1)
  1. ;
  1. ;update client file
  1. N SC1,SC1IEN,SC1ERR
  1. S SC1(1,404.46,"?+1,",.01)=SCCLI ;client version
  1. S SC1(1,404.46,"?+1,",.02)=SCACLI ;active?
  1. S SC1(1,404.46,"?+1,",.03)=DT ;today
  1. D UPDATE^DIE("","SC1(1)","SC1IEN","SC1ERR")
  1. I $D(SC1ERR)!(+$G(SC1IEN(1))<0) G UPCLNQ
  1. ;
  1. ;update server file
  1. N SC2,SC2IEN,SC2ERR
  1. S SC2(1,404.45,"?+1,",.01)=SCSER ;server version
  1. S SC2(1,404.45,"?+1,",.02)=SC1IEN(1) ;ptr - client version
  1. S SC2(1,404.45,"?+1,",.03)=DT ;today
  1. S SC2(1,404.45,"?+1,",.04)=SCASER ;active?
  1. D UPDATE^DIE("","SC2(1)","SC2IEN","SC2ERR")
  1. I $D(SC2ERR)!(+$G(SC2IEN(1))<0) G UPCLNQ
  1. S SCRESULT=1
  1. ;
  1. UPCLNQ Q SCRESULT
  1. ;