Exemplo n.º 1
0
        MessagesPack GetInboxMessages(string currentUsername, MessageTypes messageTypes, Byte[] recentVersion)
        {
            List <Message> recievedMessages = new List <Message>();
            Message        result;
            bool           deleted = messageTypes.HasFlag(MessageTypes.Deleted);
            bool           viewed  = messageTypes.HasFlag(MessageTypes.Viewed);
            ///Ищем в получателях
            List <Recipient> recipients = RecipientGateway.Select(currentUsername, currentUsername, deleted, viewed);

            foreach (Recipient item in recipients)
            {
                result = MessageGateway.Select((int)item.MessageId, currentUsername);
                recievedMessages.Add(result);
            }
            MessagesPack messagesPack = new MessagesPack();

            //Сумма Id всех полученных сообщений
            messagesPack.CountInDB = recievedMessages.Count();
            ///Сообщения с версией выше чем у клиента
            messagesPack.Messages = GetRecentVersionMessages(recievedMessages, recentVersion);
            ///Звполнить Sender, Recipients
            foreach (Message item in messagesPack.Messages)
            {
                FillMessage(item, currentUsername);
            }
            return(messagesPack);
        }
Exemplo n.º 2
0
        List <int> GetInboxMessagesIds(string currentUsername, MessageTypes messageTypes)
        {
            List <int> recievedMessagesIds = new List <int>();
            bool       deleted             = messageTypes.HasFlag(MessageTypes.Deleted);
            bool       viewed = messageTypes.HasFlag(MessageTypes.Viewed);
            ///Ищем в получателях
            List <Recipient> recipients = RecipientGateway.Select(currentUsername, currentUsername, deleted, viewed);

            foreach (Recipient item in recipients)
            {
                recievedMessagesIds.Add((int)item.MessageId);
            }
            return(recievedMessagesIds);
        }
Exemplo n.º 3
0
        public void Log(string message, MessageTypes messageType)
        {
            if (MessageType.HasFlag(messageType))
            {
                if (messageType.HasFlag(MessageTypes.ScriptAction))
                {
                    message = $">>>> {message}";
                }
                else if (messageType.HasFlag(MessageTypes.ScriptExpect))
                {
                    message = $"<<<< {message}";
                }

                Console.WriteLine(message);
            }
        }
Exemplo n.º 4
0
        MessagesPack GetSentboxMessages(string currentUsername, MessageTypes messageTypes, Byte[] recentVersion)
        {
            bool           deleted      = messageTypes.HasFlag(MessageTypes.Deleted);
            List <Message> sentMessages = MessageGateway.Select(currentUsername, currentUsername, deleted);
            MessagesPack   messagesPack = new MessagesPack();

            messagesPack.CountInDB = sentMessages.Count();
            messagesPack.Messages  = GetRecentVersionMessages(sentMessages, recentVersion);
            foreach (Message item in messagesPack.Messages)
            {
                FillMessage(item, currentUsername);
            }
            return(messagesPack);
        }
Exemplo n.º 5
0
        List <int> GetSentboxMessagesIds(string currentUsername, MessageTypes messageTypes)
        {
            bool deleted = messageTypes.HasFlag(MessageTypes.Deleted);

            return(MessageGateway.SelectIds(currentUsername, currentUsername, deleted));
        }