예제 #1
0
        public int AddUpdateBtDevice(BtDevice btdevice, GPSLocation gpsLocation)
        {
            int btDeviceId = 0;

            iBeacon_Indexer.BtDevices btDevicesIndividual = new BtDevices();

            btDevicesIndividual.Name       = btdevice.Name;
            btDevicesIndividual.Type       = btdevice.Type;
            btDevicesIndividual.MacAddress = btdevice.MacAddress;
            btDevicesIndividual.Strength   = btdevice.Strength;
            btDevicesIndividual.UUID       = btdevice.UuidString;
            btDevicesIndividual.Major      = btdevice.MajorInt;
            btDevicesIndividual.Minor      = btdevice.MinorInt;
            btDevicesIndividual.TimeFound  = btdevice.TimeFound.ToString();

            BtDevices deviceAlreadyExists = GetBtDevice(btdevice.UuidString, btdevice.MajorInt, btdevice.MinorInt);

            if (deviceAlreadyExists == null)
            {
                btDeviceId = conn.Insert(btDevicesIndividual);
                gpsLocation.BtDevicesId = btDeviceId;
                conn.Insert(gpsLocation);
            }
            else
            {
                btDevicesIndividual.Id = deviceAlreadyExists.Id;
                conn.Update(btDevicesIndividual);

                GPSLocation existingGPSLocation = GetGpsLocation(btDevicesIndividual.Id);
                if (existingGPSLocation == null)
                {
                    existingGPSLocation                   = new GPSLocation();
                    existingGPSLocation.BtDevicesId       = btDeviceId;
                    existingGPSLocation.Address           = gpsLocation.Address;
                    existingGPSLocation.Altitude          = gpsLocation.Altitude;
                    existingGPSLocation.LatitudeLongitude = gpsLocation.LatitudeLongitude;
                    conn.Insert(gpsLocation);
                }
                else
                {
                    existingGPSLocation.BtDevicesId       = btDeviceId;
                    existingGPSLocation.Address           = gpsLocation.Address;
                    existingGPSLocation.Altitude          = gpsLocation.Altitude;
                    existingGPSLocation.LatitudeLongitude = gpsLocation.LatitudeLongitude;
                    conn.Update(existingGPSLocation);
                }
            }

            return(btDeviceId);
        }
예제 #2
0
        public int AddNewBtDevice(BtDevice btdevice, GPSLocation newGpsLocation)
        {
            iBeacon_Indexer.BtDevices btDevicesIndividual = new BtDevices();
            btDevicesIndividual.Name       = btdevice.Name;
            btDevicesIndividual.Type       = btdevice.Type;
            btDevicesIndividual.MacAddress = btdevice.MacAddress;
            btDevicesIndividual.Strength   = btdevice.Strength;
            btDevicesIndividual.UUID       = btdevice.UuidString;
            btDevicesIndividual.Major      = btdevice.MajorInt;
            btDevicesIndividual.Minor      = btdevice.MinorInt;

            int newBTDeviceId = conn.Insert(btDevicesIndividual);;

            newGpsLocation.BtDevicesId = newBTDeviceId;
            conn.Insert(newGpsLocation);

            return(newBTDeviceId);
        }