public void PostEvents(Guid channelID, byte[] mainPasswordHash, ClientEvent[] args) { var channel = (from ch in Services.DataConnection.Channels where ch.ChannelID == channelID && ch.MainPasswordHash == mainPasswordHash select ch).FirstOrDefault(); if (channel != null) { var eventCount = Services.ExistingEvents[channelID].Count; if (eventCount > 50) { var eventsToDelete = (from ev in Services.DataConnection.ChatEvents where ev.ChannelID == channelID orderby ev.EventID ascending select ev).Take(10); Services.DataConnection.ChatEvents.DeleteAllOnSubmit(eventsToDelete); Services.ExistingEvents[channelID].RemoveRange(0, 10); } foreach (ClientEvent ev in args) { ChatEvent newEvent = new ChatEvent() { ChannelID = channelID, EventData = Serialize(ev.EventData), Type = (int)ev.EventType }; Services.DataConnection.ChatEvents.InsertOnSubmit(newEvent); Services.ExistingEvents[channelID].Add(newEvent); } Services.DataConnection.SubmitChanges(); } }
private void PostEvent(ClientEvent ev) { lock (m_queueLock) { m_events.Enqueue(ev); } m_submitWait.Set(); }