Alarm trigger with NICA_ORDERS table

solution tested and ready for deployment

updated SRP_Git_Services to handle creating local copies of inherited entities

updated HgCV OCAP order trigger to also look for active prove-in orders

moved error services common into sysprog to avoid compilation issues
This commit is contained in:
Infineon\StieberD 2024-12-12 13:24:48 -07:00
parent 3cd56295dc
commit ab8f9d3c24
24 changed files with 3167 additions and 1571 deletions

View File

@ -72,10 +72,11 @@ Function Error_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$Insert LOGICAL
$Insert MSG_EQUATES
$insert RTI_DEBUG_COMMON
$insert SRPMail_Inserts
$Insert RTI_DEBUG_COMMON
$Insert SRPMail_Inserts
$Insert ERROR_SERVICES_COMMON
Equ Segoe_UI$ to 'Segoe UI' : @SVM : -12 : @SVM : 400 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 34 : @SVM : 0 : @SVM : 3 : @SVM : 2 : @SVM : 1 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0
@ -98,8 +99,6 @@ If Assigned(Response) else Response = ''
AutoDisplayErrors = False$ ; // Set this to True$ when debugging so all errors will automatically display.
Common /ErrorServices/ ErrorMessages@, ErrorSources@, ErrorCodes@, RetStacks@, Unused5@, Unused6@, Unused7@, Unused8@
Declare function RetStack, Error_Services, SRPSendMail
Declare subroutine Error_Services

View File

@ -14,12 +14,13 @@ Declare Subroutine obj_Tables, Print_RootCause_Analysis, Database_Services, obj_
Declare Subroutine ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, Dialog_Box, Yield
Declare Subroutine obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, obj_Reactor_Log, obj_Post_Log
Declare Subroutine Reactor_Log_Events, Reactor_Log_Services, Error_Services, React_Servs_Services, Reactor_Services
Declare Subroutine Override_Log_Services, SRP_List
Declare Subroutine Override_Log_Services, SRP_List, Nica_Orders_Services
Declare Function Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals, EntID, Repository, NextKey
Declare Function Send_Message, Msg, Security_Check, obj_React_Item, Select_Into, MemberOf, Create_Dialog, obj_Calendar
Declare Function GetAsyncKeyState, obj_Tables, MemberOf, Environment_Services, Database_Services, Rds_Services
Declare function Reactor_Services, Error_Services, React_Servs_Services, Reactor_Log_Services, Send_Event, SRP_List
Declare Function Reactor_Services, Error_Services, React_Servs_Services, Reactor_Log_Services, Send_Event, SRP_List
Declare Function Nica_Orders_Services
$Insert MSG_EQUATES
$Insert APPCOLORS
@ -676,8 +677,9 @@ TechSign:
If Valid then
SuccessfulSign = Reactor_Log_Services('SignReactorLog', ReactorLogNo, @USER4)
If SuccessfulSign EQ 0 then
Error_Services('DisplayError')
ActiveChecklist = Xlate('REACTOR_LOG', ReactorLogNo, REACTOR_LOG_CHECKLIST_ACTIVE$, 'X')
Error_Services('DisplayError')
ActiveRlNicaOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', ReactorLogNo)
ActiveChecklist = (ActiveRlNicaOrderIds NE '')
If ActiveChecklist then
OverrideGroups = 'MAINTENANCE':@VM:'SUPERVISOR'
UserMsg = "Reactor Log PM must be processed in NICA. Override required from a member of "
@ -685,22 +687,14 @@ TechSign:
UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg)
Override = UserVerification<1>
If Override EQ True$ then
PmOrderIds = Xlate('REACTOR_LOG', ReactorLogNo, REACTOR_LOG_CHECKLIST_ORDER_ID$, 'X')
PmOrderList = SRP_List('Create', PmOrderIds, @VM)
PmTypes = Xlate('REACTOR_LOG', ReactorLogNo, REACTOR_LOG_CHECKLIST_TYPE$, 'X')
PmTypeList = SRP_List('Create', PmTypes, @VM)
ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2>
ResponseComment = ''
For each PmType in PmTypes using @VM setting Idx
PmOrderId = SRP_List('GetAt', PmOrderList, Idx)
Reactor_Log_Services('CancelReactorLogPMOrder', ReactorLogNo, PmOrderId)
If ResponseComment NE '' then
ResponseComment := ', '
end
ResponseComment := PmType
Next ProveInType
ResponseComment = ''
ActiveRlNicaOrderTypes = Xlate('NICA_ORDERS', ActiveRlNicaOrderIds, 'ORDER_TYPE', 'X')
For each ActiveRlNicaOrderId in ActiveRlNicaOrderIds using @VM setting Idx
Nica_Orders_Services('CancelOrder', ActiveRlNicaOrderId)
If ResponseComment NE '' then ResponseComment := ', '
ResponseComment := ActiveRlNicaOrderTypes<0, Idx>
Next ActiveRlNicaOrderId
Override_Log_Services('Create', 'REACTOR_LOG', ReactorLogNo, UserVerification<2>, ResponseComment, 'REACTOR_LOG_PM')
@ -732,7 +726,6 @@ TechSign:
Error_Services('DisplayError')
end
end
end
RETURN
@ -1666,3 +1659,4 @@ ColorRemRiTable:
return

View File

@ -0,0 +1,55 @@
Subroutine Debugger_Logger(Void)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from Infineon Technologies.
Name : Debugger_Logger
Description : Handler program for the logging debug data.
Notes : This is intended to be invoked by Error_Services("LogStack") (LSL2) so the current program,
Error_Services, is removed from the stack log.
History : (Date, Initials, Notes)
01/09/25 djs Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$insert RTI_DEBUG_COMMON
$insert ENVIRON_CONSTANTS
$insert ERROR_SERVICES_COMMON
Equ CRLF$ to \0D0A\
Declare function Environment_Services, Logging_Services, GetSessionCallStack, Error_Services, RetStack
Declare subroutine Logging_Services, Get_Status, Set_Env
Main:
ErrorMessages = Error_Services('GetMessages')
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\StackTrace'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Error Log.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', '', '', False$, False$)
LogData = ''
LogData<1> = CRLF$:'Timestamp: ':LogDate:' ':LogTime
LogData<2> = 'Machine: ':Environment_Services('GetServer')
LogData<3> = 'Set_Status Code:':EsSpStatCode@
LogData<4> = 'Set_Status Message:':EsSpStatMessage@
Swap @FM with @VM in ErrorMessages
LogData<5> = 'Error_Services Messages:':ErrorMessages
LogData<6> = 'Call Depth: ':CallDepth@
LogData<7> = 'Curr Program and line no: ':CallStack@<2,1>:@VM:CallStack@<2,2>
LogData<8> = 'Call Stack / Line Nos: '
Stack = CallStack@
Stack = Delete(Stack, 1, 0, 0)
LogData<9> = Stack:CRLF$
Logging_Services('AppendLog', objLog, LogData, @FM, @VM, '', '', '')
Return

View File

@ -0,0 +1,403 @@
Function Error_Services(@Service, @Params)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from SRP Computer Solutions, Inc.
Name : Error_Services
Description : Handler program for all error services.
Notes : Application errors should be logged using the Error Services module. There are a few methodological
assumptions built into way errors are managed which are important to understand in order to properly
work with Error Services:
- The term 'top' refers to the originating procedure of a call stack and the term 'bottom' refers to
the last routine (or the current routine) within a call stack. Within the OpenInsight Debugger
this will appear backwards since the originating procedure always appears at the bottom of the
list and the current routine appears at the top of the list. We are using this orientation because
it is common to refer to the process of calling other procedures as 'drilling down'.
- The reason for defining the orientation of the call stack is because Error_Services allows for
multiple error conditions to be appended to an original error. In most cases this will happen when
a procedure at the bottom of the stack generates an error condition and then returns to its
calling procedure. This higher level procedure can optionally add more information relevant to
itself. This continues as the call stack 'bubbles' its way back to the top to where the
originating procedure is waiting.
- Native OpenInsight commands that handle errors (e.g., Set_Status, Set_FSError, Set_EventStatus)
preserve their error state until explicitly cleared. This can hinder the normal execution of code
since subsequent procedures (usually SSPs) will fail if a pre-existing error condition exists.
Our philosophy is that error conditions should automatically be cleared before a new procedure
is executed to avoid this problem. However, the nature of Basic+ does not make this easy to
automate for any given stored procedure. Therefore, if a stored procedure wants to conform to our
philosophy then it should include a call into the 'Clear' service request at the top of the
program. Alternatively this can be done through a common insert (see SERVICE_SETUP for example.)
- Service modules will use the SERVICE_SETUP insert and therefore automatically clear out any
error conditions that were set before.
- The 'Set' service request is the equivelent to the various forms of setting an error within Basic+
(e.g., Set_Status, Set_FSError, Set_EventStatus). This will clear out any pre-existing error(s)
first (see 'Clear' service request description below). In most cases the 'Add' service request
(see below) should be used since error conditions are intended to be automatically cleared by
service modules or properly managed stored procedures.
- The 'Add' service request is similar to the 'Set' service request but it will not clear out any
pre-existing errors. Using 'Add', the error conditions can be stacked allowing the higher level
calling procedures the ability to contribute to the existing error or add additional errors.
- The 'Clear' service request will reset all of the error condition flags.
Parameters :
Service [in] -- Name of the service being requested
Param1-10 [in/out] -- Additional request parameter holders
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
History : (Date, Initials, Notes)
12/28/12 dmb Original programmer.
12/31/12 dmb Add hooks for various service requests. Add comments in the Notes section to explain the
theory of operation of Error Services.
01/01/13 dmb Add functionality to the Set, Add, GetMessage, and GetMessages service requests.
01/02/13 dmb Remove reference to SERVICES_SETUP and put the Assigned command lines directly into this
code to avoid infinite loop problem.
01/05/13 dmb Added HasError service request.
03/13/13 dmb [SRPFW-9] Added NoError service request.
10/01/13 dmb [SRPFW-18] Replace APP_INSERTS with LOGICAL and declare Error_Services.
10/06/13 dmb [SRPFW-17] Retrofit to use the default FrameWorks system font.
03/20/17 fjt [SRPFW-160] Conversion to EB+; addition of justification parameter to display.
10/09/17 dmb Add SendRuntimeAlert service to act as a debugger intercept process.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert LOGICAL
$Insert MSG_EQUATES
$Insert RTI_DEBUG_COMMON
$Insert SRPMail_Inserts
$Insert ERROR_SERVICES_COMMON
$Insert ENVIRON_CONSTANTS
Equ Segoe_UI$ to 'Segoe UI' : @SVM : -12 : @SVM : 400 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 34 : @SVM : 0 : @SVM : 3 : @SVM : 2 : @SVM : 1 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0
// Make sure any request parameters which have not been assigned are nulled.
// Normally these would be referenced in the SERVICES_SETUP insert but there is a call to ERROR_SERVICES in that
// insert which causes an infinite loop to occur.
If Assigned(Service) else Service = ''
If Assigned(Error) else Error = ''
If Assigned(Param1) else Param1 = ''
If Assigned(Param2) else Param2 = ''
If Assigned(Param3) else Param3 = ''
If Assigned(Param4) else Param4 = ''
If Assigned(Param5) else Param5 = ''
If Assigned(Param6) else Param6 = ''
If Assigned(Param7) else Param7 = ''
If Assigned(Param8) else Param8 = ''
If Assigned(Param9) else Param9 = ''
If Assigned(Param10) else Param10 = ''
If Assigned(Response) else Response = ''
AutoDisplayErrors = False$ ; // Set this to True$ when debugging so all errors will automatically display.
Declare function RetStack, Error_Services, SRPSendMail, Get_Env
Declare subroutine Error_Services, Set_Env, Set_Status
GoToService else
Error_Services('Set', Service : ' is not a valid service request within the Error services module.')
end
Return Response else ''
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Service Parameter Options
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Options BOOLEAN = True$, False$
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Services
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------
// Set
//
// Param1 - Error message. Messages should be fairly descriptive.
//
// Sets an error to the stack. This will automatically clear any existing error conditions first so this error will
// be the only one on the stack.
//----------------------------------------------------------------------------------------------------------------------
Service Set(ErrorMessage)
Error_Services('Clear')
Error_Services('Add', ErrorMessage)
If AutoDisplayErrors then Error_Services('DisplayError')
End Service
//----------------------------------------------------------------------------------------------------------------------
// Add
//
// Param1 - Error message. Messages should be fairly descriptive.
//
// Adds an error to the stack. This will not clear existing error conditions first. It is intended to allow higher level
// routines to add more information to an existing error condition or simply to maintain an ongoing error log for some
// troubleshooting or debugging purposes.
//----------------------------------------------------------------------------------------------------------------------
Service Add(ErrorMessage)
CurStack = RetStack()
AtSelf = CurStack[1, @FM] ; // AtSelf should be the name of this routine (e.g., ERROR_SERVICES)
Loop
CurRoutine = CurStack[1, @FM] ; // Get the next routine from the program call stack.
Until CurRoutine _NEC AtSelf
CurStack = Delete(CurStack, 1, 0, 0) ; // Remove any self-references from the program call stack.
Repeat
Convert @FM to @VM in CurStack ; // Convert the delimiter so it can be added to the global common.
If Len(ErrorMessages@) then
ErrorMessages@ := @FM : ErrorMessage
RetStacks@ := @FM : CurStack
end else
ErrorMessages@ = ErrorMessage
RetStacks@ = CurStack
end
If AutoDisplayErrors then Error_Services('DisplayError')
End Service
//----------------------------------------------------------------------------------------------------------------------
// Clear
//
// Clears all error conditions and related information.
//----------------------------------------------------------------------------------------------------------------------
Service Clear()
ErrorMessages@ = ''
ErrorSources@ = ''
ErrorCodes@ = ''
RetStacks@ = ''
End Service
//----------------------------------------------------------------------------------------------------------------------
// GetMessage
//
// Returns the most current error message.
//----------------------------------------------------------------------------------------------------------------------
Service GetMessage()
Response = ErrorMessages@[-1, 'B' : @FM]
End Service
//----------------------------------------------------------------------------------------------------------------------
// GetMessages
//
// Returns the stack of error messages. This will be @FM delimited.
//----------------------------------------------------------------------------------------------------------------------
Service GetMessages()
// Business logic goes here. Data that needs to be returned should be assigned to the Response parameter.
Response = ErrorMessages@
End Service
//----------------------------------------------------------------------------------------------------------------------
// HasError
//
// Returns True if there is an error condition, False if there is no error condition. Caller will still need to use
// the GetMessage or GetMessages service to determine what the error is. The HasError service allows the caller to
// embed the Error_Services service call inside of a conditional statement like this:
//
// If Error_Services('HasError') then
// * An error has occured. Proceed accordingly.
// ErrorMessage = Error_Services('GetMessage')
// end else
// * No error has occured.
// end
//----------------------------------------------------------------------------------------------------------------------
Service HasError()
If Len(ErrorMessages@) then
Response = True$
end else
Response = False$
end
End Service
//----------------------------------------------------------------------------------------------------------------------
// NoError
//
// Returns True if there are no error conditions, False if there is an error condition. This is the opposite of the
// HasError service and exists for improved readability.
//----------------------------------------------------------------------------------------------------------------------
Service NoError()
If Len(ErrorMessages@) then
Response = False$
end else
Response = True$
end
End Service
//----------------------------------------------------------------------------------------------------------------------
// DisplayError
//
// Displays the current error message to the end user.
//----------------------------------------------------------------------------------------------------------------------
Service DisplayError(Justification)
ErrorMessage = Error_Services('GetMessage')
If Len(ErrorMessage) then
MsgStruct = ''
MsgStruct<MTEXT$> = ErrorMessage
MsgStruct<MTYPE$> = 'BO'
MsgStruct<MMODAL$> = 'W'
MsgStruct<MICON$> = '!'
MsgStruct<MCOL$> = -1
MsgStruct<MROW$> = -1
MsgStruct<MJUST$> = Justification
MsgStruct<MCAPTION$> = 'Error Services'
MsgStruct<MFONT$> = Segoe_UI$
Msg(@Window, MsgStruct)
end
End Service
Service GetSource()
// Business logic goes here. Data that needs to be returned should be assigned to the Response parameter.
Response = '<Service Response>'
End Service
Service GetSources()
// Business logic goes here. Data that needs to be returned should be assigned to the Response parameter.
Response = '<Service Response>'
End Service
Service GetCode()
// Business logic goes here. Data that needs to be returned should be assigned to the Response parameter.
Response = '<Service Response>'
End Service
Service GetCodes()
// Business logic goes here. Data that needs to be returned should be assigned to the Response parameter.
Response = '<Service Response>'
End Service
Service GetStackTrace()
// Business logic goes here. Data that needs to be returned should be assigned to the Response parameter.
Response = '<Service Response>'
End Service
//----------------------------------------------------------------------------------------------------------------------
// LogStack
//
// Uses a custom debugger intercept to log the stack including line numbers to .../LogFiles/StackTrace.
//----------------------------------------------------------------------------------------------------------------------
Service LogStack()
DebuggerEnabled = Get_Env(ENV_DEBUGGER_ENABLED$)
DebuggerIntercept = Get_Env(ENV_DEBUGGER_INTERCEPT_PROC$)
Set_Env(ENV_DEBUGGER_ENABLED$, 2, 1)
Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$, 'DEBUGGER_LOGGER', 1)
// Save the current status code and message before forcing runtime error
// to get OI to update stack variables in RTI_DEBUG_COMMON.
EsSpStatCode@ = Get_Status(EsSpStatMessage@)
ForceRuntimeError = 1/0
Set_Env(ENV_DEBUGGER_ENABLED$, DebuggerEnabled, 1)
Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$, DebuggerIntercept, 1)
// Restore OI status variables so we don't break any logic relying on it.
Set_Status(EsSpStatCode@, EsSpStatMessage@)
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////?
//----------------------------------------------------------------------------------------------------------------------
// SendRuntimeAlert
//
// Sends out an email alert when this service is called as a debugger intercept.
//----------------------------------------------------------------------------------------------------------------------
SendRuntimeAlert:
Done = False$
Error = False$
Program = Curr_Program@
MsgSent = ''
If Program EQ '' then Program = 'Error Services'
ConfigFile = ''
ConfigFile<1> = SendUsing_Port$
ConfigFile<2> = ''
ConfigFile<3> = '' ; // Server port
ConfigFile<4> = '' ; // Mail server
ConfigFile<5> = True$ ; // Authenticate
ConfigFile<6> = '' ; // Username
ConfigFile<7> = '' ; // Password
ConfigFile<8> = False$ ; // Use SSL
Text = ''
Text<-1> = 'App: ' : @APPID<1>
Text<-1> = 'Window: ' : @WINDOW
Text<-1> = 'User: ' : @USERNAME
Text<-1> = 'Station: ' : @STATION
Text<-1> = ' '
Text<-1> = 'SP Status: ' : SPStatus@
Text<-1> = 'SP Stat Code: ' : SPStatCode@
Text<-1> = 'Program: ' : Program
Text<-1> = 'Call Depth: ' : CallDepth@
Text<-1> = 'Line No: ' : LineNo@
Text<-1> = ' '
Text<-1> = 'Stack: '
Text<-1> = CallStack@
Convert \00\ TO ',' in Text
Swap @VM with ':@VM:' IN Text
Swap @FM with Char(13) : Char(10) IN Text
Swap @TM with Char(13) : Char(10) IN Text
SentFrom = ''
SentTo = ''
Message = ''
Message<1> = '' : Program ; // Subject
Message<2> = SentFrom ; // From (email address)
Message<3> = SentTo ; // Send to (email address)
Message<5> = '' ; // Blind Carbon Copy (email address)
Message<6> = '' ; // Reply To (email address)
Message<7> = 'TEXT' ; // Content Type (TEXT or HTML)
Message<8> = Text ; // Content / Body
Message<9> = '' ; // Attachment(s) (path to file name(s))
MsgSent = SRPSendMail(Message, ConfigFile)
return

