public HttpResponseMessage<bool> Login(HttpRequestMessage request) { var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString; var isOkay = Authenticator.Authenticate(connectionstring); if (isOkay) { //Guardo un nuevo Scoring ScoreRepository scoreRepository = new ScoreRepository(connectionstring); scoreRepository.AddLoginScore(System.Web.HttpContext.Current.User.Identity.Name); if (!Session.HasLoggedUser()) { EarthwatcherRepository ewRepo = new EarthwatcherRepository(connectionstring); var ew = ewRepo.GetEarthwatcher(System.Web.HttpContext.Current.User.Identity.Name, false); if (ew != null) { Session.GenerateCookie(ew); } } return new HttpResponseMessage<bool>(isOkay) { StatusCode = HttpStatusCode.OK }; } else { return new HttpResponseMessage<bool>(isOkay) { StatusCode = HttpStatusCode.Forbidden }; } }
/// <summary> /// Busca al primer usuario que reporto esa parcela con 30 verif, le asigna los puntos, lockea la parcela y la pasa a greenpeace. /// </summary> /// <param name="land"></param> /// <param name="verifications"></param> /// <returns></returns> private LandMini VerificationScoring(LandMini land, int verifications) { if (verifications >= 30) //cantidad de Verifications { //Si es el usuario de Greenpeace debería buscar el owner original if (land.EarthwatcherId == Configuration.GreenpeaceId) { connection.Open(); int?ewId = connection.Query <int>(string.Format("EXEC Land_VerificationScoring {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault(); if (ewId != null) { land.EarthwatcherId = Convert.ToInt32(ewId); } connection.Close(); } //Obtengo el mail del owner original para mandarle la notificacion por mail connection.Open(); string idobjMail = connection.Query <string>(string.Format("EXEC Land_VerificationScoring_2 {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault(); if (idobjMail != null) { land.Email = idobjMail; } connection.Close(); //Obtengo el earthwatcher para agregarle los puntos connection.Open(); Earthwatcher earthwatcher = connection.Query <Earthwatcher>(string.Format("EXEC Earthwatcher_GetEarthwatcher {0}", land.EarthwatcherId)).FirstOrDefault(); connection.Close(); //Le asigno los 2000 puntos var scoreRepository = new ScoreRepository(connection.ConnectionString); scoreRepository.PostScore(new Score(earthwatcher.Id, ActionPoints.Action.LandVerified.ToString(), ActionPoints.Points(ActionPoints.Action.LandVerified), earthwatcher.PlayingRegion, land.LandId)); //El owner de la parcela pasa a ser Greenpeace y la parcela se lockea connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Land_VerificationScoring_3"; cmd.Parameters.Add(new SqlParameter("@LandId", land.LandId)); cmd.ExecuteNonQuery(); connection.Close(); return(land); } return(null); }
public void logSlInstall() { var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString; IScoreRepository repo = new ScoreRepository(connectionstring); Score s = new Score(17, ActionPoints.Action.Log.ToString(), ActionPoints.Points(ActionPoints.Action.Log), 0, 100, null, null, "SL_Install"); repo.PostScore(s); }
public void logSlInstall() { var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString; IScoreRepository repo = new ScoreRepository(connectionstring); Score s = new Score(); s.EarthwatcherId = 17; s.Action = ActionPoints.Action.Log.ToString(); s.Points = ActionPoints.Points(ActionPoints.Action.Log); s.Published = DateTime.UtcNow; s.Param1 = "SL_Install"; repo.PostScore(s); }
private int GetTotalScore(int Earthwatcher) { var scoreRepository = new ScoreRepository(connection.ConnectionString); return scoreRepository.GetScore(Earthwatcher); }
/// <summary> /// Busca al primer usuario que reporto esa parcela con 30 verif, le asigna los puntos, lockea la parcela y la pasa a greenpeace. /// </summary> /// <param name="land"></param> /// <param name="verifications"></param> /// <returns></returns> private LandMini VerificationScoring(LandMini land, int verifications) { if (verifications >= 30) //cantidad de Verifications { //Si es el usuario de Greenpeace debería buscar el owner original if (land.EarthwatcherId == Configuration.GreenpeaceId) { connection.Open(); int? ewId = connection.Query<int>(string.Format("EXEC Land_VerificationScoring {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault(); if (ewId != null) { land.EarthwatcherId = Convert.ToInt32(ewId); } connection.Close(); } //Obtengo el mail del owner original para mandarle la notificacion por mail connection.Open(); string idobjMail = connection.Query<string>(string.Format("EXEC Land_VerificationScoring_2 {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault(); if (idobjMail != null) { land.Email = idobjMail; } connection.Close(); //Obtengo el earthwatcher para agregarle los puntos connection.Open(); Earthwatcher earthwatcher = connection.Query<Earthwatcher>(string.Format("EXEC Earthwatcher_GetEarthwatcher {0}", land.EarthwatcherId)).FirstOrDefault(); connection.Close(); //Le asigno los 2000 puntos var scoreRepository = new ScoreRepository(connection.ConnectionString); scoreRepository.PostScore(new Score(earthwatcher.Id, ActionPoints.Action.LandVerified.ToString(), ActionPoints.Points(ActionPoints.Action.LandVerified), earthwatcher.PlayingRegion,land.LandId)); //El owner de la parcela pasa a ser Greenpeace y la parcela se lockea connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Land_VerificationScoring_3"; cmd.Parameters.Add(new SqlParameter("@LandId", land.LandId)); cmd.ExecuteNonQuery(); connection.Close(); return land; } return null; }
private int GetTotalScore(int Earthwatcher) { var scoreRepository = new ScoreRepository(connection.ConnectionString); return(scoreRepository.GetScore(Earthwatcher)); }
private LandMini VerificationScoring(LandMini land, int verifications) //Busca al primer usuario que reporto esa parcela con 30 verif, le asigna los puntos, lockea la parcela y la pasa a greenpeace. { if (verifications >= 30) //cambiar Verifications { //Si es el usuario de Greenpeace debería buscar el owner original if (land.EarthwatcherId == Configuration.GreenpeaceId) { connection.Open(); int? ewId = connection.Query<int>(string.Format("EXEC Land_VerificationScoring {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault(); if (ewId != null) { land.EarthwatcherId = Convert.ToInt32(ewId); } connection.Close(); } //Obtengo el mail del owner original para mandarle la notificacion por mail connection.Open(); string idobjMail = connection.Query<string>(string.Format("EXEC Land_VerificationScoring_2 {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault(); if (idobjMail != null) { land.Email = idobjMail; } connection.Close(); //Le asigno los 2000 puntos var scoreRepository = new ScoreRepository(connection.ConnectionString); scoreRepository.PostScore(new Score { Action = ActionPoints.Action.LandVerified.ToString(), LandId = land.LandId, EarthwatcherId = land.EarthwatcherId, Points = ActionPoints.Points(ActionPoints.Action.LandVerified), Published = DateTime.UtcNow }); //El owner de la parcela pasa a ser Greenpeace y la parcela se lockea connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Land_VerificationScoring_3"; cmd.Parameters.Add(new SqlParameter("@LandId", land.LandId)); cmd.ExecuteNonQuery(); connection.Close(); return land; } return null; }