Ejemplo n.º 1
0
        public async Task <ActionResult <List <MessageVm> > > GetMessageHistory(MessageNotifyDto model)
        {
            try
            {
                var service  = _conversationMsgAppServiceFactory(model.TargetId.ToGuid());
                var messages = await service.GetOldMessagesAsync(new GetOldMessagesInput()
                {
                    Id          = model.TargetId.ToGuid(),
                    OldestMsgId = model.LatestMsgId,
                    //Type = Enum.Parse<ConversationType>(model.TargetCategory.ToString())
                });

                var tasks = new List <Task <MessageVm> >();
                foreach (var msg in messages)
                {
                    tasks.Add(BuildMessageVmAsync(msg));
                }
                await Task.WhenAll(tasks);

                return(tasks.Select(o => o.Result).ToList());
            }
            catch (Exception ex)
            {
                return(BadRequest(LogError(_logger, ex)));
            }
        }
Ejemplo n.º 2
0
        public async Task <List <MessageVm> > GetMessageHistryAsync(MessageNotifyDto parma, string accessToken)
        {
            this._httpClient.SetBearerToken(accessToken);
            var response = await this._httpClient.PostAsync(BizUrlConfig.GetMessageHistory_POST,
                                                            new StringContent(JsonConvert.SerializeObject(parma), Encoding.UTF8, "application/json"));

            var str = await response.Content.ReadAsStringAsync();

            var response_model =
                JsonConvert.DeserializeObject <List <MessageVm> >(str);

            return(response_model);
        }
Ejemplo n.º 3
0
        public async Task PushMsgNotifyAsync(MessageNotifyDto dto)
        {
            var listConnectionIdsWrap = await StateManager.TryGetStateAsync <List <string> >(ConnectionIdListPropertyName);

            if (listConnectionIdsWrap.HasValue && listConnectionIdsWrap.Value.Count > 0)
            {
                await ActorService.EventBus.Send(new SendMessageNotify
                {
                    UserId   = this.GetActorId().GetGuidId(),
                    Notifies = new List <MessageNotifyDto> {
                        dto
                    }
                });
            }
            else
            {
                var listPushNotify = await StateManager.GetOrAddStateAsync(
                    MessageListPropertyName, new List <MessageNotifyDto>());

                listPushNotify.Add(dto);
                await StateManager.SetStateAsync(MessageListPropertyName, listPushNotify);
            }
        }