public GroupService(XueLeMeContext context, NotificationService notificationService, IHubContext <NotificationHub> hubContext, IConnectionService connectionService) { Context = context; NotificationService = notificationService; HubContext = hubContext; ConnectionService = connectionService; }
public MailAccountService(XueLeMeContext context, IMailService mailService, ISecurityService securityService, IConfiguration configuration) { Context = context; MailService = mailService; SecurityService = securityService; Configuration = configuration; }
public NotificationService( IConnectionService connectionService, XueLeMeContext context, IHubContext <NotificationHub> hubContext ) { ConnectionService = connectionService; Context = context; HubContext = hubContext; }
public async Task <string> SendMessage(int groupId, int type, string content) { bool hasUserId = ConnectionIdToUserId.TryGetValue(Context.ConnectionId, out int userId); if (!hasUserId) { return("当前未确客户端用户身份"); } if (type == (int)ChatMessage.MessageTypeEnum.Image && !CheckImageExist(content)) { return("找不到消息的图片资源,请先上传图片资源"); } var group = await GroupService.GroupFromId(groupId); if (group.State != ServiceResultEnum.Exist) { return(group.Detail); } var user = await AccountService.UserFromId(userId); if (user.State != ServiceResultEnum.Exist) { return(user.Detail); } var userInGroup = await GroupService.HasMemberShip(user.ExtraData, group.ExtraData); if (!userInGroup.ExtraData) { return(userInGroup.Detail); } var targets = Clients.Group(groupId.ToString()); var message = new ChatMessage { MessageOrImageKey = content, Type = (ChatMessage.MessageTypeEnum)type }; ChatRecord chatRecord = new ChatRecord { Sender = user.ExtraData, CreatedTime = DateTime.Now, Group = group.ExtraData, Message = message }; XueLeMeContext.ChatMessages.Add(message); XueLeMeContext.ChatRecords.Add(chatRecord); await XueLeMeContext.SaveChangesAsync(); await targets.SendAsync("OnReceiveMessage", userId, groupId, type, content, chatRecord.CreatedTime); return("发送成功"); }
public DbFileService(XueLeMeContext xueLeMeContext, MD5Service mD5Service, ILogger <DbFileService> logger) { Context = xueLeMeContext; MD5Service = mD5Service; Logger = logger; }
public TagService(XueLeMeContext context) { Context = context; }
public TopicService(XueLeMeContext context, TagService tagService, NotificationService notificationService) { Context = context; TagService = tagService; NotificationService = notificationService; }
public AccountService(XueLeMeContext context) { Context = context; }
public WeatherForecastController(IMailService mainService, XueLeMeContext context, IHubContext <ChatHub> hubContext) { MainService = mainService; Context = context; HubContext = hubContext; }
public ChatHub(XueLeMeContext xueLeMeContext, GroupService groupService, AccountService accountService) { XueLeMeContext = xueLeMeContext; GroupService = groupService; AccountService = accountService; }
public ChatRecordService(XueLeMeContext context) { Context = context; }
public NotificationHub(IConnectionService connectionService, XueLeMeContext xueLeMeContext, ILogger <NotificationHub> logger) { ConnectionService = connectionService; XueLeMeContext = xueLeMeContext; Logger = logger; }