public ReportWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            commentRequests = new CommentRequests(Constants.BaseApiUrl);
            collectionRequests = new CollectionRequests(Constants.BaseApiUrl);
            landRequests = new LandRequests(Constants.BaseApiUrl);
            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);
            bcLayer = (BasecampLayer)Current.Instance.LayerHelper.FindLayer(Constants.BasecampsLayer); //TEST
            //Add event listeners
            commentRequests.CommentsByLandReceived += CommentRequestCommentsByLandReceived;
            collectionRequests.NewItemReceived += collectionRequests_NewItemReceived;
            collectionRequests.ItemsCountReceived += collectionRequests_ItemsCountReceived;
            collectionRequests.GetTotalItems(Current.Instance.Earthwatcher.Id);
            Current.Instance.MapControl.zoomFinished += MapControlZoomFinished;
            Current.Instance.MapControl.zoomStarted += MapControlZoomStarted;

            landRequests = new LandRequests(Constants.BaseApiUrl);
            landRequests.StatusChanged += SetLandStatusStatusChanged;
            landRequests.ConfirmationAdded += landRequests_ConfirmationAdded;

            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);

            this.Loaded += ReportWindow_Loaded;

            this.ShareStoryBoard.Completed += ShareStoryBoard_Completed;
        }
        public DemandWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            selectedLand = land;
            selectedEarthwatcher = earthwatcher;
            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);
            
            if (Current.Instance.Scores.Any(x => x.Action.Equals(ActionPoints.Action.DemandAuthorities.ToString()) && (x.LandId == selectedLand.Id)))
            {
                this.DemandIcon.Source = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/demandarShare.png");
                this.Title.Text = Labels.DemandWindow2;
                this.DemandText.Text = Labels.DemandWindow3;
                this.DemandText2.Text = Labels.DemandWindow4;
                this.DemandTitleText.Text = Labels.DemandWindow2;
            }
            else
            {
                this.DemandIcon.Source = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/demandar.png");
                this.Title.Text = Labels.DemandWindow1;
                this.DemandText.Text = Labels.DemandWindow5;
                this.DemandText2.Text = Labels.DemandWindow6;
                this.DemandTitleText.Text = Labels.DemandWindow1;
            }


        }
Esempio n. 3
0
        public void AddHexagon(Land land)
        {
            var zone = GeoHex.Decode(land.GeohexKey);

            var isOwn = Current.Instance.Earthwatcher.Lands.Any(x => x.GeohexKey == land.GeohexKey);
            var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords());
            var polygon = new Polygon { ExteriorRing = new LinearRing(sphericalCoordinates) };
            var feature = new Feature { Geometry = polygon };
            feature["isGreenpeaceUser"] = land.EarthwatcherId.HasValue && land.EarthwatcherId.Value == Configuration.GreenpeaceId ? "True" : "False";
            feature["hexcode"] = zone.code;

            bool ischecked = false;
            if (land.OKs.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())) || land.Alerts.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
            {
                ischecked = true;
            }

            bool denouncedByMe = false;
            if(Current.Instance.Scores.Any(x => x.Action.Equals(ActionPoints.Action.DemandAuthorities.ToString()) && (x.LandId == land.Id)))
            {
                denouncedByMe = true;
            }

            bool islockedOnly = land.IsLocked == true && land.DemandAuthorities == false ? true : false;

            feature.Styles.Add(GetVectorStyle(land.LandStatus, isOwn, land.DemandAuthorities, ischecked, land.EarthwatcherId.HasValue && land.EarthwatcherId.Value == Configuration.GreenpeaceId ? true : false, islockedOnly, denouncedByMe));

            source.Features.Add(feature);
        }
        public void AddBasecamp(Land land)
        {
            var zone = GeoHex.Decode(land.GeohexKey);

             var isOwn = Current.Instance.Lands.Any(x => x.GeohexKey == land.GeohexKey);
             var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords());
             var polygon = new Polygon { ExteriorRing = new LinearRing(sphericalCoordinates) };
             var feature = new Feature { Geometry = polygon };
             feature["bccode"] = zone.code;

             _source.Features.Add(feature);
        }
