public void ExportMessages(string filepath) { var content = JObject.Parse(File.ReadAllText(filepath)); var messageLog = (JArray)content.SelectToken("chat_log"); var champions = new HashSet <string>(); foreach (JObject message in messageLog) { var deserializedMessage = message.ToObject <MessageJsonEntry>(); if (deserializedMessage.champion_name == null) { continue; } if (champions.Contains(deserializedMessage.champion_name)) { continue; } champions.Add(deserializedMessage.champion_name); } foreach (JObject message in messageLog) { var deserializedMessage = message.ToObject <MessageJsonEntry>(); _messages.AddMessage(deserializedMessage, champions); } }
private void AddLine(string message) { if (_linesBuffer == null) { return; } lock (_linesBuffer_lock) { _linesBuffer.AddMessage(message); } }
public IHttpActionResult Post([FromBody] Message receivedMessage) { string username = Thread.CurrentPrincipal.Identity.Name; try { receivedMessage.Username = username; Message message = messageCollection.AddMessage(receivedMessage); //var responseMessage = Request.CreateResponse(HttpStatusCode.Created, message); //responseMessage.Headers.Location = new Uri(Request.RequestUri + "/" + (message.Id).ToString()); return(CreatedAtRoute("DefaultApi", new { id = message.Id }, message)); } catch (Exception ex) { Console.Error.WriteLine(ex); return(StatusCode(HttpStatusCode.InternalServerError)); } }