private void BotLogicLogStart(object sender, BotEventArgs e) { Application.Current.Dispatcher.Invoke(() => { AddClientInBdAndDTO(e); AddClientInCombaBox(e); var message = new DisBotMessage() { Content = e.Message.Content, Date = e.Message.Date, LastName = e.Message.LastName, FirstName = e.Message.FirstName, UserName = e.Message.UserName, FullName = e.Message.FirstName, Type = DisBotMessage.MessageType.OutMessage, }; Messages.Add(message); _mainListBox.ScrollIntoView(message); _clients = _modelClientService.GetClients(); var tmpId = 0; foreach (var item in _clients) { if (item.TelegramId.Equals(e.Message.Id)) { tmpId = item.Id; break; } } var messageDB = new ClientMessageInfo() { MessageClient = e.Message.Content, TimeMassage = e.Message.Date, UserId = User.Id, ClientId = tmpId }; _modelClientMessageService.Add(messageDB); if (_clients.Count != 0) { IsSendMessage = true; } }); }
private void _botLogic_LogStart(object sender, BLL.Logic.EventsArgs.BotEventArgs e) { Application.Current.Dispatcher.Invoke(() => { var countClientDB = 0; var coutClientList = 0; if (_clients.Count == 0) { var addClient = new ClientInfo() { FirstName = _botLogic.Messages.FirstName, LastName = _botLogic.Messages.LastName, TelegramId = _botLogic.Messages.Id, Username = _botLogic.Messages.UserName, }; _modelClientService.Add(addClient); _clients.Add(addClient); _clientsChat.Add(addClient); } foreach (var client in _clients) { if (client.TelegramId.Equals(_botLogic.Messages.Id)) { break; } else if (!string.IsNullOrEmpty(client.TelegramId)) { countClientDB++; } if (_clients.Count == countClientDB) { var addClient = new ClientInfo() { FirstName = e.Message.FirstName, LastName = e.Message.LastName, TelegramId = e.Message.Id, Username = e.Message.UserName, }; _modelClientService.Add(addClient); _clients.Add(addClient); _clientsChat.Add(addClient); break; } } var addClientList = new ClientInfo() { FirstName = e.Message.FirstName, LastName = e.Message.LastName, TelegramId = e.Message.Id, Username = e.Message.UserName, }; if (_clientsChat.Count == 0) { _clientsChat.Add(addClientList); } foreach (var item in _clientsChat) { if (item.TelegramId.Equals(e.Message.Id)) { break; } else if (!item.TelegramId.Equals(e.Message.Id)) { coutClientList++; } if (coutClientList == _clientsChat.Count()) { _clientsChat.Add(addClientList); break; } } var message = new DisBotMessage() { Content = e.Message.Content, Date = e.Message.Date, LastName = e.Message.LastName, FirstName = e.Message.FirstName, UserName = e.Message.UserName, Type = DisBotMessage.MessageType.OutMessage, }; Messages.Add(message); _mainListBox.ScrollIntoView(message); _clients = _modelClientService.GetClients(); var tmpId = 0; foreach (var item in _clients) { if (item.TelegramId.Equals(e.Message.Id)) { tmpId = item.Id; break; } } CheckUserName(); var messageDB = new ClientMessageInfo() { MessageClient = e.Message.Content, TimeMassage = e.Message.Date, UserId = UserInfo.Id, ClientId = tmpId }; _modelClientMessageService.Add(messageDB); if (!String.IsNullOrEmpty(UserName)) { IsSendMessage = true; } }); }
private void EventPost() { UserInfo = StaticLogicBot.UserInfo; Console.WriteLine(); _botLogic.Log += buffer => { var countClientDB = 0; var coutClientList = 0; if (_clients.Count == 0) { var addClient = new ClientInfo() { FirstName = _botLogic.Masseges.FirstName, LastName = _botLogic.Masseges.LastName, TelegramId = _botLogic.Masseges.Id, Username = _botLogic.Masseges.UserName, }; _modelClientService.Add(addClient); _clients.Add(addClient); _clientsChat.Add(addClient); } foreach (var client in _clients) { if (client.TelegramId.Equals(_botLogic.Masseges.Id)) { break; } else if (!string.IsNullOrEmpty(client.TelegramId)) { countClientDB++; } if (_clients.Count == countClientDB) { var addClient = new ClientInfo() { FirstName = _botLogic.Masseges.FirstName, LastName = _botLogic.Masseges.LastName, TelegramId = _botLogic.Masseges.Id, Username = _botLogic.Masseges.UserName, }; _modelClientService.Add(addClient); _clients.Add(addClient); _clientsChat.Add(addClient); break; } } var addClientList = new ClientInfo() { FirstName = _botLogic.Masseges.FirstName, LastName = _botLogic.Masseges.LastName, TelegramId = _botLogic.Masseges.Id, Username = _botLogic.Masseges.UserName, }; if (_clientsChat.Count == 0) { _clientsChat.Add(addClientList); } foreach (var item in _clientsChat) { if (item.TelegramId.Equals(_botLogic.Masseges.Id)) { break; } else if (!item.TelegramId.Equals(_botLogic.Masseges.Id)) { coutClientList++; } if (coutClientList == _clientsChat.Count()) { _clientsChat.Add(addClientList); break; } } var message = new DisBotMessage() { Content = _botLogic.Masseges.Content, Date = _botLogic.Masseges.Date, LastName = _botLogic.Masseges.LastName, FirstName = _botLogic.Masseges.FirstName, UserName = _botLogic.Masseges.UserName, Type = DisBotMessage.MessageType.OutMessage, }; Messages.Add(message); _mainListBox.ScrollIntoView(message); _clients = _modelClientService.GetClients(); var tmpId = 0; foreach (var item in _clients) { if (item.TelegramId.Equals(_botLogic.Masseges.Id)) { tmpId = item.Id; break; } } CheckUserName(); var messageDB = new ClientMessageInfo() { MessageClient = _botLogic.Masseges.Content, TimeMassage = _botLogic.Masseges.Date, UserId = UserInfo.Id, ClientId = tmpId }; _modelClientMessageService.Add(messageDB); if (!String.IsNullOrEmpty(UserName)) { IsSendMessage = true; } }; }