Пример #1
0
        public async void ContinueGeofence()
        {
            GefenceManager gefenceManager = new GefenceManager();

            if (true)
            {
                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, "CompletePoint");

                    GefenceLocation.gefenceModel.OnePointForAddressOrder = GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders[index + 1];
                }
            }
        }
Пример #2
0
        public async void EndGeofence()
        {
            GefenceManager gefenceManager = new GefenceManager();

            if (true)
            {
                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.LocMgr != null)
                    {
                        gefenceModel.LocMgr.StopUpdatingLocation();
                    }
                    gefenceModel = null;
                }
            }
        }
Пример #3
0
        private static async void LocationsUpdated_Event(object sender, CLLocationsUpdatedEventArgs e)
        {
            if (true)
            {
                if (gefenceModel == null)
                {
                    if (!GefenceLocation.ResetGeofnceModel())
                    {
                        return;
                    }
                }
                int            index          = GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders.FindIndex(one => one == GefenceLocation.gefenceModel.OnePointForAddressOrder);
                GefenceManager gefenceManager = new GefenceManager();
                if (GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders.Count - 1 == index)
                {
                    if ((GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat - 0.00073 < e.Locations[0].Coordinate.Latitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat + 0.00073 > e.Locations[0].Coordinate.Latitude) &&
                        (GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng - 0.00073 < e.Locations[0].Coordinate.Longitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng + 0.00073 > e.Locations[0].Coordinate.Longitude))
                    {
                        if (GefenceLocation.gefenceModel.IsNewOrder)
                        {
                            await gefenceManager.RecurentStatusOrder(GefenceLocation.gefenceModel.OrderMobile.ID, "NewOrder");
                        }
                        else
                        {
                            await gefenceManager.RecurentStatusOrder(GefenceLocation.gefenceModel.OrderMobile.ID, "NewOrderAndEndOrder");
                        }
                        gefenceModel.LocMgr.StopUpdatingLocation();
                        gefenceModel = null;
                        //ComponentName receiver = new ComponentName(context, this.Class);
                        //PackageManager pm = context.PackageManager;
                        //pm.SetComponentEnabledSetting(receiver, ComponentEnabledState.Disabled, ComponentEnableOption.DontKillApp);
                        //if (MainActivity.GetInstance() == null)
                        //{
                        //    MainActivity mainActivity = new MainActivity();
                        //    mainActivity.Intent = new Intent(context, typeof(MainActivity));
                        //    mainActivity.Intent.AddFlags(ActivityFlags.NewTask);
                        //    context.StartActivity(mainActivity.Intent);
                        //}
                        //else
                        //{
                        //    context.StartActivity(MainActivity.GetInstance().Intent);
                        //}
                    }
                    else if ((GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat - 0.0022 < e.Locations[0].Coordinate.Latitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat + 0.0022 > e.Locations[0].Coordinate.Latitude) &&
                             (GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng - 0.0022 < e.Locations[0].Coordinate.Longitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng + 0.0022 > e.Locations[0].Coordinate.Longitude) && !GefenceLocation.gefenceModel.IsNewOrder)
                    {
                        await gefenceManager.RecurentStatusOrder(GefenceLocation.gefenceModel.OrderMobile.ID, "NewOrder");

                        GefenceLocation.gefenceModel.IsNewOrder = true;
                    }
                }
                else
                {
                    if (GefenceLocation.gefenceModel.OnePointForAddressOrder.Type == "Start")
                    {
                        if ((GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat - 0.00073 < e.Locations[0].Coordinate.Latitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat + 0.00073 > e.Locations[0].Coordinate.Latitude) &&
                            (GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng - 0.00073 < e.Locations[0].Coordinate.Longitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng + 0.00073 > e.Locations[0].Coordinate.Longitude))
                        {
                            await gefenceManager.RecurentStatusOrder(GefenceLocation.gefenceModel.OrderMobile.ID, "CompletePoint");

                            GefenceLocation.gefenceModel.OnePointForAddressOrder = GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders[index + 1];
                            gefenceManager.GoDriveTo(GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat, GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng);
                        }
                    }
                    else if (GefenceLocation.gefenceModel.OnePointForAddressOrder.Type == "End")
                    {
                        if ((GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat - 0.00073 < e.Locations[0].Coordinate.Latitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat + 0.00073 > e.Locations[0].Coordinate.Latitude) &&
                            (GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng - 0.00073 < e.Locations[0].Coordinate.Longitude && GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng + 0.00073 > e.Locations[0].Coordinate.Longitude))
                        {
                            await gefenceManager.RecurentStatusOrder(GefenceLocation.gefenceModel.OrderMobile.ID, "CompletePoint");

                            GefenceLocation.gefenceModel.OnePointForAddressOrder = GefenceLocation.gefenceModel.OrderMobile.OnePointForAddressOrders[index + 1];
                            gefenceManager.GoDriveTo(GefenceLocation.gefenceModel.OnePointForAddressOrder.Lat, GefenceLocation.gefenceModel.OnePointForAddressOrder.Lng);
                        }
                    }
                }
            }
        }