public void Run(object source, ElapsedEventArgs elapsedEventArgs) { try { _sysUserLogService.DeleteExpiredData(); _unitOfWork.CommitAsync(); _sysLogService.Add(new SysLog { Level = "Info", Message = "成功清理过期用户日志。" }); } catch (Exception e) { _sysLogService.Add(new SysLog { Level = "Error", Message = e.Message }); } try { _sysLogService.DeleteExpiredData(); _sysLogService.Add(new SysLog { Level = "Info", Message = "成功清理过期系统日志。" }); } catch (Exception e) { _sysLogService.Add(new SysLog { Level = "Error", Message = e.Message }); } try { int sent = _iSysMailService.SendMail(); _unitOfWork.Commit(); _sysLogService.Add(new SysLog { Level = "Info", Message = "邮件发送成功" + sent + "封。" }); } catch (Exception e) { _sysLogService.Add(new SysLog { Level = "Error", Message = e.Message }); } }
public async Task Run(object source, ElapsedEventArgs elapsedEventArgs) { //清理过期用户操作日志 _sysUserLogService.DeleteExpiredData(); await _unitOfWork.CommitAsync(); }