Exemplo n.º 1
0
        /// <summary>
        /// Сообщения из ChatHelpDesc
        /// </summary>
        /// <param name="dialog">id диалога</param>
        /// <param name="type">тип сообщения</param>
        /// <param name="readState">прочитанные/непрочитанные сообщения</param>
        /// <returns></returns>
        List <Msg> GetChat2DescMessages(string dialog, string type, bool?readState)
        {
            bool             setRead        = Configer.IsSetRead();
            int              limit          = Configer.MessagesLimit();
            MessagesResponse messagesInCh2D = Messages.GetMessages(type, readState, limit, setRead, dialog);
            List <Msg>       messages       = new List <Msg>();

            foreach (var msg in messagesInCh2D.messages)
            {
                Client client = new Clients().GetClient(Int32.Parse(msg.clientID));
                //var transport = ChatHelpdescAgent.Messages.GetMessage(msg.ID).transport;
                Msg message = new Msg()
                {
                    ID            = msg.ID,
                    Name          = client.name,
                    Post          = client.extra_comment_2,
                    Company       = client.extra_comment_1,
                    text          = msg.text,
                    Transport     = msg.transport,
                    Phone         = client.phone,
                    dialog        = msg.dialog_id,
                    Date          = msg.created,
                    type          = msg.type,
                    assigned_name = client.assigned_name
                };
                messages.Add(message);
            }
            return(messages);
        }
