public void AddOrUpdateConversation(SignalConversation conversation, SignalMessage updateMessage) { SignalConversation uiConversation; if (!ConversationsDictionary.ContainsKey(conversation.ThreadId)) { uiConversation = conversation.Clone(); Conversations.Add(uiConversation); ConversationsDictionary.Add(uiConversation.ThreadId, uiConversation); } else { uiConversation = ConversationsDictionary[conversation.ThreadId]; uiConversation.LastActiveTimestamp = conversation.LastActiveTimestamp; uiConversation.CanReceive = conversation.CanReceive; uiConversation.LastMessage = conversation.LastMessage; uiConversation.LastSeenMessage = conversation.LastSeenMessage; uiConversation.LastSeenMessageIndex = conversation.LastSeenMessageIndex; uiConversation.MessagesCount = conversation.MessagesCount; uiConversation.ThreadDisplayName = conversation.ThreadDisplayName; uiConversation.UnreadCount = conversation.UnreadCount; if (uiConversation is SignalContact ourContact && conversation is SignalContact newContact) { ourContact.Color = newContact.Color; }
private void AnalizeToken(int index) { Conversation conversation = ExtractConversation(index); if (!Conversations.ContainsKey(Tokens[index])) { Conversations.Add(Tokens[index], new List <Conversation>()); } Conversations[Tokens[index]].Add(conversation); if (IsTollFree(conversation.To)) { if (GetIndexByTenant(conversation.Tenant) != -1) { Bills[GetIndexByTenant(conversation.Tenant)].AddTollFreeMinutes(conversation.Billing); } } else { if (IsInternational(conversation.To)) { if (GetIndexByTenant(conversation.Tenant) != -1) { Bills[GetIndexByTenant(conversation.Tenant)].AddInterMinutes(conversation.Billing); } } if (GetIndexByTenant(conversation.Tenant) != -1) { Bills[GetIndexByTenant(conversation.Tenant)].AddMinutes(conversation.Billing); } } }
public void Run() { Envelope envelope; Conversation conversation; while (stillRunning) { envelope = UdpCommunicator.Receive(1000); if (envelope == null && TcpCommunicator != null) { envelope = TcpCommunicator.Receive(1000); } if (envelope != null) { ConversationId id = envelope.Message.ConversationId; conversation = Conversations.GetConversation(id); if (conversation != null) // If the conversation already exists { conversation.IncomingEnvelopes.Enqueue(envelope); } else // If the conversation does not exist { Responder newConversation; newConversation = _conversationFactory.CreateFromEnvelope(envelope); Message m = envelope.Message; newConversation.Launch(m); Conversations.Add(newConversation); } } } }
internal void AttachConversation(Conversation conversation) { if (conversation == null) { return; } //TODO bug 怎么会出现重复的Conversation? Conversations.Add(conversation.ID, conversation); }
public Cain(World world, int snoId, TagMap tags) : base(world, snoId, tags) { this.Attributes[GameAttribute.MinimapActive] = true; Conversations.Add(new ConversationInteraction(72416)); Conversations.Add(new ConversationInteraction(198588)); Conversations.Add(new ConversationInteraction(73171)); Interactions.Add(new IdentifyAllInteraction()); }
private void ExecuteRepeatCommand() { Conversations.Add(new Conversation { IsAI = false, Message = "Repeat." }); Conversations.Add(new Conversation { IsAI = true, Message = lastAIText }); Audio.PlayBase64(lastTTS); }
private void LoadMessages(List <MessageDTO> messages, bool newMessages) { messages.Sort((x, y) => x.SendDate.CompareTo(y.SendDate)); foreach (var message in messages) { if (Conversations.All(x => x.Username != message.Username)) { var conversation = new Conversation() { InterlocutorId = message.UserId, Name = message.Name, Username = message.Username, Messages = new ObservableCollection <Message>(), IsActive = true, Color = new SolidColorBrush(Color.FromRgb((byte)_random.Next(30, 255), (byte)_random.Next(30, 255), (byte)_random.Next(30, 255))), }; if (newMessages) { conversation.UnreadMessages++; } conversation.Messages.Add(new Message() { Content = message.Content, Id = message.Id, IsAuthor = message.IsAuthor }); Conversations.Add(conversation); } else { var conversation = Conversations.First(x => x.Username == message.Username); if (conversation.Messages.All(x => x.Id != message.Id)) { conversation.Messages.Add(new Message() { Content = message.Content, Id = message.Id, IsAuthor = message.IsAuthor }); if (newMessages) { conversation.UnreadMessages++; } } } _parent.MessagesListBox.Items.Refresh(); } }
public async Task LoadDataAsync() { var data = await _conversationService.GetAllConversationsForUser(); Conversations.Clear(); foreach (var item in data) { Conversations.Add(new ConversationViewModel(item)); } SelectedConversation = Conversations.FirstOrDefault(); }
private async Task UpdateConversationsAsync() { var conversations = await _graphService.GetGroupConversationsAsync(Group); foreach (var conversation in conversations.Reverse()) { conversation.IsOwnedByUser = conversation.UniqueSenders .Any(us => us.Contains(_configService.User.DisplayName)); Conversations.Add(conversation); } OnConversationsChanged(); }
private void ExecuteHelpCommand() { Conversations.Add(new Conversation { IsAI = false, Message = "Help." }); CurrentSpeech = "Ok, no problem! I will send a supervisor to help you."; lastAIText = CurrentSpeech; Conversations.Add(new Conversation { IsAI = true, Message = lastAIText }); hubConnector.GetText2Speech("XamarinDemoApp", CurrentSpeech); }
/// <summary> /// add content to the stream /// </summary> /// <param name="dest"></param> public void Add(String dest) { Conversation neo = new Conversation(_Server, name, dest); if (!Conversations.Contains(neo)) { Conversations.Add(neo); neo.delete += new EventHandler <EventArgs>(neo_delete); neo.focus += new EventHandler <EventArgs>(neo_focus); OnPropertyChanged("Conversations"); } }
public async void SearchPossibleUsers(string text) { if (ServiceManager.IsConnected) { if (_isSearching) { return; } _isSearching = true; ClearSearchUsers(); _canClear = false; var temp = new List <Conversation>(); var possibleUsers = await ServiceManager.GetPossibleUsers(text); if (string.IsNullOrEmpty(_parent.SearchTextBox.Text)) { _isSearching = false; return; } foreach (var conversation in Conversations) { conversation.IsActive = conversation.Username.StartsWith(text); } foreach (var user in possibleUsers) { if (Conversations.All(x => x.Username != user.Username)) { var conversation = new Conversation() { InterlocutorId = user.UserId, Name = user.Name, Username = user.Username, Messages = new ObservableCollection <Message>(), IsActive = true, Color = new SolidColorBrush(Color.FromRgb((byte)_random.Next(30, 255), (byte)_random.Next(30, 255), (byte)_random.Next(30, 255))), }; Conversations.Add(conversation); temp.Add(conversation); } } _tempList = temp; _parent.ConversationsListBox.Items.Refresh(); _canClear = true; _isSearching = false; } }
private void HandleMessage(Message message) { switch (message.messageType) { case MessageTypes.RegResponse: ID = message.id; Conversations[-1] = message.message + "\r\n"; foreach (UserInfo userInfo in message.users) { if (ID != userInfo.ID) { Users.Add(userInfo.ID, userInfo.Name); Conversations.Add(userInfo.ID, ""); } } break; case MessageTypes.UserJoinOrLeft: if (message.isJoin) { if (message.id != ID) { Conversations.Add(message.id, ""); Conversations[-1] += message.message + "\r\n"; Users.Add(message.id, message.name); } } else { Conversations[-1] += message.message + "\r\n"; Conversations.Remove(message.id); Users.Remove(message.id); } break; case MessageTypes.PrivateMsg: Conversations[message.sourceID] += message.message + "\r\n"; break; case MessageTypes.ToAllMsg: Conversations[message.id] += message.message + "\r\n"; break; case MessageTypes.SearchResponse: ServerPort = message.port; ServerIPAddress = message.ipAddress; break; } UpdateUI?.Invoke(); }
public static void SaveConversation() { Hashtable table = new Hashtable(); IoC.Resolve <IUnitOfWorkFactory>().SaveUnitOfWorkToHashtable(table); if (UnitOfWork.LongConversationIsPrivate) { Conversations.Add(UnitOfWork.CurrentLongConversationId, table); } else { Conversations.Add(DefaultLongConversationKey, table); } }
internal void ProcessConversation(Conversation conv, User creator, double time) { using (var db = new LiteDatabase(DbPath)) { // Update the in-memory model and the db var conversations = db.GetCollection <Conversation>("conversations"); conversations.Insert(conv); RunOnUI(new ThreadStart(() => { Conversations.Add(conv); })); conversations.EnsureIndex(x => x.Id); // Create the 'creation' event ProcessConversationItem(new ConversationEvent(creator, time, conv.Id, EventType.ConversationCreated)); } }
private async Task InitializeHubConnector() { hubConnector = new HubConnector(); hubConnector.TTSResponseDelegate += HubConnector_TTSResponseDelegate; hubConnector.StartAsync(); await Task.Delay(500); CurrentSpeech = "We invite you to experience the future of AI that will empower your employees with disabilities to pick a warehouse order and inspire your team."; Conversations.Add(new Conversation { IsAI = true, Message = CurrentSpeech }); hubConnector.GetText2Speech("XamarinDemoApp", CurrentSpeech); CurrentSpeech = "Are you ready to start picking?"; lastAIText = CurrentSpeech; hubConnector.GetText2Speech("XamarinDemoApp", CurrentSpeech); }
public void SendMessage(string message) { var guidId = Guid.NewGuid().ToString(); var messageData = new ChatMessage { MessageId = $"{myAccount.IdUser}{UserId}{guidId}", SenderId = myAccount.IdUser, RecieverId = UserId, Message = message }; Conversations.Add(messageData); if (OnSendMessage != null) { OnSendMessage(messageData); } }
private async void AddConversationAsync() { IsLoading = true; // Reset the text box. var text = ConversationText; ConversationText = ""; // Create a local message and add it. var newConversation = new ConversationModel { Preview = text, UniqueSenders = new List <string> { _configService.User.DisplayName }, IsOwnedByUser = true }; Conversations.Add(newConversation); OnConversationsChanged(); // Create the request object. var newThread = new NewConversationModel { Topic = "Property Manager", Posts = new List <NewPostModel> { new NewPostModel { Body = new BodyModel(text, "html"), NewParticipants = new List <ParticipantModel> { new ParticipantModel(_configService.User.DisplayName, _configService.User.Mail) } } } }; // Add the message. await _graphService.AddGroupConversation(Group, newThread); IsLoading = false; }
private async void HubConnector_TTSResponseDelegate(string user, string message) { if (!string.IsNullOrEmpty(message)) { while (Audio.IsPlaying) { await Task.Delay(100); } lastTTS = message; Audio.PlayBase64(lastTTS); if (firstLoad) { firstLoad = false; Conversations.Add(new Conversation { IsAI = true, Message = CurrentSpeech }); } } }
/// <summary> /// add content to the stream and create a chat /// </summary> /// <param name="dest"></param> /// <param name="content"></param> public void Add(String dest, String content) { Application.Current.Dispatcher.Invoke(new Action(delegate() { Conversation neo = new Conversation(_Server, name, dest, content); if (!Conversations.Contains(neo)) { Conversations.Add(neo); neo.delete += new EventHandler <EventArgs>(neo_delete); neo.focus += new EventHandler <EventArgs>(neo_focus); OnPropertyChanged("Conversations"); } else { Conversations.ElementAt(Conversations.IndexOf(neo)).addContent(content); } }), null); }
private void AddConversationToView(Conversation conversation) { if (ConversationByCID.ContainsKey(conversation.CID)) { ConversationByCID[conversation.CID].UIDS = conversation.UIDS; if (conversation.Equals(CurrentConversation)) { CurrentConversation = ConversationByCID[conversation.CID]; } } else { ConversationByCID.Add(conversation.CID, conversation); App.Current.Dispatcher.Invoke((Action) delegate { Conversations.Add(conversation); }); } }
/// <summary> /// Loads Messenger conversation from given path. Gives progress updates by second parameter /// </summary> /// <param name="path">Directory where facebook data is stored (xx/facebook-xxx/messages/inbox)</param> /// <param name="conversationChange">if specified gets fired every time there is a progress update</param> public static async Task Load(string path, EventHandler conversationChange = null) { Dictionary <string, int> count = new Dictionary <string, int>(); var dirs = Directory.GetDirectories(path); foreach (var dir in dirs) { var conv = await ParseConversation(dir, conversationChange); foreach (var item in conv.Messages.Keys) { if (!count.ContainsKey(item)) { count.Add(item, 0); } count[item]++; } Conversations.Add(conv); } WeightActivity(); User = count.Aggregate((l, r) => l.Value > r.Value ? l : r).Key; }
/// <summary> /// Add a Conversation /// </summary> /// <param name="conversation">The conversation<see cref="Conversation"/></param> public void AddConversation(Conversation conversation) { Conversations.Add(conversation); }
private DataContext() { User Hans = new User { UserGuid = "146f61f1-6dd0-471f-a8ed-264be2293630", Nickname = "Hans User1" }; User Peter = new User { UserGuid = "195471a1-459a-4b26-9d10-14a885e50cba", Nickname = "Peter User2" }; User Moritz = new User { UserGuid = "1537974b-283b-44fa-8d2d-2e80ba4fc245", Nickname = "Moritz User3" }; User Linda = new User { UserGuid = "c86f038a-896e-432f-9e8d-d3ecf3a9aae2", Nickname = "Linda User4" }; Message messageFromHans = new Message { From = Hans, Content = new MessageContent("Hey wie geht es. grüße Hans."), DateTime = DateTime.Parse("16.12.2019 08:24:00") /*, FromGuid = "1", ToGuid = "123", MessageGuid = "1-1" */ }; Message messageFromHans2 = new Message { From = Hans, Content = new MessageContent { ContentString = fileBase64, FileName = "Bild.jpeg", ContentTyp = MessageContentTyp.Image }, DateTime = DateTime.Parse("06.06.2019 08:24:00") /*, FromGuid = "1", ToGuid = "123", MessageGuid = "1-1" */ }; Message messageFromPeter = new Message { From = Peter, Content = new MessageContent("Hey wie geht es. grüße Peter."), DateTime = DateTime.Parse("16.12.2019 10:20:00") /*, FromGuid = "2", ToGuid = "123", MessageGuid = "2-1"*/ }; Message messageFromMoritz = new Message { From = Moritz, Content = new MessageContent("Hey wie geht es. grüße Moritz."), DateTime = DateTime.Parse("16.12.2019 11:17:00") /*, FromGuid = "3", ToGuid = "123", MessageGuid = "3-1"*/ }; Message messageFromLinda = new Message { From = Linda, Content = new MessageContent("Hey wie geht es. grüße Linda."), DateTime = DateTime.Parse("15.12.2019 10:00:00") /*, FromGuid = "4", ToGuid = "123", MessageGuid = "4-1"*/ }; List <Message> messagesFromHans = new List <Message> { messageFromHans, messageFromHans2 }; List <Message> messagesFromPeter = new List <Message> { messageFromPeter }; List <Message> messagesFromMoritz = new List <Message> { messageFromMoritz }; List <Message> messagesFromLinda = new List <Message> { messageFromLinda }; Conversations.Add(new Conversation { From = Hans, Messages = new ObservableCollection <Message>(messagesFromHans) }); Conversations.Add(new Conversation { From = Peter, Messages = new ObservableCollection <Message>(messagesFromPeter) }); Conversations.Add(new Conversation { From = Moritz, Messages = new ObservableCollection <Message>(messagesFromMoritz) }); Conversations.Add(new Conversation { From = Linda, Messages = new ObservableCollection <Message>(messagesFromLinda) }); }
private void ExecuteNoCommand() { Conversations.Add(new Conversation { IsAI = false, Message = "No." }); }