Ejemplo n.º 1
0
        public void OnRegionStateChanged(GeofenceResult result)
        {
            Debug.WriteLine($"Region State changed to {result.TransitionName} for region {result.RegionId}.");

            if (result.Transition == GeofenceTransition.Entered)
            {
                Shift newShift = new Shift
                {
                    CompanyId  = "Yo",
                    EmployeeId = "Jarod",
                    LocationId = "YoCity",
                    StartTime  = DateTime.Now,
                    Wage       = new ShiftWage {
                        Title = "Prankster", HourlyRate = 500
                    }
                };

                SettingsService.CurrentShift = newShift;
                App.ShiftGoing = true;
            }
            else if (result.Transition == GeofenceTransition.Exited)
            {
                if (SettingsService.CurrentShift == null)
                {
                    return;
                }

                Shift currentShift = SettingsService.CurrentShift;
                currentShift.EndTime = DateTime.Now;

                apiService.CreateShift(currentShift);
                App.ShiftGoing = false;
            }
        }
Ejemplo n.º 2
0
 public void OnRegionStateChanged(GeofenceResult result)
 {
     if (result.Transition == GeofenceTransition.Entered)
     {
         Debug.WriteLine($"Crossed finish at point -> {result.RegionId}");
         MessagingCenter.Send <CrossGeofenceListener>(this, "crossed");
     }
 }
Ejemplo n.º 3
0
 public void OnRegionStateChanged(GeofenceResult result)
 {
     // The problem is this event firing does not work.. -- buddhima
     if (result.Transition == GeofenceTransition.Exited || result.Transition == GeofenceTransition.Entered)
     {
         // If this event fires, it will send the region resut using messaging center
         MessagingCenter.Send(result, "region");
     }
 }
Ejemplo n.º 4
0
        public void OnRegionStateChanged(GeofenceResult result)
        {
            var e = new Event()
            {
                Date        = (result.Transition != GeofenceTransition.Exited)?result.LastEnterTime.ToString():result.LastExitTime.ToString(),
                Id          = App.Events.Count + 1,
                Description = result.ToString()
            };

            App.Events.Add(e);
            Settings.SaveResult(e);
            Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, result.ToString()));
        }
Ejemplo n.º 5
0
 public void OnRegionStateChanged(GeofenceResult result)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (result.TransitionName == "Entered")
         {
             string[] lanlong = result.RegionId.Split(',');
             CrossGeofence.Current.StopMonitoring(result.RegionId);
             var options = new MapLaunchOptions {
                 Name = "1", NavigationMode = NavigationMode.None
             };
             await Map.OpenAsync(Convert.ToDouble(lanlong[1]), Convert.ToDouble(lanlong[2]), options);
         }
     });
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Send Region change using Messaging Center and then it will be call to API
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_Clicked(object sender, EventArgs e)
        {
            try
            {
                GeofenceResult result = new GeofenceResult()
                {
                    Transition    = GeofenceTransition.Exited,
                    RegionId      = "Depot",
                    Latitude      = 0,
                    Longitude     = 0,
                    LastEnterTime = DateTime.Now.AddMinutes(-5),
                    LastExitTime  = DateTime.Now
                };

                MessagingCenter.Send(result, "region");
            }
            catch (Exception ex)
            {
                await DisplayAlert("", ex.Message, "OK");
            }
        }
Ejemplo n.º 7
0
        private static void writeGeofenceData(GeofenceResult geofenceResultData)
        {
            string sqlCommandText = $@"
					INSERT INTO geo_fence  
						(
							floor_id,  
							geofence_id,  
							geofence_name
						)  
					VALUES  
						(  
							'{geofenceResultData.msg.floor_id}',
							'{geofenceResultData.msg.geofence_id}',
							'{geofenceResultData.msg.geofence_name}'
						);"                        ;

            writeSqlData(sqlCommandText);

            //Now write the points
            foreach (PointList p in geofenceResultData.msg.point_list)
            {
                sqlCommandText = $@"
					INSERT INTO point_list  
						(
							geofence_id,  
							x,  
							y
						)  
					VALUES  
						(  
							'{geofenceResultData.msg.geofence_id}',
							'{p.x}',
							'{p.y}'
						);"                        ;
                writeSqlData(sqlCommandText);
            }

            Console.WriteLine("Added geofenceResultData");
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Raises the region state changed event.
 /// </summary>
 /// <param name="result">Change result.</param>
 public void OnRegionStateChanged(GeofenceResult result)
 {
 }
Ejemplo n.º 9
0
 public void OnRegionStateChanged(GeofenceResult result)
 {
     Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, result.ToString()));
 }
Ejemplo n.º 10
0
 public void OnRegionStateChanged(GeofenceResult result)
 {
     Debug.WriteLine(result.ToString());
 }