public async Task <DataFileSystem> ExportSystem(PKSystem system) { // Export members var members = new List <DataFileMember>(); var pkMembers = await _members.GetBySystem(system); // Read all members in the system var messageCounts = await _members.MessageCountsPerMember(system); // Count messages proxied by all members in the system members.AddRange(pkMembers.Select(m => new DataFileMember { Id = m.Hid, Name = m.Name, DisplayName = m.DisplayName, Description = m.Description, Birthday = m.Birthday != null ? Formats.DateExportFormat.Format(m.Birthday.Value) : null, Pronouns = m.Pronouns, Color = m.Color, AvatarUrl = m.AvatarUrl, Prefix = m.Prefix, Suffix = m.Suffix, Created = Formats.TimestampExportFormat.Format(m.Created), MessageCount = messageCounts.Where(x => x.Member.Equals(m.Id)).Select(x => x.MessageCount).FirstOrDefault() })); // Export switches var switches = new List <DataFileSwitch>(); var switchList = await _switches.GetTruncatedSwitchList(system, Instant.FromDateTimeUtc(DateTime.MinValue.ToUniversalTime()), SystemClock.Instance.GetCurrentInstant()); switches.AddRange(switchList.Select(x => new DataFileSwitch { Timestamp = Formats.TimestampExportFormat.Format(x.TimespanStart), Members = x.Members.Select(m => m.Hid).ToList() // Look up member's HID using the member export from above })); return(new DataFileSystem { Id = system.Hid, Name = system.Name, Description = system.Description, Tag = system.Tag, AvatarUrl = system.AvatarUrl, TimeZone = system.UiTz, Members = members, Switches = switches, Created = Formats.TimestampExportFormat.Format(system.Created), LinkedAccounts = (await _systems.GetLinkedAccountIds(system)).ToList() }); }
public async Task <DataFileSystem> ExportSystem(PKSystem system) { var members = new List <DataFileMember>(); foreach (var member in await _members.GetBySystem(system)) { members.Add(await ExportMember(member)); } var switches = new List <DataFileSwitch>(); foreach (var sw in await _switches.GetSwitches(system, 999999)) { switches.Add(await ExportSwitch(sw)); } return(new DataFileSystem { Id = system.Hid, Name = system.Name, Description = system.Description, Tag = system.Tag, AvatarUrl = system.AvatarUrl, TimeZone = system.UiTz, Members = members, Switches = switches, Created = Formats.TimestampExportFormat.Format(system.Created), LinkedAccounts = (await _systems.GetLinkedAccountIds(system)).ToList() }); }
public async Task <ActionResult <IEnumerable <PKMember> > > GetMembers(string hid) { var system = await _systems.GetByHid(hid); if (system == null) { return(NotFound("System not found.")); } var members = await _members.GetBySystem(system); return(Ok(members)); }
public async Task <IActionResult> OnGet(string systemId) { System = await _systems.GetByHid(systemId); if (System == null) { return(NotFound()); } Members = await _members.GetBySystem(System); return(Page()); }
public async Task MemberShortList(Context ctx, PKSystem system) { if (system == null) { throw Errors.NoSystemError; } var members = await _members.GetBySystem(system); var embedTitle = system.Name != null ? $"Members of {system.Name.SanitizeMentions()} (`{system.Hid}`)" : $"Members of `{system.Hid}`"; await ctx.Paginate <PKMember>( members.OrderBy(m => m.Name.ToLower()).ToList(), 25, embedTitle, (eb, ms) => eb.Description = string.Join("\n", ms.Select((m) => { if (m.HasProxyTags) { return($"[`{m.Hid}`] **{m.Name.SanitizeMentions()}** *({m.ProxyString.SanitizeMentions()})*"); } return($"[`{m.Hid}`] **{m.Name.SanitizeMentions()}**"); })) ); }