View File

@ -0,0 +1,875 @@
Function HTTPClient_Services(@Service, @Params)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from SRP Computer Solutions, Inc.
Name : HTTPClient_Services
Description : Handler program for all module related services.
Notes : The generic parameters should contain all the necessary information to process the services. Often
this will be information like the data Record and Key ID.
Parameters :
Service [in] -- Name of the service being requested
Param1-10 [in/out] -- Additional request parameter holders
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
Metadata :
History : (Date, Initials, Notes)
03/28/16 dmb [SRPFW-120] Original programmer.
07/01/17 dmb [SRPFW-184] Refactor using Enhanced BASIC+ syntax.
05/19/18 dmb [SRPFW-235] Check for content in the HeaderList variable before calling the For Each loop.
11/15/18 dmb [SRPFW-238] Add ClientCertPath argument to the SendHTTPRequest service to support
client-side certificates.
02/28/19 dmb Change UseXMLHTTP argument to UseClientXMLHTTP in the SendHTTPRequest service to make it
easier to interpret.
02/09/20 dmb [SRPFW-309] Fix a bug in the SendHTTPRequest service so that request headers are properly
parsed. All colons were erroneously being converted to @VM instead of the first colon (which
separated the header name from the header value).
02/09/20 dmb [SRPFW-309] Update the SetResponseHeaderField service to better support Set-Cookie headers.
Allow multiple cookie names to be stored but only store the value of the last cookie name
if it is duplicated.
02/09/20 dmb [SRPFW-309] Update the GetResponseHeaderField by adding a Delimiter argument so the caller
can specify an alternative delimiter for the values being returned.
02/09/20 dmb [SRPFW-309] Add GetCookies service to make it easier to view all cookies returned in the
response.
02/09/20 dmb [SRPFW-309] Add GetCookie service to make it easier to see the entire cookie string of a
specified cookie.
02/10/20 dmb [SRPFW-309] Update the GetCookie service to include an IgnoreAttributes argument. If this
is True$, then only the cookie name and value will be returned.
12/19/24 djs Created LSL version of service module. Added IgnoreCertErrors parameter to SendHttpRequest service.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$insert SERVICE_SETUP
Equ CRLF$ to \0D0A\
// The readyState property will have this value when the request has returned from the server.
// http://msdn.microsoft.com/en-us/library/ms753800(v=vs.85).aspx
Equ HTTP_COMPLETED$ to 4
Equ SXH_SERVER_CERT_IGNORE_UNKNOWN_CA$ to 256 ; // Unknown certificate authority
Equ SXH_SERVER_CERT_IGNORE_WRONG_USAGE$ to 512 ; // Malformed certificate such as a certificate with no subject name.
Equ SXH_SERVER_CERT_IGNORE_CERT_CN_INVALID$ to 4096 ; // Mismatch between the visited hostname and the certificate name being used on the server.
Equ SXH_SERVER_CERT_IGNORE_CERT_DATE_INVALID$ to 8192 ; // The date in the certificate is invalid or has expired.
Equ SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS$ to 13056 ; // All certificate errors.
Common /HTTPClientServices/ RequestHeaderFields@, RequestHeaderValues@, ResponseHeaderFields@, ResponseHeaderValues@, ResponseStatusCode@, ResponseStatusPhrase@, ResponseBody@, TimeoutDuration@
Declare function SRP_COM, HTTPClient_Services, GetTickCount, OLECreateInstance, OLEGetProperty, OLECallMethod, OLEStatus
Declare subroutine SRP_COM, HTTPClient_Services, OLEPutProperty
GoToService else
Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' module.')
end
Return Response OR ''
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Service Parameter Options
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Options BOOLEAN = True$, False$
Options RESPONSEHEADERNAMES = 'Access-Control-Allow-Headers', 'Access-Control-Allow-Methods', 'Access-Control-Allow-Origin', 'Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-Location', 'Content-Disposition', 'Content-Type', 'Date', 'Expires', 'Last-Modified', 'Link', 'Location', 'Retry-After', 'Server', 'Set-Cookie', 'Transfer-Encoding', 'Vary', 'WWW-Authenticate',
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Services
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------
// SendHTTPRequest
//
// Method - The HTTP method to submit to the server. - [Required]
// URL - The URL receiving the HTTP request. - [Required]
// HeaderList - An @FM/@VM list of request header names and values. - [Optional]
// Body - The request body to be sent to the server. - [Optional]
// ProxyUser - Username needed to authenticate against a proxy server. - [Optional]
// ProxyPassword - Password needed to authenticate against a proxy server. - [Optional]
// UseAsynchronous - Flag to determine if the HTTP request should be processed asynchronously. Default is True.
// - [Optional]
// UseClientXMLHTTP - Flag to determine if client XMLHTTP or server XMLHTTP should be used. Default is server XMLHTTP.
// - [Optional]
// ClientCertPath - Path to a client-side certificate. This is usually in Location\Certificate Store\Subject format.
// - [Optional]
//
// Calls the indicated HTTP web service routine.
//----------------------------------------------------------------------------------------------------------------------
Service SendHTTPRequestOLE(Method, URL, HeaderList, Body, ProxyUser, ProxyPassword, UseAsynchronous, UseClientXMLHTTP, ClientCertPath)
// Defaults.
If UseAsynchronous NE False$ then UseAsynchronous = True$
If UseClientXMLHTTP NE True$ then UseClientXMLHTTP = False$
If (Method NE '') AND (URL NE '') then
// Make sure all prior response settings are cleared before performing the next HTTP request.
HTTPClient_Services('ClearResponseSettings')
// Attempt to get a handle for the best XMLHTTP object.
objXMLHTTP = ''
If UseClientXMLHTTP then
ServerPrefix = ''
end else
ServerPrefix = 'Server'
end
XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.6.0'
objXMLHTTP = OLECreateInstance(XMLHTTPProgID)
Status = OLEStatus()
If Status then
XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.3.0'
objXMLHTTP = OLECreateInstance(XMLHTTPProgID)
Status = OLEStatus()
If Status then
XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP'
objXMLHTTP = OLECreateInstance(XMLHTTPProgID)
Status = OLEStatus()
If Status then
Error = 'Unable to create a handle to the XMLHTTP object in the ' : Service : ' service.'
Error := ' OLE Error: ' : Status
Error_Services('Add', Error)
end
end
end
If Error_Services('NoError') then
// Invoke the XMLHTTP object's open method to initialize a request.
rv = OLECallMethod(objXMLHTTP, 'open', Method, URL, UseAsynchronous, ProxyUser, ProxyPassword)
Status = OLEStatus()
If Status then
Error = 'Error calling the open method for the XMLHTTP object in the ' : Service : ' service.'
Error := ' OLE Error: ' : Status
Error_Services('Add', Error)
end
end
* If Error_Services('NoError') then
* // Set the request header names and values. This will add or update any header fields passed in through this
* // service with those have may have been previously set using the SetRequestHeaderFields or
* // SetRequestHeaderField already.
* If Len(HeaderList) then HTTPClient_Services('SetRequestHeaderFields', HeaderList)
* // Now get all of the request header fields.
* HeaderList = HTTPClient_Services('GetRequestHeaderFields')
* If Error_Services('NoError') then
* If HeaderList NE '' then
* For Each HeaderPair in HeaderList using @FM
* HeaderName = HeaderPair<0, 1>
* HeaderValue = HeaderPair<0, 2>
* SRP_COM(objXMLHTTP, 'CALL', 'setRequestHeader', HeaderName, HeaderValue)
* If SRP_COM('', 'HASERROR') then
* Error = 'Error setting the setRequestHeader property for the ' : HeaderName : ' field in the XMLHTTP object in the ' : Service : ' service.'
* Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
* Error_Services('Add', Error)
* end
* Next HeaderPair
* end
* end
* end
* If ClientCertPath NE '' then
* If Error_Services('NoError') then
* // Invoke the XMLHTTP object's setOption method to invoke a certificate.
* rv = SRP_COM(objXMLHTTP, 'CALL', 'setOption', 3, ClientCertPath)
* If SRP_COM('', 'HASERROR') then
* Error = 'Error calling the setOption method for the XMLHTTP object in the ' : Service : ' service.'
* Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
* Error_Services('Add', Error)
* end
* end
* end
If Error_Services('NoError') then
// Invoke the XMLHTTP object's send method to submit the request to the server.
rv = OLECallMethod(objXMLHTTP, 'send', Body)
Status = OLEStatus()
If Status then
Error = 'Error calling the send method for the XMLHTTP object in the ' : Service : ' service.'
Error := ' OLE Error: ' : Status
Error_Services('Add', Error)
end
end
If Error_Services('NoError') then
If UseAsynchronous then
StartTime = GetTickCount()
TimeoutDuration = HTTPClient_Services('GetTimeoutDuration')
TimedOut = False$
Loop
ReadyState = OLEGetProperty(objXMLHTTP, 'readyState')
CurrentTime = GetTickCount()
ElapsedTime = Int((CurrentTime - StartTime) / 1000)
TimedOut = ElapsedTime GE TimeoutDuration
While (ReadyState NE HTTP_COMPLETED$) AND Not(TimedOut)
Repeat
end
// Check the XMLHTTP object's responseBody property to get the server's response.
Response = OLEGetProperty(objXMLHTTP, 'responseBody')
Response1 = OLEGetProperty(objXMLHTTP, 'responseText')
Response2 = objXMLHTTP->responseBody
Response3 = objXMLHTTP->responseText
Status = OLEStatus()
If Status then
Error = 'Error getting the responseBody property for the XMLHTTP object in the ' : Service : ' service.'
Error := ' OLE Error: ' : Status
Error_Services('Add', Error)
Response = ''
end else
HTTPClient_Services('SetResponseBody', Response)
end
end
If Error_Services('NoError') then
// If the request was successful, get the response status code, phrase, and response headers and set them
// using HTTPClient_Services so the caller can retrieve is desired.
Code = OLEGetProperty(objXMLHTTP, 'status')
Phrase = Trim(OLEGetProperty(objXMLHTTP, 'statusText'))
HTTPClient_Services('SetResponseStatusCode', Code)
HTTPClient_Services('SetResponseStatusPhrase', Phrase)
ResponseHeaders = OLECallMethod(objXMLHTTP, 'getAllResponseHeaders')
Swap CRLF$ with @FM in ResponseHeaders
For Each ResponseHeader in ResponseHeaders using @FM
Name = ResponseHeader[1, 'F:']
Value = Trim(ResponseHeader[Col2() + 1, 9999])
If (Name NE '') AND (Value NE '') then
HTTPClient_Services('SetResponseHeaderField', Name, Value)
end
Next ResponseHeader
end
// Make sure all prior request settings are cleared so future HTTP request won't be affected.
Error = Error_Services('GetMessage') ; // Get any pre-existing errors so they can be preserved.
HTTPClient_Services('ClearRequestSettings') ; // This will automatically clear the error stack.
Error_Services('Set', Error) ; // Restore any errors so the caller can check for them.
end else
Error_Services('Add', 'Method or URL argument was missing from the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// SendHTTPRequest
//
// Method - The HTTP method to submit to the server. - [Required]
// URL - The URL receiving the HTTP request. - [Required]
// HeaderList - An @FM/@VM list of request header names and values. - [Optional]
// Body - The request body to be sent to the server. - [Optional]
// ProxyUser - Username needed to authenticate against a proxy server. - [Optional]
// ProxyPassword - Password needed to authenticate against a proxy server. - [Optional]
// UseAsynchronous - Flag to determine if the HTTP request should be processed asynchronously. Default is True.
// - [Optional]
// UseClientXMLHTTP - Flag to determine if client XMLHTTP or server XMLHTTP should be used. Default is server XMLHTTP.
// - [Optional]
// ClientCertPath - Path to a client-side certificate. This is usually in Location\Certificate Store\Subject format.
// - [Optional]
//
// Calls the indicated HTTP web service routine.
//----------------------------------------------------------------------------------------------------------------------
Service SendHTTPRequest(Method, URL, HeaderList, Body, ProxyUser, ProxyPassword, UseAsynchronous, UseClientXMLHTTP, ClientCertPath, IgnoreCertErrors)
// Defaults.
If UseAsynchronous NE False$ then UseAsynchronous = True$
If UseClientXMLHTTP NE True$ then UseClientXMLHTTP = False$
If IgnoreCertErrors NE True$ then IngoreCertErrors = False$
If (Method NE '') AND (URL NE '') then
// Make sure all prior response settings are cleared before performing the next HTTP request.
HTTPClient_Services('ClearResponseSettings')
// Attempt to get a handle for the best XMLHTTP object.
objXMLHTTP = ''
If UseClientXMLHTTP then
ServerPrefix = ''
end else
ServerPrefix = 'Server'
end
XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.6.0'
If SRP_COM(objXMLHTTP, 'CREATE', XMLHTTPProgID) else
XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.3.0'
If SRP_COM(objXMLHTTP, 'CREATE', XMLHTTPProgID) else
XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP'
If SRP_COM(objXMLHTTP, 'CREATE', XMLHTTPProgID) else
Error = 'Unable to create a handle to the XMLHTTP object in the ' : Service : ' service.'
If SRP_COM('', 'HASERROR') then
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
end
Error_Services('Add', Error)
end
end
end
If Error_Services('NoError') then
// Invoke the XMLHTTP object's open method to initialize a request.
SRP_COM(objXMLHTTP, 'CALL', 'open', Method, URL, UseAsynchronous, ProxyUser, ProxyPassword)
If SRP_COM('', 'HASERROR') then
Error = 'Error calling the open method for the XMLHTTP object in the ' : Service : ' service.'
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
Error_Services('Add', Error)
end
end
If Error_Services('NoError') then
// Set the request header names and values. This will add or update any header fields passed in through this
// service with those have may have been previously set using the SetRequestHeaderFields or
// SetRequestHeaderField already.
If Len(HeaderList) then HTTPClient_Services('SetRequestHeaderFields', HeaderList)
// Now get all of the request header fields.
HeaderList = HTTPClient_Services('GetRequestHeaderFields')
If Error_Services('NoError') then
If HeaderList NE '' then
For Each HeaderPair in HeaderList using @FM
HeaderName = HeaderPair<0, 1>
HeaderValue = HeaderPair<0, 2>
SRP_COM(objXMLHTTP, 'CALL', 'setRequestHeader', HeaderName, HeaderValue)
If SRP_COM('', 'HASERROR') then
Error = 'Error setting the setRequestHeader property for the ' : HeaderName : ' field in the XMLHTTP object in the ' : Service : ' service.'
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
Error_Services('Add', Error)
end
Next HeaderPair
end
end
end
If IgnoreCertErrors then
If Error_Services('NoError') then
rv = SRP_COM(objXMLHTTP, 'CALL', 'setOption', 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS$)
If SRP_COM('', 'HASERROR') then
Error = 'Error calling the setOption method for the XMLHTTP object in the ' : Service : ' service.'
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
Error_Services('Add', Error)
end
end
end
If ClientCertPath NE '' then
If Error_Services('NoError') then
// Invoke the XMLHTTP object's setOption method to invoke a certificate.
rv = SRP_COM(objXMLHTTP, 'CALL', 'setOption', 3, ClientCertPath)
If SRP_COM('', 'HASERROR') then
Error = 'Error calling the setOption method for the XMLHTTP object in the ' : Service : ' service.'
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
Error_Services('Add', Error)
end
end
end
If Error_Services('NoError') then
// Invoke the XMLHTTP object's send method to submit the request to the server.
rv = SRP_COM(objXMLHTTP, 'CALL', 'send', Body)
If SRP_COM('', 'HASERROR') then
Error = 'Error calling the send method for the XMLHTTP object in the ' : Service : ' service.'
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
Error_Services('Add', Error)
end
end
If Error_Services('NoError') then
If UseAsynchronous then
StartTime = GetTickCount()
TimeoutDuration = HTTPClient_Services('GetTimeoutDuration')
TimedOut = False$
Loop
ReadyState = SRP_COM(objXMLHTTP, 'GET', 'readyState')
CurrentTime = GetTickCount()
ElapsedTime = Int((CurrentTime - StartTime) / 1000)
TimedOut = ElapsedTime GE TimeoutDuration
While (ReadyState NE HTTP_COMPLETED$) AND Not(TimedOut)
Repeat
end
// Check the XMLHTTP object's responseBody property to get the server's response.
* Response = SRP_COM(objXMLHTTP, 'GET', 'responseBody')
Response = SRP_COM(objXMLHTTP, 'GET', 'responseText')
If SRP_COM('', 'HASERROR') then
Error = 'Error getting the responseBody property for the XMLHTTP object in the ' : Service : ' service.'
Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR')
Error_Services('Add', Error)
Response = ''
end else
HTTPClient_Services('SetResponseBody', Response)
end
end
If Error_Services('NoError') then
// If the request was successful, get the response status code, phrase, and response headers and set them
// using HTTPClient_Services so the caller can retrieve is desired.
Code = SRP_COM(objXMLHTTP, 'GET', 'status')
Phrase = Trim(SRP_COM(objXMLHTTP, 'GET', 'statusText'))
HTTPClient_Services('SetResponseStatusCode', Code)
HTTPClient_Services('SetResponseStatusPhrase', Phrase)
ResponseHeaders = SRP_COM(objXMLHTTP, 'CALL', 'getAllResponseHeaders')
Swap CRLF$ with @FM in ResponseHeaders
For Each ResponseHeader in ResponseHeaders using @FM
Name = ResponseHeader[1, 'F:']
Value = Trim(ResponseHeader[Col2() + 1, 9999])
If (Name NE '') AND (Value NE '') then
HTTPClient_Services('SetResponseHeaderField', Name, Value)
end
Next ResponseHeader
end
// Release the handle to the XMLHTTP object in case it was created.
SRP_COM(objXMLHTTP, 'RELEASE')
// Make sure all prior request settings are cleared so future HTTP request won't be affected.
Error = Error_Services('GetMessage') ; // Get any pre-existing errors so they can be preserved.
HTTPClient_Services('ClearRequestSettings') ; // This will automatically clear the error stack.
Error_Services('Set', Error) ; // Restore any errors so the caller can check for them.
end else
Error_Services('Add', 'Method or URL argument was missing from the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// SetRequestHeaderFields
//
// HeaderList - An @FM/@VM list of request header fields and their values. - [Required]
//
// Sets the Request Header Fields as indicated by the HeaderList argument. The HeaderList should not be formatted as a
// list rather than an associated multivalue array. This is easier for the developer to manage in the code that calls
// this service.
//----------------------------------------------------------------------------------------------------------------------
Service SetRequestHeaderFields(HeaderList)
If HeaderList NE '' then
For Each HeaderPair in HeaderList using @FM
HeaderName = HeaderPair<0, 1>
HeaderValue = HeaderPair<0, 2>
HTTPClient_Services('SetRequestHeaderField', HeaderName, HeaderValue)
Next HeaderPair
end else
Error_Services('Add', 'HeaderList argument was missing from the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// SetRequestHeaderField
//
// Name - Header Field Name to set. - [Required]
// Value - Value for the header field. This will be Trimmed to enforce proper formatting. - [Required]
//
// Sets the indicated Request Header Field with the indicated value.
//----------------------------------------------------------------------------------------------------------------------
Service SetRequestHeaderField(Name, Value)
If (Name NE '') AND (Value NE '') then
SearchName = Name
Convert @Lower_Case to @Upper_Case in SearchName
SearchFields = RequestHeaderFields@
Convert @Lower_Case to @Upper_Case in SearchFields
Locate SearchName in SearchFields using @FM setting fPos else
fPos = Count(RequestHeaderFields@, @FM) + (RequestHeaderFields@ NE '') + 1
end
RequestHeaderFields@<fPos> = Name
RequestHeaderValues@<fPos> = Trim(Value)
end else
Error_Services('Add', 'The Name or Value argument is missing in the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// GetRequestHeaderFields
//
// Returns all of the Request Header Field names and values. This returns an @FM/@VM list of names and values.
//----------------------------------------------------------------------------------------------------------------------
Service GetRequestHeaderFields()
HeaderFieldBlock = ''
If RequestHeaderFields@ NE '' then
NumFields = Count(RequestHeaderFields@, @FM) + (RequestHeaderFields@ NE '')
For FieldCnt = 1 to NumFields
HeaderFieldBlock := RequestHeaderFields@<FieldCnt> : @VM : RequestHeaderValues@<FieldCnt> : @FM
Next FieldCnt
HeaderFieldBlock[-1, 1] = ''
end
Response = HeaderFieldBlock
end service
//----------------------------------------------------------------------------------------------------------------------
// GetRequestHeaderField
//
// Name - Header Field Name to get. - [Required]
//
// Returns the value previously set for the indicated Request Header Field.
//----------------------------------------------------------------------------------------------------------------------
Service GetRequestHeaderField(Name)
Value = ''
If Name NE '' then
SearchName = Name
Convert @Lower_Case to @Upper_Case in SearchName
SearchFields = RequestHeaderFields@
Convert @Lower_Case to @Upper_Case in SearchFields
Locate SearchName in SearchFields using @FM setting fPos then
Value = RequestHeaderValues@<fPos>
end else
Error_Services('Add', Name : ' is not a header field in the request.')
end
end else
Error_Services('Add', 'The Name argument is missing in the ' : Service : ' service.')
end
Response = Value
end service
//----------------------------------------------------------------------------------------------------------------------
// SetResponseHeaderField
//
// Name - Header Field Name to set. - [Required]
// Value - Value for the header field. This will be Trimmed to enforce proper formatting. - [Required]
//
// Sets the indicated Response Header Field with the indicated value.
//----------------------------------------------------------------------------------------------------------------------
Service SetResponseHeaderField(Name, Value)
If (Name NE '') AND (Value NE '') then
SearchName = Name
Convert @Lower_Case to @Upper_Case in SearchName
SearchFields = ResponseHeaderFields@
Convert @Lower_Case to @Upper_Case in SearchFields
Locate SearchName in SearchFields using @FM setting fPos else
fPos = Count(ResponseHeaderFields@, @FM) + (ResponseHeaderFields@ NE '') + 1
end
ResponseHeaderFields@<fPos> = Name
PreviousValue = ResponseHeaderValues@<fPos>
If PreviousValue EQ '' then
ResponseHeaderValues@<fPos> = Trim(Value)
end else
If Name EQ 'Set-Cookie' then
// Unlike other response headers, Set-Cookie can have multiple entries. However, if more than one
// cookie of a particular name exists then only store the last entry.
SetCookieFound = False$
CookieName = Value[1, 'F='][1, 'F '][1, 'F;']
For Each HeaderField in ResponseHeaderFields@ using @FM setting fPos
If HeaderField EQ 'Set-Cookie' then
SetCookieFound = True$
end
Until SetCookieFound EQ True$
Next HeaderField
If SetCookieFound EQ True$ then
// Set-Cookie was found. Check to see if the cookie name has already been added.
CookieNameFound = False$
CookieValues = ResponseHeaderValues@<fPos>
For Each CookieValue in CookieValues using @VM setting vPos
MatchCookieName = CookieValue[1, 'F='][1, 'F '][1, 'F;']
If CookieName EQ MatchCookieName then
CookieNameFound = True$
end
Until CookieNameFound EQ True$
Next CookieValue
If CookieNameFound EQ True$ then
// Cookie name already exists. Replace the old value with the new one.
ResponseHeaderValues@<fPos, vPos> = Trim(Value)
end else
// This is a new cookie name. Append the Set-Cookie value to the list.
ResponseHeaderValues@<fPos, -1> = Trim(Value)
end
end else
// No cookies have been set yet.
ResponseHeaderValues@<fPos> = Trim(Value)
end
end else
ResponseHeaderValues@<fPos> = PreviousValue : ' ;' : Trim(Value)
end
end
end else
Error_Services('Add', 'The Name or Value argument is missing in the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// GetResponseHeaderFields
//
// Returns all of the Response Header Field names and values. This returns an @FM/@VM list of names and values.
//----------------------------------------------------------------------------------------------------------------------
Service GetResponseHeaderFields()
HeaderFieldBlock = ''
If ResponseHeaderFields@ NE '' then
NumFields = Count(ResponseHeaderFields@, @FM) + (ResponseHeaderFields@ NE '')
For FieldCnt = 1 to NumFields
HeaderFieldBlock := ResponseHeaderFields@<FieldCnt> : @VM : ResponseHeaderValues@<FieldCnt> : @FM
Next FieldCnt
HeaderFieldBlock[-1, 1] = ''
end else
Error_Services('Add', 'There are no response header fields get.')
end
Response = HeaderFieldBlock
end service
//----------------------------------------------------------------------------------------------------------------------
// GetResponseHeaderField
//
// Name - Header Field Name to get. - [Required]
// Delimiter - Delimiter to use for multiple values. Default is '; ' for all header fields except for Set-Cookie.
// Set-Cookie defaults to @VM. - [Optional]
//
// Returns the value previously set for the indicated Response Header Field. The Name argument is case-insensitive but
// if the indicated Response Header Field has not been set then an error condition will be set.
//----------------------------------------------------------------------------------------------------------------------
Service GetResponseHeaderField(Name=RESPONSEHEADERNAMES, Delimiter)
Value = ''
If Name NE '' then
SearchName = Name
Convert @Lower_Case to @Upper_Case in SearchName
SearchFields = ResponseHeaderFields@
Convert @Lower_Case to @Upper_Case in SearchFields
Locate SearchName in SearchFields using @FM setting fPos then
Value = ResponseHeaderValues@<fPos>
If Delimiter NE '' then
If Name EQ 'Set-Cookie' then
Convert @VM to Delimiter in Value
end else
Swap '; ' with Delimiter in Value
end
end
end else
Error_Services('Add', Name : ' is not a header field in the response.')
end
end else
Error_Services('Add', 'The Name argument is missing in the ' : Service : ' service.')
end
Response = Value
end service
//----------------------------------------------------------------------------------------------------------------------
// GetCookies
//
// Delimiter - Delimiter to use for multiple cookies. Default is @FM - [Optional]
//
// Returns all cookie strings from the response headers.
//----------------------------------------------------------------------------------------------------------------------
Service GetCookies(Delimiter)
If Delimiter EQ '' then Delimiter = @FM
Cookies = HTTPClient_Services('GetResponseHeaderField', 'Set-Cookie', Delimiter)
Response = Cookies
end service
//----------------------------------------------------------------------------------------------------------------------
// GetCookie
//
// Name - Name of the cookie to get. - [Required]
// IgnoreAttributes - Boolean flag to indicate if the cookie's attributes should be removed when returning the cookie.
// Default value is False$. - [Optional]
//
// Returns the value for the indicated cookie name.
//----------------------------------------------------------------------------------------------------------------------
Service GetCookie(Name, IgnoreAttributes=BOOLEAN)
If IgnoreAttributes NE True$ then IgnoreAttributes = False$
Cookie = ''
If Name NE '' then
CookieNameFound = False$
Cookies = HTTPClient_Services('GetCookies')
For Each CookieString in Cookies using @FM
MatchCookieName = CookieString[1, 'F='][1, 'F '][1, 'F;']
If Name EQ MatchCookieName then
CookieNameFound = True$
end
Until CookieNameFound EQ True$
Next CookieValue
If CookieNameFound EQ True$ then
If IgnoreAttributes EQ True$ then
CookieString = Trim(CookieString[1, ';'])
end
Transfer CookieString to Cookie
end
end else
Error_Services('Add', 'The Name argument is missing in the ' : Service : ' service.')
end
Response = Cookie
end service
//----------------------------------------------------------------------------------------------------------------------
// SetResponseStatusCode
//
// Code - HTTP status code to set. - [Required]
//
// Sets the response status code generated by the most recent HTTP request.
//----------------------------------------------------------------------------------------------------------------------
Service SetResponseStatusCode(Code)
If Code NE '' then
ResponseStatusCode@ = Code
end else
Error_Services('Add', 'The Code argument is missing in the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// GetResponseStatusCode
//
// Gets the response status code generated by the most recent HTTP request.
//----------------------------------------------------------------------------------------------------------------------
Service GetResponseStatusCode()
Response = ResponseStatusCode@
end service
//----------------------------------------------------------------------------------------------------------------------
// SetResponseStatusPhrase
//
// Phrase - HTTP status phrase to set. - [Required]
//
// Sets the response status phrase generated by the most recent HTTP request.
//----------------------------------------------------------------------------------------------------------------------
Service SetResponseStatusPhrase(Phrase)
If Phrase NE '' then
ResponseStatusPhrase@ = Phrase
end else
Error_Services('Add', 'The Phrase argument is missing in the ' : Service : ' service.')
end
end service
//----------------------------------------------------------------------------------------------------------------------
// GetResponseStatusPhrase
//
// Gets the response status phrase generated by the most recent HTTP request.
//----------------------------------------------------------------------------------------------------------------------
Service GetResponseStatusPhrase()
Response = ResponseStatusPhrase@
end service
//----------------------------------------------------------------------------------------------------------------------
// SetResponseBody
//
// Body - The response body which would have been generated by an XMLHTTP call.
//
// Sets the response body generated by the most recent HTTP request.
//----------------------------------------------------------------------------------------------------------------------
Service SetResponseBody(Body)
ResponseBody@ = Body
end service
//----------------------------------------------------------------------------------------------------------------------
// GetResponseBody
//
// Gets the response body generated by the most recent HTTP request.
//----------------------------------------------------------------------------------------------------------------------
Service GetResponseBody()
Response = ResponseBody@
end service
//----------------------------------------------------------------------------------------------------------------------
// SetTimeoutDuration
//
// TimeoutDuration - The length of time (in seconds) before an HTTP request will abort.
//
// Sets the timeout duration that will be used before an HTTP request will abort. This is only applicable if the
// request is asynchronous. If the timeout duration is empty, a default setting of 30 minutes (1800 seconds) will be
// set.
//----------------------------------------------------------------------------------------------------------------------
Service SetTimeoutDuration(TimeoutDuration)
If TimeoutDuration EQ '' then TimeoutDuration = 1800
TimeoutDuration@ = TimeoutDuration
end service
//----------------------------------------------------------------------------------------------------------------------
// GetTimeoutDuration
//
// Returns the timeout duration that will be used before an HTTP request will abort. This is only applicable if the
// request is asynchronous. If the timeout duration is empty, a default setting of 30 minutes (1800) seconds) will be
// returned.
//----------------------------------------------------------------------------------------------------------------------
Service GetTimeoutDuration()
If TimeoutDuration@ EQ '' then TimeoutDuration@ = 1800
Response = TimeoutDuration@
end service
//----------------------------------------------------------------------------------------------------------------------
// ClearResponseSettings
//
// Clears all of the global common variables used for responses.
//----------------------------------------------------------------------------------------------------------------------
Service ClearResponseSettings()
ResponseHeaderFields@ = ''
ResponseHeaderValues@ = ''
ResponseStatusCode@ = ''
ResponseStatusPhrase@ = ''
ResponseBody@ = ''
end service
//----------------------------------------------------------------------------------------------------------------------
// ClearRequestSettings
//
// Clears all of the global common variables used for requests.
//----------------------------------------------------------------------------------------------------------------------
Service ClearRequestSettings()
RequestHeaderFields@ = ''
RequestHeaderValues@ = ''
TimeoutDuration@ = 1800
end service

View File

@ -43,6 +43,7 @@ Function Metrology_Services(@Service, @Params)
09/18/18 djs Added code within the ImportTencorData service to post wafer image pdfs to a staging table
where they will be stored locally on the App server.
09/11/19 fdr Add new service "ImportStratusData"
12/05/24 djs Updated GetIQSViolations service to store reactor violations in the respective reactor record.
***********************************************************************************************************************/
@ -67,6 +68,7 @@ $insert WO_MAT_EQUATES
$Insert NOTIFICATION_EQUATES
$Insert RLIST_EQUATES
$Insert WM_OUT_EQUATES
$Insert IQS_VIOL_DATA_EQUATES
Common /MetrologyServices/ MachineType@, RDSNo@
@ -91,7 +93,7 @@ Equ Comma$ to ','
Declare subroutine SRP_Stopwatch, Error_Services, obj_Tables, Metrology_Services, obj_RDS_Test, SRP_JSON
Declare subroutine RTI_Set_Debugger, Database_Services, Btree.Extract, Set_Status, QA_Services, obj_Notes
Declare subroutine Logging_Services, SRP_Send_Mail, SRP_Run_Command, PM_Services, Httpclient_Services
Declare subroutine Tool_Services, Mona_Services
Declare subroutine Tool_Services, Mona_Services, Reactor_Services
Declare function SRP_Sort_Array, Metrology_Services, obj_RDS_Test, obj_Test_Point_Map, Database_Services, UCase
Declare function Work_Order_Services, SRP_JSON, Logging_Services, Environment_Services, SRP_Trim, Min, Max
Declare function QA_Services, SRP_Join_Arrays, Get_Status, Obj_Clean_Insp, Datetime, SRP_Datetime
@ -2039,6 +2041,7 @@ end service
Service GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer)
CalculatedLayer = ''
If (RDSKeyID NE '') AND (Machine NE '') then
@ -2223,7 +2226,9 @@ Service RemoveOldMetrology()
end service
Service ImportBioRadEPPFQAData(RunData, FileName)
Timestamp = RunData<2>
WMOKeyID = RunData<6>
Swap '.' with '*' in WMOKeyID
@ -2303,8 +2308,10 @@ Service ImportBioRadEPPFQAData(RunData, FileName)
end else
Metrology_Services('LogResults', RDSNo@, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage'))
end
end service
//----------------------------------------------------------------------------------------------------------------------
// CleanRepository
//
@ -2349,61 +2356,23 @@ Service MonitorQueue(NumFiles)
// Enable manual entry restriction - check current status to avoid unnecessary writes.
CurrLockStatus = Database_Services('ReadDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK')
If CurrLockStatus EQ False$ then
Database_Services('WriteDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK', True$)
// Add message to OI Admins' Inbox
* OIAdmins = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
* Recipients = OIAdmins
* SentFrom = 'ADMIN_OI'
* Subject = 'ROTR Manual Entry Restriction Re-enabled'
* Message = 'Metrology run data queue currently has ':CurrFileCount:' files. ' |
* : 'ROTR manual entry lock has been re-enabled.'
* AttachWindow = ''
* AttachKey = ''
* SendToGroup = ''
* Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
* Set_Status(0)
* obj_Notes('Create',Parms)
*
Database_Services('WriteDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK', True$)
end
end else
// Lift manual entry restriction - check current status to avoid unnecessary writes.
CurrLockStatus = Database_Services('ReadDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK')
If CurrLockStatus EQ True$ then
Database_Services('WriteDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK', False$)
// Add message to OI Admins' Inbox
* OIAdmins = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
* Recipients = OIAdmins
* SentFrom = 'ADMIN_OI'
* Subject = 'ROTR Manual Entry Restriction Disabled'
* Message = 'Metrology run data queue currently has ':CurrFileCount:' files. ' |
* : 'ROTR manual entry lock has been temporarily disabled.'
* AttachWindow = ''
* AttachKey = ''
* SendToGroup = ''
* Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
* Set_Status(0)
* obj_Notes('Create',Parms)
end
end
end service
Service GetIQSViolations()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
Equ ViolReactorCol$ To 1
Equ ViolTestCol$ To 2
Equ ViolUSLCol$ To 3
Equ ViolTARCol$ To 4
Equ ViolLSLCol$ To 5
Equ ViolLastEntryCol$ To 6
Equ ViolLastAlarmCol$ To 7
Equ ViolAlarmCol$ To 8
Equ ViolSubGroupCol$ To 9
Equ ViolMeanCol$ To 10
Equ LastWriteTimeCol$ To 11
Response = 0
ParsedIQSData = ''
Pass = 1
@ -2445,21 +2414,21 @@ Service GetIQSViolations()
//Delete useuless Entire Database column
FilteredData = Delete(FilteredData, i,1,0)
ParsedIQSData<ViolReactorCol$, i> = FilteredData<i, ViolReactorCol$>
ParsedIQSData<ViolTestCol$, i> = FilteredData<i, ViolTestCol$>
ParsedIQSData<ViolUSLCol$, i> = FilteredData<i, ViolUSLCol$>
ParsedIQSData<ViolTARCol$, i> = FilteredData<i, ViolTARCol$>
ParsedIQSData<ViolLSLCol$, i> = FilteredData<i, ViolLSLCol$>
ParsedIQSData<ViolLastEntryCol$, i> = FilteredData<i, ViolLastEntryCol$>
ParsedIQSData<ViolLastAlarmCol$, i> = FilteredData<i, ViolLastAlarmCol$>
ParsedIQSData<IQS_VIOL_DATA.REACTOR$, i> = FilteredData<i, IQS_VIOL_DATA.REACTOR$>
ParsedIQSData<IQS_VIOL_DATA.TEST$, i> = FilteredData<i, IQS_VIOL_DATA.TEST$>
ParsedIQSData<IQS_VIOL_DATA.USL$, i> = FilteredData<i, IQS_VIOL_DATA.USL$>
ParsedIQSData<IQS_VIOL_DATA.TAR$, i> = FilteredData<i, IQS_VIOL_DATA.TAR$>
ParsedIQSData<IQS_VIOL_DATA.LSL$, i> = FilteredData<i, IQS_VIOL_DATA.LSL$>
ParsedIQSData<IQS_VIOL_DATA.LAST_ENTRY$, i> = FilteredData<i, IQS_VIOL_DATA.LAST_ENTRY$>
ParsedIQSData<IQS_VIOL_DATA.LAST_ALARM$, i> = FilteredData<i, IQS_VIOL_DATA.LAST_ALARM$>
swap '&gt;' with '>' in FilteredData
swap '&lt;' with '<' in FilteredData
ParsedIQSData<ViolAlarmCol$, i> = FilteredData<i, ViolAlarmCol$>
ParsedIQSData<ViolSubGroupCol$, i> = FilteredData<i, ViolSubGroupCol$>
ParsedIQSData<ViolMeanCol$, i> = FilteredData<i, ViolMeanCol$>
ParsedIQSData<IQS_VIOL_DATA.ALARM$, i> = FilteredData<i, IQS_VIOL_DATA.ALARM$>
ParsedIQSData<IQS_VIOL_DATA.SUBGROUPS$, i> = FilteredData<i, IQS_VIOL_DATA.SUBGROUPS$>
ParsedIQSData<IQS_VIOL_DATA.MEAN$, i> = FilteredData<i, IQS_VIOL_DATA.MEAN$>
Next i
LastWriteTime = IConv(PublishDate, 'DT')
ParsedIQSData<LastWriteTimeCol$> = LastWriteTime
LastWriteTime = IConv(PublishDate, 'DT')
ParsedIQSData<IQS_VIOL_DATA.LAST_WRITE_TIME$> = LastWriteTime
Database_Services('WriteDataRow', 'CONFIG', 'IQS_VIOL_DATA', ParsedIQSData, True$, False$, True$)
//Send status of last write time
@ -2469,8 +2438,11 @@ Service GetIQSViolations()
Mona_Services('SendBufferedStatus', 'IQS_VIOLATION_DATA', 'LastDataTimestamp', 'OK')
end
Reactor_Services('UpdateReactorIQSViolations')
Unlock hSysLists, ServiceKeyID else Null
end
end service
Service ScanRecipeMatchesRdsTestSpecThickMrecipe(RdsNo, RecipeLayer, RecipeInScan, RdsTestKeysFromRdsLayer, Zone='')
@ -2555,6 +2527,7 @@ Service ScanNumDataPointsMatchesRdsTestSpecThickMPattern(RdsNo, RecipeLayer, Sca
Response = MatchFound
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -3015,5 +2988,3 @@ LoadRunDataToDatabase:
return

View File

@ -0,0 +1,565 @@
Compile function Nica_Orders_Services(@Service, @Params)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from Infineon Technologies.
Name : Nica_Orders_Services
Description : Handler program for all module related services.
Notes : The generic parameters should contain all the necessary information to process the services. Often
this will be information like the data Record and Key ID.
Parameters :
Service [in] -- Name of the service being requested
Param1-10 [in/out] -- Additional request parameter holders
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
History : (Date, Initials, Notes)
12/05/24 djs Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert APP_INSERTS
$Insert SERVICE_SETUP
$Insert REACTOR_EQUATES
$Insert REACTOR_LOG_EQUATES
$Insert NICA_ORDERS_EQUATES
Declare function Environment_Services, Database_Services, Error_Services, Logging_Services, Nica_Orders_Services
Declare function Httpclient_Services, SRP_JSON
Declare subroutine Error_Services, Btree.Extract, Database_Services, Logging_Services, Nica_Orders_Services, Delay
Declare subroutine Httpclient_Services, SRP_JSON, Mona_Services, Service_Services
Machine = Environment_Services('GetServer')
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
GoToService
Return Response or ""
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Service Parameter Options
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Options BOOLEAN = True$, False$
Options ENTITY_TYPES = 'REACTOR','REACTOR_LOG'
Options ORDER_TYPES = 'INTRUSIVE_MAINT','CHANGEOVER','INITIATE_IDLE','IDLE','ASM_HTR_TUBE_CHANGE','ASM_HTR_ANNUAL_PM','ASM_HTR_SEMIANNUAL_PM','ASM_HTR_FIVE_AND_TEN_YEAR_PM','IQS_HGCV_ALARM'
Options ORDER_STATUSES = 'new','creating','not-started','in-progress','cancelled','done'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SERVICES
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Service GetOrderIds(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES, OrderStatus=ORDER_STATUSES, IsComplete=BOOLEAN)
OrderKeys = ''
ErrorMsg = ''
If ( (EntityType NE '') or (EntityID NE '') or (OrderType NE '') or (OrderStatus NE '') or (IsComplete NE '') ) then
Open 'DICT.NICA_ORDERS' to hDict then
Query = ''
Table = 'NICA_ORDERS'
Option = 'E'
Flag = ''
If EntityType NE '' then Query := 'ENTITY_TYPE' : @VM : EntityType : @FM
If EntityID NE '' then Query := 'ENTITY_ID' : @VM : EntityID : @FM
If OrderType NE '' then Query := 'ORDER_TYPE' : @VM : OrderType : @FM
If OrderStatus NE '' then Query := 'ORDER_STATUS' : @VM : OrderStatus : @FM
If IsComplete NE '' then Query := 'IS_COMPLETE' : @VM : IsComplete : @FM
Btree.Extract(Query, Table, hDict, OrderKeys, Option, Flag)
If Flag NE 0 then
ErrorMsg = 'Error in ':Service:' service. Btree.Extract call failed.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to open DICT.NICA_ORDERS.'
end
end else
ErrorMsg = 'Error in ':Service:' service. At least one search parameter must be provided.'
end
If ErrorMsg EQ '' then
Response = OrderKeys
end else
Error_Services('Add', ErrorMsg)
end
End Service
Service GetOrderUpdates()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
ActiveOrderIds = Nica_Orders_Services('GetActiveOrders')
For each OrderId in ActiveOrderIds using @VM
Nica_Orders_Services('GetOrderStatusUpdate', OrderId)
Next OrderId
Unlock hSysLists, ServiceKeyID else Null
end
end service
Service GetActiveOrders(EntityType=ENTITY_TYPES, EntityId, OrderType=ORDER_TYPES)
Response = Nica_Orders_Services('GetOrderIds', EntityType, EntityID, OrderType, '#cancelled', False$)
end service
Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES)
ErrorMsg = ''
EntityTypes = 'REACTOR,REACTOR_LOG'
OrderTypes = 'INTRUSIVE_MAINT,CHANGEOVER,INITIATE_IDLE,IDLE,ASM_HTR_TUBE_CHANGE,ASM_HTR_ANNUAL_PM,'
OrderTypes := 'ASM_HTR_SEMIANNUAL_PM,ASM_HTR_FIVE_AND_TEN_YEAR_PM,IQS_HGCV_ALARM'
Machine = Environment_Services('GetServer')
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
ColumnWidths = 20 : @FM : 15 : @FM : 300
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders'
makeDirSuccess = Utility("MAKEDIR", LogPath)
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : LogTime : '_CreateNicaOrder.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
Prod = Environment_Services('IsProd')
IgnoreCertErrors = Not(Prod)
If ( (EntityType NE '') and (EntityID NE '') and (OrderType NE '') ) then
Begin Case
Case Not(InList(EntityTypes, EntityType, ','))
ErrorMsg = 'Error in ':Service:' service. Unsupported entity type'
Case Not(InList(OrderTypes, OrderType, ','))
ErrorMsg = 'Error in ':Service:' service. Unsupported order type'
End Case
If ErrorMsg EQ '' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempting to create NICA order for entity ':EntityType:' ' :EntityID:' of type ':OrderType
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderType)
OrderTypeAlreadyActive = (CurrActiveOrders NE '')
If OrderTypeAlreadyActive EQ False$ then
Begin Case
Case EntityType EQ 'REACTOR'
ReactNo = EntityID
Case EntityType EQ 'REACTOR_LOG'
ReactNo = Xlate(EntityType, EntityID, REACTOR_LOG_REACTOR$, 'X')
End Case
// Call the API
NicaURL = Environment_Services("GetProveInApiUrl"):'/checklists?'
NicaURL := 'checklistType=':OrderType
NicaURL := '&reactorNumber=':ReactNo
Retries = 3
BackoffSeconds = 1
IsSuccessful = False$
OrderId = ''
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - retries) * BackoffSeconds
Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors)
If HttpResponseJson NE '' then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
OrderId = SRP_JSON(ObjResponseJson, 'GetValue', 'id')
If OrderId NE '' then
Convert @Lower.Case to @Upper.Case in OrderId
NicaOrderRec = ''
NicaOrderRec<NICA_ORDERS.ORDER_TYPE$> = OrderType
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = SRP_JSON(ObjResponseJson, 'GetValue', 'state')
NicaOrderRec<NICA_ORDERS.ENTITY_TYPE$> = EntityType
NicaOrderRec<NICA_ORDERS.ENTITY_ID$> = EntityID
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete')
Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$)
If Error_Services('NoError') then
If ( (OrderType _EQC 'INITIATE_IDLE') and (EntityType _EQC 'REACTOR') ) then
Open 'REACTOR' to hReactor then
WriteV True$ to hReactor, ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$ else
ErrorMsg = 'Error in ':Service:' service. Error setting IDLE_STARTUP_REQUIRED flag in REACTOR record.'
end
end
end
If ErrorMsg EQ '' then
IsSuccessful = True$
Response = OrderId
end
end else
ErrorMsg = Error_Services('GetMessage')
end
end else
ErrorMsg = 'Error in ':Service:' service. Null OrderId returned from MesaProveInAPI.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Error parsing JSON response from MesaProveInAPI.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null JSON response returned from MesaProveInAPI.'
end
SRP_JSON(ObjResponseJson, 'Release')
Repeat
If Environment_Services('IsProd') then
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI'
end else
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV'
end
StatusName = 'CreateNicaOrder'
If IsSuccessful then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Successfully created Nica order for entity ':EntityType:' ':EntityID:' of type ':OrderType
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok')
end else
ErrorMsg = 'Error encountered when attempting to create Nica in order for reactor ':ReactNo:' of type ':OrderType
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical')
end
end else
ErrorMsg = 'Error encountered when attempting to create Nica order for entity ':EntityType:' ' :EntityID:' of type ':OrderType:'. Active order already exists.'
end
end
end else
ErrorMsg = 'Error in ':Service:' service. Null EntityType, EntityID, or OrderType passed in.'
end
If ErrorMsg NE '' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = ErrorMsg
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMsg)
Response = 'error'
end
end service
Service CancelOrder(OrderId)
ErrorMsg = ''
Machine = Environment_Services('GetServer')
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
ColumnWidths = 20 : @FM : 15 : @FM : 300
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders'
makeDirSuccess = Utility("MAKEDIR", LogPath)
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_CancelNicaOrder.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempting to cancel Nica order ' : OrderId :'.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Prod = Environment_Services('IsProd')
IgnoreCertErrors = Not(Prod)
If OrderId NE '' then
LockRetries = 3
LockBackoffSeconds = 1
HaveLock = False$
Loop
While (HaveLock EQ False$ and LockRetries GT 0)
WaitSeconds = (3 - LockRetries) * LockBackoffSeconds
Delay(WaitSeconds)
LockRetries = LockRetries - 1
HaveLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS', OrderId, True$)
Repeat
If HaveLock then
NicaOrderRec = Database_Services('ReadDataRow', 'NICA_ORDERS', OrderId)
If Error_Services('NoError') then
EntityType = NicaOrderRec<NICA_ORDERS.ENTITY_TYPE$>
EntityId = NicaOrderRec<NICA_ORDERS.ENTITY_ID$>
Begin Case
Case EntityType EQ 'REACTOR'
ReactNo = EntityId
Case EntityType EQ 'REACTOR_LOG'
ReactNo = Xlate(EntityType, EntityId, REACTOR_LOG_REACTOR$, 'X')
Case Otherwise$
ErrorMsg = 'Error in ':Service:' service. Unsupported entity type.'
End Case
If ErrorMsg EQ '' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Sending cancel request for Nica order ' : OrderId : ' for reactor ' : ReactNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Response = False$
BaseProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?'
UrlOrderId = OrderId
Convert @Upper.Case to @Lower.Case in UrlOrderId
ProveInUrl = BaseProveInUrl:'checklistOrderId=':UrlOrderId
ProveInUrl = ProveInUrl:'&checklistState=cancelled'
Retries = 3
BackoffSeconds = 1
IsSuccessful = False$
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - Retries) * BackoffSeconds
Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'PUT', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors)
If HttpResponseJson NE '' then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'pendingUpdate')
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = SRP_JSON(ObjResponseJson, 'GetValue', 'state')
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete')
Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$)
If Error_Services('NoError') then
OrderType = NicaOrderRec<NICA_ORDERS.ORDER_TYPE$>
If ( (OrderType _EQC 'IDLE') and (EntityType EQ 'REACTOR') ) then
Open 'REACTOR' to hReactor then
WriteV False$ on hReactor, ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$ else
ErrorMsg = 'Error in ':Service:' service. Error setting IDLE_STARTUP_REQUIRED flag in REACTOR record.'
end
end
end
If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$
end else
ErrorMsg = Error_Services('GetMessage')
end
If IsComplete EQ True$ then
Response = True$
end else
Response = False$
end
end
end
SRP_JSON(ObjResponseJson, 'Release')
Repeat
If Environment_Services('IsProd') then
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI'
end else
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV'
end
StatusName = 'CancelNicaOrder'
If ( (IsSuccessful EQ True$) and (Response NE 'error') and (ErrorMsg EQ '') ) then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Successfully cancelled Nica order ' : OrderId : ' for reactor ' : ReactNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok')
end else
ErrorMsg = 'Error encountered cancelling Nica order ' : OrderId : ' for reactor ' : ReactNo
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical')
end
end else
ErrorMsg = Error_Services('GetMessage')
Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId)
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to lock NICA_ORDERS ':OrderId:' for cancellation.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null OrderID passed in.'
end
end else
ErrorMsg = Error_Services('GetMessage')
end
If ErrorMsg NE '' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = ErrorMsg
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMsg)
Response = 'error'
end
end service
Service GetOrderStatus(OrderId)
If OrderId NE '' then
If RowExists('NICA_ORDERS', OrderId) then
Response = Xlate('NICA_ORDERS', OrderId, 'ORDER_STATUS', 'X')
end else
Error_Services('Add', 'Error in ':Service:' service. Nica order ':OrderId:' does not exist.')
end
end else
Error_Services('Add', 'Error in ':Service:' service. Null OrderId passed in.')
end
end service
Service GetOrderStatusUpdate(OrderId)
ErrorMsg = ''
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
ColumnWidths = 20 : @FM : 15 : @FM : 300
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders'
makeDirSuccess = Utility("MAKEDIR", LogPath)
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_GetOrderStatusUpdate.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempting to update Nica order ' : OrderId :'.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Prod = Environment_Services('IsProd')
IgnoreCertErrors = Not(Prod)
If OrderId NE '' then
HaveLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS', OrderId, True$)
If HaveLock then
NicaOrderRec = Database_Services('ReadDataRow', 'NICA_ORDERS', OrderId)
If Error_Services('NoError') then
EntityType = NicaOrderRec<NICA_ORDERS.ENTITY_TYPE$>
EntityId = NicaOrderRec<NICA_ORDERS.ENTITY_ID$>
Begin Case
Case EntityType EQ 'REACTOR'
ReactNo = EntityId
Case EntityType EQ 'REACTOR_LOG'
ReactNo = Xlate(EntityType, EntityId, REACTOR_LOG_REACTOR$, 'X')
Case Otherwise$
ErrorMsg = 'Error in ':Service:' service. Unsupported entity type.'
End Case
If ErrorMsg EQ '' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempting to fetch Nica order ':OrderId:' for reactor ':ReactNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Response = True$
IsSuccessful = True$
BaseProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?'
UrlOrderId = OrderId
Convert @Upper.Case to @Lower.Case in UrlOrderId
ProveInUrl = BaseProveInUrl:'checklistOrderId=':UrlOrderId
Retries = 3
BackoffSeconds = 1
IsSuccessful = False$
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - Retries) * BackoffSeconds
Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'GET', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors)
If HttpResponseJson NE '' then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete')
NicaOrderRec<NICA_ORDERS.ORDER_TYPE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'type')
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = SRP_JSON(ObjResponseJson, 'GetValue', 'state')
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = IsComplete
Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$)
If Error_Services('NoError') then
If IsComplete EQ True$ then
OrderType = NicaOrderRec<NICA_ORDERS.ORDER_TYPE$>
If ( (OrderType _EQC 'IDLE') and (EntityType _EQC 'REACTOR') ) then
Open 'REACTOR' to hReactor then
WriteV False$ on hReactor, ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$ else
ErrorMsg = 'Error in ':Service:' service. Error setting IDLE_STARTUP_REQUIRED flag in REACTOR record.'
end
end
end
If ErrorMsg EQ '' then Response = True$
end else
Response = False$
end
If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$
end else
ErrorMsg = Error_Services('GetMessage')
end
end
end
SRP_JSON(ObjResponseJson, 'Release')
Repeat
If Environment_Services('IsProd') then
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI'
end else
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV'
end
StatusName = 'GetNicaOrderUpdate'
If IsSuccessful and Response NE 'error' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Successfully updated Nica order ':OrderId:' for reactor ':ReactNo:'.'
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok')
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
end else
Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId)
ErrorMsg = 'Error encountered updating Nica order ':OrderId:' for reactor ':ReactNo:'.'
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical')
end
end
end else
ErrorMsg = Error_Services('GetMessage')
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to lock NICA_ORDERS ':OrderId:'.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null OrderId passed in.'
end
If ErrorMsg NE '' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = ErrorMsg
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMsg)
Response = 'error'
end
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,90 +1,97 @@
Compile function PROVE_IN_OVERRIDE_EVENTS(CtrlEntId, Event, @PARAMS)
#pragma precomp SRP_PreCompiler
#window PROVE_IN_OVERRIDE
$Insert APP_INSERTS
$Insert REACTOR_EQUATES
$insert Message_Box_Equates
Declare subroutine Placedialog, Message_Box
GoToEvent Event for CtrlEntId else
// Event not implemented
end
Return EventFlow or 1
//-----------------------------------------------------------------------------
// EVENT HANDLERS
//-----------------------------------------------------------------------------
Event WINDOW.CREATE(CreateParam)
ReactNo = CreateParam
Placedialog(-2, -2)
ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X')
for each ProveInType in ProveInTypes using @VM setting dummy
Begin Case
Case ProveInType _EQC 'changeover'
Set_Property(@Window:'.CHB_CHANGEOVER', 'ENABLED', True$)
Case ProveInType _EQC 'initiate_idle'
Set_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'ENABLED', True$)
Case ProveInType _EQC 'idle'
Set_Property(@Window:'.CHB_IDLE_STARTUP', 'ENABLED', True$)
Case ProveInType _EQC 'intrusive_maint'
Set_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'ENABLED', True$)
Case Otherwise$
Null
End Case
Next ProveInType
End Event
Event PUB_SUBMIT.CLICK()
OverrideData = ''
SelectedTypes = ''
If Get_Property(@Window:'.CHB_CHANGEOVER', 'CHECK') then
SelectedTypes = "CHANGEOVER"
end
If Get_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'CHECK') then
If SelectedTypes NE '' then
SelectedTypes := @VM
end
SelectedTypes := 'INITIATE_IDLE'
end
If Get_Property(@Window:'.CHB_IDLE_STARTUP', 'CHECK') then
If SelectedTypes NE '' then
SelectedTypes := @VM
end
SelectedTypes := 'IDLE'
end
If Get_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'CHECK') then
If SelectedTypes NE '' then
SelectedTypes := @VM
end
SelectedTypes := 'INTRUSIVE_MAINT'
end
If SelectedTypes EQ '' then
Message_Box(@Window, "You must select at least one prove in type!", "Error", MSG_ICON_EXCLAM$)
return
end else
OverrideData<1, 1> = SelectedTypes
end
OverrideData<2, 1> = Get_Property(@Window:'.EDB_COMMENT', 'TEXT')
If OverrideData<2, 1> EQ '' or Len(OverrideData<2, 1>) LT 4 then
Message_Box(@Window, "Your comment must be at least 4 characters!", "Error", MSG_ICON_EXCLAM$)
return
end
End_Dialog(@Window, OverrideData)
end event
Event PUB_CANCEL.CLICK()
End_Dialog(@Window, '')
end event
Compile function PROVE_IN_OVERRIDE_EVENTS(CtrlEntId, Event, @PARAMS)
#pragma precomp SRP_PreCompiler
#window PROVE_IN_OVERRIDE
$Insert APP_INSERTS
$insert Message_Box_Equates
Declare subroutine Placedialog, Message_Box
Declare function Nica_Orders_Services
GoToEvent Event for CtrlEntId else
// Event not implemented
end
Return EventFlow or 1
//-----------------------------------------------------------------------------
// EVENT HANDLERS
//-----------------------------------------------------------------------------
Event WINDOW.CREATE(CreateParam)
ReactNo = CreateParam
Placedialog(-2, -2)
ActiveOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo)
For each OrderType in ActiveOrders using @VM setting dummy
Begin Case
Case OrderType _EQC 'changeover'
Set_Property(@Window:'.CHB_CHANGEOVER', 'ENABLED', True$)
Case OrderType _EQC 'initiate_idle'
Set_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'ENABLED', True$)
Case OrderType _EQC 'idle'
Set_Property(@Window:'.CHB_IDLE_STARTUP', 'ENABLED', True$)
Case OrderType _EQC 'intrusive_maint'
Set_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'ENABLED', True$)
Case Otherwise$
Null
End Case
Next OrderType
End Event
Event PUB_SUBMIT.CLICK()
OverrideData = ''
SelectedTypes = ''
If Get_Property(@Window:'.CHB_CHANGEOVER', 'CHECK') then
SelectedTypes = "CHANGEOVER"
end
If Get_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'CHECK') then
If SelectedTypes NE '' then
SelectedTypes := @VM
end
SelectedTypes := 'INITIATE_IDLE'
end
If Get_Property(@Window:'.CHB_IDLE_STARTUP', 'CHECK') then
If SelectedTypes NE '' then
SelectedTypes := @VM
end
SelectedTypes := 'IDLE'
end
If Get_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'CHECK') then
If SelectedTypes NE '' then
SelectedTypes := @VM
end
SelectedTypes := 'INTRUSIVE_MAINT'
end
If SelectedTypes EQ '' then
Message_Box(@Window, "You must select at least one prove in type!", "Error", MSG_ICON_EXCLAM$)
return
end else
OverrideData<1, 1> = SelectedTypes
end
OverrideData<2, 1> = Get_Property(@Window:'.EDB_COMMENT', 'TEXT')
If OverrideData<2, 1> EQ '' or Len(OverrideData<2, 1>) LT 4 then
Message_Box(@Window, "Your comment must be at least 4 characters!", "Error", MSG_ICON_EXCLAM$)
return
end
End_Dialog(@Window, OverrideData)
end event
Event PUB_CANCEL.CLICK()
End_Dialog(@Window, '')
end event

