private void SubmitReferenceEvents(ref JToken latestLocationEvent, ref JToken latestFileHeader, ref SingleThreadLogger logger)
{
try
{
if (latestFileHeader != null)
{
logger.Log("submit ref event : latestFileHeader");
// memorize the latest header
JournalEventRecieved.Raise(this, new JournalEventArgs() { EventType = JournalEvent.Fileheader, Data = latestFileHeader });
latestFileHeader = null;
}
if (latestLocationEvent != null)
{
logger.Log("submit ref event : latestLocationEvent");
// pre-check for base data which is currently not in the database.
BasedataEventArgs newBasedataArgItem = new BasedataEventArgs() {
EventType = JournalEvent.Basedata,
System = latestLocationEvent.Value<String>("StarSystem").NToString(""),
Station = latestLocationEvent.Value<String>("StationName").NToString("")
};
if(latestLocationEvent.Value<Object>("StarPos") != null)
{
newBasedataArgItem.Coordinates = new Point3Dbl((Double)latestLocationEvent["StarPos"][0],
(Double)latestLocationEvent["StarPos"][1],
(Double)latestLocationEvent["StarPos"][2]);
}
BasedataEventRecieved.Raise(this, newBasedataArgItem);
// always inform about the latest location information
JournalEventRecieved.Raise(this, new JournalEventArgs() { EventType = JournalEvent.Location, Data = latestLocationEvent });
latestLocationEvent = null;
}
}
catch (Exception ex)
{
throw new Exception("Error while processing reference events", ex);
}
}