Beispiel #1
0
            public async Task <object> Handle(Users.Query cmd, CancellationToken cancellationToken)
            {
                var users = await _storage.GetUserEmailIdPairs();

                var result = new List <UserView>();

                foreach (var(email, userId) in users)
                {
                    var guid = new System.Guid(userId);
                    var user = await _storage.GetUser(guid);

                    var options = await _portfolio.GetOwnedOptions(guid);

                    var notes = await _portfolio.GetNotes(guid);

                    var stocks = await _portfolio.GetStocks(guid);

                    var alerts = await _alerts.GetAlerts(guid);

                    var u = new UserView(user, stocks, options, notes, alerts);

                    result.Add(u);
                }

                return(result.OrderByDescending(u => u.LastLogin));
            }
Beispiel #2
0
            public async Task <Unit> Handle(Command cmd, CancellationToken cancellationToken)
            {
                var users = await _storage.GetUserEmailIdPairs();

                foreach (var u in users)
                {
                    if (!cmd.Everyone.Value && u.Item1 != "*****@*****.**")
                    {
                        Console.WriteLine("Skipping user " + u.Item1);
                        continue;
                    }

                    try
                    {
                        await ProcessUser(u);
                    }
                    catch (Exception error)
                    {
                        Console.Error.WriteLine(
                            "Failed to generate review for " + u.Item1 + " with error: " + error
                            );
                    }
                }

                return(new Unit());
            }
Beispiel #3
0
        private async Task ScanSells()
        {
            var pairs = await _accounts.GetUserEmailIdPairs();

            foreach (var p in pairs)
            {
                try
                {
                    await ProcessUser(p);
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Failed to process 30 day check for {p.email}: {ex}");
                }
            }
        }
        public async Task <ActionResult> ActiveAccountsAsync()
        {
            var users = await _storage.GetUserEmailIdPairs();

            var total    = 0;
            var loggedIn = 0;

            var tableHtml = new StringBuilder();

            tableHtml.Append(@"
            <table>
                <tr>
                    <th>Email</th>
                    <th>User Id</th>
                    <th>Last Login</th>
                    <th>Verified</th>
                    <th>Level</th>
                    <th>Stocks</th>
                    <th>Options</th>
                    <th>Notes</th>
                </tr>");

            foreach (var(email, userId) in users)
            {
                tableHtml.AppendLine($"<tr>");
                tableHtml.Append($"<td>{email}</td>");
                tableHtml.Append($"<td>{userId}</td>");

                var guid = new System.Guid(userId);

                var user = await _storage.GetUser(guid);

                tableHtml.Append($"<td>{user?.LastLogin?.ToString()}</td>");
                tableHtml.Append($"<td>{user?.Verified}</td>");
                tableHtml.Append($"<td>{user?.SubscriptionLevel}</td>");

                var options = await _portfolio.GetOwnedOptions(guid);

                var notes = await _portfolio.GetNotes(guid);

                var stocks = await _portfolio.GetStocks(guid);

                tableHtml.Append($"<td>{stocks.Count()}</td>");
                tableHtml.Append($"<td>{options.Count()}</td>");
                tableHtml.Append($"<td>{notes.Count()}</td>");

                tableHtml.AppendLine("</tr>");

                total++;
                if (user != null && user.LastLogin.HasValue)
                {
                    loggedIn++;
                }
            }

            tableHtml.AppendLine("</table>");

            var body = $@"<html>
                <body>
                    <h3>Users: {total}</h3>
                    <h4>Logged In: {loggedIn}</h4>
                    ${tableHtml.ToString()}
                </body>
            </html>";

            return(new ContentResult {
                Content = body,
                ContentType = "text/html"
            });
        }