View File

@ -44,8 +44,8 @@ $insert HTTP_INSERTS
$insert REACTOR_LOG_EQUATES
$insert OI_WIZARD_EQUATES
Declare function Reactor_Log_Services, OI_Wizard_Services, MemberOf
Declare subroutine Database_Services, Reactor_Log_Services, Override_Log_Services
Declare function Reactor_Log_Services, OI_Wizard_Services, MemberOf, Nica_Orders_Services
Declare subroutine Database_Services, Reactor_Log_Services, Override_Log_Services, Nica_Orders_Services
GoToAPI else
// The specific resource endpoint doesn't have a API handler yet.
@ -185,13 +185,13 @@ API ReactorLogs.ID.nicaOverride.POST
If OverrideComment NE '' then
Override_Log_Services('Create', 'REACTOR_LOG', RLKey, OverrideUser, OverrideComment, 'REACTOR_LOG_PM', '')
If Error_Services('NoError') then
// Cancel all ReactorLog PMs
ActivePMKeys = Xlate('REACTOR_LOG', RLKey, REACTOR_LOG_CHECKLIST_ORDER_ID$, 'X')
If ActivePMKeys NE '' then
For each ActivePMKey in ActivePMKeys using @VM setting vPos
Reactor_Log_Services('CancelReactorLogPMOrder', RLKey, ActivePMKey)
// Cancel all ReactorLog NICA Orders
ActiveRlNicaOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey)
If ActiveRlNicaOrderIds NE '' then
For each ActiveRlNicaOrderId in ActiveRlNicaOrderIds using @VM setting vPos
Nica_Orders_Services('CancelOrder', ActiveRlNicaOrderId)
Until Error_Services('HasError')
Next ActivePMKey
Next ActiveRlNicaOrderId
end
If Error_Services('NoError') then
HTTP_Services('SetResponseStatus', 200, 'Nica orders canceled for REACTOR_LOG "':RLKey:'".')
@ -261,3 +261,4 @@ API reactorlogs.ID.nicaoverride.PUT
end api