Esempio n. 5
0
        public void UpdateStatus(int landId, LandStatus landStatus, string username, string password)
        {
            client.Authenticator = new HttpBasicAuthenticator(username, password);

            var land = new Land { Id = landId, LandStatus = landStatus };
            var request = new RestRequest("land/" + landId.ToString(CultureInfo.InvariantCulture) + @"/updatestatus", Method.PUT);
            request.RequestFormat = DataFormat.Json;
            request.JsonSerializer = new JsonSerializer();

            request.AddBody(land);
            client.ExecuteAsync(request, response =>
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    StatusChanged(null, null)
            ));
        }
Esempio n. 6
0
 public Land Get(string name)
 {
     var land = new Land { Latitude = 5, Longitude = 10};
     return land;
 }
 public AlertedLandControl(Land land)
 {
     InitializeComponent();
     this.land = land;
     Init();
 }
        public void LoadReportWindowContent(string geoHexCode)
        {
            //Limpio los bordes y rellenos de las manitos
            var noBorder = new Thickness(0);
            var white = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

            this.AlertButton.BorderThickness = noBorder;
            this.AlertButton.Background = white;
            this.OkButton.BorderThickness = noBorder;
            this.OkButton.Background = white;
            this.ConfirmButton.BorderThickness = noBorder;
            this.ConfirmButton.Background = white;
            this.DeconfirmButton.BorderThickness = noBorder;
            this.DeconfirmButton.Background = white;

            //Muestro la ventanita
            this.Visibility = Visibility.Visible;

            //Oculto el TITLE y los grid de REPORTE, VERIFICACION, SHARE, DEMANDA. Mostrar FOOTER, COMMENTS, USER TITLE
            this.ValidateMessageText.Visibility = System.Windows.Visibility.Collapsed;
            this.Title.Visibility = System.Windows.Visibility.Collapsed;
            this.ReportGrid.Visibility = System.Windows.Visibility.Collapsed;
            this.ConfirmGrid.Visibility = System.Windows.Visibility.Collapsed;
            this.DemandGrid.Visibility = System.Windows.Visibility.Collapsed;
            this.ShareGrid.Visibility = System.Windows.Visibility.Collapsed;
            this.FooterGrid.Visibility = System.Windows.Visibility.Visible;
            this.commentsBorder.Visibility = System.Windows.Visibility.Visible;
            this.FincasGrid.Visibility = System.Windows.Visibility.Visible;
            this.UserTitle.Visibility = System.Windows.Visibility.Visible;
               //Luego de mostrar el shareGrid la animacion pone opacity 0 a las grillas de report y confirm
            this.ShareGrid.Opacity = 0;
            this.ConfirmGrid.Opacity = 1;
            this.ReportGrid.Opacity = 1;

            //Cargo los datos de la land y el earthwatcher de esa land
            foreach (var land in Current.Instance.LandInView)
            {
                if (land.GeohexKey.Equals(geoHexCode))
                {
                    selectedLand = land;
                    selectedEarthwatcher = new Earthwatcher { Name = selectedLand.EarthwatcherName, Id = selectedLand.EarthwatcherId.Value, IsPowerUser = selectedLand.IsPowerUser.Value };
                }
            }

            if (selectedLand == null)
                return;

            if (selectedLand.DemandAuthorities == false) //Si es reporte o verificacion
            {
               LoadReportORVerificationGrid();
            }
            else //Si es Denuncia
            {
                LoadDenounceGrid();
            }
        }
