示例#1
0
 public CleanUpWorker(MessagesContainer messageContainer, MessageHistoryContainer historyContainer, ServiceConfiguration configuration, ILogger <GreeterService> logger)
 {
     Logger = logger;
     ServiceConfiguration = configuration;
     MessageContainer     = messageContainer;
     HistoryContainer     = historyContainer;
 }
示例#2
0
        public void SendStickerOnTheRight(MessageCore.Sticker.Sticker stickerInfo, bool reversed = false)
        {
            try
            {
                Resources.CustomControls.Sticker sticker =
                    new Resources.CustomControls.Sticker(this, false, stickerInfo.ID, stickerInfo.CategoryID, 130, stickerInfo.Duration, stickerInfo.SpriteURL, true);

                Thickness margin = sticker.Margin;
                margin.Right  = 30;
                margin.Top    = 10;
                margin.Bottom = 10;
                sticker.HorizontalAlignment = HorizontalAlignment.Right;
                sticker.Margin = margin;

                if (reversed)
                {
                    spMessagesContainer.Children.Insert(0, sticker);
                }
                else
                {
                    spMessagesContainer.Children.Add(sticker);
                }
                MessagesContainer.ScrollToEnd();
            }
            catch (Exception e)
            {
                throw new Exception("Sticker ex: ", e);
            }
        }
 public WindowsEventLogsMonitor(MessagesContainer messageContainer, ServiceConfiguration configuration, ILogger <WindowsEventLogsMonitor> logger)
 {
     MessageContainer = messageContainer;
     Configuration    = configuration;
     Logger           = logger;
     Logs             = new List <EventLog>();
 }
 public GreeterService(MessagesContainer messageContainer, MessageHistoryContainer historyContainer, GRPCLogConsumer grpcLogConsumer, ILogger <GreeterService> logger)
 {
     MessageHistoryContainer = historyContainer;
     _grpcLogConsumer        = grpcLogConsumer;
     Logger           = logger;
     MessageContainer = messageContainer;
 }
示例#5
0
        public void SendStickerOnTheLeft(MessageCore.Sticker.Sticker stickerInfo, bool reversed = false, BubbleChat previous = null, BubbleChat head = null)
        {
            try
            {
                Resources.CustomControls.Sticker sticker =
                    new Resources.CustomControls.Sticker(this, false, stickerInfo.ID, stickerInfo.CategoryID, 130, stickerInfo.Duration, stickerInfo.SpriteURL, true);

                Thickness margin = sticker.Margin;
                margin.Left   = 30;
                margin.Top    = 10;
                margin.Bottom = 10;
                sticker.HorizontalAlignment = HorizontalAlignment.Left;
                sticker.Margin = margin;

                if (reversed)
                {
                    head.InsertSticker(sticker);
                }
                else
                {
                    previous.AddSticker(sticker);
                }
                // spMessagesContainer.Children.Add(sticker);
                MessagesContainer.ScrollToEnd();
            }
            catch (Exception e)
            {
                throw new Exception("Sticker ex: ", e);
            }
        }