View File

@ -0,0 +1,232 @@
Function Reactor_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record, Status, OrigRecord, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from Infineon.
Name : Reactor_Actions
Description : Handles calculated columns and MFS calls for the current table.
Notes : This function uses @ID, @RECORD, and @DICT to make sure {ColumnName} references work correctly.
If called from outside of a calculated column these will need to be set and restored.
Parameters :
Action [in] -- Name of the action to be taken
CalcColName [in] -- Name of the calculated column that needs to be processed. Normally this should only be
populated when the CalcField action is being used.
FSList [in] -- The list of MFSs and the BFS name for the current file or volume. This is an @SVM
delimited array, with the current MFS name as the first value in the array, and the BFS
name as the last value. Normally set by a calling MFS.
Handle [in] -- The file handle of the file or media map being accessed. Note, this does contain the
entire handle structure that the Basic+ Open statement would provide. Normally set by a
calling MFS.
Name [in] -- The name (key) of the record or file being accessed. Normally set by a calling MFS.
FMC [in] -- Various functions. Normally set by a calling MFS.
Record [in] -- The entire record (for record-oriented functions) or a newly-created handle (for
"get handle" functions). Normally set by a calling MFS.
Status [in/out] -- Indicator of the success or failure of an action. Normally set by the calling MFS but
for some actions can be set by the action handler to indicate failure.
OrigRecord [in] -- Original content of the record being processed by the current action. This is
automatically being assigned by the WRITE_RECORD and DELETE_RECORD actions within
BASE_MFS.
Param1-10 [in/out] -- Additional request parameter holders
ActionFlow [out] -- Used to control the action chain (see the ACTION_SETUP insert for more information.)
Can also be used to return a special value, such as the results of the CalcField
method.
History : (Date, Initials, Notes)
12/05/24 djs Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert LOGICAL
$Insert FILE.SYSTEM.EQUATES
$Insert ACTION_SETUP
$Insert REACTOR_EQUATES
$Insert IQS_VIOL_DATA_EQUATES
Declare function Error_Services, Database_Services, Logging_Services, Environment_Services, Nica_Orders_Services
Declare subroutine Error_Services, Database_Services, Logging_Services, Set_Status, Reactor_Services
If KeyID then GoSub Initialize_System_Variables
Begin Case
Case Action _EQC 'CalculateColumn' ; GoSub CalculateColumn
Case Action _EQC 'READ_RECORD_PRE' ; GoSub READ_RECORD_PRE
Case Action _EQC 'READ_RECORD' ; GoSub READ_RECORD
Case Action _EQC 'READONLY_RECORD_PRE' ; GoSub READONLY_RECORD_PRE
Case Action _EQC 'READONLY_RECORD' ; GoSub READONLY_RECORD
Case Action _EQC 'WRITE_RECORD_PRE' ; GoSub WRITE_RECORD_PRE
Case Action _EQC 'WRITE_RECORD' ; GoSub WRITE_RECORD
Case Action _EQC 'DELETE_RECORD_PRE' ; GoSub DELETE_RECORD_PRE
Case Action _EQC 'DELETE_RECORD' ; GoSub DELETE_RECORD
Case Otherwise$ ; Status = 'Invalid Action'
End Case
If KeyID then GoSub Restore_System_Variables
If Assigned(ActionFlow) else ActionFlow = ACTION_CONTINUE$
Return ActionFlow
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Calculated Columns
//
// The typical structure of a calculated column will look like this:
//
// Declare function Database_Services
//
// @ANS = Database_Services('CalculateColumn')
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CalculateColumn:
// Make sure the ActionFlow return variable is cleared in case nothing is calculated.
ActionFlow = ''
return
// ----- MFS calls -----------------------------------------------------------------------------------------------------
READ_RECORD_PRE:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
// ActionFlow = ACTION_STOP$
return
READ_RECORD:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
return
READONLY_RECORD_PRE:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
// ActionFlow = ACTION_STOP$
return
READONLY_RECORD:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
return
WRITE_RECORD_PRE:
return
WRITE_RECORD:
OrigIqsAlarmDtm = OrigRecord<REACTOR_IQS_ALARM_DTM$>
NewIqsAlarmDtm = Record<REACTOR_IQS_ALARM_DTM$>
Begin Case
Case ( ( (OrigIqsAlarmDtm EQ '') and (NewIqsAlarmDtm NE '') ) or (OrigIqsAlarmDtm LT NewIqsAlarmDtm) )
// New alarm
NewIqsAlarmTest = Record<REACTOR_IQS_ALARM_TEST$>
If IndexC(NewIqsAlarmTest, 'HgCV', 1) then
// New HgCV alarm -> Create NICA order
If @User4 EQ '' then
ModeUser = 'OI_ADMIN'
end else
ModeUser = @User4
end
CurrActiveHgCVOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', Name, 'IQS_HGCV_ALARM')
CurrActiveProveInOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', Name, 'CHANGEOVER')
OrderTypeAlreadyActive = ( (CurrActiveHgCVOrders NE '') or (CurrActiveProveInOrders NE '') )
If Not(OrderTypeAlreadyActive) then
// Only create an order and change the mode if there is not already an active IQS_HGCV_ALARM order
OrderResponse = Nica_Orders_Services('CreateNewOrder', 'REACTOR', Name, 'IQS_HGCV_ALARM')
Reactor_Services('CreateReactModeChange', ModeUser, Name, 'TROUBLESHOOT_OPERATOR', 'WF-Product HgCV', 'IQS SPC HgCV Alarm Detected', False$)
end
end
Case NewIqsAlarmDtm EQ '' and OrigIqsAlarmDtm NE ''
// Alarm cleared
Null
Case Otherwise$
// No change to alarm state
Null
End Case
return
DELETE_RECORD_PRE:
return
DELETE_RECORD:
return
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Initialize_System_Variables:
// Save these for restoration later
SaveDict = @DICT
SaveID = @ID
SaveRecord = @RECORD
OrigFileError = @FILE.ERROR
// Now make sure @DICT, ID, and @RECORD are populated
CurrentDictName = ''
If @DICT then
DictHandle = @DICT<1, 2>
Locate DictHandle in @TABLES(5) Using @FM Setting fPos then
CurrentDictName = Field(@TABLES(0), @FM, fPos, 1)
end
end
If CurrentDictName NE DictName then
Open DictName to @DICT else Status = 'Unable to initialize @DICT'
end
@ID = KeyID
If Record else
// Record might not have been passed in. Read the record from the database table just to make sure.
@FILE.ERROR = ''
Open TableName to hTable then
FullFSList = hTable[1, 'F' : @VM]
BFS = FullFSList[-1, 'B' : @SVM]
LastHandle = hTable[-1, 'B' : \0D\]
FileHandle = \0D\ : LastHandle[1, @VM]
Call @BFS(READO.RECORD, BFS, FileHandle, KeyID, FMC, Record, ReadOStatus)
end
end
@RECORD = Record
return
Restore_System_Variables:
Transfer SaveDict to @DICT
Transfer SaveID to @ID
Transfer SaveRecord to @RECORD
@FILE.ERROR = OrigFileError
return