Esempio n. 9
0
        private void LandChanged(object sender, EventArgs e)
        {
            var land = sender as Land;
            selectedLand = land;

            if (land == null)
                return;

            if (!Current.Instance.Tutorial2Started)
            {
                Current.Instance.EarthwatcherLand = land;
                zone = GeoHex.Decode(land.GeohexKey);

                var hexagonLayer = Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername) as HexagonLayer;

                if (hexagonLayer != null && zone != null)
                    hexagonLayer.AddHexagon(zone, LandStatus.NotChecked, true);
            }

            MapHelper.ZoomToHexagon(Current.Instance.MapControl, land.GeohexKey);

            if (Current.Instance.Tutorial2Started)
            {
                this.Tutorial21StoryBoard.Begin();
            }
        }
        private void LandChanged(Land land)
        {
            selectedLand = land;
            bool openPoll = true;

            if (land == null)
                return;

            if (!Current.Instance.TutorialStarted)
            {
                //Chequeo Scoring para abrir Modals
                var logins = Current.Instance.RegionScores.Where(x => x.Action.Equals(ActionPoints.Action.Login.ToString())).OrderByDescending(x => x.Published);
                Score lastLogin = null;
                if (logins.Count() > 1)
                {
                    lastLogin = logins.Skip(1).First();
                }
                if (lastLogin != null)
                {
                    if (Current.Instance.RegionScores.Any(x => x.Action.Equals("DemandAuthoritiesApproved") && x.Published > lastLogin.Published))
                    {
                        NotificationsWindow notificationsWindow = new NotificationsWindow("DemandAuthoritiesApproved");
                        notificationsWindow.Show();
                        openPoll = false;
                    }

                    if (selectedLand.LastReset > lastLogin.Published)
                    {
                        NotificationsWindow notificationsWindow = new NotificationsWindow("NewLand");
                        notificationsWindow.Show();
                        openPoll = false;
                    }
                }

                var last2 = Current.Instance.RegionScores.OrderByDescending(x => x.Published).Take(2);
                if (last2.Any(x => x.Action.Equals(ActionPoints.Action.LandVerified.ToString())) && !last2.Any(x => x.Action.Equals(ActionPoints.Action.LandVerifiedInformed.ToString())))
                {
                    NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.LandVerifiedInformed.ToString());
                    notificationsWindow.Show();
                    openPoll = false;
                }

                //    //DESCOMENTAR ESTO PARA HABILITAR LAS POLLS
                //    //Si el ultimo login es de más de 2 horas, abrir el poll
                //    if (openPoll && lastLogin != null && DateTime.UtcNow.AddHours(-2) >= lastLogin.Published)
                //    {
                //        //TODO: DB. verificar con lucas
                //        //agrego como condicion final que el feature de poll este desbloqueado.
                //        if (Current.Instance.Features.IsUnlocked(EwFeature.Polls))
                //        {
                //            landRequest.GetVerifiedLandsGeoHexCodes(Current.Instance.Earthwatcher.Id, true);
                //        }
                //    }
            }

            if (!Current.Instance.TutorialStarted || Current.Instance.TutorialCurrentStep < 4)
            {
                var hexagonLayer = Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername) as HexagonLayer;

                if (hexagonLayer != null)
                    hexagonLayer.AddHexagon(selectedLand);

                //Inicializar fincas paito
                var basecampLayer = Current.Instance.LayerHelper.FindLayer(Constants.BasecampsLayer) as BasecampLayer;

                if (basecampLayer != null)
                    basecampLayer.LoadData();
            }

            if (string.IsNullOrEmpty(geohexcode))
            {
                if (!string.IsNullOrEmpty(land.GeohexKey))
                {
                    MapHelper.ZoomToHexagon(Current.Instance.MapControl, land.GeohexKey);
                }
                else
                {
                    MapHelper.ZoomToHexagon(Current.Instance.MapControl, "NY8582044"); // Hack: Si viene nulo por algun motivo lo mando a la land del tutor(siempre verde, lockeada)
                    //MessageBox.Show("TEST: MAPA CHICO, LLENDO A PARCELA DEL TUTOR");
                }
            }
            else
            {
                MapHelper.ZoomToHexagon(Current.Instance.MapControl, "NY8582044");
            }

            //Si tengo la land del tutor / No hay mas parcelas - Deshabilito el boton "Mi parcela" y "Cambiar Parcela" y muestro el msj
            if (!Current.Instance.TutorialStarted && Current.Instance.Earthwatcher.Lands.FirstOrDefault().IsTutorLand)
            {
                //Muestro el mensaje
                NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.RegionCompleted.ToString());
                notificationsWindow.Show();

                this.newPlotDiv.IsHitTestVisible = false;
                this.newPlotDiv.Opacity = 0.2;
                this.myPlotDiv.IsHitTestVisible = false;
                this.myPlotDiv.Opacity = 0.2;
            }
            else
            {
                this.newPlotDiv.IsHitTestVisible = true;
                this.newPlotDiv.Opacity = 1;
                this.myPlotDiv.IsHitTestVisible = true;
                this.myPlotDiv.Opacity = 1;
            }
        }