示例#6
0
        private void UsersList_ItemClicked(object sender, string Name, int UserID)
        {
            if (bNeedSplash)
            {
                Thread T = new Thread(delegate()
                {
                    SplashWindow.CreateCoverSplash(true, this.Top + MessagesContainer.Top, this.Left + MessagesContainer.Left,
                                                   MessagesContainer.Height, MessagesContainer.Width);
                });
                T.Start();

                while (!SplashWindow.bSmallCreated)
                {
                    ;
                }
            }

            UserImageBox.Image = UsersList.Items[UsersList.Selected].Image;

            InfiniumMessages.FillMessages(UserID);

            MessagesContainer.InitializeItems();

            InfiniumMessages.ClearSubscribes(UserID);

            SelectedUsersList.Selected = -1;

            if (bNeedSplash)
            {
                bC = true;
            }
        }
        public MainPage()
        {
            this.InitializeComponent();

            //Initialize main components
            AppManager appManager   = new AppManager();
            Stage      initialStage = appManager.CurrentStage;

            GithubMessageProvider gitHubMessageProvider = new GithubMessageProvider();

            gitHubMessageProvider.RepositoryOwner = "logistics-mgmt";
            gitHubMessageProvider.RepositoryName  = "logistics-mgmt";

            MessagesContainer testContainer = new MessagesContainer(appManager.MessageProviderManager.Context);

            testContainer.MessageProvider = gitHubMessageProvider;
            initialStage.Containers.Add(testContainer);
            testContainer.Messages.Add(new Message("testHeader", "1234", "testContent", "http://test.pl"));
            initialStage.updateContainers();

            MessagesContainerViewModel testContainerViewModel = new MessagesContainerViewModel(testContainer);

            HubSection0.DataContext = testContainerViewModel;


            // Dynamically created container MVVM
            GithubMessageProvider newtonMessagesProvider = new GithubMessageProvider();

            newtonMessagesProvider.RepositoryOwner = "m-ciesielski";
            newtonMessagesProvider.RepositoryName  = "newtons-interpolation";

            MessagesContainer newtonContainer = new MessagesContainer(appManager.MessageProviderManager.Context);

            newtonContainer.MessageProvider = newtonMessagesProvider;
            initialStage.Containers.Add(newtonContainer);
            initialStage.updateContainers();

            MessagesContainerViewModel newtonViewModel = new MessagesContainerViewModel(newtonContainer);

            MessagesContainerView newtonView = MessagesContainerViewFactory.createMessagesContainerView(newtonViewModel, StageHub);

            // Dynamically created container MVVM - Slack
            SlackMessageProvider slackMessagesProvider = new SlackMessageProvider();

            slackMessagesProvider.AuthToken = "xoxp-14123929075-14126498321-39212835763-6796628539";
            slackMessagesProvider.Channel   = "C0E3RLZKJ";

            MessagesContainer slackMessagesContainer = new MessagesContainer(appManager.MessageProviderManager.Context);

            slackMessagesContainer.MessageProvider = slackMessagesProvider;
            initialStage.Containers.Add(slackMessagesContainer);
            initialStage.updateContainers();

            MessagesContainerViewModel slackMessagesViewModel = new MessagesContainerViewModel(slackMessagesContainer);

            MessagesContainerView slackMessagesView = MessagesContainerViewFactory.createMessagesContainerView(slackMessagesViewModel, StageHub);


            testContainerViewModel.ToString();
        }
示例#8
0
        private void SendMessagesButton_Click(object sender, EventArgs e)
        {
            if (TextBox.Text.Length == 0)
            {
                return;
            }

            if (bNeedSplash)
            {
                Thread T = new Thread(delegate()
                {
                    SplashWindow.CreateCoverSplash(true, this.Top + MessagesContainer.Top, this.Left + MessagesContainer.Left,
                                                   MessagesContainer.Height, MessagesContainer.Width);
                });
                T.Start();

                while (!SplashWindow.bSmallCreated)
                {
                    ;
                }
            }

            if (SelectedUsersList.Selected == -1)
            {
                int iRes = InfiniumMessages.AddUserToSelected(UsersList.Items[UsersList.Selected].UserID);

                SelectedUsersList.InitializeItems();

                if (iRes == -1)//ok
                {
                    SelectedUsersList.Selected = SelectedUsersList.Items.Count() - 1;
                    SelectedUsersList.ScrollDown();
                }
                else//in the list already
                {
                    SelectedUsersList.SelectOnly(iRes);
                }
            }

            InfiniumMessages.SendMessage(TextBox.Text, SelectedUsersList.Items[SelectedUsersList.Selected].UserID);

            InfiniumMessages.FillMessages(SelectedUsersList.Items[SelectedUsersList.Selected].UserID);

            MessagesContainer.InitializeItems();

            TextBox.Clear();

            if (UsersList.Top != 159)
            {
                UsersList.Top    = 159;
                UsersList.Height = UsersList.Parent.Height - UsersList.Top;
            }

            if (bNeedSplash)
            {
                bC = true;
            }
        }
 /// <summary>
 /// Загружает сообщение в контейнер и задаёт понятную для пользователя дату
 /// </summary>
 private void AddNewMessageInContainerAndUpdateDateSend()
 {
     MessagesContainer.AddMessage(Messages[Messages.Count - 1].Id,
                                  Messages[Messages.Count - 1].SenderName,
                                  Messages[Messages.Count - 1].DateSend,
                                  Messages[Messages.Count - 1].SendMessage,
                                  Messages[Messages.Count - 1].IsItMe);
     Messages[Messages.Count - 1].DateSend = Day.GetParsedDate(Messages[Messages.Count - 1].DateSend);
 }
