|
@@ -23,9 +23,14 @@ namespace OASystem.API.OAMethodLib.Quartz.Jobs
|
|
|
_hubContext = hubContext;
|
|
|
}
|
|
|
|
|
|
- public Task Execute(IJobExecutionContext context)
|
|
|
+ /// <summary>
|
|
|
+ /// 任务消息推送
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="context"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task Execute(IJobExecutionContext context)
|
|
|
{
|
|
|
- _logger.LogInformation("调用任务消息推送 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ _logger.LogInformation("调用任务消息推送 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"【在线人数】:"+JsonConvert.SerializeObject(ServerHub.OnlineUser));
|
|
|
|
|
|
//在此处编写任务业务代码
|
|
|
#region 消息处理
|
|
@@ -138,19 +143,28 @@ namespace OASystem.API.OAMethodLib.Quartz.Jobs
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
- //查询需要提示的消息 Singlr
|
|
|
- string sql = string.Format(@"Select smra.Id,su.CnName As Issuer,sm.ReleaseTime,sm.Title,
|
|
|
+ string msg = string.Empty;
|
|
|
+ if (ServerHub.OnlineUser.Count > 0)
|
|
|
+ {
|
|
|
+ //查询需要提示的消息 Singlr
|
|
|
+ string sql = string.Format(@"Select smra.Id,su.CnName As Issuer,sm.ReleaseTime,sm.Title,
|
|
|
sm.Content,smra.ReadableUId,smra.IsRead,smra.CreateTime
|
|
|
From Sys_Message sm
|
|
|
Left Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
|
|
|
Left Join Sys_Users su On sm.IssuerId = su.Id
|
|
|
Where sm.IsDel = 0 And sm.Type = 6 And smra.IsRead = 0
|
|
|
Order By smra.ReadableUId,smra.CreateTime Desc");
|
|
|
- //var datas = _taskAllocationRep._sqlSugar.SqlQueryable<MessageReadAuthPushView>(sql).ToList();
|
|
|
+ var datas = _taskAllocationRep._sqlSugar.SqlQueryable<MessageReadAuthPushView>(sql).ToList();
|
|
|
+ msg = JsonConvert.SerializeObject(datas);
|
|
|
|
|
|
- _hubContext.Clients.All.SendAsync("ReceiveMessage", "系统通知", $"最新消息{DateTime.Now}");
|
|
|
+ //_hubContext.Clients.All.SendAsync("ReceiveMessage", "系统通知", $"最新消息{DateTime.Now}");
|
|
|
+ //推送给所有连接ID的第一条数据
|
|
|
+ }
|
|
|
|
|
|
- return Task.CompletedTask;
|
|
|
+ _logger.LogInformation("调用任务消息推送 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "【在线人数】:" + JsonConvert.SerializeObject(ServerHub.OnlineUser) +"【推送消息】:"+ msg);
|
|
|
+
|
|
|
+ await _hubContext.Clients.Clients(ServerHub.OnlineUser.Select(q => q.ConnectionId).ToList()).SendAsync("SendMessageResponse", $"最新消息{DateTime.Now}");
|
|
|
+ //return Task.CompletedTask;
|
|
|
}
|
|
|
}
|
|
|
}
|