public void Process(LightningContext context) { var closePackets = context.Datapackets.Where(x => x.Received > this.packet.Received - TOACorrelator.MAXDELAY); var fullInfo = (from data in closePackets join status in context.Statuspackets on data.Batchid equals status.Batchid select new { DetectionInstance = DetectionInstance.FromPacket(data), Status = status }).ToList(); foreach (var x in fullInfo) { x.DetectionInstance.DetectorLat = x.Status.Gpslat.Value; x.DetectionInstance.DetectorLon = x.Status.Gpslon.Value; } Strike strike = TOACorrelator.Correlate(fullInfo.Select(x => x.DetectionInstance).ToList()); if (strike != null) { context.Add(strike); } }
public void StoreInDB() { Rawpackets packet = new Rawpackets { Data = RawBytes, Port = IPPort.ToString(), Address = IPAddress.ToString(), }; using (var context = new LightningContext()) { context.Add(packet); context.SaveChanges(); } }
public void StoreInDB(LightningContext context) { if (!packet.IsReady()) { throw new InvalidOperationException("Packet not constructed properly"); } try { context.Add(packet); Process(context); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.Message); if (ex.InnerException != null) { Console.Write(ex.InnerException.Message); } } }
public void StoreInDB(LightningContext context) { if (!packet.IsReady()) { throw new InvalidDataException("Packet not constructed properly"); } Console.WriteLine($"Status Packet storing on thread {Thread.CurrentThread.ManagedThreadId}"); try { context.Add(packet); context.SaveChanges(); } catch (Exception e) { if (e.InnerException != null) { Console.WriteLine($"{e.InnerException.Message} : storing status"); } else { Console.WriteLine($"{e.Message} : storing status"); } } }