Modfied NICA_ORDERS_SERVICES to back off exponentially when it encounters an HTTP error response. Added 200 response status code check. Added additional logging.

Modified services to ensure NICA_ORDERS record is always unlocked after canceling or updating the status
This commit is contained in:
Infineon\StieberD
2025-11-11 12:14:58 -07:00
parent 39bdf5f9cb
commit 60e70b9958

View File

@ -69,7 +69,7 @@ Options NICA_CHECKLISTS = 'PROCESS_INTERRUPTION_FLOW_C_PRE','PROCESS_IN
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Service GetOrderIds(EntityType=ENTITY_TYPES, EntityID, OrderTypes=ORDER_TYPES, OrderStatus=ORDER_STATUSES, IsComplete=BOOLEAN)
OrderKeys = ''
ErrorMsg = ''
If ( (EntityType NE '') or (EntityID NE '') or (OrderTypes NE '') or (OrderStatus NE '') or (IsComplete NE '') ) then
@ -116,7 +116,7 @@ End Service
Service GetOrderChecklistIds(NicaOrdersIds, NicaChecklistIds=NICA_CHECKLISTS, IsComplete=BOOLEAN, ChecklistOrderStates=ORDER_CHECKLIST_STATUSES)
OrderChecklistIds = ''
ErrorMsg = ''
If ( (NicaOrdersIds NE '') or (IsComplete NE '') or (ChecklistOrderStates NE '') ) then
@ -133,11 +133,11 @@ Service GetOrderChecklistIds(NicaOrdersIds, NicaChecklistIds=NICA_CHECKLISTS, Is
Query := @FM
end
If (NicaChecklistIds NE '') then
Query := 'NICA_CHECKLISTS_ID'
For each NicaChecklistId in NicaChecklistIds using @VM
Query := @VM : NicaChecklistId
Next NicaChecklistId
Query := @FM
Query := 'NICA_CHECKLISTS_ID'
For each NicaChecklistId in NicaChecklistIds using @VM
Query := @VM : NicaChecklistId
Next NicaChecklistId
Query := @FM
end
If (IsComplete NE '') then
Query := 'IS_COMPLETE'
@ -147,11 +147,11 @@ Service GetOrderChecklistIds(NicaOrdersIds, NicaChecklistIds=NICA_CHECKLISTS, Is
Query := @FM
end
If (ChecklistOrderStates NE '') then
Query := 'STATE'
For each ChecklistOrderState in ChecklistOrderStates using @VM
Query := @VM : ChecklistOrderState
Next ChecklistOrderState
Query := @FM
Query := 'STATE'
For each ChecklistOrderState in ChecklistOrderStates using @VM
Query := @VM : ChecklistOrderState
Next ChecklistOrderState
Query := @FM
end
Btree.Extract(Query, Table, hDict, OrderChecklistIds, Option, Flag)
If Flag NE 0 then
@ -169,12 +169,12 @@ Service GetOrderChecklistIds(NicaOrdersIds, NicaChecklistIds=NICA_CHECKLISTS, Is
end else
Error_Services('Add', ErrorMsg)
end
end service
Service GetOrderUpdates()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
Nica_Orders_Services('UpdateNicaChecklistBaseInstructionIds')
@ -251,21 +251,21 @@ Service UpdateNicaFlags()
Next ReactNo
end
end
end service
Service GetActiveOrders(EntityType=ENTITY_TYPES, EntityId, OrderTypes=ORDER_TYPES)
Response = Nica_Orders_Services('GetOrderIds', EntityType, EntityID, OrderTypes, '#cancelled', False$:@VM:'')
end service
Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES, OrderFlows, OrderResponseLevel, ChecklistIds, Intrusive=BOOLEAN)
If Intrusive NE True$ then Intrusive = False$
If Intrusive NE True$ then Intrusive = False$
ErrorMsg = ''
EntityTypes = 'REACTOR,REACTOR_LOG'
OrderTypes = 'INTRUSIVE_MAINT,CHANGEOVER,INITIATE_IDLE,IDLE,ASM_HTR_TUBE_CHANGE,ASM_HTR_ANNUAL_PM,'
@ -300,36 +300,36 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES,
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Begin Case
Case OrderType _EQC 'ABORT_ALARM'
OrderTypes = OrderType:@VM:'INTRUSIVE_MAINT'
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderTypes)
If CurrActiveOrders NE '' then
// If any active ABORT_ALARM orders are marked as intrusive (i.e., they were merged
// with an INTRUSIVE_MAINT order then mark the new order as intrusive).
ActiveOrdersIntrusive = Sum(Xlate('NICA_ORDERS', CurrActiveOrders, 'INTRUSIVE', 'X'))
If ActiveOrdersIntrusive then Intrusive = True$
end
Case OrderType _EQC 'INTRUSIVE_MAINT'
Intrusive = True$
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderType)
CurrActiveAbortAlarmOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, 'ABORT_ALARM')
If CurrActiveAbortAlarmOrders NE '' then
CurrActiveOrders<-1> = CurrActiveAbortAlarmOrders
// Merge INTRUSIVE_MAINT and ABORT_ALARM orders into one ABORT_ALARM order.
// Preserve ABORT_ALARM order flow ids for Reactor mode change logic that relies on these
// to determine whether or not to trigger a new ABORT/ALARM order when changing ABORT/ALARM sub modes.
OrderType = 'ABORT_ALARM'
OrderFlows = Xlate('NICA_ORDERS', CurrActiveAbortAlarmOrders, 'ORDER_FLOW_IDS', 'X')
OrderFlows = SRP_Array('Clean', OrderFlows, 'TrimAndMakeUnique', @VM)
end
Case Otherwise$
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderType)
Case OrderType _EQC 'ABORT_ALARM'
OrderTypes = OrderType:@VM:'INTRUSIVE_MAINT'
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderTypes)
If CurrActiveOrders NE '' then
// If any active ABORT_ALARM orders are marked as intrusive (i.e., they were merged
// with an INTRUSIVE_MAINT order then mark the new order as intrusive).
ActiveOrdersIntrusive = Sum(Xlate('NICA_ORDERS', CurrActiveOrders, 'INTRUSIVE', 'X'))
If ActiveOrdersIntrusive then Intrusive = True$
end
Case OrderType _EQC 'INTRUSIVE_MAINT'
Intrusive = True$
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderType)
CurrActiveAbortAlarmOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, 'ABORT_ALARM')
If CurrActiveAbortAlarmOrders NE '' then
CurrActiveOrders<-1> = CurrActiveAbortAlarmOrders
// Merge INTRUSIVE_MAINT and ABORT_ALARM orders into one ABORT_ALARM order.
// Preserve ABORT_ALARM order flow ids for Reactor mode change logic that relies on these
// to determine whether or not to trigger a new ABORT/ALARM order when changing ABORT/ALARM sub modes.
OrderType = 'ABORT_ALARM'
OrderFlows = Xlate('NICA_ORDERS', CurrActiveAbortAlarmOrders, 'ORDER_FLOW_IDS', 'X')
OrderFlows = SRP_Array('Clean', OrderFlows, 'TrimAndMakeUnique', @VM)
end
Case Otherwise$
CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderType)
End Case
OrderTypeAlreadyActive = (CurrActiveOrders NE '')
@ -403,15 +403,15 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES,
NewChecklistIds = SRP_Array('Clean', NewChecklistIds, 'TrimAndMakeUnique', @VM)
If Intrusive then
// Remove checklist ids with REMOVE_IF_INRUSIVE flag set to True$
ChecklistIdsToRemove = Nica_Orders_Services('GetChecklistIds', '', '', '', '', '', '', True$)
If ChecklistIdsToRemove NE '' then
For each ChecklistIdToRemove in ChecklistIdsToRemove using @VM
Locate ChecklistIdToRemove in NewChecklistIds using @VM setting vPos then
NewChecklistIds = Delete(NewChecklistIds, 0, vPos, 0)
end
Next ChecklistIdToRemove
end
// Remove checklist ids with REMOVE_IF_INRUSIVE flag set to True$
ChecklistIdsToRemove = Nica_Orders_Services('GetChecklistIds', '', '', '', '', '', '', True$)
If ChecklistIdsToRemove NE '' then
For each ChecklistIdToRemove in ChecklistIdsToRemove using @VM
Locate ChecklistIdToRemove in NewChecklistIds using @VM setting vPos then
NewChecklistIds = Delete(NewChecklistIds, 0, vPos, 0)
end
Next ChecklistIdToRemove
end
end
NewChecklistPriorities = Xlate('NICA_CHECKLISTS', NewChecklistIds, 'PRIORITY', 'X')
ChecklistArray = NewChecklistIds:@FM:NewChecklistPriorities
@ -441,16 +441,16 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES,
// Send the request
IsSuccessful = False$
If ErrorMsg EQ '' then
AttemptNo = 0
AttemptNo = 0
Retries = 3
BackoffSeconds = 1
OrderId = ''
Loop
while (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = (3 - retries) * BackoffSeconds
Delay(WaitSeconds)
While (IsSuccessful EQ False$ and Retries GT 0)
WaitSeconds = ( (3 - Retries) * BackoffSeconds ) ** 2
If WaitSeconds GT 0 then Delay(WaitSeconds)
Retries = Retries - 1
If Body NE '' then
@ -459,107 +459,113 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES,
Headers = 'Accept':@VM:'*/*'
end
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
AttemptNo += 1
LogData<3> = 'Attempt number ':AttemptNo:' to send HTTP POST request to ':NicaURL
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
// Write directly to the log file to avoid mangling the JSON
OSRead LogBytes from LogPath:'\':LogFileName then
LogBytes := CRLF$:Body
OSWrite LogBytes to LogPath:'\':LogFileName
end
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, Headers, Body, '', '', False$, False$, '', IgnoreCertErrors)
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
AttemptNo += 1
LogData<3> = 'Attempt number ':AttemptNo:' to send HTTP POST request to ':NicaURL
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempt number ':AttemptNo:' HttpResponse from ':NicaURL:':'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
// Write directly to the log file to avoid mangling the JSON
OSRead LogBytes from LogPath:'\':LogFileName then
LogBytes := CRLF$:HttpResponseJson
OSWrite LogBytes to LogPath:'\':LogFileName
end
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
ReqDtm = SRP_JSON(ObjResponseJson, 'GetValue', 'requestedDate')
ReqDate = IConv(ReqDtm[1, 'FT'], 'DJ')
ReqTime = IConv(ReqDtm[Col2() + 1, 'F.'], 'MT')
CreatedDtm = ReqDate + (ReqTime/SECONDS_IN_DAY$)
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')
NicaOrderRec<NICA_ORDERS.CREATED_DTM$> = CreatedDtm
If NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> EQ False$ then
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'progressPercentage')
end else
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = 100
end
NicaOrderRec<NICA_ORDERS.ORDER_FLOW_IDS$> = OrderFlows
NicaOrderRec<NICA_ORDERS.ORDER_RESPONSE_LEVEL$> = OrderResponseLevel
NicaOrderRec<NICA_ORDERS.INTRUSIVE$> = Intrusive
LogNicaOrderRec = NicaOrderRec
Swap @FM with ',' in LogNicaOrderRec
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Nica order record to write: ':LogNicaOrderRec
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
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.'
// Write directly to the log file to avoid mangling the JSON
OSRead LogBytes from LogPath:'\':LogFileName then
LogBytes := CRLF$:Body
OSWrite LogBytes to LogPath:'\':LogFileName
end
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, Headers, Body, '', '', False$, False$, '', IgnoreCertErrors)
HttpResponseStatusCode = Httpclient_Services('GetResponseStatusCode')
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Attempt number ':AttemptNo:' HttpResponse from ':NicaURL:':'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
// Write directly to the log file to avoid mangling the JSON
OSRead LogBytes from LogPath:'\':LogFileName then
LogBytes := CRLF$:HttpResponseJson
OSWrite LogBytes to LogPath:'\':LogFileName
end
If (HttpResponseStatusCode EQ 200) then
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
ReqDtm = SRP_JSON(ObjResponseJson, 'GetValue', 'requestedDate')
ReqDate = IConv(ReqDtm[1, 'FT'], 'DJ')
ReqTime = IConv(ReqDtm[Col2() + 1, 'F.'], 'MT')
CreatedDtm = ReqDate + (ReqTime/SECONDS_IN_DAY$)
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')
NicaOrderRec<NICA_ORDERS.CREATED_DTM$> = CreatedDtm
If NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> EQ False$ then
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'progressPercentage')
end else
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = 100
end
NicaOrderRec<NICA_ORDERS.ORDER_FLOW_IDS$> = OrderFlows
NicaOrderRec<NICA_ORDERS.ORDER_RESPONSE_LEVEL$> = OrderResponseLevel
NicaOrderRec<NICA_ORDERS.INTRUSIVE$> = Intrusive
LogNicaOrderRec = NicaOrderRec
Swap @FM with ',' in LogNicaOrderRec
LogData = ''
LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM
LogData<2> = Machine
LogData<3> = 'Nica order record to write: ':LogNicaOrderRec
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
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 ( (OrderType _EQC 'INTRUSIVE_MAINT') or (OrderType _EQC 'ABORT_ALARM') ) then
// Create NICA_ORDERS_CHECKLISTS child records for each checklist
If NewSortedChecklistIds NE '' then
For each ChecklistId in NewSortedChecklistIds using @VM
Key = OrderId:'*':ChecklistId
NicaOrdersChecklistsRec = ''
NicaOrdersChecklistsRec<NICA_ORDERS_CHECKLISTS.IS_COMPLETE$> = False$
Database_Services('WriteDataRow', 'NICA_ORDERS_CHECKLISTS', Key, NicaOrdersChecklistsRec, True$, False$, True$)
If Error_Services('HasError') then ErrorMsg = Error_Services('GetMessage')
Until (ErrorMsg NE '')
Next ChecklistId
end else
ErrorMsg = 'Error in ':Service:' service. failed to create NICA_ORDERS_CHECKLIST records due to empty checklist array.'
end
end
end
If ( (OrderType _EQC 'INTRUSIVE_MAINT') or (OrderType _EQC 'ABORT_ALARM') ) then
// Create NICA_ORDERS_CHECKLISTS child records for each checklist
If NewSortedChecklistIds NE '' then
For each ChecklistId in NewSortedChecklistIds using @VM
Key = OrderId:'*':ChecklistId
NicaOrdersChecklistsRec = ''
NicaOrdersChecklistsRec<NICA_ORDERS_CHECKLISTS.IS_COMPLETE$> = False$
Database_Services('WriteDataRow', 'NICA_ORDERS_CHECKLISTS', Key, NicaOrdersChecklistsRec, True$, False$, True$)
If Error_Services('HasError') then ErrorMsg = Error_Services('GetMessage')
Until (ErrorMsg NE '')
Next ChecklistId
end else
ErrorMsg = 'Error in ':Service:' service. failed to create NICA_ORDERS_CHECKLIST records due to empty checklist array.'
If ErrorMsg EQ '' then
For each OrderId in CurrActiveOrders using @VM
Nica_Orders_Services('CancelOrder', Orderid)
Next OrderId
IsSuccessful = True$
Response = OrderId
end
end
If ErrorMsg EQ '' then
For each OrderId in CurrActiveOrders using @VM
Nica_Orders_Services('CancelOrder', Orderid)
Next OrderId
IsSuccessful = True$
Response = OrderId
end else
ErrorMsg = Error_Services('GetMessage')
end
end else
ErrorMsg = Error_Services('GetMessage')
ErrorMsg = 'Error in ':Service:' service. Null OrderId returned from NicaIntegrationService.'
end
SRP_JSON(ObjResponseJson, 'Release')
end else
ErrorMsg = 'Error in ':Service:' service. Null OrderId returned from MesaProveInAPI.'
ErrorMsg = 'Error in ':Service:' service. Error parsing JSON response from NicaIntegrationService.'
end
SRP_JSON(ObjResponseJson, 'Release')
end else
ErrorMsg = 'Error in ':Service:' service. Error parsing JSON response from MesaProveInAPI.'
ErrorMsg = 'Error in ':Service:' service. Null JSON response returned from NicaIntegrationService.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null JSON response returned from MesaProveInAPI.'
ErrorMsg = 'Error in ':Service:' service. Expected 200 http response status code from NicaIntegrationService. ':HttpResponseStatusCode:' returned. '
ErrorMsg := 'Http Response Status Phrase: ':HttpClient_Services('GetResponseStatusPhrase')
end
Repeat
end
@ -574,7 +580,7 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES,
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('PostStatus', MonaResource, StatusName, 'Ok')
end else
ErrorMsg = 'Error encountered when attempting to create Nica in order for reactor ':ReactNo:' of type ':OrderType
ErrorMsg = 'Error encountered when attempting to create Nica in order for reactor ':ReactNo:' of type ':OrderType:'. Error message: ':ErrorMsg
Mona_Services('PostStatus', MonaResource, StatusName, 'Critical')
end
end
@ -624,8 +630,8 @@ Service CancelOrder(OrderId)
HaveLock = False$
Loop
While (HaveLock EQ False$ and LockRetries GT 0)
WaitSeconds = (3 - LockRetries) * LockBackoffSeconds
Delay(WaitSeconds)
WaitSeconds = ( (3 - LockRetries) * LockBackoffSeconds ) ** 2
If WaitSeconds GT 0 then Delay(WaitSeconds)
LockRetries = LockRetries - 1
HaveLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS', OrderId, True$)
Repeat
@ -667,54 +673,64 @@ Service CancelOrder(OrderId)
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', 'isComplete')
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = 'cancelled'
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = IsComplete
CloseDtm = Datetime()
NicaOrderRec<NICA_ORDERS.CLOSED_DTM$> = CloseDtm
If IsComplete EQ False$ then
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'progressPercentage')
end else
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = 100
end
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
WaitSeconds = ( (3 - Retries) * BackoffSeconds) ** 2
If WaitSeconds GT 0 then Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'PUT', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors)
HttpResponseStatusCode = Httpclient_Services('GetResponseStatusCode')
If (HttpResponseStatusCode EQ 200) then
If (HttpResponseJson NE '') then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete')
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = 'cancelled'
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = IsComplete
CloseDtm = Datetime()
NicaOrderRec<NICA_ORDERS.CLOSED_DTM$> = CloseDtm
If IsComplete EQ False$ then
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'progressPercentage')
end else
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = 100
end
If (OrderType EQ 'ABORT_ALARM') then
ActiveAbortAlarmOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'ABORT_ALARM')
AbortAlarmOrderActive = (ActiveAbortAlarmOrders NE '')
If (AbortAlarmOrderActive EQ False$) then
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 True$ on hReactor, ReactNo, REACTOR_ABORT_ALARM_COMPLETE$ else
ErrorMsg = 'Error in ':Service:' service. Error setting ABORT_ALARM_COMPLETE flag in REACTOR record.'
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
end
If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$
If (OrderType EQ 'ABORT_ALARM') then
ActiveAbortAlarmOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'ABORT_ALARM')
AbortAlarmOrderActive = (ActiveAbortAlarmOrders NE '')
If (AbortAlarmOrderActive EQ False$) then
Open 'REACTOR' to hReactor then
WriteV True$ on hReactor, ReactNo, REACTOR_ABORT_ALARM_COMPLETE$ else
ErrorMsg = 'Error in ':Service:' service. Error setting ABORT_ALARM_COMPLETE flag in REACTOR record.'
end
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 else
ErrorMsg = Error_Services('GetMessage')
end
If IsComplete EQ True$ then
Response = True$
end else
Response = False$
ErrorMsg = 'Error in ':Service:' service. Error parsing JSON response from NICAIntegrationService.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null response returned from NICAIntegrationService.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Expected 200 http response status code from NICAIntegrationService. Received ':HttpResponseStatusCode
ErrorMsg := 'Http response status phrase: ':HttpClient_Services('GetResponseStatusPhrase')
end
SRP_JSON(ObjResponseJson, 'Release')
Repeat
@ -728,13 +744,13 @@ Service CancelOrder(OrderId)
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
Mona_Services('PostStatus', MonaResource, StatusName, 'Ok')
end else
ErrorMsg = 'Error encountered cancelling Nica order ' : OrderId : ' for reactor ' : ReactNo
ErrorMsg = 'Error encountered cancelling Nica order ' : OrderId : ' for reactor ' : ReactNo : 'Error message: ':ErrorMsg
Mona_Services('PostStatus', MonaResource, StatusName, 'Critical')
end
end else
ErrorMsg = Error_Services('GetMessage')
Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId)
end
end
If Database_Services('IsKeyIDSelfLocked', 'NICA_ORDERS', OrderId) then Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId)
end else
ErrorMsg = 'Error in ':Service:' service. Failed to lock NICA_ORDERS ':OrderId:' for cancellation.'
end
@ -831,108 +847,117 @@ Service GetOrderStatusUpdate(OrderId)
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')
State = SRP_JSON(ObjResponseJson, 'GetValue', 'state')
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = State
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = IsComplete
CloseDtm = NicaOrderRec<NICA_ORDERS.CLOSED_DTM$>
If ( (CloseDtm EQ '' ) and ( (State _EQC 'done') or (State _EQC 'cancelled') ) ) then
CloseDtm = Datetime()
NicaOrderRec<NICA_ORDERS.CLOSED_DTM$> = CloseDtm
end
If IsComplete EQ False$ then
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'progressPercentage')
end else
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = 100
end
Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$)
If Error_Services('NoError') then
OrderType = NicaOrderRec<NICA_ORDERS.ORDER_TYPE$>
If ( (OrderType _EQC 'INTRUSIVE_MAINT') or (OrderType _EQC 'ABORT_ALARM') ) then
// Update NICA_ORDERS_CHECKLISTS records (documents)
Open 'NICA_ORDERS_CHECKLISTS' to hNicaOrdersChecklists then
// Parse documents array for their isComplete flag
ObjDocumentArray = SRP_JSON(ObjResponseJson, 'get', 'progresses')
If ObjDocumentArray NE 0 then
NumDocs = SRP_JSON(objDocumentArray, 'GetCount')
For DocIndex = 1 to NumDocs
DocumentId = SRP_JSON(ObjDocumentArray, 'GetValue', '[':DocIndex:'].baseInstructionId', '')
If DocumentId NE '' then
State = SRP_JSON(ObjDocumentArray, 'GetValue', '[':DocIndex:'].state', False$)
IsComplete = (State _EQC 'done')
ChecklistId = ''
Extract_SI_Keys('NICA_CHECKLISTS', 'NICA_BASE_INSTRUCTION_ID', DocumentId, ChecklistId)
ErrorCode = ''
If Not(Get_Status(ErrorCode)) then
If ChecklistId NE '' then
NicaOrdersChecklistsKey = OrderId:'*':ChecklistId
HaveOrderChecklistLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey)
If HaveOrderChecklistLock then
NicaOrdersChecklistsRec = Database_Services('ReadDataRow', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey)
If Error_Services('NoError') then
NicaOrdersChecklistsRec<NICA_ORDERS_CHECKLISTS.IS_COMPLETE$> = IsComplete
NicaOrdersChecklistsRec<NICA_ORDERS_CHECKLISTS.STATE$> = State
Database_Services('WriteDataRow', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey, NicaOrdersChecklistsRec, True$, False$, False$)
If Error_Services('HasError') then
Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey)
WaitSeconds = ( (3 - Retries) * BackoffSeconds ) ** 2
If WaitSeconds GT 0 then Delay(WaitSeconds)
Retries = Retries - 1
HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'GET', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors)
HttpResponseStatusCode = Httpclient_Services('GetResponseStatusCode')
If (HttpResponseStatusCode EQ 200) then
If (HttpResponseJson NE '') then
ObjResponseJson = ''
If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then
IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete')
State = SRP_JSON(ObjResponseJson, 'GetValue', 'state')
NicaOrderRec<NICA_ORDERS.ORDER_STATUS$> = State
NicaOrderRec<NICA_ORDERS.IS_COMPLETE$> = IsComplete
CloseDtm = NicaOrderRec<NICA_ORDERS.CLOSED_DTM$>
If ( (CloseDtm EQ '' ) and ( (State _EQC 'done') or (State _EQC 'cancelled') ) ) then
CloseDtm = Datetime()
NicaOrderRec<NICA_ORDERS.CLOSED_DTM$> = CloseDtm
end
If IsComplete EQ False$ then
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = SRP_JSON(ObjResponseJson, 'GetValue', 'progressPercentage')
end else
NicaOrderRec<NICA_ORDERS.PROGRESS_PERCENTAGE$> = 100
end
Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$)
If Error_Services('NoError') then
OrderType = NicaOrderRec<NICA_ORDERS.ORDER_TYPE$>
If ( (OrderType _EQC 'INTRUSIVE_MAINT') or (OrderType _EQC 'ABORT_ALARM') ) then
// Update NICA_ORDERS_CHECKLISTS records (documents)
Open 'NICA_ORDERS_CHECKLISTS' to hNicaOrdersChecklists then
// Parse documents array for their isComplete flag
ObjDocumentArray = SRP_JSON(ObjResponseJson, 'get', 'progresses')
If ObjDocumentArray NE 0 then
NumDocs = SRP_JSON(objDocumentArray, 'GetCount')
For DocIndex = 1 to NumDocs
DocumentId = SRP_JSON(ObjDocumentArray, 'GetValue', '[':DocIndex:'].baseInstructionId', '')
If DocumentId NE '' then
State = SRP_JSON(ObjDocumentArray, 'GetValue', '[':DocIndex:'].state', False$)
IsComplete = (State _EQC 'done')
ChecklistId = ''
Extract_SI_Keys('NICA_CHECKLISTS', 'NICA_BASE_INSTRUCTION_ID', DocumentId, ChecklistId)
ErrorCode = ''
If Not(Get_Status(ErrorCode)) then
If ChecklistId NE '' then
NicaOrdersChecklistsKey = OrderId:'*':ChecklistId
HaveOrderChecklistLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey)
If HaveOrderChecklistLock then
NicaOrdersChecklistsRec = Database_Services('ReadDataRow', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey)
If Error_Services('NoError') then
NicaOrdersChecklistsRec<NICA_ORDERS_CHECKLISTS.IS_COMPLETE$> = IsComplete
NicaOrdersChecklistsRec<NICA_ORDERS_CHECKLISTS.STATE$> = State
Database_Services('WriteDataRow', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey, NicaOrdersChecklistsRec, True$, False$, False$)
If Error_Services('HasError') then
Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS_CHECKLISTS', NicaOrdersChecklistsKey)
end
end
end
end else
ErrorMsg = 'Error in ':Service:' service. No NICA_CHECKLISTS record found for documentId ':DocumentId:'.'
end
end else
ErrorMsg = 'Error in ':Service:' service. No NICA_CHECKLISTS record found for documentId ':DocumentId:'.'
ErrorMsg = 'Error in ':Service:' service. Error calling Extract_SI_Keys on NICA_CHECKLISTS table. Error code: ':ErrorCode:'.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Error calling Extract_SI_Keys on NICA_CHECKLISTS table. Error code: ':ErrorCode:'.'
ErrorMsg = 'Error in ':Service:' service. Null documentId return from Json response.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null documentId return from Json response.'
end
Next DocIndex
SRP_JSON(ObjDocumentArray, 'Release')
Next DocIndex
SRP_JSON(ObjDocumentArray, 'Release')
end else
ErrorMsg = 'Error in ':Service:' service. Error retrieving documents array from Json response.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Error retrieving documents array from Json response.'
ErrorMsg = 'Error in ':Service:' service. Error opening NICA_ORDERS_CHECKLISTS table.'
end
end
If ( (OrderType _EQC 'ABORT_ALARM') and ( (State _EQC 'done') or (State _EQC 'cancelled') ) ) then
ActiveAbortAlarmOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'ABORT_ALARM')
AbortAlarmOrderActive = (ActiveAbortAlarmOrders NE '')
If (AbortAlarmOrderActive EQ False$) then
Open 'REACTOR' to hReactor then
WriteV True$ on hReactor, ReactNo, REACTOR_ABORT_ALARM_COMPLETE$ else
ErrorMsg = 'Error in ':Service:' service. Error setting ABORT_ALARM_COMPLETE flag in REACTOR record.'
end
end
end
end
If IsComplete EQ True$ then
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
ErrorMsg = 'Error in ':Service:' service. Error opening NICA_ORDERS_CHECKLISTS table.'
end
end
If ( (OrderType _EQC 'ABORT_ALARM') and ( (State _EQC 'done') or (State _EQC 'cancelled') ) ) then
ActiveAbortAlarmOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'ABORT_ALARM')
AbortAlarmOrderActive = (ActiveAbortAlarmOrders NE '')
If (AbortAlarmOrderActive EQ False$) then
Open 'REACTOR' to hReactor then
WriteV True$ on hReactor, ReactNo, REACTOR_ABORT_ALARM_COMPLETE$ else
ErrorMsg = 'Error in ':Service:' service. Error setting ABORT_ALARM_COMPLETE flag in REACTOR record.'
end
end
end
end
If IsComplete EQ True$ then
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$
Response = False$
end
If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$
end else
Response = False$
end
If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$
ErrorMsg = Error_Services('GetMessage')
end
end else
ErrorMsg = Error_Services('GetMessage')
ErrorMsg = 'Error in ':Service:' service. Error parsing JSON response from NicaIntegrationService.'
end
SRP_JSON(ObjResponseJson, 'Release')
end else
ErrorMsg = 'Error in ':Service:' service. Null JSON response returned from NicaIntegrationService.'
end
SRP_JSON(ObjResponseJson, 'Release')
end else
ErrorMsg = 'Error in ':Service:' service. Expected 200 http response status code from NicaIntegrationService. ':HttpResponseStatusCode:' returned. '
ErrorMsg := 'Http Response Status Phrase: ':HttpClient_Services('GetResponseStatusPhrase')
end
Repeat
@ -945,21 +970,21 @@ Service GetOrderStatusUpdate(OrderId)
Mona_Services('PostStatus', 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:'.'
ErrorMsg = 'Error encountered updating Nica order ':OrderId:' for reactor ':ReactNo:'. Error message: ':ErrorMsg
Mona_Services('PostStatus', MonaResource, StatusName, 'Critical')
end
end
end else
ErrorMsg = Error_Services('GetMessage')
end
If Database_Services('IsKeyIDSelfLocked', 'NICA_ORDERS', OrderId) then Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId)
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
@ -969,12 +994,12 @@ Service GetOrderStatusUpdate(OrderId)
Error_Services('Add', ErrorMsg)
Response = 'error'
end
end service
Service GetFlowChecklistIds(NicaOrderFlowIds, NicaOrderFlowType=ORDER_TYPES, ReactorTypes=REACTOR_TYPES)
ErrorMsg = ''
FlowChecklistIds = ''
If ( (NicaOrderFlowIds NE '') and (NicaOrderFlowType NE '') and (ReactorTypes NE '') ) then
@ -1013,7 +1038,7 @@ Service GetFlowChecklistIds(NicaOrderFlowIds, NicaOrderFlowType=ORDER_TYPES, Rea
end else
Response = FlowChecklistIds
end
end service
@ -1039,44 +1064,44 @@ end service
Service AbortAlarmFromIntrusiveMaintRequired(ReactNo)
ErrorMsg = ''
AbortAlarmFromIntrusiveMaintRequired = ''
If ReactNo NE '' then
If RowExists('REACTOR', ReactNo) then
ActiveIntrusiveMaintOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'INTRUSIVE_MAINT')
IntrusiveMaintOrderActive = (ActiveIntrusiveMaintOrderIds NE '')
If IntrusiveMaintOrderActive then
// If any FIRST_PRODUCT_RUN_THICK or FIRST_PRODUCT_RUN_HGCV associated with active INTRUSIVE_MAINT
// orders have been started or completed, then an ABORT/ALARM order should be triggerd.
ChecklistIdsToSearch = 'FIRST_PRODUCT_RUN_THICK':@VM:'FIRST_PRODUCT_RUN_HGCV'
InProcessOrCompleteOrderChecklistIds = Nica_Orders_Services('GetOrderChecklistIds', ActiveIntrusiveMaintOrderIds, ChecklistIdsToSearch, '', '#not-started')
AbortAlarmFromIntrusiveMaintRequired = (InProcessOrCompleteOrderChecklistIds NE '')
end else
AbortAlarmFromIntrusiveMaintRequired = False$
end
end else
ErrorMsg = 'Error in ':Service:' service. REACTOR ':ReactNo:' does not exist.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null ReactNo passed into service.'
end
If ErrorMsg EQ '' then
Response = AbortAlarmFromIntrusiveMaintRequired
end else
Error_Services('Add', ErrorMsg)
end
ErrorMsg = ''
AbortAlarmFromIntrusiveMaintRequired = ''
If ReactNo NE '' then
If RowExists('REACTOR', ReactNo) then
ActiveIntrusiveMaintOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'INTRUSIVE_MAINT')
IntrusiveMaintOrderActive = (ActiveIntrusiveMaintOrderIds NE '')
If IntrusiveMaintOrderActive then
// If any FIRST_PRODUCT_RUN_THICK or FIRST_PRODUCT_RUN_HGCV associated with active INTRUSIVE_MAINT
// orders have been started or completed, then an ABORT/ALARM order should be triggerd.
ChecklistIdsToSearch = 'FIRST_PRODUCT_RUN_THICK':@VM:'FIRST_PRODUCT_RUN_HGCV'
InProcessOrCompleteOrderChecklistIds = Nica_Orders_Services('GetOrderChecklistIds', ActiveIntrusiveMaintOrderIds, ChecklistIdsToSearch, '', '#not-started')
AbortAlarmFromIntrusiveMaintRequired = (InProcessOrCompleteOrderChecklistIds NE '')
end else
AbortAlarmFromIntrusiveMaintRequired = False$
end
end else
ErrorMsg = 'Error in ':Service:' service. REACTOR ':ReactNo:' does not exist.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null ReactNo passed into service.'
end
If ErrorMsg EQ '' then
Response = AbortAlarmFromIntrusiveMaintRequired
end else
Error_Services('Add', ErrorMsg)
end
end service
Service GetChecklistIds(Priorities, NicaBaseInstructionIds, NicaOrderFlowIds, NicaOrderFlowTypes, ReactorTypes, RemoveIfComplete=BOOLEAN, RemoveIfIntrusive=BOOLEAN)
ChecklistIds = ''
ErrorMsg = ''
If ( (Priorities NE '') or (NicaBaseInstructionIds NE '') or (NicaOrderFlowIds NE '') or (NicaOrderFlowTypes NE '') |
or (ReactorTypes NE '') or (RemoveIfComplete NE '') or (RemoveIfIntrusive NE '') ) then
or (ReactorTypes NE '') or (RemoveIfComplete NE '') or (RemoveIfIntrusive NE '') ) then
Open 'DICT.NICA_CHECKLISTS' to hDict then
Query = ''
Table = 'NICA_CHECKLISTS'
@ -1090,11 +1115,11 @@ Service GetChecklistIds(Priorities, NicaBaseInstructionIds, NicaOrderFlowIds, Ni
Query := @FM
end
If (NicaBaseInstructionIds NE '') then
Query := 'NICA_BASE_INSTRUCTION_ID'
For each NicaBaseInstructionId in NicaBaseInstructionIds using @VM
Query := @VM : NicaBaseInstructionId
Next NicaBaseInstructionId
Query := @FM
Query := 'NICA_BASE_INSTRUCTION_ID'
For each NicaBaseInstructionId in NicaBaseInstructionIds using @VM
Query := @VM : NicaBaseInstructionId
Next NicaBaseInstructionId
Query := @FM
end
If (NicaOrderFlowIds NE '') then
Query := 'NICA_ORDER_FLOW_IDS'
@ -1104,32 +1129,32 @@ Service GetChecklistIds(Priorities, NicaBaseInstructionIds, NicaOrderFlowIds, Ni
Query := @FM
end
If (NicaOrderFlowTypes NE '') then
Query := 'NICA_ORDER_FLOW_TYPE'
For each NicaOrderFlowType in NicaOrderFlowTypes using @VM
Query := @VM : NicaOrderFlowType
Next NicaOrderFlowTypes
Query := @FM
Query := 'NICA_ORDER_FLOW_TYPE'
For each NicaOrderFlowType in NicaOrderFlowTypes using @VM
Query := @VM : NicaOrderFlowType
Next NicaOrderFlowTypes
Query := @FM
end
If (ReactorTypes NE '') then
Query := 'REACTOR_TYPES'
For each NicaOrderFlowType in NicaOrderFlowTypes using @VM
Query := @VM : NicaOrderFlowType
Next NicaOrderFlowTypes
Query := @FM
Query := 'REACTOR_TYPES'
For each NicaOrderFlowType in NicaOrderFlowTypes using @VM
Query := @VM : NicaOrderFlowType
Next NicaOrderFlowTypes
Query := @FM
end
If (RemoveIfComplete NE '') then
Query := 'REMOVE_IF_COMPLETE'
For each Val in RemoveIfComplete using @VM
Query := @VM : Val
Next RemoveIfComplete
Query := @FM
Query := 'REMOVE_IF_COMPLETE'
For each Val in RemoveIfComplete using @VM
Query := @VM : Val
Next RemoveIfComplete
Query := @FM
end
If (RemoveIfIntrusive NE '') then
Query := 'REMOVE_IF_INTRUSIVE'
For each Val in RemoveIfIntrusive using @VM
Query := @VM : Val
Next Val
Query := @FM
Query := 'REMOVE_IF_INTRUSIVE'
For each Val in RemoveIfIntrusive using @VM
Query := @VM : Val
Next Val
Query := @FM
end
Btree.Extract(Query, Table, hDict, ChecklistIds, Option, Flag)
If Flag NE 0 then
@ -1147,7 +1172,7 @@ Service GetChecklistIds(Priorities, NicaBaseInstructionIds, NicaOrderFlowIds, Ni
end else
Error_Services('Add', ErrorMsg)
end
end service