View File

@ -59,8 +59,9 @@ $Insert WO_MAT_QA_EQUATES
Equ WOCust$ to 2
Equ Comma$ to ','
Declare function Error_Services, Database_Services, Logging_Services, Environment_Services
Declare function Error_Services, Database_Services, Logging_Services, Environment_Services, Nica_Orders_Services
Declare subroutine Error_Services, Database_Services, Logging_Services, Set_Status, Reactor_Log_Services, Rds_Services
Declare subroutine Nica_Orders_Services
If KeyID then GoSub Initialize_System_Variables
@ -100,10 +101,6 @@ CalculateColumn:
// Make sure the ActionFlow return variable is cleared in case nothing is calculated.
ActionFlow = ''
* Begin Case
* Case CalcColName EQ 'ROTR_ACTION' ; GoSub ROTR_ACTION
* End Case
return
@ -234,18 +231,18 @@ WRITE_RECORD:
If (FiveYearAdded or TenYearAdded) then
// Create NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM')
Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM')
end
end
If (FiveYearRemoved or TenYearRemoved) then
// Cancel NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
ChecklistTypes = Record<REACTOR_LOG_CHECKLIST_TYPE$>
ChecklistOrderIds = Record<REACTOR_LOG_CHECKLIST_ORDER_ID$>
Locate 'ASM_HTR_FIVE_AND_TEN_YEAR_PM' in ChecklistTypes using @VM setting vPos then
OrderId = ChecklistOrderIds<0, vPos>
Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId)
OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM')
If OrderIds NE '' then
For each OrderId in OrderIds
Nica_Orders_Services('CancelOrder', OrderId)
Next OrderId
end
end
end
@ -253,57 +250,57 @@ WRITE_RECORD:
If (AsmTubeChangeAdded or HtrTubeChangeAdded) then
// Create NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_TUBE_CHANGE')
Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_TUBE_CHANGE')
end
end
If (AsmTubeChangeRemoved or HtrTubeChangeRemoved) then
// Cancel NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
ChecklistTypes = Record<REACTOR_LOG_CHECKLIST_TYPE$>
ChecklistOrderIds = Record<REACTOR_LOG_CHECKLIST_ORDER_ID$>
Locate 'ASM_HTR_TUBE_CHANGE' in ChecklistTypes using @VM setting vPos then
OrderId = ChecklistOrderIds<0, vPos>
Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId)
end
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_TUBE_CHANGE')
If OrderIds NE '' then
For each OrderId in OrderIds
Nica_Orders_Services('CancelOrder', OrderId)
Next OrderId
end
end
end
If SemiannualAdded then
// Create NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_SEMIANNUAL_PM')
Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_SEMIANNUAL_PM')
end
end
If SemiannualRemoved then
// Cancel NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
ChecklistTypes = Record<REACTOR_LOG_CHECKLIST_TYPE$>
ChecklistOrderIds = Record<REACTOR_LOG_CHECKLIST_ORDER_ID$>
Locate 'ASM_HTR_SEMIANNUAL_PM' in ChecklistTypes using @VM setting vPos then
OrderId = ChecklistOrderIds<0, vPos>
Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId)
end
OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_SEMIANNUAL_PM')
If OrderIds NE '' then
For each OrderId in OrderIds
Nica_Orders_Services('CancelOrder', OrderId)
Next OrderId
end
end
end
If AnnualAdded then
// Create NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_ANNUAL_PM')
Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_ANNUAL_PM')
end
end
If AnnualRemoved then
// Cancel NICA order
If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then
ChecklistTypes = Record<REACTOR_LOG_CHECKLIST_TYPE$>
ChecklistOrderIds = Record<REACTOR_LOG_CHECKLIST_ORDER_ID$>
Locate 'ASM_HTR_ANNUAL_PM' in ChecklistTypes using @VM setting vPos then
OrderId = ChecklistOrderIds<0, vPos>
Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId)
end
OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_ANNUAL_PM')
If OrderIds NE '' then
For each OrderId in OrderIds
Nica_Orders_Services('CancelOrder', OrderId)
Next OrderId
end
end
end
end
@ -379,3 +376,4 @@ Restore_System_Variables:
return

