Ejemplo n.º 1
0
        public async Task <IActionResult> PostContextAsync([FromBody] Catalog.Models.Balance balance)
        {
            try
            {
                if (Security.User.TryGetValue(balance.Kiwoom, out Catalog.Models.User user))
                {
                    user.Balance[balance.Code] = balance;

                    if (hub is not null && user.Id.Length > 0)
                    {
                        if (user.Id.Length == 1)
                        {
                            await hub.Clients.User(user.Id[0]).SendAsync(message, balance);
                        }

                        else
                        {
                            await hub.Clients.Users(user.Id).SendAsync(message, balance);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{GetType()}\n{ex.Message}\n{nameof(this.PostContextAsync)}");
            }
            return(Ok(balance.Name));
        }
Ejemplo n.º 2
0
        public async Task PostContextAsync([FromBody] Catalog.Models.Balance balance)
        {
            if (hub is not null)
            {
                await hub.Clients.All.SendAsync(message, balance);
            }

            else
            {
                Base.SendMessage(message, balance.Name, GetType());
            }
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> PostContextAsync([FromBody] Catalog.Models.Balance balance)
 {
     if (hub is not null)
     {
         try
         {
             await hub.Clients.All.SendAsync(message, balance);
         }
         catch (Exception ex)
         {
             Base.SendMessage(GetType(), ex.StackTrace);
         }
     }
     return(Ok(balance.Name));
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> PostContextAsync([FromBody] Catalog.Models.Balance balance)
        {
            try
            {
                if (Security.User.TryGetValue(balance.Kiwoom, out Catalog.Models.User user))
                {
                    user.Balance[balance.Code] = balance;

                    if (hub is not null)
                    {
                        foreach (var email in from o in context.User.AsNoTracking() where o.Kiwoom.Equals(balance.Kiwoom) select o.Email)
                        {
                            await hub.Clients.User(context.Users.AsNoTracking().First(o => o.Email.Equals(email)).Id).SendAsync(message, balance);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{GetType()}\n{ex.Message}\n{nameof(this.PostContextAsync)}");
            }
            return(Ok(balance.Name));
        }
Ejemplo n.º 5
0
 public async Task SendBalanceMessage(Catalog.Models.Balance balance) => await Clients.All.SendAsync("ReceiveBalanceMessage", balance);
Ejemplo n.º 6
0
 public async Task SendBalanceMessage(string user, Catalog.Models.Balance balance) => await Clients.User(user).SendAsync("ReceiveBalanceMessage", balance);