Esempio n. 11
0
        private void UpdateInfo(string hexCode, bool isRefresh)
        {
            if (Current.Instance.Earthwatcher.Lands != null &&
                Current.Instance.Earthwatcher.Lands.Any(x => x.GeohexKey == hexCode))
            {
                selectedLand = Current.Instance.Earthwatcher.Lands.Where(x => x.GeohexKey == hexCode).First();
                selectedEarthwatcher = Current.Instance.Earthwatcher;

                this.reportText.Text = Labels.HexInfo1;
                this.reportIcon.Source = ResourceHelper.GetBitmap("/Resources/Images/reportar.png");

                this.ActionButton.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                foreach (var land in Current.Instance.LandInView)
                {
                    if (land.GeohexKey.Equals(hexCode))
                        selectedLand = land;
                }

                if (selectedLand == null)
                    return;

                selectedEarthwatcher = new Earthwatcher { Name = selectedLand.EarthwatcherName, Id = selectedLand.EarthwatcherId.Value, IsPowerUser = selectedLand.IsPowerUser.Value };

                this.reportText.Text = Labels.HexInfo2;
                this.reportIcon.Source = ResourceHelper.GetBitmap("/Resources/Images/revisar.png");

                if (selectedLand.LandStatus == LandStatus.Alert || selectedLand.LandStatus == LandStatus.Ok)
                {
                    this.ActionButton.Visibility = System.Windows.Visibility.Visible;

                }
                else
                {
                    this.ActionButton.Visibility = System.Windows.Visibility.Collapsed;
                }
            }

            RenderActivity();
            commentRequests.GetCommentsByLand(selectedLand.Id);
        }
Esempio n. 12
0
        public ReportWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            this.ShareStoryBoard.Completed += ShareStoryBoard_Completed;

            selectedLand = land;

            string[] oks = null;
            string[] alerts = null;
            char[] charsep = new char[] { ',' };

            if (!string.IsNullOrEmpty(selectedLand.OKs))
            {
                oks = selectedLand.OKs.Split(charsep, StringSplitOptions.RemoveEmptyEntries);
            }

            if (!string.IsNullOrEmpty(selectedLand.Alerts))
            {
                alerts = selectedLand.Alerts.Split(charsep, StringSplitOptions.RemoveEmptyEntries);
            }

            if (Current.Instance.Earthwatcher.Lands.Any(x => x.Id == selectedLand.Id))
            {
                //NO SELECCIONAR LA MANITO OK o ALERT SEGUN EL STATUS, SINO LO QUE EL USER REPORTO
                this.ReportGrid.Visibility = System.Windows.Visibility.Visible;
                this.ConfirmGrid.Visibility = System.Windows.Visibility.Collapsed;

                //if (land.LandStatus == LandStatus.Alert)
                if (alerts != null && alerts.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.AlertButton.BorderThickness = new Thickness(4);
                    this.AlertButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));
                }

                //if (land.LandStatus == LandStatus.Ok)
                else if (oks != null && oks.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.OkButton.BorderThickness = new Thickness(4);
                    this.OkButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));
                }
            }
            else
            {
                this.Title.Text = Labels.Report5;
                this.ReportButton.Content = Labels.Report11;

                this.ReportGrid.Visibility = System.Windows.Visibility.Collapsed;
                this.ConfirmGrid.Visibility = System.Windows.Visibility.Visible;

                if (oks != null && oks.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.ConfirmButton.BorderThickness = new Thickness(4);
                    this.ConfirmButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));

                    this.ConfirmButton.IsHitTestVisible = false;
                    this.ConfirmButton.Cursor = Cursors.Arrow;
                }

                if (alerts != null && alerts.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.DeconfirmButton.BorderThickness = new Thickness(4);
                    this.DeconfirmButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));

                    this.DeconfirmButton.IsHitTestVisible = false;
                    this.DeconfirmButton.Cursor = Cursors.Arrow;
                }
            }

            int countConfirm = 0;
            int countDeconfirm = 0;

            if (oks != null)
            {
                countConfirm = oks.Length;
            }

            if (alerts != null)
            {
                countDeconfirm = alerts.Length;
            }

            //asocia esto a algún mensaje que muestre confirmación / deconfirmación
            this.countConfirm1.Text = string.Format("{0} {1}", countConfirm + countDeconfirm, Labels.Report12);
            this.countConfirm2.Text = string.Format("{0} {1}", countConfirm + countDeconfirm, Labels.Report12);

            //Limite de 30 verificaciones
            if (selectedLand.IsLocked || selectedLand.DemandAuthorities)
            {
                DisableActions();
            }
