Ejemplo n.º 1
0
        protected void HandleFoundBeacon(string beaconId, ushort major, ushort minor)
        {
            var beaconModel = new BeaconModel
            {
                UUID  = beaconId,
                Major = major,
                Minor = minor
            };

            var activity = new BeaconActivity
            {
                BeaconModel  = beaconModel,
                CreationDate = DateTime.Now
            };

            //If we registered a beacon in lesser period than threshold we should ignore this event
            var lastActivity = _beaconsActivity.LastOrDefault(x => x.BeaconModel.Equals(activity.BeaconModel) && DateTime.Now - x.CreationDate < _threshold);

            if (lastActivity != null)
            {
                return;
            }

            _beaconsActivity.RemoveAll(s => s.BeaconModel.Equals(activity.BeaconModel));
            _beaconsActivity.Add(activity);

            Debug.WriteLine("Found beacon: {0}.{1} - {2}", major, minor, beaconId);

            BeaconFound?.Invoke(null, beaconModel);
        }
Ejemplo n.º 2
0
        private async Task InitLocalStoreAsync()
        {
            // new code to initialize the SQLite store
            string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), localDbFilename);

            if (!File.Exists(path))
            {
                File.Create(path).Dispose();
            }

            var store = new MobileServiceSQLiteStore(localDbFilename);

            BeaconActivity      beaconact      = new BeaconActivity();
            GuiSettingsActivity guisettingsact = new GuiSettingsActivity();

            store.DefineTable <Beacon>();
            store.DefineTable <GuiSettings>();
            store.DefineTable <Location>();
            store.DefineTable <Map>();
            store.DefineTable <Prompt>();
            store.DefineTable <PromptStep>();
            store.DefineTable <Reminder>();
            store.DefineTable <Settings>();
            store.DefineTable <UserSettings>();
            store.DefineTable <Users>();
            store.DefineTable <UserMaps>();


            // Uses the default conflict handler, which fails on conflict
            // To use a different conflict handler, pass a parameter to InitializeAsync. For more details, see http://go.microsoft.com/fwlink/?LinkId=521416
            await client.SyncContext.InitializeAsync(store);
        }