示例#10
0
        public MessagesForm(ref Form tTopForm)
        {
            InitializeComponent();

            Thread T = new Thread(delegate()
            {
                SplashWindow.CreateCoverSplash(true, (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2, (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2,
                                               503, 1014);
            });

            T.Start();

            while (!SplashWindow.bSmallCreated)
            {
                ;
            }


            TopForm = tTopForm;

            InfiniumMessages         = new InfiniumMessages();
            UsersList.ItemsDataTable = InfiniumMessages.UsersDataTable;
            UsersList.InitializeItems();

            InfiniumMessages.FillSelectedUsers(-1);

            SelectedUsersList.ItemsDataTable = InfiniumMessages.SelectedUsersDataTable;
            SelectedUsersList.InitializeItems();

            MessagesContainer.UsersDataTable = InfiniumMessages.FullUsersDataTable;
            MessagesContainer.CurrentUserID  = Security.CurrentUserID;

            if (InfiniumMessages.SelectedUsersDataTable.Rows.Count > 0)
            {
                UsersList.Top    = 159;
                UsersList.Height = UsersList.Parent.Height - UsersList.Top;

                SelectedUsersList.Selected = 0;
                InfiniumMessages.FillMessages(SelectedUsersList.Items[0].UserID);

                MessagesContainer.ItemsDataTable = InfiniumMessages.MessagesDataTable;
                MessagesContainer.InitializeItems();
            }
            else
            {
                UsersList.Top    = 0;
                UsersList.Height = UsersList.Parent.Height;

                UsersList.Selected = 0;

                InfiniumMessages.FillMessages(UsersList.Items[0].UserID);
                MessagesContainer.ItemsDataTable = InfiniumMessages.MessagesDataTable;
                MessagesContainer.InitializeItems();
            }

            bC = true;
        }
        IRestResponse RecoverMessagesContainer(MessagesContainer container, string category)
        {
            var worker  = new RestClient(container.GetCooperator());
            var request = new RestRequest($"failures/{category}", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(new { Name = container.GetName(), Cooperator = ServerAddress });

            return(worker.Execute(request));
        }
        public void StartLoad(bool isHavePastMessage)
        {
            Messages = new ObservableCollection <Message>();
            MessagesContainer.OpenContainer(Name);
            List <ChatMessageDTO> chatMessagesServer = new List <ChatMessageDTO>();

            if (isHavePastMessage)
            {
                (List <ChatMessageDTO>, int, int)data = _serverWorker.GetMessagesStartWithPastMessage();
                chatMessagesServer = data.Item1;
                _topID             = chatMessagesServer[0].Id;
                for (int i = 0; i < data.Item3; i++)
                {
                    Messages.Add(new Message
                    {
                        Id          = chatMessagesServer[i].Id,
                        SenderName  = chatMessagesServer[i].SenderName,
                        DateSend    = chatMessagesServer[i].DateSend,
                        SendMessage = chatMessagesServer[i].SendMessage,
                        IsItMe      = chatMessagesServer[i].SenderName == Name
                    });
                    AddNewMessageInContainerAndUpdateDateSend();
                }
                if (chatMessagesServer.Count > data.Item3)
                {
                    _typeOfSource = 1;
                    MessagesLoadAsync(chatMessagesServer.Skip(data.Item3).ToList(), data.Item2, data.Item3 - 1);
                }
                else
                {
                    _typeOfSource = 0;
                }
            }
            else
            {
                chatMessagesServer = _serverWorker.GetMessagesStart();

                _topID        = chatMessagesServer.Count > 0 ? chatMessagesServer[0].Id : -1;
                _typeOfSource = 0;

                foreach (var message in chatMessagesServer)
                {
                    Messages.Add(new Message
                    {
                        Id          = message.Id,
                        SenderName  = message.SenderName,
                        DateSend    = message.DateSend,
                        SendMessage = message.SendMessage,
                        IsItMe      = message.SenderName == Name
                    });
                    AddNewMessageInContainerAndUpdateDateSend();
                }
            }
        }
示例#13
0
        public Person(string fullName, MessagesContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            this.FullName  = fullName.DecodeString();
            PersonMessages =
                new MessagesContainer(FindPersonMessages(container.Messages));

            SetDays();
            SetDoubleNumbers(container.NumberOfMessages,
                             container.NumberOfUniqueWords, container.NumberOfAllWords);
        }
        public async void UsuallyLoadAsync()
        {
            Messages = new ObservableCollection <Message>();
            List <Message> chatMessagesClient = MessagesContainer.GetMessages();

            foreach (var message in chatMessagesClient)
            {
                if (message.IsItMe && message.SenderName != Name)
                {
                    message.SenderName = Name;
                }
                message.DateSend = Day.GetParsedDate(message.DateSend);
                Messages.Add(message);
            }

            if (Messages.Count > 0)
            {
                await Task.Run(() => _serverWorker.GetMessages(Messages[Messages.Count - 1].Id, "New messages"));
            }
        }
示例#15
0
        public void SendLeftMessages(AbstractMessage msg, bool isSimulating = false, bool reversed = false, bool loadConversation = false)
        {
            Console.WriteLine(msg.SenderID);

            if (reversed)
            {
                if (_headBubbleChat == null)
                {
                    _headBubbleChat = new BubbleChat();
                    _headBubbleChat.SetAva(msg.SenderID);
                    _headBubbleChat.NickName.Foreground = iconColor.Foreground;
                    spMessagesContainer.Children.Insert(0, _headBubbleChat);
                }
            }
            else
            {
                if (_previousBubbleChat == null)
                {
                    _previousBubbleChat = new BubbleChat();
                    _previousBubbleChat.SetAva(msg.SenderID);
                    _previousBubbleChat.NickName.Foreground = iconColor.Foreground;
                    spMessagesContainer.Children.Add(_previousBubbleChat);
                }
            }

            Bubble          b         = null;
            ThumbnailBubble thumbnail = null;
            var             app       = MainWindow.chatApplication;

            if (BubbleTypeParser.Parse(msg) == BubbleType.Text)
            {
                b          = new Bubble();
                b.Messages = (msg as TextMessage).Message;
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Attachment)
            {
                b          = new Bubble();
                b.Messages = (msg as AttachmentMessage).FileName;
                b.SetLink((msg as AttachmentMessage).FileID);
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Image)
            {
                string    fileID   = (msg as ImageMessage).FileID;
                string    fileName = (msg as ImageMessage).FileName;
                MediaInfo media    = GetMediaInfo(fileID, fileName, app.model.currentSelectedConversation);
                thumbnail = new ThumbnailBubble(media);
                thumbnail.HorizontalAlignment = HorizontalAlignment.Left;
                thumbnail.Margin = new Thickness(5, 0, 0, 0);
                Console.WriteLine("Image sent");
                AddMedia(fileID, fileName, isSimulating);
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Video)
            {
                string    fileID   = (msg as VideoMessage).FileID;
                string    fileName = (msg as VideoMessage).FileName;
                MediaInfo media    = GetMediaInfo(fileID, fileName, app.model.currentSelectedConversation);
                thumbnail = new ThumbnailBubble(media);
                thumbnail.HorizontalAlignment = HorizontalAlignment.Left;
                thumbnail.Margin = new Thickness(5, 0, 0, 0);
                AddMedia(fileID, fileName, isSimulating);
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Sticker)
            {
                MessageCore.Sticker.Sticker sticker = (msg as StickerMessage).Sticker;
                MessageCore.Sticker.Sticker.LoadedStickers.TryGetValue(sticker.ID, out var result);
                SendStickerOnTheLeft(result, reversed, _previousBubbleChat, _headBubbleChat);
            }

            if (b != null)
            {
                b.Type = BubbleTypeParser.Parse(msg);
                b.ControlUpdate();

                b.SetSeen(false);
                b.SetBG(Color.FromRgb(246, 246, 246));
                b.SetDirect(true); // true = left false = right
            }

            if (reversed)
            {
                if (b != null)
                {
                    _headBubbleChat.InsertBubble(0, b);
                }
                if (thumbnail != null)
                {
                    _headBubbleChat.InsertMedia(thumbnail);
                }
                if (loadConversation)
                {
                    MessagesContainer.ScrollToEnd();
                }
                else
                {
                    MessagesContainer.ScrollToHome();
                }
            }
            else
            {
                if (b != null)
                {
                    _previousBubbleChat.AddBubble(b);
                }
                if (thumbnail != null)
                {
                    _previousBubbleChat.AddMedia(thumbnail);
                }
                MessagesContainer.ScrollToEnd();
            }

            if (thumbnail != null)
            {
                thumbnail.Click += ThumbnailClick;
            }

            app.model.CurrentUserMessages.Add(new BubbleInfo(msg, true));
            app.model.Conversations[app.model.currentSelectedConversation].Bubbles.Add(new BubbleInfo(msg, true));
        }
示例#16
0
        public void SendMessage(AbstractMessage msg, bool isSimulating = false, bool reversed = false, bool loadConversation = false) //on the Rightside
        {
            if (reversed)
            {
                _headBubbleChat = null;
            }
            else
            {
                _previousBubbleChat = null;
            }

            Bubble          b         = null;
            ThumbnailBubble thumbnail = null;
            var             app       = MainWindow.chatApplication;

            if (BubbleTypeParser.Parse(msg) == BubbleType.Text)
            {
                b          = new Bubble();
                b.Messages = (msg as TextMessage).Message;
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Attachment)
            {
                b          = new Bubble();
                b.Messages = (msg as AttachmentMessage).FileName;
                b.SetLink((msg as AttachmentMessage).FileID);
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Image)
            {
                string    fileID   = (msg as ImageMessage).FileID;
                string    fileName = (msg as ImageMessage).FileName;
                MediaInfo media    = GetMediaInfo(fileID, fileName, app.model.currentSelectedConversation);
                thumbnail = new ThumbnailBubble(media);
                thumbnail.HorizontalAlignment = HorizontalAlignment.Right;
                thumbnail.Margin = new Thickness(0, 0, 16, 0);
                // thumbnail.IsActive = true;
                Console.WriteLine("Image sent");
                AddMedia(fileID, fileName, isSimulating);
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Video)
            {
                string    fileID   = (msg as VideoMessage).FileID;
                string    fileName = (msg as VideoMessage).FileName;
                MediaInfo media    = GetMediaInfo(fileID, fileName, app.model.currentSelectedConversation);
                thumbnail = new ThumbnailBubble(media);
                thumbnail.HorizontalAlignment = HorizontalAlignment.Right;
                thumbnail.Margin = new Thickness(0, 0, 16, 0);
                // thumbnail.IsActive = true;

                AddMedia(fileID, fileName, isSimulating);
            }
            else if (BubbleTypeParser.Parse(msg) == BubbleType.Sticker)
            {
                MessageCore.Sticker.Sticker sticker = (msg as StickerMessage).Sticker;
                //var result;
                MessageCore.Sticker.Sticker.LoadedStickers.TryGetValue(sticker.ID, out var result);
                SendStickerOnTheRight(result, reversed);
            }

            if (b != null)
            {
                b.Type = BubbleTypeParser.Parse(msg);
                b.ControlUpdate();

                b.SetBG(bubbleColor);

                b.IsLeft = false;

                if (bubbleColor.R + bubbleColor.G + bubbleColor.B >= 565)
                {
                    b.SetTextColor(Colors.Black);
                }
                else
                {
                    b.SetTextColor(Colors.White);
                }
                b.SetDirect(false);// true = left false = right
                b.SetSeen(false);
            }

            if (reversed)
            {
                if (b != null)
                {
                    spMessagesContainer.Children.Insert(0, b);
                }
                if (thumbnail != null)
                {
                    spMessagesContainer.Children.Insert(0, thumbnail);
                }
                if (loadConversation)
                {
                    MessagesContainer.ScrollToEnd();
                }
                else
                {
                    MessagesContainer.ScrollToHome();
                }
            }
            else
            {
                if (b != null)
                {
                    spMessagesContainer.Children.Add(b);
                }
                if (thumbnail != null)
                {
                    spMessagesContainer.Children.Add(thumbnail);
                }
                MessagesContainer.ScrollToEnd();
            }

            if (thumbnail != null)
            {
                thumbnail.Click += ThumbnailClick;
            }

            app.model.CurrentUserMessages.Add(new BubbleInfo(msg, false));
            app.model.Conversations[app.model.currentSelectedConversation].Bubbles.Add(new BubbleInfo(msg, false));

            if (isSimulating)
            {
                return;
            }
            SendMessage packet = new SendMessage();

            packet.ConversationID = app.model.currentSelectedConversation;
            packet.Message        = msg;
            _ = ChatConnection.Instance.Send(packet);
        }
示例#17
0
 public MessagesController(MessagesContainer messageContainer, ILogger <MessagesController> logger)
 {
     this.messageContainer = messageContainer;
     Logger = logger;
 }
        /// <summary>
        /// Отображает или убирает кнопку "Вниз"
        /// </summary>
        /// <param name="isVisible"></param>
        public async void ShowButtonToBottomAsync(bool isVisible)
        {
            IsFocus = false;
            if (_cache.IndexLevel == 0 && CountNewMessages == 0 && !_haveNewMessage)
            {
                IsVisibleButtonToBottom = isVisible;
                await Task.Run(() => _serverWorker.GetUpdate(!IsVisibleButtonToBottom));

                if (IsVisibleButtonToBottom)
                {
                    GetFlickerAsync();
                }
                else
                {
                    CountNewMessages = 0;
                }
                _countClickButtonToBottom = 0;
                IsFocus = true;
            }
            else if (_cache.IndexLevel > 0 && _isGoToBottom == false)
            {
                _isGoToBottom = true;
                Application.Current.Dispatcher.Invoke(LoadFromCache, DispatcherPriority.Background);
                _countClickButtonToBottom = 0;
                IsFocus = true;
            }
            else if (_cache.IndexLevel > 0)
            {
                _isGoToBottom = false;
                IsFocus       = true;
            }
            else if (CountNewMessages > 0 && _isGoToBottom == false)
            {
                if (CountNewMessages > 100)
                {
                    await Task.Run(() => _serverWorker.GetMessages(Messages[Messages.Count - 1].Id, "New messages"));
                }
                else
                {
                    CountNewMessages = 0;
                    var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Message, ChatMessageDTO>()).CreateMapper();
                    await Task.Run(() => _serverWorker.GetMessages(mapper.Map <Message, ChatMessageDTO>(MessagesContainer.GetMessage())));
                }
                _countClickButtonToBottom = 0;
            }
            else
            {
                _isGoToBottom = false;
            }
        }
示例#19
0
 public Day(List <Message> messages, Date date)
 {
     this.ThisDate          = date;
     this.MessagesContainer = new MessagesContainer(messages);
 }
示例#20
0
 public MessagesContainerViewModel(MessagesContainer model)
 {
     this.Model    = model;
     this.Messages = model.Messages;
 }