/*
            if (land.DemandAuthorities)
            {
                this.shareText.Text = Labels.Share5;
            }
 * */

            selectedEarthwatcher = earthwatcher;
            if (earthwatcher.IsPowerUser)
            {
                this.badgeIcon.Source = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/badgej.png");
                ToolTipService.SetToolTip(this.badgeIcon, "Jaguar");
            }

            if (Current.Instance.Scores.Count(x => x.Action == ActionPoints.Action.FoundTheJaguar.ToString()) != 0)
            {
                JaguarBadge.Visibility = Visibility.Visible;
            }
            if (Current.Instance.Scores.Any(x => x.Action.StartsWith(ActionPoints.Action.ContestWon.ToString())))
            {
                this.ContestWinnerBadge.Visibility = Visibility.Visible;
            }
            landRequests = new LandRequests(Constants.BaseApiUrl);
            landRequests.StatusChanged += SetLandStatusStatusChanged;
            landRequests.ConfirmationAdded += landRequests_ConfirmationAdded;

            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);

            this.Loaded += ReportWindow_Loaded;
        }
Esempio n. 13
0
        //NO SE USA
        public LandMini ReassignLand(Land land, string basecamp)
        {
            var earthwatcherRepository = new EarthwatcherRepository(connection.ConnectionString);
            var newLand = earthwatcherRepository.GetFreeLand(basecamp, "'" + land.GeohexKey + "'");
            if (newLand != null && !String.IsNullOrEmpty(newLand.GeohexKey))
            {
                connection.Open();
                var command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "Land_ReassignLand";
                command.Parameters.Add(new SqlParameter("@EarthwatcherId", land.EarthwatcherId));
                command.Parameters.Add(new SqlParameter("@currentLand", land.Id));
                command.Parameters.Add(new SqlParameter("@newGeoHexKey", newLand.GeohexKey));
                command.Parameters.Add(new SqlParameter("@status", Convert.ToInt32(land.LandStatus)));
                command.ExecuteNonQuery();
                connection.Close();

                return newLand;
            }
            else return null;
        }
