public static void SendToGroup(Group group, string text, MessageType type, GroupMessageRecipientType recipientType = GroupMessageRecipientType.Members, Guid? authorId = null, DateTime? date = null) { if (!date.HasValue) date = DateTime.Now; var messageInfo = new MessageStruct { AuthorId = authorId, Text = text, Type = (byte)type, Date = date.Value }; Current.SendToGroup(group, messageInfo, recipientType); }
public void SendToGroup(Group group, MessageStruct messageInfo, GroupMessageRecipientType recipientType) { var recipientIdList = new List <Guid>(); if (recipientType.HasFlag(GroupMessageRecipientType.Members)) { recipientIdList.AddRange(DataService.PerThread.GroupMemberSet.Where( x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.Approved).Select(uig => uig.UserId) .ToList()); } if (recipientType.HasFlag(GroupMessageRecipientType.Moderators)) { recipientIdList.AddRange(DataService.PerThread.GroupMemberSet.Where( x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.Moderator).Select(uig => uig.UserId) .ToList()); } if (recipientType.HasFlag(GroupMessageRecipientType.NotApprovedUsers)) { recipientIdList.AddRange(DataService.PerThread.GroupMemberSet.Where( x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.NotApproved).Select(uig => uig.UserId) .ToList()); } recipientIdList = recipientIdList.Distinct().ToList(); if (recipientIdList.Count > 0) { foreach (var userId in recipientIdList) { var message = new MessageStruct { AuthorId = messageInfo.AuthorId, RecipientId = userId, Text = messageInfo.Text, Type = messageInfo.Type, Date = messageInfo.Date }; Send(message); } DataService.PerThread.SaveChanges(); } UserContextService.GroupMembersAbandon(group.Id); }
public static void SendToGroup(Group group, string text, MessageType type, GroupMessageRecipientType recipientType = GroupMessageRecipientType.Members, Guid?authorId = null, DateTime?date = null) { if (!date.HasValue) { date = DateTime.Now; } var messageInfo = new MessageStruct { AuthorId = authorId, Text = text, Type = (byte)type, Date = date.Value }; Current.SendToGroup(group, messageInfo, recipientType); }
public static void SendToGroup(Group group, MessageStruct messageInfo, GroupMessageRecipientType recipientType = GroupMessageRecipientType.Members) { Current.SendToGroup(group, messageInfo, recipientType); }
public void SendToGroup(Group group, MessageStruct messageInfo, GroupMessageRecipientType recipientType) { var recipientIdList = new List<Guid>(); if (recipientType.HasFlag(GroupMessageRecipientType.Members)) recipientIdList.AddRange(DataService.PerThread.GroupMemberSet.Where( x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.Approved).Select(uig => uig.UserId) .ToList()); if (recipientType.HasFlag(GroupMessageRecipientType.Moderators)) recipientIdList.AddRange(DataService.PerThread.GroupMemberSet.Where( x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.Moderator).Select(uig => uig.UserId) .ToList()); if (recipientType.HasFlag(GroupMessageRecipientType.NotApprovedUsers)) recipientIdList.AddRange(DataService.PerThread.GroupMemberSet.Where( x => x.GroupId == group.Id && x.State == (byte)GroupMemberState.NotApproved).Select(uig => uig.UserId) .ToList()); recipientIdList = recipientIdList.Distinct().ToList(); if (recipientIdList.Count > 0) { foreach (var userId in recipientIdList) { var message = new MessageStruct { AuthorId = messageInfo.AuthorId, RecipientId = userId, Text = messageInfo.Text, Type = messageInfo.Type, Date = messageInfo.Date }; Send(message); } DataService.PerThread.SaveChanges(); } UserContextService.GroupMembersAbandon(group.Id); }