示例#1
0
 public AreaVisitEvent(DeviceLabelEvent _labelEvent,  Area _area, LastAreaAccess _areaAccess, int _nTimeDelay)
 {
     device = _labelEvent.device;
     label = _labelEvent.label;
     signal = _labelEvent.signal;
     area = _area;
     areaAccess = _areaAccess;
     timeDelay = _nTimeDelay;
 }
示例#2
0
 public LastAreaAccess findOrCreateLastAreaAccess(Area _area, Device _device)
 {
     try
     {
         return (
             from m in db.LastAreaAccesses
             where m.areaId == _area.areaId && m.deviceId == _device.deviceId
             select m
         ).First<LastAreaAccess>();
     }
     catch (Exception)
     {
         TimeSpan span = DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0));
         LastAreaAccess record = db.LastAreaAccesses.Create();
         record.Area = _area;
         record.Device = _device;
         record.accessTime = (int)span.TotalSeconds;
         db.LastAreaAccesses.Add(record);
         db.SaveChanges();
         System.Diagnostics.Debug.Write("\n Create new area access, area:" + _area.areaId + ", device: " + _device.deviceId + ", devicename: '" + _device.deviceName + "'");
         return record;
     }
 }