Exemplo n.º 2
0
        private void _ParseResponse(string response)
        {
            try
            {
                if (response == null)
                {
                    _callback(new List <Dialog>());
                }
                else
                {
                    response = SerializeHelper.FixResponseArrayString(response);
                    MessagesResponse messagesResponse = SerializeHelper.Deserialise <MessagesResponse>(response);

                    List <Dialog> dialogs = new List <Dialog>();

                    if (messagesResponse.Messages != null)
                    {
                        foreach (var message in messagesResponse.Messages)
                        {
                            //if (message != null)
                            //    dialogs.Add(new Dialog(message, _friends, App.Current.EntityService.DefaultAvatar));
                        }
                    }

                    _callback(dialogs);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Parse response from DialogsGet failed." + ex.Message + "\n" + ex.StackTrace);
                _callback(new List <Dialog>());
            }
        }
Exemplo n.º 3
0
 public PaymentInitiationApiProfileHttpResponse(
     PaymentInitiationApiProfileResponse data,
     MessagesResponse messages)
 {
     Data     = data;
     Messages = messages;
 }
Exemplo n.º 4
0
        public MessagesResponse Read(long MessageID)
        {
            MessagesResponse response = new MessagesResponse();

            try
            {
                using (IDbConnection conn = GetConnection())
                {
                    response.message = conn.Get <Messages>(MessageID);
                    if (response.message != null)
                    {
                        response.Status      = true;
                        response.Description = "Successful";
                    }
                    else
                    {
                        response.Status      = false;
                        response.Description = "No data";
                    }
                }
            }
            catch (Exception ex)
            {
                response.Status      = false;
                response.Description = ex.Message;
            }
            return(response);
        }
Exemplo n.º 5
0
        private void _ParseResponse(string response)
        {
            try
            {
                if (response == null)
                {
                    _callback(new List <Message>());
                }
                else
                {
                    response = SerializeHelper.FixResponseArrayString(response);

                    MessagesResponse messages = SerializeHelper.Deserialise <MessagesResponse>(response);

                    if (messages.Messages != null)
                    {
                        _callback(messages.Messages);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Parse response from MessagesSearch failed: " + ex.Message);

                _callback(new List <Message>());
            }
        }
 private void MessagesHandler()
 {
     lock (_messages)
     {
         var messages = _messages[_clientNumber];
         _messages[_clientNumber] = new List <Message>();
         var response = new MessagesResponse(messages);
         SendReponse(response);
     }
 }
Exemplo n.º 7
0
 public static void ClassInitialize(TestContext context)
 {
     OkChannelResponse           = JsonLoader.LoadJson <ChannelResponse>(@"Channels/Data/channel_info.json");
     OkBaseResponse              = JsonLoader.LoadJson <BaseResponse>(@"Data/base.json");
     OkMessagesResponse          = JsonLoader.LoadJson <MessagesResponse>(@"Data/messages.json");
     OkChannelLeaveResponse      = JsonLoader.LoadJson <ChannelLeaveResponse>(@"Channels/Data/channel_leave.json");
     OkChannelListResponse       = JsonLoader.LoadJson <ChannelListResponse>(@"Channels/Data/channel_list.json");
     OkChannelSetPurposeResponse = JsonLoader.LoadJson <ChannelSetPurposeResponse>(@"Channels/Data/channel_setPurpose.json");
     OkChannelSetTopicResponse   = JsonLoader.LoadJson <ChannelSetTopicResponse>(@"Channels/Data/channel_setTopic.json");
 }
Exemplo n.º 8
0
        private ISmsSendResult ConvertToISmsSendResult(MessagesResponse response)
        {
            if (response == null || !response.Messages.Any())
            {
                return(new SmsBlissSentResult(SmsSentStatus.UnknownError)
                {
                    Description = "От сервера получен пустой ответ"
                });
            }
            MessageResponse messageResponse = response.Messages.First();

            return(new SmsBlissSentResult(messageResponse));
        }
 private void OnMessagesResponse(MessagesResponse response)
 {
     foreach (var message in response.Messages)
     {
         SendOutMessage(new NewsMessage
         {
             Source     = message.From,
             Headline   = message.Text,
             Story      = message.Text,
             ServerTime = message.Date?.ToDto() ?? CurrentTime.Convert(TimeHelper.Moscow),
         });
     }
 }
Exemplo n.º 10
0
        public async Task <IActionResult> GetMessagesAsync(
            [FromQuery] SearchOptions <MessagesSearchObject, Message> searchOptions,
            CancellationToken ct)
        {
            var messages = await _repository.GetAllAsync(searchOptions, ct);

            var response = new MessagesResponse
            {
                Value = messages.ToArray(),
                Self  = Link.ToCollection(nameof(GetMessagesAsync))
            };

            return(Ok(response));
        }
 private void OnMessagesResponse(MessagesResponse response)
 {
     foreach (var message in response.Messages)
     {
         SendOutMessage(new NewsMessage
         {
             Source     = message.From,
             Headline   = message.Text,
             Story      = message.Text,
             ServerTime = message.Date == null
                                         ? SessionHolder.CurrentTime.Convert(TimeHelper.Moscow)
                                         : message.Date.Value.ApplyTimeZone(TimeHelper.Moscow),
         });
     }
 }
Exemplo n.º 12
0
        public async Task <Response <MessagesResponse> > GetMesssgesForUser(string uid, params MessageType[] messageTypes)
        {
            if (!messageTypes.Any())
            {
                return(new Response <MessagesResponse>("must include at least one type."));
            }

            var result = await _getMessagesRepository.GetMessagesAsync();

            if (!result.Success)
            {
                return(new Response <MessagesResponse>("Error Getting Messages"));
            }

            var messages = result.Data;

            messages = await GetTargetedMesages(uid, messages);

            var messageTypesList = new Queue <MessageType>(messageTypes);


            var response = new MessagesResponse();

            var item = messageTypesList.Dequeue();

            response.Banner = GetPriorityMessageOfType(messages.Where(x => x.TYPE == item));
            if (messageTypesList.Count() != 0)
            {
                item = messageTypesList.Dequeue();
            }
            response.Popup = GetPriorityMessageOfType(messages.Where(x => x.TYPE == item));
            if (messageTypesList.Count() != 0)
            {
                item = messageTypesList.Dequeue();
            }
            response.Acknowledgment = GetPriorityMessageOfType(messages.Where(x => x.TYPE == item));
            if (messageTypesList.Count() != 0)
            {
                item = messageTypesList.Dequeue();
            }
            response.Marketing = messages.Where(x => x.TYPE == item).OrderByDescending(x => x.ENDDATE).Take(3).ToList();
            // Add more if needed.


            var messagesResponse = response;

            return(new Response <MessagesResponse>(messagesResponse));
        }
        public async Task <List <Message> > GetMessages(string userName, string token, string uuid)
        {
            if (userName == "" || token == "" || uuid == "")
            {
                return(new List <Message>());
            }

            MessagesResponse response = await awsHttpClient.GetMessagesAsync(new UIDInfoRequest()
            {
                Username = userName, Token = token, UID = uuid
            });

            if (response == null || response?.Messages == null)
            {
                return(new List <Message>());
            }

            return(response.Messages);
        }
Exemplo n.º 14
0
        private void NotifyBalanceChangeOnSendSuccessfully(MessagesResponse response)
        {
            if (response == null || !response.Messages.Any())
            {
                return;
            }
            MessageResponse messageResponse = response.Messages.First();

            if (messageResponse.Status == MessageResponseStatus.Accepted)
            {
                foreach (var item in response.Balances)
                {
                    if (!decimal.TryParse(item.BalanceValue, out decimal balance))
                    {
                        logger.Warn($"Невозможно преобразовать значение баланса из \"{item.BalanceValue}\" в число");
                        continue;
                    }
                    OnBalanceChange?.Invoke(this, new SmsBalanceEventArgs(ConvertBalanceType(item.Type), balance));
                }
            }
        }
Exemplo n.º 15
0
        private void AddMessage(MessagesResponse oMessage)
        {
            Panel oPanel = new Panel();

            oPanel.Width     = panelMessages.Width - 30;
            oPanel.Height    = 70;
            oPanel.BackColor = Color.White;

            //oPanel.Location = new Point(10,posYFinal);



            if (lastPanel == null)
            {
                oPanel.Location = new Point(10, 10);
            }
            else
            {
                oPanel.Location = new Point(10, lastPanel.Location.Y + lastPanel.Height + 10);
            }

            lastPanel = oPanel;
            //posYFinal += oPanel.Height + 10;
            panelMessages.Controls.Add(oPanel);
            panelMessages.ScrollControlIntoView(oPanel);

            // agregamos hijos al panel

            TextBox txtMessage = new TextBox();

            txtMessage.Text        = oMessage.Message;
            txtMessage.Location    = new Point(10, 10);
            txtMessage.Width       = oPanel.Width - 20;
            txtMessage.ReadOnly    = true;
            txtMessage.BorderStyle = BorderStyle.None;

            oPanel.Controls.Add(txtMessage);
        }
 public BankClientProfileHttpResponse(BankClientProfileResponse data, MessagesResponse messages)
 {
     Data     = data;
     Messages = messages;
 }
Exemplo n.º 17
0
 public PaymentResponse(MessagesResponse messages, OBWriteDomesticResponse4Data data)
 {
     Messages = messages;
     Data     = data;
 }
Exemplo n.º 18
0
 public PostSoftwareStatementProfileResponse(MessagesResponse messages)
 {
     Messages = messages;
 }
Exemplo n.º 19
0
 public DomesticPaymentConsentHttpResponse(MessagesResponse messages, PaymentConsentResponse data)
 {
     Messages = messages;
     Data     = data;
 }
Exemplo n.º 20
0
 public static void ClassInitialize(TestContext context)
 {
     OkBaseResponse     = JsonLoader.LoadJson <BaseResponse>(@"Data/base.json");
     OkGroupResponse    = JsonLoader.LoadJson <GroupResponse>(@"Groups/Data/group_create.json");
     OkMessagesResponse = JsonLoader.LoadJson <MessagesResponse>(@"Data/messages.json");
 }