public async void EndGeofence() { var cm = (ConnectivityManager)MainActivity.GetInstance().BaseContext.GetSystemService(Context.ConnectivityService); GefenceManager gefenceManager = new GefenceManager(); if (cm.ActiveNetworkInfo == null ? false : cm.ActiveNetworkInfo.IsConnected) { if (gefenceModel == null) { if (GefenceLocation.ResetGeofnceModel()) { UpdateLocation(); } else { return; } } int index = GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders.FindIndex(one => one == GefenceLocation.gefenceModel.OnePointForAddressOrder); if (GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders.Count - 1 == index) { await gefenceManager.RecurentStatusOrder(GefenceLocation.gefenceModel.OrderMobile.ID, "NewOrderAndEndOrder"); if (gefenceModel.PendingIntent != null) { gefenceModel.PendingIntent.Cancel(); } gefenceModel = null; } } }
public void StopGeofence() { if (gefenceModel != null) { gefenceModel.PendingIntent.Cancel(); gefenceModel = null; } }
public void StartGeofence(string Id, double fromLat, double fromLng, double tooLat, double toLng, double radius) { gefenceModel = new GefenceModel(); gefenceModel.FromLat = fromLat; gefenceModel.FromLng = fromLng; gefenceModel.ToLat = tooLat; gefenceModel.ToLng = toLng; gefenceModel.Status = "From"; gefenceModel.Radius = radius; Dexter.WithActivity(MainActivity) .WithPermission(Manifest.Permission.AccessFineLocation) .WithListener(this) .Check(); }
public void StartGeofence(OrderMobile orderMobile) { if (gefenceModel == null) { gefenceModel = new GefenceModel(); } gefenceModel.OrderMobile = orderMobile; gefenceModel.OnePointForAddressOrder = orderMobile.OnePointForAddressOrders[0]; gefenceModel.IsNewOrder = false; Dexter.WithActivity(MainActivity.GetInstance()) .WithPermission(Manifest.Permission.AccessFineLocation) .WithListener(this) .Check(); }
public static bool ResetGeofnceModel() { string token = CrossSettings.Current.GetValueOrDefault("Token", ""); OrderMobile orderMobile = null; IRestResponse response = null; string content = null; try { RestClient client = new RestClient(Config.BaseReqvesteUrl); RestRequest request = new RestRequest("Api.Mobile/OrderMobile", Method.POST); client.Timeout = 60000; request.AddHeader("Accept", "application/json"); request.AddParameter("token", token); response = client.Execute(request); content = response.Content; } catch (Exception) { return(false); } if (content == "" || response.StatusCode == System.Net.HttpStatusCode.NotFound) { return(false); } else { if (GetData(content, ref orderMobile) == 3) { if (gefenceModel == null) { gefenceModel = new GefenceModel(); } gefenceModel.OrderMobile = orderMobile; gefenceModel.OnePointForAddressOrder = orderMobile.OnePointForAddressOrders.FirstOrDefault(oP => oP.Status == "DriveFromPoint"); gefenceModel.IsNewOrder = false; return(true); } else { return(false); } } }