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

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