COMPILE FUNCTION obj_React_Esc(Method,Parms) /* Methods for REACT_ESC table 09/26/2007 JCH - Initial Coding Properties: Methods: Find() ;* Lookup Reactor Escalation key */ DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Dialog_Box DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, Send_Dyn, Btree.Extract, ErrMsg DECLARE SUBROUTINE obj_Notes, Send_Info, RList, obj_React_Event $INSERT REACT_ESC_EQUATES $INSERT MSG_EQUATES $INSERT NOTIFICATION_EQUATES EQU CRLF$ TO \0D0A\ ErrTitle = 'Error in Stored Procedure "obj_React_Esc"' ErrorMsg = '' IF NOT(ASSIGNED(Method)) THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine' IF NOT(ASSIGNED(Parms)) THEN Parms = '' IF ErrorMsg NE '' THEN Set_Status(-1,ErrTitle:@SVM:ErrorMsg) RETURN '' END Result = '' BEGIN CASE CASE Method = 'Find' ; GOSUB Find CASE Method = 'Create' ; GOSUB Create CASE Method = 'Close' ; GOSUB Close CASE Method = 'EscDates' ; GOSUB EscDates CASE Method = 'DateEscHrs' ; GOSUB DateEscHrs CASE 1 ErrorMsg = 'Unknown Method ':QUOTE(Method):' passed to routine.' END CASE IF ErrorMsg NE '' THEN Set_Status(-1,ErrTitle:@SVM:ErrorMsg) RETURN '' END RETURN Result * * * * * * * Find: * * * * * * * ReactEscKeys = Dialog_Box( 'DIALOG_REACT_ESC_QUERY', @WINDOW, '' ) Result = ReactEscKeys RETURN * * * * * * * Create: * * * * * * * ReactNo = Parms[1,@RM] StartDTM = Parms[COL2()+1,@RM] UserID = Parms[COL2()+1,@RM] Reason = Parms[COL2()+1,@RM] OutOfProdDTM = Parms[COL2()+1,@RM] IF ReactNo = '' THEN ErrorMsg = 'Null parameter ReactNo passed to routine (':Method:').' IF StartDTM = '' THEN ErrorMsg = 'Null parameter StartDTM passed to routine (':Method:').' IF UserID = '' THEN ErrorMsg = 'Null parameter UserID passed to routine (':Method:').' IF ErrorMsg NE '' THEN RETURN thisStartDTM = ICONV(StartDTM,'DT') IF thisStartDTM = '' THEN ErrorMsg = 'Invalid value ':QUOTE(StartDTM):' passed for parameter StartDTM (':Method:').' RETURN END thisOutOfProdDTM = ICONV(OutOfProdDTM,'DT') IF thisOutOfProdDTM = '' THEN ErrorMsg = 'Invalid value ':QUOTE(OutOfProdDTM):' passed for parameter OutOfProdDTM (':Method:').' RETURN END ReactEscKey = ReactNo:'*':thisStartDTM ReactEscRec = '' ReactEscRec = UserID ReactEscRec = Reason ReactEscRec = thisOutOfProdDTM TableVar = '' OtParms = 'REACT_ESC':@RM:ReactEscKey:@RM:TableVar:@RM:ReactEscRec obj_Tables('WriteRec',OtParms) ;* Writes and unlocks the record * Added 3/5/2013 jch Recipients = XLATE('NOTIFICATION','TOOL_ESCALATION',NOTIFICATION_USER_ID$,'X') SentFrom = UserID Subject = 'Reactor Escalation Opened' Message = "React No ":ReactNo:" escalation opened.":CRLF$:Reason AttachWindow = 'REACT_ESC' AttachKey = ReactNo:'*':StartDTM SendToGroup = '' Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup obj_Notes('Create',Parms) ***** Added 12/5/1013 JCH - Log Mode change in the REACT_EVENT table. CurrMode = XLATE('REACTOR',ReactNo,'CURR_MODE','X') oREParms = ReactNo:@RM oREParms := StartDTM:@RM oREParms := 'ESTR':@RM oREParms := UserID:@RM oREParms := Reason:@RM oREParms := '':@RM ;* Mode not changed -> no New Mode oREParms := CurrMode ;* Added 12/5/2013 JCH obj_React_Event('Create',oREParms) RETURN * * * * * * * Close: * * * * * * * ReactNo = Parms[1,@RM] StartDTM = Parms[COL2()+1,@RM] StopDTM = Parms[COL2()+1,@RM] UserID = Parms[COL2()+1,@RM] Reason = Parms[COL2()+1,@RM] IF ReactNo = '' THEN ErrorMsg = 'Null parameter ReactNo passed to routine (':Method:').' IF StartDTM = '' THEN ErrorMsg = 'Null parameter StartDTM passed to routine (':Method:').' IF StopDTM = '' THEN ErrorMsg = 'Null parameter StopDTM passed to routine (':Method:').' IF UserID = '' THEN ErrorMsg = 'Null parameter UserID passed to routine (':Method:').' IF ErrorMsg NE '' THEN RETURN thisStartDTM = ICONV(StartDTM,'DT') IF thisStartDTM = '' THEN ErrorMsg = 'Invalid value ':QUOTE(StartDTM):' passed for parameter StartDTM (':Method:').' RETURN END thisStopDTM = ICONV(StopDTM,'DT') IF thisStopDTM = '' THEN ErrorMsg = 'Invalid value ':QUOTE(StopDTM):' passed for parameter StopDTM (':Method:').' RETURN END ReactEscKey = ReactNo:'*':thisStartDTM OtParms = 'REACT_ESC':@RM:ReactEscKey ReactEscRec = obj_Tables('ReadRec',OtParms) ReactEscRec = thisStopDTM ReactEscRec = UserID ReactEscRec = Reason OtParms = FieldStore(OtParms,@RM,4,1,ReactEscRec) obj_Tables('WriteRec',OtParms) ;* Writes and unlocks the record ***** Added 12/5/1013 JCH - Log Mode change in the REACT_EVENT table. CurrMode = XLATE('REACTOR',ReactNo,'CURR_MODE','X') oREParms = ReactNo:@RM oREParms := StopDTM:@RM oREParms := 'ESTP':@RM oREParms := UserID:@RM oREParms := Reason:@RM oREParms := '':@RM ;* Mode not changed -> no New Mode oREParms := CurrMode ;* Added 12/5/2013 JCH obj_React_Event('Create',oREParms) * * * * * * * Recipients = XLATE('NOTIFICATION','TOOL_ESCALATION',NOTIFICATION_USER_ID$,'X') SentFrom = UserID Subject = 'Reactor Escalation Closed' Message = "React No ":ReactNo:" escalation closed.":CRLF$:Reason AttachWindow = 'REACT_ESC' AttachKey = ReactNo:'*':StartDTM SendToGroup = '' Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup obj_Notes('Create',Parms) * * * * * * RETURN * * * * * * * EscDates: * * * * * * * RecKey = Parms[1,@RM] Record = Parms[COL2()+1,@RM] IF RecKey = '' THEN RETURN IF Record = '' THEN Record = XLATE('REACT_ESC',RecKey,'','X') StartDtm = FIELD(RecKey,'*',2) StartDt = StartDtm[1,'.'] StopDt = Record[1,'.'] IF StopDt = '' THEN StopDt = Date() END Ans = '' FOR EscDt = StartDt TO StopDt LOCATE EscDt IN Ans USING @VM SETTING Pos ELSE Ans = INSERT(Ans,1,Pos,0,EscDt) END NEXT StopDt Result = Ans RETURN * * * * * * * DateEscHrs: * * * * * * * ReactNo = Parms[1,@RM] EscDt = Parms[COL2()+1,@RM] IF ReactNo = '' THEN ErrorMsg = 'Null parameter ReactNo passed to routine (':Method:').' IF EscDt = '' THEN ErrorMsg = 'Null parameter EscDt passed to routine (':Method:').' IF ErrorMsg NE '' THEN RETURN thisEscDt = ICONV(EscDt,'D') IF thisEscDt = '' THEN ErrorMsg = 'Invalid value ':QUOTE(EscDt):' passed for parameter EscDt (':Method:').' RETURN END OPEN 'DICT.REACT_ESC' TO DictVar ELSE CALL FsMsg() RETURN END SearchString = 'REACT_NO':@VM:ReactNo:@FM SearchString := 'ESC_DT':@VM:OConv(thisEscDt, 'D4/'):@FM Option = '' Flag = '' Btree.Extract(SearchString, 'REACT_ESC', DictVar, ReactEscKeys, Option, Flag) Ans = '' FOR I = 1 TO COUNT(ReactEscKeys,@VM) + (ReactEscKeys NE '') ReactEscKey = ReactEscKeys<1,I> ReactEscRec = XLATE('REACT_ESC',ReactEscKey,'','X') DateStartDTM = thisEscDt:'.0000115741' DateStopDTM = thisEscDt:'.999988459' StartDTM = FIELD(ReactEscKey,'*',2) StopDTM = ReactEscRec IF StartDTM _LTX DateStartDTM THEN StartDTM = DateStartDTM IF StopDTM = '' THEN IF thisEscDt = Date() THEN StopDTM = ICONV(OCONV(thisEscDt,'D4/'):' ':OCONV(Time(),'MTS'),'DT') END ELSE StopDTM = DateStopDTM END END ELSE IF StopDTM _GTX DateStopDTM THEN StopDTM = DateStopDTM END Ans += (StopDTM - StartDTM)*24 NEXT I IF Ans NE '' THEN Result = ICONV(Ans,'MD2') END RETURN