Adding basic backend functionality to prod.

This commit is contained in:
Infineon\Ouellette 2025-01-13 14:56:14 -07:00 committed by Ouellette Jonathan (CSC FI SPS MESLEO)
parent 0eac3839ea
commit 860cab9f68
2 changed files with 164 additions and 29 deletions

View File

@ -1,16 +1,27 @@
Compile function RETURN_TO_FAB_Services(@Service, @Params) Compile function RETURN_TO_FAB_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler #pragma precomp SRP_PreCompiler
Declare subroutine Error_Services, Database_Services, Btree.Extract Declare subroutine Error_Services, Database_Services, Btree.Extract, Logging_Services
Declare function Rti_Createguid, Database_Services, Return_To_Fab_Services, Datetime, Error_Services Declare function Rti_Createguid, Database_Services, Return_To_Fab_Services, Datetime, Error_Services
Declare function Logging_Services, Environment_Services
$insert LOGICAL $insert LOGICAL
$Insert APP_INSERTS
$Insert RETURN_TO_FAB_LOTS_EQUATES $Insert RETURN_TO_FAB_LOTS_EQUATES
$Insert RETURN_TO_FAB_RESULT_OPTION_EQUATES $Insert RETURN_TO_FAB_RESULT_OPTION_EQUATES
$Insert WO_MAT_EQUATES $Insert WO_MAT_EQUATES
$Insert RDS_EQUATES $Insert RDS_EQUATES
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Return_To_Fab_Services'; //Define the directory where the log will be saved to. This happens the first time of the day that the log is written to.
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' ReturnToFabServicesLog.csv'
Headers = 'Logging DTM' : @FM : 'Cass Id' : @FM: 'User' : @FM : 'ReturnToFabId' : @FM : 'Message'; //Define the column names in the log file, delimited by a Field Mark.
objReturnToFabLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$); //Actually creates the log.
GoToService GoToService
Return Response or "" Return Response or ""
@ -73,9 +84,23 @@ Service CreateReturnToFabRecord(CassId, UserId)
ErrorMessage = 'Error creating return to fab record, Cassette ID was null' ErrorMessage = 'Error creating return to fab record, Cassette ID was null'
end end
If ErrorMessage EQ '' AND NewRTFId NE '' then If ErrorMessage EQ '' AND NewRTFId NE '' then
Response = NewRTFId LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = CassId
LogData<3> = UserId
LogData<4> = NewRTFId
LogData<5> = 'Successfully created new RETURN_TO_FAB_LOTS record'
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Response = NewRTFId
end else end else
//Todo Log error message LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = CassId
LogData<3> = UserId
LogData<4> = NewRTFId
LogData<5> = ErrorMessage
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Response = NewRTFId
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
End Service End Service
@ -103,7 +128,6 @@ Service GetReturnToFabReasonOptions()
If ErrorMessage EQ '' then If ErrorMessage EQ '' then
Response = RTFReasons Response = RTFReasons
end else end else
//Todo Log error message
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
end service end service
@ -164,7 +188,6 @@ Service GetReturnToFabRecordIdByCassId(CassId)
If ErrorMessage EQ '' then If ErrorMessage EQ '' then
Response = RTFRecords Response = RTFRecords
end else end else
//Todo Log error message
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
End Service End Service
@ -189,27 +212,35 @@ Service GetOpenReturnToFabRecordIdByCassId(CassId)
If ErrorMessage EQ '' then If ErrorMessage EQ '' then
Response = OpenRTFRecords Response = OpenRTFRecords
end else end else
//Todo Log error message
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
End Service End Service
Service SetReasonForReturn(RTFId, Reason) Service SetReasonForReturn(RTFId, UserId, Reason)
ErrorMessage = '' ErrorMessage = ''
If RTFId NE '' then If RTFId NE '' then
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$) RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$> RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>
If RTFRecordComplete NE True$ then If RTFRecordComplete NE True$ then
If Reason NE '' then If UserId NE '' then
RTFRecord<RETURN_TO_FAB_LOTS_REASON$> = Reason if RowExists('LSL_USERS', UserId) then
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$) If Reason NE '' then
If Error_Services('HasError') then RTFRecord<RETURN_TO_FAB_LOTS_REASON$> = Reason
ErrorMessage = Error_Services('GetMessage') Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$)
end If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Error setting return to fab reason. Reason was null.'
end
end else
ErrorMessage = 'Error setting return to fab reason. User not found in openinsight.'
end
end else end else
ErrorMessage = 'Error setting return to fab reason. Reason was null.' ErrorMessage = 'Error setting return to fab reason. User ID was null.'
end end
end else end else
ErrorMessage = 'Error setting return to fab reason. Return to fab record has already been completed.' ErrorMessage = 'Error setting return to fab reason. Return to fab record has already been completed.'
end end
@ -219,9 +250,23 @@ Service SetReasonForReturn(RTFId, Reason)
end else end else
ErrorMessage = 'Error setting return to fab reason. Return to fab record id was null' ErrorMessage = 'Error setting return to fab reason. Return to fab record id was null'
end end
if ErrorMessage NE '' then if ErrorMessage EQ '' then
//Todo Add loggging LogData = ''
Error_Services('Add', ErrorMessage) LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = UserId
LogData<4> = RTFId
LogData<5> = 'Successfully set reason for return on RETURN_TO_FAB_LOTS record'
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
end else
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = UserId
LogData<4> = RTFId
LogData<5> = ErrorMessage
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
end end
end service end service
@ -256,10 +301,24 @@ Service SetBinToBin(RTFId, MHUserId)
end else end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null' ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null'
end end
if ErrorMessage NE '' then If ErrorMessage EQ '' then
//Todo Add loggging LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = MHUserId
LogData<4> = RTFId
LogData<5> = 'Successfully set bin to bin complete on RETURN_TO_FAB_LOTS record'
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
end else
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = MHUserId
LogData<4> = RTFId
LogData<5> = ErrorMessage
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
end service end service
Service SetEvalInfo(RTFId, EvalUserId, ResultId) Service SetEvalInfo(RTFId, EvalUserId, ResultId)
@ -303,14 +362,28 @@ Service SetEvalInfo(RTFId, EvalUserId, ResultId)
end else end else
ErrorMessage = 'Error setting Eval. info. Return to fab id was null.' ErrorMessage = 'Error setting Eval. info. Return to fab id was null.'
end end
If ErrorMessage NE '' then If ErrorMessage EQ '' then
//Todo add logging LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = EvalUserId
LogData<4> = RTFId
LogData<5> = 'Successfully set evaluation result on RETURN_TO_FAB_LOTS record'
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
end else
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = EvalUserId
LogData<4> = RTFId
LogData<5> = ErrorMessage
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
end service end service
Service SetFinalBinToBin(RTFId, MHUserId) Service SetFinalBinToBin(RTFId, MHUserId)
ErrorMessage = '' ErrorMessage = ''
If RTFId NE '' then If RTFId NE '' then
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$) RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
@ -342,14 +415,75 @@ Service SetFinalBinToBin(RTFId, MHUserId)
end else end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null' ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null'
end end
if ErrorMessage NE '' then If ErrorMessage EQ '' then
//Todo Add loggging LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = MHUserId
LogData<4> = RTFId
LogData<5> = 'Successfully set final bin to bin on RETURN_TO_FAB_LOTS record'
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
end else
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = MHUserId
LogData<4> = RTFId
LogData<5> = ErrorMessage
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
end service end service
Service AddMiscNote(RTFId, Note) Service AddMiscNote(RTFId, Note, UserId)
ErrorMessage = ''
If RTFId NE '' then
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>
If RTFRecordComplete NE True$ then
If UserId NE '' then
If RowExists('LSL_USERS', UserId) then
RTFRecord<RETURN_TO_FAB_LOTS_NOTES$> = Insert(RTFRecord<RETURN_TO_FAB_LOTS_NOTES$>, 1, -1, 0, Note)
RTFRecord<RETURN_TO_FAB_LOTS_NOTES_USER$> = Insert(RTFRecord<RETURN_TO_FAB_LOTS_NOTES_USER$>, 1, -1, 0, UserId)
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Error adding note to RTF Record. User ID was not found in OpenInsight.'
end
end else
ErrorMessage = 'Error adding note to RTF Record. User ID was null.'
end
end else
ErrorMessage = 'Error adding note to RTF Record. Return to fab record has already been completed.'
end
end else
ErrorMessage = 'Error adding note to RTF Record. Return to fab record did not exists'
end
end else
ErrorMessage = 'Error adding note to RTF Record. Return to fab record id was null'
end
If ErrorMessage EQ '' then
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = UserId
LogData<4> = RTFId
LogData<5> = 'Successfully added note to RETURN_TO_FAB_LOTS record'
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
end else
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = ''
LogData<3> = UserId
LogData<4> = RTFId
LogData<5> = ErrorMessage
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
end
end service end service

