123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using Microsoft.AspNetCore.SignalR;
- using OASystem.API.OAMethodLib.Hubs;
- using OASystem.API.OAMethodLib.Quartz.Business;
- using OASystem.Infrastructure.Repositories.PersonnelModule;
- using Quartz;
- namespace OASystem.API.OAMethodLib.Quartz.Jobs
- {
-
-
-
-
- public class TaskNewsFeedJob : IJob
- {
- private readonly ILogger<TaskNewsFeedJob> _logger;
- private readonly TaskAllocationRepository _taskAllocationRep = AutofacIocManager.Instance.GetService<TaskAllocationRepository>();
- private readonly IHubContext<ServerHub> _hubContext;
- public TaskNewsFeedJob(ILogger<TaskNewsFeedJob> logger, TaskAllocationRepository taskAllocationRep, IHubContext<ServerHub> hubContext)
- {
- _logger = logger;
- _taskAllocationRep = taskAllocationRep;
- _hubContext = hubContext;
- }
-
-
-
-
-
- public async Task Execute(IJobExecutionContext context)
- {
-
-
- #region 消息处理
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- string msg = string.Empty;
- if (ServerHub.OnlineUser.Count > 0)
- {
-
- 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();
- msg = JsonConvert.SerializeObject(datas);
-
-
- }
- _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}");
-
- }
- }
- }
|