View File

@ -20,8 +20,6 @@ Compile function Reactor_Log_Services(@Service, @Params)
??/??/?? jro Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert APP_INSERTS
@ -37,10 +35,10 @@ $Insert REACTOR_EQUATES
Declare function Database_Services, Reactor_Log_Services, Obj_React_Item, Set_Status, Errmsg, Error_Services, Utility
Declare function obj_Calendar, NextKey, SRP_JSON, Datetime, Reactor_Services, React_Servs_Services, Logging_Services
Declare function Environment_Services, HttpClient_Services, SRP_List
Declare function Environment_Services, HttpClient_Services, SRP_List, Nica_Orders_Services
Declare subroutine Set_Status, RList, Errmsg, Database_Services, Error_Services, obj_React_Reads, obj_Post_Log, Delay
Declare subroutine obj_Reactor_Log, Btree.Extract, SRP_JSON, Reactor_Services, Logging_Services, Mona_Services, SRP_List
Declare subroutine Reactor_Log_Services
Declare subroutine Reactor_Log_Services, Nica_Orders_Services
GoToService
@ -89,13 +87,14 @@ Service SignReactorLog(ReactorLogID, UserID)
ErrorMsg = ''
If RowExists('REACTOR_LOG', ReactorLogID) then
// Update any NICA checklist order statuses
Reactor_Log_Services('GetReactorLogPMStatus', ReactorLogID)
Nica_Orders_Services('GetOrderUpdates')
If Error_Services('NoError') then
If RowExists('LSL_USERS', UserID) then
ReactorLogRec = Database_Services('ReadDataRow', 'REACTOR_LOG', ReactorLogID)
If Error_Services('NoError') then
// Verify NICA checklists are complete
If Sum(ReactorLogRec<REACTOR_LOG_CHECKLIST_ACTIVE$>) EQ 0 then
ActiveRlNicaOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', ReactorLogID)
If ActiveRLNicaOrders EQ '' then
// Verify reactor number is populated
ReactorNo = ReactorLogRec<REACTOR_LOG_REACTOR$>
If ReactorNo NE '' then
@ -135,6 +134,7 @@ Service SignReactorLog(ReactorLogID, UserID)
Until ErrorMsg NE ''
Next ServiceID
end
// Check if any react items are missing disposition codes
If ErrorMsg EQ '' then
RemRINos = Xlate('REACTOR_LOG', ReactorLogID, 'REM_RI_NO', 'X')
@ -159,7 +159,6 @@ Service SignReactorLog(ReactorLogID, UserID)
end
end
If ErrorMsg EQ '' then
// Check if we need to "post" any items that are being installed
InstRINo = ReactorLogRec<REACTOR_LOG_INST_RI_NO$>
@ -301,16 +300,10 @@ Service SignReactorLog(ReactorLogID, UserID)
ErrorMsg = 'Error in ':Service:' service. Reactor number is missing.'
end
end else
ActiveCheckLists = ''
CheckListTypes = ReactorLogRec<REACTOR_LOG_CHECKLIST_TYPE$>
CheckListActives = ReactorLogRec<REACTOR_LOG_CHECKLIST_ACTIVE$>
For each CheckListType in CheckListTypes using @VM setting vPos
If CheckListActives<0, vPos> EQ True$ then
ActiveCheckLists := CheckListType:','
end
Next CheckListType
If ActiveCheckLists NE '' then ActiveCheckLists[-1, 1] = ''
ErrorMsg = 'Error in ':Service:' service. NICA order(s) ':ActiveCheckLists:' must be completed prior to signing reactor log.'
ActiveChecklistTypes = Xlate('NICA_ORDERS', ActiveRlNicaOrders, 'ORDER_TYPE', 'X')
Swap @VM with ',' in ActiveChecklistTypes
ErrorMsg = 'Error in ':Service:' service. NICA order(s) ':ActiveChecklistTypes
ErrorMsg := ' must be completed prior to signing reactor log.'
end
end else
ErrorMsg = Error_Services('GetMessage')
@ -907,6 +900,21 @@ Service ConvertJSONToRecord(JSON)
end service
Service GetRlChecklistActive(RLKey)
If RLKey NE '' then
ActiveTubeChangeIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_TUBE_CHANGE')
ActiveAnnualPmIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_ANNUAL_PM')
ActiveSemiannualPmIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_SEMIANNUAL_PM')
ActiveFiveAndTenPmIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM')
Response = ( (ActiveTubeChangeIds NE '') or (ActiveAnnualPmIds NE '') or (ActiveSemiannualPmIds NE '') or (ActiveFiveAndTenPmIds NE '') )
end else
Error_Services('Add', 'Error in ':Service:' service. Null ReactNo passed into service.')
end
end service
Service AddComment(Reactor, NewNote, User)
ReactModeNGKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', Reactor, 'REACT_MODE_KEY_IDS', 'X')
@ -928,348 +936,6 @@ Service AddComment(Reactor, NewNote, User)
end service
Service CreateReactorLogPMOrder(RLNo, PmType=PM_TYPES)
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
ColumnWidths = 20 : @FM : 15 : @FM : 300
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorLogPM'
makeDirSuccess = Utility("MAKEDIR", LogPath)
LogDate = Oconv(Date(), 'D4/')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorLogPM.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
RlRec = Database_Services('ReadDataRow', 'REACTOR_LOG', RLNo)
ReactNo = RlRec<REACTOR_LOG_REACTOR$>
Machine = Environment_Services('GetServer')
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempting to create PM order for reactor ':ReactNo:' of type ':PMType
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
CurrentPmTypes = RlRec<REACTOR_LOG_CHECKLIST_TYPE$>
PmTypeAlreadyActive = False$
For each ActivePmType in CurrentPmTypes using @VM setting dummy
If ActivePmType EQ PmType then PmTypeAlreadyActive = True$
Next ActivePmType
If PmTypeAlreadyActive EQ False$ then
RlRec<REACTOR_LOG_CHECKLIST_ACTIVE$> = True$
RlRec<REACTOR_LOG_CHECKLIST_TYPE$, -1> = PmType
// Call the API
NicaURL = Environment_Services("GetProveInApiUrl"):'/checklists?'
NicaURL := 'checklistType=':PmType
NicaURL := '&reactorNumber=':ReactNo
Retries = 3
BackoffSeconds = 1
IsSuccessful = False$
OrderId = ''
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - retries) * BackoffSeconds
Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, 'Accept':@VM:'*/*', '', '', '', False$, False$, '')
If HttpResponseJson NE '' then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
OrderId = SRP_JSON(ObjResponseJson, 'GetValue', 'id')
If orderId NE '' then
IsSuccessful = True$
Response = OrderId
end
end
end
SRP_JSON(ObjResponseJson, 'Release')
Repeat
RlRec<REACTOR_LOG_CHECKLIST_ORDER_ID$, -1> = OrderId
Database_Services('WriteDataRow', 'REACTOR_LOG', RlNo, RlRec, True$, False$, True$)
If Environment_Services('IsProd') then
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI'
end else
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV'
end
StatusName = 'CreateReactorLogPmOrder'
If IsSuccessful then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Successfully created PM order for reactor ':ReactNo:' and reactor log ':RlNo:' of type ':PmType
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'ok')
end else
Response = 'error'
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Error encountered when attempting to create PM order for reactor ':ReactNo:' and reactor log ':RlNo:' of type ':PmType
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'critical')
Error_Services('Add', 'Error in ' : Service : ' service. Could not create NICA order.')
end
end
end service
Service CancelReactorLogPMOrder(RlNo, OrderId)
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
ColumnWidths = 20 : @FM : 15 : @FM : 300
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorLogPM'
makeDirSuccess = Utility("MAKEDIR", LogPath)
LogDate = Oconv(Date(), 'D4/')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorLogPM.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
RlRec = Database_Services('ReadDataRow', 'REACTOR_LOG', RlNo)
ReactNo = RlRec<REACTOR_LOG_REACTOR$>
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
Machine = Environment_Services('GetServer')
LogData<2> = Machine
LogData<3> = 'Attempting to cancel PM order ' : OrderId : ' for reactor ' : ReactNo : ' and reactor log ' : RlNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Response = False$
BaseNicaUrl = Environment_Services("GetProveInApiUrl"):'/checklists?'
NicaUrl = BaseNicaUrl:'checklistOrderId=':OrderId
NicaUrl := '&checklistState=cancelled'
Retries = 3
BackoffSeconds = 1
IsSuccessful = False$
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - Retries) * BackoffSeconds
Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'PUT', NicaUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '')
If HttpResponseJson NE '' then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'pendingUpdate')
Response = (IsComplete EQ True$)
end
end
SRP_JSON(ObjResponseJson, 'Release')
IsSuccessful = ( (Response EQ True$) or (Response EQ False$) )
Repeat
If Environment_Services('IsProd') then
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI'
end else
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV'
end
StatusName = 'UpdateReactorLogPmOrderState'
If IsSuccessful and Response NE 'error' then
PmOrderIds = RlRec<REACTOR_LOG_CHECKLIST_ORDER_ID$>
PmOrderIdList = SRP_List('Create', PmOrderIds, @VM)
PmTypes = RlRec<REACTOR_LOG_CHECKLIST_TYPE$>
PmTypeList = SRP_List('Create', PmTypes, @VM)
For each PmOrderId in PmOrderIds using @VM setting Idx
If OrderId EQ PmOrderId then
SRP_List('RemoveAt', PmOrderIdList, Idx)
SRP_List('RemoveAt', PmTypeList, Idx)
end
Next ProveInOrderId
RlRec<REACTOR_LOG_CHECKLIST_ORDER_ID$> = SRP_List("GetVariable", PmOrderIdList, @VM)
RlRec<REACTOR_LOG_CHECKLIST_TYPE$> = SRP_List("GetVariable", PmTypeList, @VM)
SRP_List('Release', PmTypeList)
OrderIdCount = SRP_List("Count", PmOrderIdList)
SRP_List("Release", PmOrderIdList)
// remove flag if pm passed
If OrderIdCount EQ 0 then RlRec<REACTOR_LOG_CHECKLIST_ACTIVE$> = False$
Database_Services('WriteDataRow', 'REACTOR_LOG', RlNo, RlRec, True$, False$, True$)
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Successfully cancelled PM order ' : PmOrderId : ' for reactor ' : ReactNo : ' and reactor log ' : RlNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'ok')
end else
Response = 'error'
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Error encountered cancelling PM order ' : PmOrderId : ' for reactor ' : ReactNo : ' and reactor log ' : RlNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'critical')
Error_Services('Add', 'Error in ' : Service : ' service. Could not cancel NICA order')
end
end service
Service GetReactorLogPMStatus(RlNo)
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
ColumnWidths = 20 : @FM : 15 : @FM : 300
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorLogPm'
makeDirSuccess = Utility("MAKEDIR", LogPath)
LogDate = Oconv(Date(), 'D4/')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorLogPm.csv'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
RlRec = Database_Services('ReadDataRow', 'REACTOR_LOG', RlNo)
ReactNo = RlRec<REACTOR_LOG_REACTOR$>
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
Machine = Environment_Services('GetServer')
LogData<2> = Machine
LogData<3> = 'Attempting to fetch pm order for reactor ':ReactNo:' and reactor log ':RlNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Response = True$
IsSuccessful = True$
// Check flag on reactor first, then call api if necessary
PmActive = RlRec<REACTOR_LOG_CHECKLIST_ACTIVE$>
If PmActive then
PmOrderIds = RlRec<REACTOR_LOG_CHECKLIST_ORDER_ID$>
PmOrderIdList = SRP_List("Create", PmOrderIds, @VM)
PmTypes = RlRec<REACTOR_LOG_CHECKLIST_TYPE$>
PmTypeList = SRP_List("Create", PmTypes, @VM)
For each PmOrderId in PmOrderIds using @VM setting Idx
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Fetching pm order ':PmOrderId
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
BaseNicaUrl = Environment_Services("GetProveInApiUrl"):'/checklists?'
NicaUrl = BaseNicaUrl:'checklistOrderId=':PmOrderId
Retries = 3
BackoffSeconds = 1
IsSuccessful = False$
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - Retries) * BackoffSeconds
Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'GET', NicaUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '')
If HttpResponseJson NE '' then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete')
If IsComplete EQ True$ then
SRP_List('RemoveAt', PmOrderIdList, Idx)
SRP_List('RemoveAt', PmTypeList, Idx)
Response = True$
end else
Response = False$
end
end
end
SRP_JSON(ObjResponseJson, 'Release')
IsSuccessful = ( (Response EQ True$) or (Response EQ False$) )
Repeat
Next PmOrderId
If Environment_Services('IsProd') then
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI'
end else
MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV'
end
StatusName = 'GetReactorLogPmOrderStatus'
If IsSuccessful and Response NE 'error' then
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Successfully fetched pm order for reactor ':ReactNo:' and reactor log ':RlNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'ok')
end else
Response = 'error'
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Error encountered when fetching pm order for reactor ':RlNo
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'critical')
Error_Services('Add', 'Error in ' : Service : ' service. Could not retrieve NICA order status.')
end
RlRec<REACTOR_LOG_CHECKLIST_ORDER_ID$> = SRP_List("GetVariable", PmOrderIdList, @VM)
RlRec<REACTOR_LOG_CHECKLIST_TYPE$> = SRP_List("GetVariable", PmTypeList, @VM)
SRP_List('Release', PmTypeList)
OrderIdCount = SRP_List("Count", PmOrderIdList)
SRP_List("Release", PmOrderIdList)
// remove flag if prove in passed
If OrderIdCount EQ 0 then RlRec<REACTOR_LOG_CHECKLIST_ACTIVE$> = False$
Database_Services('WriteDataRow', 'REACTOR_LOG', RlNo, RlRec, True$, False$, True$)
end
end service
Service UpdateReactorLogPMStatuses()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
Open 'DICT.REACTOR_LOG' to hDict then
RLKeys = ''
Query = 'CHECKLIST_ACTIVE':@VM:True$:@FM
Flag = ''
Btree.Extract(Query, 'REACTOR_LOG', hDict, RLKeys, '', Flag)
If Flag EQ 0 then
// Btree.Extract successful
If RLKeys NE '' then
For each RLKey in RLKeys using @VM
Reactor_Log_Services("GetReactorLogPMStatus", RLKey)
Next RLKey
end
end else
Error_Services('Add', 'Error in ':Service:' service. Btree.Extract call failed.')
end
end
Unlock hSysLists, ServiceKeyID else Null
end
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1282,6 +948,3 @@ ClearCursors:
return