Esempio n. 14
0
        private void UpdateInfo(string hexCode, bool isRefresh)
        {
            if (selectedLand == null || !selectedLand.GeohexKey.Equals(hexCode) || isRefresh)
            {
                if (Current.Instance.EarthwatcherLand != null &&
                    Current.Instance.EarthwatcherLand.GeohexKey.Equals(hexCode))
                {
                    selectedLand = Current.Instance.EarthwatcherLand;
                    selectedEarthwatcher = Current.Instance.Earthwatcher;

                    txtName.Text = selectedEarthwatcher.FullName;
                    txtCountry.Text = selectedEarthwatcher.Country;

                    //this.reportIcon.Source
                    this.reportText.Text = "REPORTAR";
                    this.ActionButton.Visibility = System.Windows.Visibility.Visible;
                    this.reportIcon.Source = ResourceHelper.GetBitmap("/Resources/Images/reportar.png");
                }
                else
                {
                    foreach (var land in Current.Instance.LandInView)
                    {
                        if (land.GeohexKey.Equals(hexCode))
                            selectedLand = land;
                    }

                    if (selectedLand == null)
                        return;

                    if (selectedLand.LandStatus == LandStatus.Alert)
                    {
                        this.ActionButton.Visibility = System.Windows.Visibility.Visible;
                        this.reportText.Text = "REVISAR";
                        this.reportIcon.Source = ResourceHelper.GetBitmap("/Resources/Images/revisar.png"); 
                    }
                    else
                    {
                        this.ActionButton.Visibility = System.Windows.Visibility.Collapsed;
                    }

                    earthwatcherRequest.GetById(selectedLand.EarthwatcherId.ToString());
                }

                commentRequests.GetCommentsByLand(selectedLand.Id);
            }

            /*
            //A new zone is clicked request data
            if (selectedLand == null || !selectedLand.GeohexKey.Equals(hexCode) || isRefresh)
            {
                ClearInfo();

                //If the zone is the zone of the logged in user););
                if (Current.Instance.EarthwatcherLand != null &&
                    Current.Instance.EarthwatcherLand.GeohexKey.Equals(hexCode))
                {
                    unassignedGrid.Visibility = Visibility.Collapsed;
                    confirmation.Visibility = Visibility.Collapsed;
                    statusChanger.Visibility = Visibility.Visible;

                    selectedLand = Current.Instance.EarthwatcherLand;
                    selectedEarthwatcher = Current.Instance.Earthwatcher;

                    commentRequests.GetCommentsByLand(selectedLand.Id);

                    var selectedIndex = 0;
                    if (((int) selectedLand.LandStatus) - 2 > -1) //-2 cause first 2 can not be set by user
                        selectedIndex = (int) selectedLand.LandStatus - 2;

                    cbSetStatus.SelectedIndex = selectedIndex;
                    txtStatus.Text = selectedLand.LandStatus.ToString();
                
                    txtName.Text = selectedEarthwatcher.FullName;
                    txtCountry.Text = selectedEarthwatcher.Country;
                }
                else
                {
                    foreach (var land in Current.Instance.LandInView)
                    {
                        if (land.GeohexKey.Equals(hexCode))
                            selectedLand = land;
                    }

                    if (selectedLand == null)
                        return;

                    //If there is no user attached to the land
                    if (selectedLand.LandStatus == LandStatus.Unwatched ||
                        selectedLand.LandStatus == LandStatus.Unassigned)
                    {
                        unassignedGrid.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        unassignedGrid.Visibility = Visibility.Collapsed;
                        statusChanger.Visibility = Visibility.Collapsed;

                        if (selectedLand.LandStatus == LandStatus.Alert && Current.Instance.Earthwatcher != null)
                            confirmation.Visibility = Visibility.Visible;
                        if (selectedLand.LandStatus != LandStatus.Alert || Current.Instance.Earthwatcher == null)
                            confirmation.Visibility = Visibility.Collapsed;

                        commentRequests.GetCommentsByLand(selectedLand.Id);
                        earthwatcherRequest.GetById(selectedLand.EarthwatcherId.ToString());
                    }
                }

                if (selectedLand.LandStatus == LandStatus.Alert)//if alerted show confirmers deconfirmers
                {
                    txtConfirmed.Visibility = Visibility.Visible;
                    txtDeconfirmed.Visibility = Visibility.Visible;
                    
                    var countConfirm = selectedLand.DeforestationConfirmers.Split(',');
                    var countDeconfirm = selectedLand.DeforestationDeconfirmers.Split(',');

                    if (countConfirm[0].Equals(""))
                        countConfirm = new string[0];
                    if (countDeconfirm[0].Equals(""))
                        countDeconfirm = new string[0];

                    txtConfirmed.Text = "Confirmed: " + countConfirm.Length;
                    txtDeconfirmed.Text = "Deconfirmed: " + countDeconfirm.Length;
                }
            }
             * */
        }
Esempio n. 15
0
        public static void AddLinks(Land land, HttpRequestMessage request)
        {
            //var uriBuilder = new UriBuilder(request.RequestUri) {Path = land.Uri};
            //land.Uri = uriBuilder.Uri.ToString();

        }