View File

@ -1,7 +1,7 @@
compile insert RETURN_TO_FAB_LOTS_EQUATES compile insert RETURN_TO_FAB_LOTS_EQUATES
/*---------------------------------------- /*----------------------------------------
Author : Table Create Insert Routine Author : Table Create Insert Routine
Written : 10/01/2025 Written : 13/01/2025
Description : Insert for Table RETURN_TO_FAB_LOTS Description : Insert for Table RETURN_TO_FAB_LOTS
----------------------------------------*/ ----------------------------------------*/
#ifndef __RETURN_TO_FAB_LOTS_EQUATES__ #ifndef __RETURN_TO_FAB_LOTS_EQUATES__
@ -22,5 +22,6 @@ compile insert RETURN_TO_FAB_LOTS_EQUATES
equ RETURN_TO_FAB_LOTS_COMPLETED_DTM$ to 14 equ RETURN_TO_FAB_LOTS_COMPLETED_DTM$ to 14
equ RETURN_TO_FAB_LOTS_REASON$ to 15 equ RETURN_TO_FAB_LOTS_REASON$ to 15
equ RETURN_TO_FAB_LOTS_NOTES$ to 16 equ RETURN_TO_FAB_LOTS_NOTES$ to 16
equ RETURN_TO_FAB_LOTS_NOTES_USER$ to 17
#endif #endif