View File

@ -31,7 +31,8 @@ $Insert REACT_PROB_CAT_EQUATES
$Insert REACTOR_EQUATES
$Insert RLIST_EQUATES
Declare function Database_Services, React_Prob_Cat_Services, Reactor_Modes_Services, Memberof, Error_Services
Declare function Database_Services, React_Prob_Cat_Services, Reactor_Modes_Services, Memberof, Error_Services
Declare function Nica_Orders_Services, Reactor_Services
Declare subroutine Error_Services, Database_Services, delete, RList, Reactor_Services
GoToService
@ -223,17 +224,9 @@ Service AvailableModes(ReactorModesKey, CurrUser, ReactNo)
CurModeReleaseGroups = XLATE('REACTOR_MODES', ReactorModesKey, REACTOR_MODES_GROUPS_RELEASE$, 'X')
CanRelease = 0
IdleStartupRequired = False$
If ReactNo NE '' then
IdleStartupRequired = Xlate('REACTOR', ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$, 'X')
If IdleStartupRequired EQ True$ then
Reactor_Services('GetReactorProveInStatus', ReactNo)
end
IdleStartupRequired = Xlate('REACTOR', ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$, 'X')
If IdleStartupRequired EQ '' then IdleStartupRequired = False$
end
IdleStartupRequired = Reactor_Services('GetIdleStartupRequired', ReactNo)
//Check can release from current mode
// Check can release from current mode
for each ReleaseGroup in CurModeReleaseGroups using @VM
if Memberof(CurrUser, ReleaseGroup) then
CanRelease = 1
@ -267,8 +260,10 @@ Service AvailableModes(ReactorModesKey, CurrUser, ReactNo)
Next mode
end
for each PossibleMode in PossibleModes using @FM
For each PossibleMode in PossibleModes using @FM
AllowMode = True$
If PossibleMode EQ 'IDLE_STARTUP' and IdleStartupRequired EQ False$ then
AllowMode = False$
end
@ -299,5 +294,3 @@ Service AvailableModes(ReactorModesKey, CurrUser, ReactNo)
end service

File diff suppressed because it is too large Load Diff

View File

@ -54,10 +54,11 @@ $insert Message_Box_Equates
Declare function center_window, msg, Memberof, Get_Property, NextKey, next_key, rowexists, Get_Status
Declare function SRP_Array, start_window, Dialog_Box, Reactor_Log_Services, Reactor_Modes_Services, GetTickCount
Declare function Reactor_Services, Error_Services, Logging_Services, Environment_Services, Database_Services
Declare function SRP_List
Declare function SRP_List, Nica_Orders_Services
Declare subroutine RList, Set_Property, Set_List_Box_Data, end_dialog, record_lock, obj_React_Mode, ErrMsg
Declare subroutine Mona_Services, Reactor_Services, Error_Services, obj_React_Status, Logging_Services
Declare subroutine Database_Services, Override_Log_Services, SRP_List, Message_Box, Reactor_Log_Services
Declare subroutine Nica_Orders_Services
GoToEvent Event for CtrlEntId else
// Event not implemented
@ -281,52 +282,73 @@ Event APPLY.CLICK()
If Error_Services('NoError') then
Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText)
If Error_Services('NoError') then
End_Dialog(@Window, NewMode)
end else
Error_Services('DisplayError')
ActiveProveIn = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_ACTIVE$, 'X')
If ActiveProveIn then
OverrideGroups = 'LEAD':@VM:'SUPERVISOR'
UserMsg = "Reactor prove in must be processed in NICA. Override required from a lead or supervisor to bypass NICA."
UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg)
Override = UserVerification<1>
If Override EQ True$ then
ProveInOrderIds = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_ORDER_ID$, 'X')
ProveInOrderList = SRP_List('Create', ProveInOrderIds, @VM)
ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X')
ProveInTypeList = SRP_List('Create', ProveInTypes, @VM)
If SRP_List('Count', ProveInOrderList) GT 1 then
OverrideData = Dialog_Box('PROVE_IN_OVERRIDE', @Window, ReactNo)
ProveInTypesToCancel = OverrideData<1, 1>
ProveInTypesToCancelList = SRP_List('Create', ProveInTypesToCancel, @VM)
ResponseComment = ''
for each ProveInType in ProveInTypes using @VM setting Idx
If SRP_List('Locate', ProveInTypesToCancelList, ProveInType) GT 0 then
ProveInOrderId = SRP_List('GetAt', ProveInOrderList, Idx)
Reactor_Services('CancelReactorProveIn', ReactNo, ProveInOrderId)
If ResponseComment NE '' then
ResponseComment := ', '
ActiveProveIn = Reactor_Services('GetProveInActive', ReactNo)
ActiveHgCVChecklists = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'IQS_HGCV_ALARM')
HgCVChecklistActive = (ActiveHgCVChecklists NE '')
Begin Case
Case ActiveProveIn
OverrideGroups = 'LEAD':@VM:'SUPERVISOR'
UserMsg = "Reactor prove in must be processed in NICA. Override required from a lead or supervisor to bypass NICA."
UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg)
Override = UserVerification<1>
If Override EQ True$ then
ProveInOrderIds = Reactor_Services('GetActiveProveInOrderIds', ReactNo)
If (DCount(ProveInOrderIds, @VM) GT 1) then
ProveInTypes = Xlate('NICA_ORDERS', ProveInOrderIds, 'ORDER_TYPE', 'X')
OverrideData = Dialog_Box('PROVE_IN_OVERRIDE', @Window, ReactNo)
ProveInTypesToCancel = OverrideData<1, 1>
ResponseComment = ''
For each ProveInType in ProveInTypes using @VM setting Idx
Locate ProveInType in ProveInTypesToCancel using @VM setting Unused then
ProveInOrderId = ProveInOrderIds<0, Idx>
Nica_Orders_Services('CancelOrder', ProveInOrderId)
If ResponseComment NE '' then ResponseComment := ', '
ResponseComment := ProveInType
end
ResponseComment := ProveInType
end
Next ProveInType
ResponseComment := ': '
ResponseComment := OverrideData<2, 1>
Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'REACTOR_PROVE_IN')
SRP_List('Release', ProveInTypesToCancelList)
end else
ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2>
If Assigned(ResponseComment) and Len(ResponseComment) GT 4 then
ProveInOrderId = SRP_List('GetAt', ProveInOrderList, 1)
Reactor_Services('CancelReactorProveIn', ReactNo, ProveInOrderId)
Next ProveInType
ResponseComment := ': '
ResponseComment := OverrideData<2, 1>
Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'REACTOR_PROVE_IN')
Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText)
If Error_Services('NoError') then End_Dialog(@Window, NewMode)
end else
ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2>
If Assigned(ResponseComment) and Len(ResponseComment) GT 4 then
Nica_Orders_Services('CancelOrder', ProveInOrderIds<0, 1>)
Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'REACTOR_PROVE_IN')
Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText)
If Error_Services('NoError') then End_Dialog(@Window, NewMode)
end else
Message_Box(@Window, 'You must enter a comment greater than 4 letters!', 'Error', MSG_ICON_EXCLAM$)
end
end
end
Case HgCVChecklistActive
OverrideGroups = 'LEAD':@VM:'SUPERVISOR'
UserMsg = "HgCV OCAP Checklist must be completed in NICA. Override required from a lead or supervisor to bypass NICA."
UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg)
Override = UserVerification<1>
If Override then
ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2>
If Assigned(ResponseComment) and Len(ResponseComment) GT 4 then
For each ActiveHgCVOrderId in ActiveHgCVChecklists using @VM
Nica_Orders_Services('CancelOrder', ActiveHgCVOrderId)
Next ActiveHgCVChecklistId
Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'HGCV_OCAP_CHECKLIST')
Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText)
If Error_Services('NoError') then
@ -335,11 +357,9 @@ Event APPLY.CLICK()
end else
Message_Box(@Window, 'You must enter a comment greater than 4 letters!', 'Error', MSG_ICON_EXCLAM$)
end
end
SRP_List('Release', ProveInOrderList)
SRP_List('Release', ProveInTypeList)
end
end
end
End Case
end
end
@ -504,3 +524,4 @@ return

