Refactored email service to use in-house RevDotNet solution. Added logging. Replaced sending of OI note on email send failure with mona critical status instead.
This commit is contained in:
@ -16,19 +16,27 @@ COMPILE FUNCTION obj_Notes(Method,Parms)
|
||||
|
||||
|
||||
DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, NextKey, SRP_Send_Mail, obj_Calendar, Database_Services, SRP_Stopwatch
|
||||
DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, RList, ErrMsg, obj_Notes_Sent, Btree.Extract, Send_Info, obj_Notes
|
||||
DECLARE SUBROUTINE Obj_Post_Log, SRP_Stopwatch, Notes_Services
|
||||
DECLARE FUNCTION Email_Services, Environment_Services, Logging_Services
|
||||
DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, RList, ErrMsg, obj_Notes_Sent, Btree.Extract, Send_Info, obj_Notes
|
||||
DECLARE SUBROUTINE Obj_Post_Log, SRP_Stopwatch, Notes_Services, Mona_Services, Logging_Services
|
||||
|
||||
$INSERT MSG_EQUATES
|
||||
$INSERT NOTES_EQU
|
||||
$INSERT NOTE_PTRS_EQU
|
||||
$INSERT LSL_USERS_EQU
|
||||
$INSERT EMAIL_BOX_EQUATES
|
||||
|
||||
$INSERT LOGICAL
|
||||
$INSERT RLIST_EQUATES
|
||||
$INSERT APP_INSERTS
|
||||
$INSERT SRPMail_Inserts
|
||||
|
||||
EQU TARGET_ACTIVELIST$ TO 5
|
||||
LogDate = Oconv(Date(), 'D4/')
|
||||
LogTime = Oconv(Time(), 'MTS')
|
||||
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||
|
||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\EmailService'
|
||||
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' EmailService.csv'
|
||||
Headers = 'Logging DTM' : @FM : 'Error'
|
||||
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
||||
|
||||
ErrTitle = 'Error in Stored Procedure "obj_Notes"'
|
||||
ErrorMsg = ''
|
||||
@ -350,7 +358,6 @@ ForwardEMail:
|
||||
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
||||
ServiceKeyID = 'Obj_Notes*ForwardEMail'
|
||||
Lock hSysLists, ServiceKeyID then
|
||||
|
||||
rv = Set_Status(0)
|
||||
RList('SELECT EMAIL_BOX BY NOTE_KEY', 5, '', '', '')
|
||||
Done = 0
|
||||
@ -365,59 +372,22 @@ ForwardEMail:
|
||||
eMailText = eMailBoxRec<EMAIL_BOX_EMAIL_TEXT$>
|
||||
eMailHeader = eMailBoxRec<EMAIL_BOX_EMAIL_HEADER$>
|
||||
OISentFrom = eMailBoxRec<EMAIL_BOX_FROM_USER$>
|
||||
|
||||
|
||||
ConfigFile = ''
|
||||
ConfigFile<1> = SendUsing_Port$
|
||||
ConfigFile<2> = ''
|
||||
ConfigFile<3> = 25 ;* Server port
|
||||
ConfigFile<4> = 'smtp.intra.infineon.com' ;* Infinfeon Mail Server for internal recipents
|
||||
ConfigFile<5> = Yes$ ;* Authenticate
|
||||
ConfigFile<6> = 'oinotify@infineon.com' ;* Username (IFX)
|
||||
ConfigFile<7> = 'oinotify1' ;* Password
|
||||
ConfigFile<8> = No$ ;* Use SSL
|
||||
|
||||
SentFrom = 'oinotify@infineon.com'
|
||||
SendTo = eMailAddr
|
||||
|
||||
SentFrom = 'oinotify@infineon.com'
|
||||
SendTo = eMailAddr
|
||||
IF OISentFrom = 'OI_ERROR' THEN SendTo := XLATE('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
|
||||
Message = ''
|
||||
Message<1> = eMailHeader ; // Subject
|
||||
Message<2> = SentFrom ; // From (email address)
|
||||
Message<3> = SendTo ; // Send to (email address)
|
||||
Message<5> = '' ; // Blind Carbon Copy (email address)
|
||||
Message<6> = '' ; // Reply To (email address)
|
||||
Message<7> = 'TEXT' ; // Content Type (TEXT or HTML)
|
||||
Message<8> = eMailText ; // Content / Body
|
||||
Message<9> = '' ; // Attachment(s) (path to file name(s))
|
||||
|
||||
MsgSent = SRP_Send_Mail(Message, ConfigFile)
|
||||
|
||||
IF MsgSent NE True$ THEN
|
||||
Set_Status(0)
|
||||
obj_Tables('UnlockRec',mbParms)
|
||||
|
||||
Recipients = XLATE('NOTIFICATION', 'FI_SUPPORT', 'USER_ID', 'X')
|
||||
SentFrom = 'FI Support'
|
||||
Subject = 'OpenInsight eMail Server Error'
|
||||
Message = 'Unable to send email.' : \0D0A\
|
||||
Message := 'Sent From: ' : SentFrom : \0D0A\
|
||||
Message := 'Send To: ' : SendTo : \0D0A\
|
||||
Message := 'Original Subject: ' : eMailHeader : \0D0A\
|
||||
Message := 'Original Message: ' : eMailText : \0D0A\
|
||||
Message := '========================================' : \0D0A\
|
||||
Message := 'Error Message: ' : MsgSent
|
||||
AttachWindow = ''
|
||||
AttachKey = ''
|
||||
SendToGroup = ''
|
||||
|
||||
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
||||
obj_Notes('Create',Parms)
|
||||
END
|
||||
Success = Email_Services('SendEmail', SentFrom, SendTo, eMailHeader, eMailText)
|
||||
If Success then
|
||||
Mona_Services('SendBufferedStatus', 'OPENINSIGHT_MES_OP_FE', 'Email-Service', 'ok')
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDtm
|
||||
LogData<2> = Error_Services('GetMessage')
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
Mona_Services('SendBufferedStatus', 'OPENINSIGHT_MES_OP_FE', 'Email-Service', 'critical')
|
||||
end
|
||||
obj_Tables('DeleteRec',mbParms)
|
||||
end
|
||||
REPEAT
|
||||
|
||||
Unlock hSysLists, ServiceKeyID else Null
|
||||
end
|
||||
|
||||
@ -673,3 +643,4 @@ BulkCreate:
|
||||
|
||||
RETURN
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user