Exemplo n.º 1
0
        protected override Task OnConnected(IRequest request, string connectionId)
        {
            Groups.Add(connectionId, _groupName);

            _iSysSignalROnlineService.Remove(a => a.GroupId == GroupId && a.UserId == _iUserInfo.UserId && a.EnterpriseId == _iUserInfo.EnterpriseId);

            //添加新的登录信息
            _iSysSignalROnlineService.Add(new SysSignalROnline()
            {
                ConnectionId = connectionId, GroupId = GroupId, UserId = _iUserInfo.UserId, EnterpriseId = _iUserInfo.EnterpriseId
            });

            return(base.OnConnected(request, connectionId));
        }
Exemplo n.º 2
0
        public override Task OnConnected()
        {
            var item = _iMessageService.GetAll(a => a.SysUserId == _iUserInfo.UserId).Count(a => !a.Read);

            if (item > 0)
            {
                Clients.Client(Context.ConnectionId).add("您有" + item + "条新信息");
            }

            var date = DateTime.Now.AddDays(-1);

            _iSysSignalROnlineService.Remove(a => a.CreatedDate < date && a.GroupId == GroupId && a.UserId == _iUserInfo.UserId && a.EnterpriseId == _iUserInfo.EnterpriseId);

            _iSysSignalROnlineService.Add(new SysSignalROnline {
                ConnectionId = Context.ConnectionId, GroupId = GroupId, UserId = _iUserInfo.UserId, EnterpriseId = _iUserInfo.EnterpriseId
            });
            return(base.OnConnected());
        }