EventInbox 在线发送消息与Email给用户
#server static void markEmailAs(SysEmailItemId _emailItemId,SysEmailStatus _emailStatus, boolean _increaseRetryCount = false)
#{
# SysOutgoingEmailTable outgoingEmailTable;
# SAG_BanKIntegrationLog logs;
# EventInbox inbox;
# EventInboxId inboxId;
# ;
# ttsbegin;
#
# select forupdate outgoingEmailTable
# index hint EmailIdx
# where outgoingEmailTable.EmailItemId == _emailItemId;
#
# outgoingEmailTable.Status = _emailStatus;
#
# if (_emailStatus != SysEmailStatus::Executing)
# {
# outgoingEmailTable.LatestStatusChangeDateTime = DateTimeUtil::getSystemDateTime();
# }
#
# if (_increaseRetryCount)
# outgoingEmailTable.RetryNum = outgoingEmailTable.RetryNum + 1;
#
# outgoingEmailTable.update();
#
# ttscommit;
#
# ttsbegin;
# if(_emailStatus != SysEmailStatus::Unsent)
# {
# logs = logs.find(outgoingEmailTable.SAG_LogRecId);
# if(logs.EmailRec == outgoingEmailTable.RecId)
# {
# logs.Status = _emailStatus;
# logs.EmailUpdateDT = DateTimeUtil::getSystemDateTime();
# logs.update();
# }
# }
# ttscommit;
# //send alert to user
# ttsbegin;
# if((_emailStatus == SysEmailStatus::Failed) && outgoingEmailTable.SAG_LogRecId)
# {
# inboxId = EventInbox::nextEventId();
# inbox.initValue();
# inbox.ShowPopup = NoYes::Yes;
# inbox.Subject = "@HFM1708";
# inbox.Message = outgoingEmailTable.Origin;
# inbox.AlertedFor = "@HFM1709";
# inbox.SendEmail = NoYes::No;
# inbox.UserId = outgoingEmailTable.UserId;
# inbox.TypeId = classnum(EventType);
# inbox.AlertTableId = TableNum(SysOutgoingEmailTable);
# inbox.AlertFieldId = fieldNum(SysOutgoingEmailTable ,Status);
# inbox.TypeTrigger = EventTypeTrigger::FieldChanged;
# inbox.CompanyId = CurExt();
# inbox.InboxId = inboxId;
# inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
# inbox.insert();
# }
# ttscommit;
#}
ENDSOURCE