コード例 #1
0
        public int UpdateMessageId(string business_id, [FromQuery] string access_token)
        {
            int count = 0;

            if (access_token != "@bazavietnam")
            {
                return(count);
            }
            var list = _messageService.All(business_id, new Paging {
                Limit = 10
            }).Result.ToList();

            for (int i = 0; i < list.Count(); i++)
            {
                var t   = list[i];
                var id  = t.id;
                var tid = t.thread_id;
                t.id = MessageService.FormatId(business_id, t.ext_id);
                var d    = string.IsNullOrWhiteSpace(t.thread_id) ? null : t.thread_id.Split('_');
                var tidn = d != null && d.Length > 0 ? d.Last() : "";
                t.thread_id = ThreadService.FormatId(business_id, tidn);
                if (t.timestamp > 9999999999 || id != t.id || t.timestamp < 99999999)
                {
                    count++;
                    if (t.timestamp > 9999999999)
                    {
                        t.timestamp = t.timestamp / 1000;
                    }
                    if (t.timestamp < 99999999)
                    {
                        t.timestamp = t.timestamp * 1000;
                    }

                    var job = BackgroundJob.Enqueue <MessageService>(x => x.CopyMessageToRealtimeDB(business_id, t.id, t.timestamp));

                    BackgroundJob.ContinueWith <MessageService>(job, x => x.Delete(business_id, id));

                    if (!string.IsNullOrWhiteSpace(tid))
                    {
                        BackgroundJob.ContinueWith <MessageService>(job, x => x.Delete(business_id, tid, id));
                    }
                }
            }

            return(count);
        }
コード例 #2
0
ファイル: MessageController.cs プロジェクト: excleake/ChatApp
        public IActionResult All(int chatId)
        {
            if (chatId == 0)
            {
                return(BadRequest());
            }

            var result = _messageService.All(chatId);

            return(Ok(result));
        }
コード例 #3
0
        public int FindPhoneNumber(string business_id, [FromQuery] string customer_id, [FromQuery] string access_token, [FromQuery] int limit = 100)
        {
            int count = 0;

            if (access_token != "@bazavietnam")
            {
                return(count);
            }
            if (!string.IsNullOrWhiteSpace(customer_id))
            {
                var customer = _customerService.GetById(business_id, customer_id);
                if (customer != null)
                {
                    List <string> phoneList = customer.phone_list == null ? new List <string>() : customer.phone_list;
                    foreach (var t in _messageService.GetByCustomer(business_id, customer_id, new Paging {
                        Limit = limit
                    }).Result.OrderBy(m => m.timestamp))
                    {
                        if (!string.IsNullOrWhiteSpace(t.message) && t.sender_ext_id != t.channel_ext_id)
                        {
                            phoneList.AddRange(Core.Helpers.CommonHelper.FindPhoneNumbers(t.message));
                        }
                    }
                    var lastPhoneNumber = phoneList.Count() > 0 ? phoneList.Last() : customer.phone;
                    if (!string.IsNullOrWhiteSpace(lastPhoneNumber))
                    {
                        count++;
                        _customerService.UpdatePhoneNumber(business_id, customer_id, phoneList, lastPhoneNumber);
                    }
                }
            }
            else
            {
                var customers = _customerService.SearchCustomers(business_id, "", "", "", "", "", new Paging {
                    Limit = limit
                }).Result.ToDictionary(a => a.id, b => b.phone_list == null ? new List <string>() : b.phone_list);

                foreach (var t in _messageService.All(business_id, new Paging {
                    Limit = limit
                }).Result)
                {
                    if (t.sender_ext_id != t.channel_ext_id && !string.IsNullOrWhiteSpace(t.customer_id) && !string.IsNullOrWhiteSpace(t.message) && customers.ContainsKey(t.customer_id))
                    {
                        var newPhoneList = Core.Helpers.CommonHelper.FindPhoneNumbers(t.message);
                        if (newPhoneList.Count() > 0)
                        {
                            //tam bo
                            // customers[t.customer_id] = customers[t.customer_id].Union(newPhoneList);
                        }
                    }
                }
                foreach (var c in customers)
                {
                    if (c.Value != null && c.Value.Count() > 0)
                    {
                        count++;
                        var lastPhoneNumber = c.Value.Last();
                        _customerService.UpdatePhoneNumber(business_id, c.Key, c.Value, lastPhoneNumber);
                        //var jobId = BackgroundJob.Enqueue<CustomerService>(x => x.UpdatePhoneNumber(business_id, customer_id, c.Value, lastPhoneNumber));
                    }
                }
            }
            return(count);
        }
コード例 #4
0
 public async Task <ActionResult <List <MessageResponseModel> > > All() =>
 await messageService.All();
コード例 #5
0
 public async Task <ICollection <Message> > All()
 {
     return(await _messageService.All());
 }
コード例 #6
0
 public IActionResult GetAll()
 {
     return(new ObjectResult(messageService.All()));
 }
コード例 #7
0
        public async Task <IActionResult> All()
        {
            var result = await service.All();

            return(View(result));
        }
コード例 #8
0
 public ActionResult <IEnumerable <MessageViewModel> > All()
 {
     return(messageService.All());
 }