View File

@ -32,6 +32,7 @@ $insert SERVICE_SETUP
$insert SERVICES_EQUATES
$insert RLIST_EQUATES
$insert SQL_REQUESTS_EQUATES
$Insert PROC_QUEUE_EQUATES
Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@
@ -154,20 +155,17 @@ end service
Service ProcessProcedureQueue()
hValidationRequests = Database_Services('GetTableHandle', 'PROC_QUEUE')
If Error_Services('NoError') then
Sentence = "SELECT PROC_QUEUE WITH COMP_DTM NE ''"
Set_Status(0)
RList(Sentence, TARGET_ACTIVELIST$, '', '', '')
Open 'PROC_QUEUE' to hProcQueue then
Select hProcQueue
EOF = False$
Loop
ReadNext RequestKeyID else EOF = True$
Until EOF
Lock hValidationRequests, RequestKeyID then
Lock hProcQueue, RequestKeyID then
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
If RequestRow NE '' then
Procedure = RequestRow<1>
Params = RequestRow<2>
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
Params = RequestRow<PROC_QUEUE.PARAMS$>
If Procedure NE '' then
Dim ProcParams(10)
For each Param in Params using @VM setting pPos
@ -190,13 +188,13 @@ Service ProcessProcedureQueue()
end
end
If Error_Services('NoError') then
RequestRow<3> = DateTime()
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$)
end else
RequestRow<3> = DateTime()
RequestRow<4> = Error_Services('GetMessage')
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = DateTime()
RequestRow<PROC_QUEUE.ERROR$> = Error_Services('GetMessage')
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, True$)
end
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, True$)
Unlock hValidationRequests, RequestKeyID else Null
Unlock hProcQueue, RequestKeyID else Null
end
Repeat
end
@ -208,35 +206,13 @@ Service PostProcecure(ProcedureName, Params)
Response = ''
If (ProcedureName NE '') then
RequestKeyID = RTI_CreateGUID()
RequestRow = ''
RequestRow<SQL_REQUESTS.DB_PATH$> = ''
RequestRow<SQL_REQUESTS.QUERY$> = ''
Database_Services('WriteDataRow', 'SQL_REQUESTS', RequestKeyID, RequestRow, False$, False$, False$)
If Error_Services('NoError') then
TimeExpired = False$
Start = GetTickCount()
Loop
RequestRow = Database_Services('ReadDataRow', 'SQL_REQUESTS', RequestKeyID)
ResponseDate = RequestRow<SQL_REQUESTS.RESPONSE_DATE$>
If ResponseDate NE '' then
Response = RequestRow<SQL_REQUESTS.RESPONSE$>
Response = SRP_Decode(Response)
end
// Time will expire after 30 seconds.
If GetTickCount() - Start GE 30000 then TimeExpired = True$
Until (ResponseDate NE '') OR TimeExpired
Sleepery(10)
WinYield()
Yield();Yield();Yield();Yield();Yield();Yield();Yield();Yield()
Repeat
If TimeExpired then
Error_Services('Add', 'Timed out attempting to retrieve wafer image.')
end
Database_Services('DeleteDataRow', 'SQL_REQUESTS', RequestKeyID, True$)
end
RequestKeyID = RTI_CreateGUID()
RequestRow = ''
RequestRow<PROC_QUEUE.PROC_NAME$> = ProcedureName
RequestRow<PROC_QUEUE.PARAMS$> = Params
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$)
end else
Error_Services('Add', 'Null parameter passed into service call. All parameters are required.')
Error_Services('Add', 'Error in ':Service:' service. Null ProcedureName passed in.')
end
return
@ -247,3 +223,4 @@ return
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -10,8 +10,8 @@ function wo_daily_sched_all_comm(Branch,CurrParm)
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
declare function set_property, fieldcount, get_property, msg, dialog_box, security_check
declare function send_message, utility, key_sort, start_window, entid, repository
declare function set_property, fieldcount, get_property, msg, dialog_box, security_check, Reactor_Log_Services
declare function send_message, utility, key_sort, start_window, entid, repository, Nica_Orders_Services
declare function relational_call, memberof, get_mode_icon, Database_Services, Reactor_Services
declare subroutine extract_si_keys, end_dialog, make.list, security_err_msg, Set_Property, SRP_Stopwatch, Dialog_Box
Declare subroutine Send_Message
@ -67,24 +67,21 @@ ChecklistButton:
Message = ''
ReactorNo = CurrParm[-1, 'B_']
Status_ProveIn = XLATE('REACTOR', ReactorNo, REACTOR_PROVE_IN_ACTIVE$, 'X')
If Status_ProveIn EQ '' Then Status_ProveIn = False$
Status_ProveIn = Reactor_Services('GetProveInActive', ReactorNo)
Status_0311 = XLATE('REACTOR', ReactorNo, REACTOR_0311_ACTIVE$, 'X')
If Status_0311 EQ '' then Status_0311 = False$
CurrModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactorNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')
CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$, 'X')
Status_ReactorPM = Xlate('REACTOR_LOG', CurrRLKey, REACTOR_LOG_CHECKLIST_ACTIVE$, 'X')
If Status_ReactorPM EQ '' then Status_ReactorPM = False$
CurrModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactorNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')
CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$, 'X')
ReactorPmOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', CurrRlKey)
HgCVAlarmOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', I, 'IQS_HGCV_ALARM')
ChecklistInfo = 'The following checklist(s) are active: '
If Status_ProveIn then
// Add each active prove in order
ProveInOrderTypes = Xlate('REACTOR', ReactorNo, REACTOR_PROVE_IN_TYPE$, 'X')
ProveInOrderTypes = Reactor_Services('GetActiveProveInTypes', ReactorNo)
For each ProveInOrderType in ProveInOrderTypes using @VM setting vPos
ChecklistInfo<-1> = ProveInOrderType
Next ProveInOrderType
@ -92,13 +89,18 @@ ChecklistButton:
If Status_0311 then ChecklistInfo<-1> = '0311 OCAP'
If Status_ReactorPM then
// Add each active reactor PM order
RlPmTypes = Xlate('REACTOR_LOG', CurrRLKey, REACTOR_LOG_CHECKLIST_TYPE$, 'X')
For each RlPmType in RlPmTypes using @VM setting vPos
ChecklistInfo<-1> = RlPmType
If ReactorPmOrderIds NE '' then
// Add each active reactor PM checklist order
For each ReactorPmOrderId in ReactorPmOrderIds using @VM setting vPos
ChecklistInfo<-1> = Xlate('NICA_ORDERS', ReactorPmOrderId, 'ORDER_TYPE', 'X')
Next RlPmType
end
If HgCVAlarmOrderIds NE '' then
For each HgCVAlarmOrderId in HgCVAlarmOrderIds using @VM
ChecklistInfo<-1> = Xlate('NICA_ORDERS', HgCVAlarmOrderId, 'ORDER_TYPE', 'X')
Next HgCVAlarmOrder
end
Swap @FM with CRLF$ in ChecklistInfo
@ -246,17 +248,11 @@ FORM_CREATE:
RPanelTitle := ' - PP'
END
Status_ProveIn = XLATE('REACTOR', I, REACTOR_PROVE_IN_ACTIVE$, 'X')
IF Status_ProveIn EQ '' THEN
Status_ProveIn = FALSE$
END
Status_ProveIn = Reactor_Services('GetProveInActive', I)
Status_0311 = XLATE('REACTOR', I, REACTOR_0311_ACTIVE$, 'X')
IF Status_0311 EQ '' THEN
Status_0311 = FALSE$
END
IF Status_0311 EQ '' THEN Status_0311 = FALSE$
Set_Property(Window:'.RPANEL':I, 'TEXT', RpanelTitle ) ;* Display Wafer Size in inches
Set_Property(Window:'.RWO':I, 'TEXT', WO ) ;* Display WO #
@ -271,8 +267,8 @@ FORM_CREATE:
end
CurrModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', I, 'REACT_MODE_KEY_IDS', 'X')
CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, 'START_RL_ID', 'X')
Status_ReactorPM = Xlate('REACTOR_LOG', CurrRLKey, 'CHECKLIST_ACTIVE', 'X')
CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, 'START_RL_ID', 'X')
Status_ReactorPM = Reactor_Log_Services('GetRlChecklistActive', CurrRLKey)
If Status_ReactorPM EQ '' then Status_ReactorPM = False$
@ -280,7 +276,13 @@ FORM_CREATE:
Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveReactorPM.png')
end
OlePicVisible = ( (Status_ProveIn EQ True$) or (Status_0311 EQ True$) or (Status_ReactorPM EQ True$) )
Status_HgCV_Alarm = (Nica_Orders_Services('GetActiveOrders', 'REACTOR', I, 'IQS_HGCV_ALARM') NE '')
If Status_HgCV_Alarm EQ True$ then
Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveProveIn.png')
end
OlePicVisible = ( Status_ProveIn or Status_0311 or Status_ReactorPM or Status_HgCV_Alarm)
Set_Property(Window:'.OLE_PIC_':I,'VISIBLE', OlePicVisible)
IQSPicControl = @Window : '.OLE_PIC_IQS_': i
@ -329,3 +331,4 @@ return
*===============================================================================================*

View File

@ -0,0 +1,13 @@
Compile Insert IQS_VIOL_DATA_EQUATES
Equ IQS_VIOL_DATA.REACTOR$ to 1
Equ IQS_VIOL_DATA.TEST$ to 2
Equ IQS_VIOL_DATA.USL$ to 3
Equ IQS_VIOL_DATA.TAR$ to 4
Equ IQS_VIOL_DATA.LSL$ to 5
Equ IQS_VIOL_DATA.LAST_ENTRY$ to 6
Equ IQS_VIOL_DATA.LAST_ALARM$ to 7
Equ IQS_VIOL_DATA.ALARM$ to 8
Equ IQS_VIOL_DATA.SUBGROUPS$ to 9
Equ IQS_VIOL_DATA.MEAN$ to 10
Equ IQS_VIOL_DATA.LAST_WRITE_TIME$ to 11

View File

@ -0,0 +1,16 @@
compile insert NICA_ORDERS_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 05/12/2024
Description : Insert for Table NICA_ORDERS
----------------------------------------*/
#ifndef __NICA_ORDERS_EQUATES__
#define __NICA_ORDERS_EQUATES__
equ NICA_ORDERS.ORDER_TYPE$ to 1
equ NICA_ORDERS.ORDER_STATUS$ to 2
equ NICA_ORDERS.ENTITY_TYPE$ to 3
equ NICA_ORDERS.ENTITY_ID$ to 4
equ NICA_ORDERS.IS_COMPLETE$ to 5
#endif

View File

@ -1,13 +1,15 @@
compile insert PROC_QUEUE_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 15/01/2020
Author : Table Create Insert Routine
Written : 09/12/2024
Description : Insert for Table PROC_QUEUE
----------------------------------------*/
#ifndef __PROC_QUEUE_EQUATES__
#define __PROC_QUEUE_EQUATES__
equ PROC_QUEUE.PROC_NAME$ to 1
equ PROC_QUEUE.PARAMS$ to 2
equ PROC_QUEUE.LAST_ATTEMPT_DTM$ to 3
equ PROC_QUEUE.ERROR$ to 4
Equ PROC_QUEUE.REQ_ID$ To 0
Equ PROC_QUEUE.PROC_NAME$ To 1
Equ PROC_QUEUE.PARAMS$ To 2
Equ PROC_QUEUE.COMP_DTM$ To 3
Equ PROC_QUEUE.ERROR$ To 4
#endif

View File

@ -77,7 +77,5 @@ Equ REACTOR_PROVE_IN_ACTIVE$ To 65
Equ REACTOR_PROVE_IN_TYPE$ To 66
Equ REACTOR_PROVE_IN_ORDER_ID$ To 67
Equ REACTOR_IDLE_STARTUP_REQUIRED$ To 68
Equ REACTOR_IQS_ALARM_DTM$ To 69
Equ REACTOR_IQS_ALARM_TEST$ To 70

View File

@ -72,10 +72,11 @@ Function Error_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$Insert LOGICAL
$Insert MSG_EQUATES
$insert RTI_DEBUG_COMMON
$insert SRPMail_Inserts
$Insert RTI_DEBUG_COMMON
$Insert SRPMail_Inserts
$Insert ERROR_SERVICES_COMMON
Equ Segoe_UI$ to 'Segoe UI' : @SVM : -12 : @SVM : 400 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 34 : @SVM : 0 : @SVM : 3 : @SVM : 2 : @SVM : 1 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0
@ -98,8 +99,6 @@ If Assigned(Response) else Response = ''
AutoDisplayErrors = False$ ; // Set this to True$ when debugging so all errors will automatically display.
Common /ErrorServices/ ErrorMessages@, ErrorSources@, ErrorCodes@, RetStacks@, Unused5@, Unused6@, Unused7@, Unused8@
Declare function RetStack, Error_Services, SRPSendMail
Declare subroutine Error_Services

View File

@ -468,15 +468,23 @@ Service PullEntities(EntityList, StatusList, StatusCtrl, CommitId)
If Get_Status(ErrCode) then
SRP_Git_Services("SendStatus", StatusCtrl, " -- Save Failed\n Locked!\n", "", LogPos)
end else
Set_Status(0)
Repository("WRITE", EntityId, "", 1, 1, "", "", "", "", "", EntityId[-1, "B*"], Record)
If Get_Status(ErrCode) then
SRP_Git_Services("SendStatus", StatusCtrl, " -- Save Failed\n", ErrCode, LogPos)
end else
SRP_Git_Services("SendStatus", StatusCtrl, " -- Saved\n", "", LogPos)
Get_Status(ErrCode)
If Type EQ "STPROC" OR Type EQ "OIWIN" OR Type EQ "OIEVENT" then EntitiesToCompile := EntityId:@FM
end
Set_Status(0)
Repository("WRITE", EntityId, "", 1, 1, "", "", "", "", "", EntityId[-1, "B*"], Record)
If Get_Status(ErrCode) then
Set_Status(0)
Repository("NEW", EntityId, "", 1, 1, "", "", "", "", "", EntityId[-1, "B*"], Record)
If Get_Status(ErrCode) then
SRP_Git_Services("SendStatus", StatusCtrl, " -- Save Failed\n", ErrCode, LogPos)
end else
SRP_Git_Services("SendStatus", StatusCtrl, " -- Saved\n", "", LogPos)
Get_Status(ErrCode)
If Type EQ "STPROC" OR Type EQ "OIWIN" OR Type EQ "OIEVENT" then EntitiesToCompile := EntityId:@FM
end
end else
SRP_Git_Services("SendStatus", StatusCtrl, " -- Saved\n", "", LogPos)
Get_Status(ErrCode)
If Type EQ "STPROC" OR Type EQ "OIWIN" OR Type EQ "OIEVENT" then EntitiesToCompile := EntityId:@FM
end
Set_Status(0)
Repository("UNLOCK", EntityId)
end

View File

@ -0,0 +1,4 @@
Compile Insert ERROR_SERVICES_COMMON
Common /ErrorServices/ ErrorMessages@, ErrorSources@, ErrorCodes@, RetStacks@, EsSpStatCode@, EsSpStatMessage@, Unused7@, Unused8@