Exemplo n.º 1
0
        public void Confirm(int landId, int userId, ConfirmationSort confirmationSort, string username, string password)
        {
            client.Authenticator = new HttpBasicAuthenticator(username, password);

            var earthwatcher = new Earthwatcher { Id = userId };
            var request = new RestRequest("land/" + landId.ToString(CultureInfo.InvariantCulture) + @"/" + confirmationSort.ToString(), Method.PUT);
            request.AddBody(earthwatcher);
            request.RequestFormat = DataFormat.Json;
            client.ExecuteAsync(request, response =>
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    ConfirmationAdded(confirmationSort, null)
            ));
        }
Exemplo n.º 2
0
        public void Confirm(int landId, int userId, ConfirmationSort confirmationSort, string username, string password)
        {
            client.Authenticator = new HttpBasicAuthenticator(username, password);

            var earthwatcher = new Earthwatcher {
                Id = userId
            };
            var request = new RestRequest("land/" + landId.ToString(CultureInfo.InvariantCulture) + @"/" + confirmationSort.ToString(), Method.PUT);

            request.AddBody(earthwatcher);
            request.RequestFormat = DataFormat.Json;
            client.ExecuteAsync(request, response =>
                                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                                          ConfirmationAdded(confirmationSort, null)
                                                                          ));
        }
Exemplo n.º 3
0
        public void Confirm(Land land, ConfirmationSort confirmationSort, string username, string password)
        {
            client.Authenticator = new HttpBasicAuthenticator(username, password);
            var landMini = new LandMini {
                LandId = land.Id, EarthwatcherId = land.EarthwatcherId.Value, Id = Current.Instance.Earthwatcher.Id, GeohexKey = land.GeohexKey
            };
            var request = new RestRequest("land/" + confirmationSort.ToString().ToLower(), Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.JsonSerializer = new JsonSerializer();

            request.AddBody(landMini);
            client.ExecuteAsync(request, response =>
                                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                                          ConfirmationAdded(confirmationSort, null)
                                                                          ));
        }
        public void Confirm(Land land, ConfirmationSort confirmationSort, string username, string password)
        {
            client.Authenticator = new HttpBasicAuthenticator(username, password);
            var landMini = new LandMini { LandId = land.Id, EarthwatcherId = land.EarthwatcherId.Value, Id = Current.Instance.Earthwatcher.Id, GeohexKey = land.GeohexKey };
            var request = new RestRequest("land/" + confirmationSort.ToString().ToLower(), Method.POST) { RequestFormat = DataFormat.Json };
            request.JsonSerializer = new JsonSerializer();

            request.AddBody(landMini);
            client.ExecuteAsync(request, response =>
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    ConfirmationAdded(confirmationSort, null)
            ));
        }
Exemplo n.º 5
0
        //Action Clicks
        private void ReportButton_Click(object sender, RoutedEventArgs e)
        {
            if (Current.Instance.TutorialStarted)
            {
                reportWindow_Closed(null, null); //close the report window and excecute callback on mainpage
                return;
            }

            this.ValidateMessageText.Visibility = System.Windows.Visibility.Collapsed;

            if (Current.Instance.Earthwatcher.Lands != null)
            {
                //Si es tu propia Parcela
                if (Current.Instance.Earthwatcher.Lands.Any(x => x.Id == selectedLand.Id))
                {
                    ConfirmationSort confirmationSort = ConfirmationSort.Confirm;

                    int statusNumber = 0;
                    if (this.AlertButton.BorderThickness.Left > 0)
                    {
                        statusNumber     = 4;
                        confirmationSort = ConfirmationSort.Deconfirm; //Alert
                    }

                    if (this.OkButton.BorderThickness.Left > 0)
                    {
                        statusNumber     = 3;
                        confirmationSort = ConfirmationSort.Confirm; //OK
                    }

                    if (statusNumber == 0)
                    {
                        statusNumber = 2; //Not Checked
                    }

                    status = (LandStatus)statusNumber;

                    if (selectedLand.LandStatus != status)
                    {
                        //Cambio el color de la parcela, segun el reporte del usuario
                        Current.Instance.Earthwatcher.Lands.Where(x => x.Id == selectedLand.Id).First().LandStatus = status;

                        loadinAnim.Visibility          = System.Windows.Visibility.Visible;
                        this.MainGrid.IsHitTestVisible = false;
                        landRequests.Confirm(selectedLand, confirmationSort, Current.Instance.Username, Current.Instance.Password);
                        landRequests.UpdateStatus(selectedLand.Id, status, Current.Instance.Username, Current.Instance.Password);
                    }
                }
                else //Si es la parcela de otro usuario
                {
                    ConfirmationSort confirmationSort = ConfirmationSort.Confirm;
                    bool             hasAction        = false;
                    if (this.ConfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.OKs.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Confirm;
                            hasAction        = true;
                        }
                    }

                    if (this.DeconfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.Alerts.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Deconfirm;
                            hasAction        = true;
                        }
                    }

                    if (hasAction)
                    {
                        loadinAnim.Visibility          = System.Windows.Visibility.Visible;
                        this.MainGrid.IsHitTestVisible = false;
                        landRequests.Confirm(selectedLand, confirmationSort, Current.Instance.Username, Current.Instance.Password);
                    }
                    else
                    {
                        this.ValidateMessageText.Visibility = System.Windows.Visibility.Visible;
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void ReportButton_Click(object sender, RoutedEventArgs e)
        {
            bool closeWindow = true;

            if (Current.Instance.Earthwatcher.LandId.HasValue)
            {
                if (Current.Instance.Earthwatcher.LandId == selectedLand.Id)
                {
                    int statusNumber = 0;
                    if (this.AlertButton.BorderThickness.Left > 0)
                    {
                        statusNumber = 4;
                    }

                    if (this.OkButton.BorderThickness.Left > 0)
                    {
                        statusNumber = 3;
                    }

                    if (statusNumber == 0)
                    {
                        statusNumber = 2; //Not Checked
                    }

                    status = (LandStatus)statusNumber;

                    if (selectedLand.LandStatus != status)
                    {
                        closeWindow = false;
                        landRequests.StatusChanged += SetLandStatusStatusChanged;
                        landRequests.UpdateStatus(selectedLand.Id, status, Current.Instance.Username, Current.Instance.Password);

                        Current.Instance.EarthwatcherLand.LandStatus = status;
                    }
                }
                else
                {
                    ConfirmationSort confirmationSort = ConfirmationSort.Confirm;
                    bool             hasAction        = false;
                    if (this.ConfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.DeforestationConfirmers.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Confirm;
                            hasAction        = true;
                        }
                    }

                    if (this.DeconfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.DeforestationDeconfirmers.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Deconfirm;
                            hasAction        = true;
                        }
                    }

                    if (hasAction)
                    {
                        closeWindow = false;

                        landRequests.ConfirmationAdded += landRequests_ConfirmationAdded;
                        landRequests.Confirm(selectedLand.Id, Current.Instance.Earthwatcher.Id, confirmationSort, Current.Instance.Username, Current.Instance.Password);
                    }
                }
            }

            if (closeWindow)
            {
                this.Close();
            }
        }