protected override void OnHandleIntent(Intent intent) { var geofencingEvent = GeofencingEvent.FromIntent(intent); var dbAdapter = new DbAdapter_Droid(); if (geofencingEvent.HasError) { var errorMessage = GeofenceErrorMessages.GetErrorString(this, geofencingEvent.ErrorCode); dbAdapter.AddDeviceLog("ジオフェンスエラー", errorMessage); NotificationUtil.Instance.SendNotification(this, NotificationUtil.STATUS_NOTIFICATION_CHANNEL_ID, "GeofenceError", "エラーです。", errorMessage); return; } int geofenceTransition = geofencingEvent.GeofenceTransition; if (geofenceTransition == Geofence.GeofenceTransitionEnter || geofenceTransition == Geofence.GeofenceTransitionExit) { IList <IGeofence> triggeringGeofences = geofencingEvent.TriggeringGeofences; var updateGeofenceStatus = geofenceTransition == Geofence.GeofenceTransitionEnter; string geofenceTransitionDetails = GetGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); Log.Info(TAG, geofenceTransitionDetails); var triggerRegions = triggeringGeofences .Select(g => Regions.RegionList.GetRegionFromIdentifier(g.RequestId)) .Where(r => r != null) .Select(r => (Regions.GeofenceRegion)r) .ToList() ; //GPS情報 var lat = geofencingEvent.TriggeringLocation.Latitude; var lng = geofencingEvent.TriggeringLocation.Longitude; var accuracy = geofencingEvent.TriggeringLocation.Accuracy; var date = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); // 更新 foreach (var region in triggerRegions) { var statusText = geofenceTransition == Geofence.GeofenceTransitionEnter ? "侵入" : "退出"; dbAdapter.AddDeviceLog($"ジオフェンス[{region.DbIdentifierName}]の状態を[{statusText}]に更新", $"{date},Droid,{lat},{lng},{accuracy},{statusText}"); dbAdapter.UpdateGeofenceStatus(UserDataModel.Instance.DeviceId, region.DbIdentifierName, updateGeofenceStatus); } } else { // Log the error. Log.Error(TAG, this.GetString(Resource.String.geofence_transition_invalid_type, new[] { new Java.Lang.Integer(geofenceTransition) })); dbAdapter.AddDeviceLog("ジオフェンスエラー", this.GetString(Resource.String.geofence_transition_invalid_type, new[] { new Java.Lang.Integer(geofenceTransition) })); } }
/// <summary> /// ビーコン領域から退出した際のコールバック /// </summary> /// <param name="p0"></param> public void DidExitRegion(Org.Altbeacon.Beacon.Region p0) { Log.Info(TAG, "Exit [{0}] Region", p0.UniqueId); var adapter = new DbAdapter_Droid(); adapter.AddDeviceLog("ビーコンから退出:在室状況を[学内]に更新", p0.UniqueId); if (p0.UniqueId.Equals(Regions.RegionList.研究室.Identifier)) { //研究室から退出 var dbAdapter = new DbAdapter_Droid(); dbAdapter.UpdateStatus(UserDataModel.Instance.MemberId, Status.学内.GetStatusId(), true); } }
public void DidExitRegion(Org.Altbeacon.Beacon.Region p0) { Log.Info(TAG, "Exit [{0}] Region", p0.UniqueId); if (p0.UniqueId.Equals(Regions.RegionList.研究室.Identifier)) { //研究室から退出 var dbAdapter = new DbAdapter_Droid(); dbAdapter.UpdateStatus(UserDataModel.Instance.MemberId, Status.学内.GetStatusId(), true); _beaconManager.Unbind(this); StopForeground(true); } }
/// <summary> /// ビーコン領域に侵入した際のコールバック /// </summary> /// <param name="p0"></param> public void DidEnterRegion(Org.Altbeacon.Beacon.Region p0) { Log.Info(TAG, "Enter [{0}] Region", p0.UniqueId); Firebase.FirebaseApp.InitializeApp(this.ApplicationContext); var adapter = new DbAdapter_Droid(); adapter.AddDeviceLog("ビーコンに侵入:在室状況を[在室]に更新", p0.UniqueId); if (p0.UniqueId.Equals(Regions.RegionList.研究室.Identifier)) { //研究室に侵入 var dbAdapter = new DbAdapter_Droid(); dbAdapter.UpdateStatus(UserDataModel.Instance.MemberId, Status.在室.GetStatusId(), true); //var intent = new Intent(this, typeof(Beacons.BeaconMonitoringService)); //StartForegroundService(intent); } }
private void SendRegistrationToServer(string token) { IDbAdapter dbAdapter = new DbAdapter_Droid(); dbAdapter.UpdateDeviceInfo(fcmToken: token); }