Esempio n. 16
0
        public ReportWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            selectedLand = land;

            string[] confirms = null;
            string[] deconfirms = null;

            if (!string.IsNullOrEmpty(selectedLand.DeforestationConfirmers))
            {
                confirms = selectedLand.DeforestationConfirmers.Split(',');
            }

            if (!string.IsNullOrEmpty(selectedLand.DeforestationDeconfirmers))
            {
                deconfirms = selectedLand.DeforestationDeconfirmers.Split(',');
            }

            if (Current.Instance.Earthwatcher.LandId.HasValue && Current.Instance.Earthwatcher.LandId == selectedLand.Id)
            {
                this.ReportGrid.Visibility = System.Windows.Visibility.Visible;
                this.ConfirmGrid.Visibility = System.Windows.Visibility.Collapsed;

                if (land.LandStatus == LandStatus.Alert)
                {
                    this.AlertButton.BorderThickness = new Thickness(4);
                    this.AlertButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));
                }

                if (land.LandStatus == LandStatus.Ok)
                {
                    this.OkButton.BorderThickness = new Thickness(4);
                    this.OkButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));
                }
            }
            else
            {
                this.Title.Text = "VALIDAR PARCELA EN ALERTA";
                this.ReportButton.Content = "VALIDAR";

                this.ReportGrid.Visibility = System.Windows.Visibility.Collapsed;
                this.ConfirmGrid.Visibility = System.Windows.Visibility.Visible;

                if (confirms != null && confirms.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.ConfirmButton.BorderThickness = new Thickness(4);
                    this.ConfirmButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));

                    this.ConfirmButton.IsHitTestVisible = false;
                    this.ConfirmButton.Cursor = Cursors.Arrow;
                }

                if (deconfirms != null && deconfirms.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.DeconfirmButton.BorderThickness = new Thickness(4);
                    this.DeconfirmButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));

                    this.DeconfirmButton.IsHitTestVisible = false;
                    this.DeconfirmButton.Cursor = Cursors.Arrow;
                }
            }

            //asocia esto a algún mensaje que muestre confirmación / deconfirmación
            if (land.LandStatus == LandStatus.Alert)
            {
                int countConfirm = 0;
                int countDeconfirm = 0;

                if (confirms != null)
                {
                    countConfirm = confirms.Length;
                }

                if (deconfirms != null)
                {
                    countDeconfirm = deconfirms.Length;
                }

                this.countConfirm1.Text = string.Format("{0} confirmaciones", countConfirm);
                this.countConfirm2.Text = string.Format("{0} confirmaciones", countConfirm);
                this.countDeConfirm1.Text = string.Format("{0} nada sospechoso", countDeconfirm);
                this.countDeConfirm2.Text = string.Format("{0} nada sospechoso", countDeconfirm);
            }
            else
            {
                this.countConfirm1.Visibility = System.Windows.Visibility.Collapsed;
                this.countConfirm2.Visibility = System.Windows.Visibility.Collapsed;
                this.countDeConfirm1.Visibility = System.Windows.Visibility.Collapsed;
                this.countDeConfirm2.Visibility = System.Windows.Visibility.Collapsed;
            }

            selectedEarthwatcher = earthwatcher;
            landRequests = new LandRequests(Constants.BaseApiUrl);
            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);

            this.Loaded += ReportWindow_Loaded;
        }
 public HttpResponseMessage<Land> UpdateStatusLand(Land land, HttpRequestMessage<Land> request)
 {
     var landDB = landRepository.GetLand(land.Id);
     if (landDB != null)
     {
         landRepository.UpdateLandStatus(land.Id, land.LandStatus);
         try
         {
             ImagesGeneratorTool.Run(landRepository, true, landDB.GeohexKey);
         }
         catch(Exception ex)
         {
             logger.Error("No se genero la imagen para la land " + landDB.Id.ToString());
         }
         return new HttpResponseMessage<Land>(land) { StatusCode = HttpStatusCode.OK };
     }
     return new HttpResponseMessage<Land>(HttpStatusCode.BadRequest);
 }
        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)
            ));
        }
Esempio n. 19
0
 public HttpResponseMessage<Land> UpdateStatusLand(Land land, HttpRequestMessage<Land> request)
 {
     if (landRepository.GetLand(land.Id) != null)
     {
         landRepository.UpdateLandStatus(land.Id, land.LandStatus);
         return new HttpResponseMessage<Land>(land) { StatusCode = HttpStatusCode.OK };
     }
     return new HttpResponseMessage<Land>(HttpStatusCode.BadRequest);
 }