コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 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);
         }
     }
 }
コード例 #4
0
 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");
         }
     }
 }