project BLF > class BSODLog > method PostSave
Description
Actions to take after writing current instance to the database, and before final commit of the transaction.
Use the field tc_status to test the status of the updated records:
'' = unchanged
'N' = new
'C' = changed
'D' = deleted
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bsodlog.p)
<ANCESTOR-CODE>
<Q-21 run SystSODMessaging (all) (Read) (NoCache) (output dataset tqSystSODMessaging) in BSystem >
find first tqSystSODMessaging no-error.
if available tqSystSODMessaging
then
if tqSystSODMessaging.tcSystSODNotificationEmail <> ""
or tqSystSODMessaging.tcSystSODNotificationUser <> ""
then do:
/* ================================================================= */
/* Send notifications. */
/* ================================================================= */
for each tSODLog where
tSODLog.tc_Status = "N" and
tSODLog.SODLogRule = {&SODLOG-RULE1} and
tSODLog.SODLogStatus = {&SODLOG-STATUS-VIOLATION}
break by tSODLog.SODLogRole1Name
on error undo, throw:
if first-of(tSODLog.SODLogRole1Name)
then do:
vcMsg1 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE1} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-VIOLATION} and
bSODLog.SODLogRole1Name = tSODLog.SODLogRole1Name
break by bSodLog.SODLogResource1URI
on error undo, throw:
if first-of(bSODLog.SODLogResource1URI)
then vcMsg1 = vcMsg1 + chr(10) + bSODLog.SODLogResource1URI + " (" + bSODLog.SODLogCategory1Code + ")".
end.
vcMsg2 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE1} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-VIOLATION} and
bSODLog.SODLogRole1Name = tSODLog.SODLogRole1Name
break by bSodLog.SODLogResource2URI
on error undo, throw:
if first-of(bSODLog.SODLogResource2URI)
then vcMsg2 = vcMsg2 + chr(10) + bSODLog.SODLogResource2URI + " (" + bSODLog.SODLogCategory2Code + ")".
end.
vcMsg = #T-70'SOD rule 1 conflict created':255(678803470)T-70# + chr(10)
+ #T-17'Role Name':10(7027)T-17# + " = " + tSODLog.SODLogRole1Name + chr(10)
+ #T-96'Resource 1 URI':20(998717657)T-96# + " = " + vcMsg1 + chr(10)
+ #T-15'Resource 2 URI':20(117798426)T-15# + " = " + vcMsg2 + chr(10) + chr(10).
viMsg = length (vcMsg,"character").
if viMailMessageLength + viMsg > 30000
then do:
vcMailMessage = vcMailMessage + "[...]".
viMailMessageLength = 40000.
leave.
end.
vcMailMessage = vcMailMessage + vcMsg.
viMailMessageLength = viMailMessageLength + viMsg.
end.
end.
if viMailMessageLength < 30000
then
for each tSODLog where
tSODLog.tc_Status = "N" and
tSODLog.SODLogRule = {&SODLOG-RULE1} and
tSODLog.SODLogStatus = {&SODLOG-STATUS-CORRECTION}
break by tSODLog.SODLogRole1Name
on error undo, throw:
if first-of(tSODLog.SODLogRole1Name)
then do:
vcMsg1 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE1} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-CORRECTION} and
bSODLog.SODLogRole1Name = tSODLog.SODLogRole1Name
break by bSodLog.SODLogResource1URI
on error undo, throw:
if first-of(bSODLog.SODLogResource1URI)
then vcMsg1 = vcMsg1 + chr(10) + bSODLog.SODLogResource1URI + " (" + bSODLog.SODLogCategory1Code + ")".
end.
vcMsg2 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE1} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-CORRECTION} and
bSODLog.SODLogRole1Name = tSODLog.SODLogRole1Name
break by bSodLog.SODLogResource2URI
on error undo, throw:
if first-of(bSODLog.SODLogResource2URI)
then vcMsg2 = vcMsg2 + chr(10) + bSODLog.SODLogResource2URI + " (" + bSODLog.SODLogCategory2Code + ")".
end.
vcMsg = #T-10'SOD rule 1 conflict solved':255(865422587)T-10# + chr(10)
+ #T-98'Role Name':10(7027)T-98# + " = " + tSODLog.SODLogRole1Name + chr(10)
+ #T-93'Resource 1 URI':20(998717657)T-93# + " = " + vcMsg1 + chr(10)
+ #T-16'Resource 2 URI':20(117798426)T-16# + " = " + vcMsg2 + chr(10) + chr(10).
viMsg = length (vcMsg,"character").
if viMailMessageLength + viMsg > 30000
then do:
vcMailMessage = vcMailMessage + "[...]".
viMailMessageLength = 40000.
leave.
end.
vcMailMessage = vcMailMessage + vcMsg.
viMailMessageLength = viMailMessageLength + viMsg.
end.
end.
if viMailMessageLength < 30000
then
for each tSODLog where
tSODLog.tc_Status = "N" and
tSODLog.SODLogRule = {&SODLOG-RULE2} and
tSODLog.SODLogStatus = {&SODLOG-STATUS-VIOLATION}
break by tSODLog.SODLogUsrLogin
by tSODLog.SODLogCompanyCode
on error undo, throw:
if first-of(tSODLog.SODLogCompanyCode)
then do:
vcMsg1 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE2} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-VIOLATION} and
bSODLog.SODLogUsrLogin = tSODLog.SODLogUsrLogin and
bSODLog.SODLogCompanyCode = tSODLog.SODLogCompanyCode
break by bSodLog.SODLogRole1Name
by bSodLog.SODLogResource1URI
on error undo, throw:
if first-of(bSODLog.SODLogResource1URI)
then vcMsg1 = vcMsg1 + chr(10) + bSodLog.SODLogRole1Name + " : "
+ bSODLog.SODLogResource1URI + " (" + bSODLog.SODLogCategory1Code + ")".
end.
vcMsg2 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE2} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-VIOLATION} and
bSODLog.SODLogUsrLogin = tSODLog.SODLogUsrLogin and
bSODLog.SODLogCompanyCode = tSODLog.SODLogCompanyCode
break by bSodLog.SODLogRole2Name
by bSodLog.SODLogResource2URI
on error undo, throw:
if first-of(bSODLog.SODLogResource2URI)
then vcMsg2 = vcMsg2 + chr(10) + bSodLog.SODLogRole2Name + " : "
+ bSODLog.SODLogResource2URI + " (" + bSODLog.SODLogCategory2Code + ")".
end.
vcMsg = #T-45'SOD rule 2 violation created':255(526568043)T-45# + chr(10)
+ #T-39'User Login':15(8147)T-39# + " = " + tSODLog.SODLogUsrLogin + chr(10)
+ #T-77'Entity Code':24(8770)T-77# + " = " + tSODLog.SODLogCompanyCode + chr(10)
+ #T-85'Role 1 Name':20(733738256)T-85# + " : " + #T-69'Resource 1 URI':20(998717657)T-69# + " = " + vcMsg1 + chr(10)
+ #T-71'Role 2 Name':20(73458301)T-71# + " : " + #T-3'Resource 2 URI':20(117798426)T-3# + " = " + vcMsg2 + chr(10) + chr(10).
viMsg = length (vcMsg,"character").
if viMailMessageLength + viMsg > 30000
then do:
vcMailMessage = vcMailMessage + "[...]".
viMailMessageLength = 40000.
leave.
end.
vcMailMessage = vcMailMessage + vcMsg.
viMailMessageLength = viMailMessageLength + viMsg.
end.
end.
if viMailMessageLength < 30000
then
for each tSODLog where
tSODLog.tc_Status = "N" and
tSODLog.SODLogRule = {&SODLOG-RULE2} and
tSODLog.SODLogStatus = {&SODLOG-STATUS-CORRECTION}
break by tSODLog.SODLogUsrLogin
by tSODLog.SODLogCompanyCode
on error undo, throw:
if first-of(tSODLog.SODLogCompanyCode)
then do:
vcMsg1 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE2} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-CORRECTION} and
bSODLog.SODLogUsrLogin = tSODLog.SODLogUsrLogin and
bSODLog.SODLogCompanyCode = tSODLog.SODLogCompanyCode
break by bSodLog.SODLogRole1Name
by bSodLog.SODLogResource1URI
on error undo, throw:
if first-of(bSODLog.SODLogResource1URI)
then vcMsg1 = vcMsg1 + chr(10) + bSodLog.SODLogRole1Name + " : "
+ bSODLog.SODLogResource1URI + " (" + bSODLog.SODLogCategory1Code + ")".
end.
vcMsg2 = "".
for each bSODLog where
bSODLog.tc_Status = "N" and
bSODLog.SODLogRule = {&SODLOG-RULE2} and
bSODLog.SODLogStatus = {&SODLOG-STATUS-CORRECTION} and
bSODLog.SODLogUsrLogin = tSODLog.SODLogUsrLogin and
bSODLog.SODLogCompanyCode = tSODLog.SODLogCompanyCode
break by bSodLog.SODLogRole2Name
by bSodLog.SODLogResource2URI
on error undo, throw:
if first-of(bSODLog.SODLogResource2URI)
then vcMsg2 = vcMsg2 + chr(10) + bSodLog.SODLogRole2Name + " : "
+ bSODLog.SODLogResource2URI + " (" + bSODLog.SODLogCategory2Code + ")".
end.
vcMsg = #T-59'SOD rule 2 conflict solved':255(234726539)T-59# + chr(10)
+ #T-55'User Login':15(8147)T-55# + " = " + tSODLog.SODLogUsrLogin + chr(10)
+ #T-18'Entity Code':24(8770)T-18# + " = " + tSODLog.SODLogCompanyCode + chr(10)
+ #T-35'Role 1 Name':20(733738256)T-35# + " : " + #T-88'Resource 1 URI':20(998717657)T-88# + " = " + vcMsg1 + chr(10)
+ #T-49'Role 2 Name':20(73458301)T-49# + " : " + #T-58'Resource 2 URI':20(117798426)T-58# + " = " + vcMsg2 + chr(10) + chr(10).
viMsg = length (vcMsg,"character").
if viMailMessageLength + viMsg > 30000
then do:
vcMailMessage = vcMailMessage + "[...]".
viMailMessageLength = 40000.
leave.
end.
vcMailMessage = vcMailMessage + vcMsg.
viMailMessageLength = viMailMessageLength + viMsg.
end.
end.
if tqSystSODMessaging.tcSystSODNotificationEmail <> ""
and viMailMessageLength > 0
then do:
<Q-13 run UserById (all) (Read) (NoCache)
(input viUsrId, (UsrId)
output dataset tqUserById) in BUser >
find first tqUserById no-error.
if available tqUserById
then vcFrom = tqUserById.tcUsrMailAddress.
<I-47 {bFcStartAndOpenInstance
&CLASS = "Mail"}>
<M-38 run Send
(input vcFrom (icFrom),
input tqSystSODMessaging.tcSystSODNotificationEmail (icTo),
input #T-37'SOD nofitication':255(980264803)T-37# (icSubject),
input vcMailMessage (icBody),
output viFcReturnSuper (oiReturnStatus)) in Mail>
<I-8 {bFcCloseAndStopInstance
&CLASS = "Mail"}>
/* Convert any errors from sending mail into a warning */
if viFcReturnSuper <> 0
then do:
oiReturnStatus = 1.
if can-find (first tFcMessages)
then for each tFcMessages:
tFcMessages.tcFcType = "W".
end.
else do:
<M-29 run SetMessage
(input #T-48'Cannot send e-mail to $1.':100(14)T-48# (icMessage),
input tqSystSODMessaging.tcSystSODNotificationEmail (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'W' (icType),
input 4 (iiSeverity),
input '' (icRowid),
input 'blf-471001':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSODLog>
end.
end.
end.
if tqSystSODMessaging.tcSystSODNotificationUser <> ""
and viMailMessageLength > 0
then do:
<I-1 {bFcStartAndOpenInstance
&CLASS = "PWorkInbox"}>
<M-81 run CreateMessage
(input vcUserLogin (icFrom),
input tqSystSODMessaging.tcSystSODNotificationUser (icTo),
input '' (icCc),
input '' (icBcc),
input #T-42'SOD nofitication':255(980264803)T-42# (icSubject),
input vcMailMessage (icContent),
input '' (icGuid),
input '' (icContentType),
output viFcReturnSuper (oiReturnStatus)) in PWorkInbox>
<I-74 {bFcCloseAndStopInstance
&CLASS = "PWorkInbox"}>
/* Convert any errors from workflow into a warning */
if viFcReturnSuper <> 0
then do:
oiReturnStatus = 1.
for each tFcMessages:
tFcMessages.tcFcType = "W".
end.
end.
end.
end.