private async void Set_location_Click(object sender, EventArgs e)
        {
            Final_Position = googleMap.CameraPosition.Target;

            try
            {
                var p = JsonConvert.DeserializeObject <Model.Missingvehicle>(Intent.GetStringExtra("objtopass"));
                p.locationLatitude  = Final_Position.Latitude.ToString();
                p.locationLongitude = Final_Position.Longitude.ToString();
                p.Status            = "unverified";
                p.issueFlag         = "green";
                p.isresolved        = 0;
                p.isWorkingStarted  = 0;
                p.amount_collected  = 0;
                p.estimated_cost    = 0;



                try
                {
                    mapFuncHelper   = new MapFunctions.MapFunctionHelper(APIKEY, googleMap);
                    p.location_name = await mapFuncHelper.FindCordinateAddress(Final_Position);

                    p.location_name = p.location_name.Replace(", Karachi, Karachi City, Sindh, Pakistan", string.Empty);
                    if (p.issueType == "Found Vehicle")
                    {
                        p.issueStatement = "Unidentified Vehicle Found since " + p.foundDate.Date.ToShortDateString() + "with Plate No. " + p.plateNumber + " near " + p.location_name;
                    }
                    if (p.issueType == "Missing Vehicle")
                    {
                        p.issueStatement = "Vehicle gone Missing since " + p.missingDate.Date + " with Plate No. " + p.plateNumber + " near " + p.location_name;
                    }

                    Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                    AlertDialog alert = dialog.Create();

                    alert.SetMessage("Please wait while your issue is being posted ...");
                    alert.Show();
                    await Control.IssueController.PostIssue <Model.Missingvehicle>(p, this);
                }

                catch (Exception ex)
                {
                    // Handle exception that may have occurred in geocoding or posting issue.
                }
            }
            catch (Exception)
            {
                set_location.Enabled = true;
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    Toast.MakeText(this, "Unfortunately! Your Issue cannot be posted at this time", ToastLength.Long).Show();
                });
            }
        }
        private async void Next_MissingVehicle3_Click(object sender, EventArgs e)
        {
            if (MissingVehicle3_radiobtn3.Checked)
            {
                var p = JsonConvert.DeserializeObject <Model.Missingvehicle>(Intent.GetStringExtra("objtopass"));
                p.issueType = "Missing Vehicle";
                Control.DataOper.PutData <Issuelocationpickup_MissingVehicle>(this, p);
            }
            else
            {
                await Task.Run(async() =>
                {
                    var p = JsonConvert.DeserializeObject <Model.Missingvehicle>(Intent.GetStringExtra("objtopass"));
                    p.locationLatitude  = location_lati;
                    p.locationLongitude = location_longi;
                    p.Status            = "unverified";
                    p.issueType         = "Missing Vehicle";
                    p.issueFlag         = "green";
                    p.isresolved        = 0;
                    p.isWorkingStarted  = 0;
                    p.amount_collected  = 0;
                    p.estimated_cost    = 0;

                    try
                    {
                        var mapFuncHelper = new MapFunctions.MapFunctionHelper(APIKEY, null);
                        var placemark     = await mapFuncHelper.FindCordinateAddress(new Android.Gms.Maps.Model.LatLng(Convert.ToDouble(location_lati), Convert.ToDouble(location_longi)));
                        if (placemark != null)
                        {
                            LocationName     = placemark.Replace(", Karachi, Karachi City, Sindh, Pakistan", string.Empty);
                            p.location_name  = LocationName;
                            p.issueStatement = "Vehicle Gone Missing since " + p.missingDate.Date.ToShortDateString() + " with Plate No. " + p.plateNumber + " near " + LocationName;
                            MainThread.BeginInvokeOnMainThread(() =>
                            {
                                Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                                AlertDialog alert = dialog.Create();

                                alert.SetMessage("Please wait while your issue is being posted ...");
                                alert.Show();
                                Control.IssueController.PostIssue <Model.Missingvehicle>(p, this);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                });
            }
        }
Esempio n. 3
0
        private async void Set_location_Click(object sender, EventArgs e)
        {
            Final_Position = googleMap.CameraPosition.Target;

            try
            {
                var p = JsonConvert.DeserializeObject <Model.Planting>(Intent.GetStringExtra("objtopass"));
                p.locationLatitude  = Final_Position.Latitude.ToString();
                p.locationLongitude = Final_Position.Longitude.ToString();
                p.Status            = "unverified";
                p.issueFlag         = "green";
                p.isresolved        = 0;
                p.issueType         = "Planting Compaign";
                p.isWorkingStarted  = 0;
                p.amount_collected  = 0;
                p.estimated_cost    = 0;



                try
                {
                    mapFuncHelper   = new MapFunctions.MapFunctionHelper(APIKEY, googleMap);
                    p.location_name = await mapFuncHelper.FindCordinateAddress(Final_Position);

                    p.location_name  = p.location_name.Replace(", Karachi, Karachi City, Sindh, Pakistan", string.Empty);
                    p.issueStatement = string.Format("Planting compaign started near {0}", p.location_name);
                    Control.DataOper.PutData <PlantingCampaign2>(this, p);
                }

                catch (Exception ex)
                {
                    // Handle exception that may have occurred in geocoding or posting issue.
                }
            }
            catch (Exception)
            {
                set_location.Enabled = true;
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    Toast.MakeText(this, "Unfortunately! Your Issue cannot be posted at this time", ToastLength.Long).Show();
                });
            }
        }
        public async void OnMapReady(GoogleMap googleMap)
        {
            this.googleMap = googleMap;
            LatLng current_location = await getCurrentLocation();

            googleMap.CameraIdle += GoogleMap_CameraIdle;
            mapFuncHelper         = new MapFunctions.MapFunctionHelper(APIKEY, googleMap);
            googleMap.MapType     = GoogleMap.MapTypeNormal;
            try
            {
                CameraUpdate cam = CameraUpdateFactory.NewLatLngZoom(current_location, 15);
                googleMap.AnimateCamera(cam);
                showMarkerOnMap();
            }
            catch (Exception ex)
            {
                Toast.MakeText(Application.Context, "Current Location cannot be detected at the moment", ToastLength.Long).Show();
            }
        }
Esempio n. 5
0
        private async void Set_location_Click(object sender, EventArgs e)
        {
            Final_Position = googleMap.CameraPosition.Target;

            try
            {
                var p = JsonConvert.DeserializeObject <Model.Debris>(Intent.GetStringExtra("objtopass"));
                p.locationLatitude  = Final_Position.Latitude.ToString();
                p.locationLongitude = Final_Position.Longitude.ToString();
                p.Status            = "unverified";
                p.issueFlag         = new Control.IssueFlagDetector().DetectDebrisFlag(p);
                p.isresolved        = 0;
                p.issueType         = "Debris";
                p.isWorkingStarted  = 0;
                p.amount_collected  = 0;
                p.estimated_cost    = 0;



                try
                {
                    mapFuncHelper   = new MapFunctions.MapFunctionHelper(APIKEY, googleMap);
                    p.location_name = await mapFuncHelper.FindCordinateAddress(Final_Position);

                    p.location_name = p.location_name.Replace(", Karachi, Karachi City, Sindh, Pakistan", string.Empty);
                    string s_statement;
                    if (p.roadCoverage == "halfblocked")
                    {
                        s_statement      = " is blocking half road ";
                        p.issueStatement = "Debris " + s_statement + " near " + p.location_name;
                    }
                    else if (p.roadCoverage == "fullblocked")
                    {
                        s_statement      = " is blocking full road ";
                        p.issueStatement = "Debris " + s_statement + " near " + p.location_name;
                    }
                    else if (p.roadCoverage == "sidearea")
                    {
                        s_statement      = " blocking a side of road ";
                        p.issueStatement = "Debris " + s_statement + " near " + p.location_name;
                    }
                    //Alert Dialogue Box
                    Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                    AlertDialog alert = dialog.Create();
                    alert.SetMessage("Please wait while your issue is being posted ...");
                    alert.Show();
                    await Control.IssueController.PostIssue <Model.Debris>(p, this);
                }

                catch (Exception ex)
                {
                    // Handle exception that may have occurred in geocoding or posting issue.
                }
            }
            catch (Exception)
            {
                set_location.Enabled = true;
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    Toast.MakeText(this, "Unfortunately! Your Issue cannot be posted at this time", ToastLength.Long).Show();
                });
            }
        }
        private async void Set_location_Click(object sender, EventArgs e)
        {
            Final_Position = googleMap.CameraPosition.Target;
            try
            {
                loader.Visibility    = Android.Views.ViewStates.Visible;
                set_location.Enabled = false;

                var Issue = JsonConvert.DeserializeObject <Manhole>(Intent.GetStringExtra("objtopass"));
                Issue.locationLatitude  = Final_Position.Latitude.ToString();
                Issue.locationLongitude = Final_Position.Longitude.ToString();
                Issue.Status            = "unverified";
                Issue.issueType         = "Manhole";
                Issue.isWorkingStarted  = 0;
                Issue.amount_collected  = 0;
                Issue.estimated_cost    = 0;
                //using (Control.IssueFlagDetector i = new Control.IssueFlagDetector())
                //{
                //    Issue.issueFlag = i.DetectManholeFlag(Issue);
                //}
                Issue.issueFlag = new Control.IssueFlagDetector().DetectManholeFlag(Issue);
                Issue.issueDate = DateTime.Now;
                try
                {
                    mapFuncHelper = new MapFunctions.MapFunctionHelper(APIKEY, googleMap);
                    var LocationName = await mapFuncHelper.FindCordinateAddress(Final_Position);

                    if (LocationName == " ")
                    {
                        loader.Visibility    = Android.Views.ViewStates.Gone;
                        set_location.Enabled = true;
                        Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                        AlertDialog alert = dialog.Create();
                        alert.SetTitle("Zoom In");
                        alert.SetMessage("Please be more specific when selecting location, you can zoom in the map to point the exact location.");
                        alert.SetButton("OK", (c, ev) =>
                        {
                            alert.Dismiss();
                        });
                        alert.Show();
                    }
                    else
                    {
                        string s_stat;
                        if (Issue.Iswateroverflow == true)
                        {
                            s_stat = " spilling dirty water ";
                            Issue.issueStatement = "Open Manhole" + s_stat + "near " + LocationName;
                        }
                        else if (Issue.Iswateroverflow == false)
                        {
                            s_stat = "Open ";
                            Issue.issueStatement = s_stat + "Manhole " + "near " + LocationName;
                        }
                        //
                        Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                        AlertDialog alert = dialog.Create();
                        //alert.SetContentView(Resource.Layout.createisue3);
                        alert.SetMessage("Please wait while your issue is being posted ...");
                        alert.Show();

                        _ = await Control.IssueController.PostIssue <Model.Manhole>(Issue, this);
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
                }
            }



            catch (Exception)
            {
                set_location.Enabled = true;
            }
        }
        private async void Next_FoundVehicle2_Click(object sender, EventArgs e)
        {
            if (FoundVehicle2_radiobtn3.Checked)
            {
                var p = JsonConvert.DeserializeObject <Model.Missingvehicle>(Intent.GetStringExtra("objtopass"));
                p.issueType = "Found Vehicle";
                Control.DataOper.PutData <Issuelocationpickup_MissingVehicle>(this, p);
            }
            else
            {
                if (location_lati != "" && location_longi != "")
                {
                    await Task.Run(async() =>
                    {
                        var p = JsonConvert.DeserializeObject <Model.Missingvehicle>(Intent.GetStringExtra("objtopass"));
                        p.locationLatitude  = location_lati;
                        p.locationLongitude = location_longi;
                        p.Status            = "unverified";
                        p.isresolved        = 0; // Issue is not resolved yet.
                        p.issueFlag         = "green";
                        p.issueType         = "Found Vehicle";
                        p.isWorkingStarted  = 0;
                        p.amount_collected  = 0;
                        p.estimated_cost    = 0;



                        try
                        {
                            mapFuncHelper = new MapFunctions.MapFunctionHelper(APIKEY, null);
                            var placemark = await mapFuncHelper.FindCordinateAddress(new Android.Gms.Maps.Model.LatLng(Convert.ToDouble(location_lati), Convert.ToDouble(location_longi)));
                            if (placemark != null)
                            {
                                LocationName     = placemark.Replace(", Karachi, Karachi City, Sindh, Pakistan", string.Empty);
                                p.location_name  = LocationName;
                                p.issueStatement = "Unidentified vehicle found since " + p.foundDate.Date.ToShortDateString() + " with Plate No. " + p.plateNumber + " near " + LocationName;
                                Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                                AlertDialog alert = dialog.Create();

                                alert.SetMessage("Please wait while your issue is being posted ...");
                                alert.Show();
                                await Control.IssueController.PostIssue <Model.Missingvehicle>(p, this);
                            }
                        }
                        catch (FeatureNotSupportedException fnsEx)
                        {
                            // Feature not supported on device
                        }
                        catch (Exception ex)
                        {
                            // Handle exception that may have occurred in geocoding
                        }
                    });
                }
                else
                {
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        Toast.MakeText(this, "Please select Vehicle Location", ToastLength.Long).Show();
                    });
                }
            }
        }