예제 #1
0
        private void VerificationScoring(LandMini landMini)
        {
            if (landMini != null)
            {
                try
                {
                    //Mando los mails notificando
                    if (!string.IsNullOrEmpty(landMini.Email))
                    {
                        if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["smtp.enabled"]))
                        {
                            List <System.Net.Mail.MailMessage> messages = new List <System.Net.Mail.MailMessage>();

                            System.Net.Mail.MailAddress address     = new System.Net.Mail.MailAddress(landMini.Email);
                            System.Net.Mail.MailAddress addressFrom = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["smtp.user"], Labels.Labels.GuardiansGreenpeace);
                            System.Net.Mail.MailMessage message     = new System.Net.Mail.MailMessage();
                            message.From = addressFrom;
                            message.To.Add(address);
                            message.Subject = Labels.Labels.LandVerifications.ToString();

                            string domain = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority);

                            string htmlTemplate = System.IO.File.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mail.html"));
                            message.Body = string.Format(htmlTemplate, Labels.Labels.LandVerifications2
                                                         , Labels.Labels.LandVerifications3
                                                         , string.Format("{0}/index.html?geohexcode={1}", domain, landMini.GeohexKey), Labels.Labels.LandVerifications4, Labels.Labels.LandVerifications5, Labels.Labels.LandVerifications6, landMini.Email
                                                         , Labels.Labels.LandVerifications7
                                                         , Labels.Labels.LandVerifications8, domain);
                            message.IsBodyHtml   = true;
                            message.BodyEncoding = System.Text.Encoding.UTF8;
                            message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.None;
                            messages.Add(message);

                            SendMails.Send(messages);
                        }
                    }

                    //Genero la imagen de este land
                    ImagesGeneratorTool.Run(landRepository, true, landMini.GeohexKey);

                    //Notify the land owner if logged in
                    var context = GlobalHost.ConnectionManager.GetHubContext <Hubs>();
                    context.Clients.All.LandVerified(landMini.EarthwatcherId);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
예제 #2
0
        public HttpResponseMessage GenerateGameImages(HttpRequestMessage request)
        {
            try
            {
                //Genero las imágenes
                ImagesGeneratorTool.Run(landRepository, false, null);

                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                });
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(ex.Message);
            }
        }
예제 #3
0
        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));
        }
예제 #4
0
        public HttpResponseMessage UpdateLandsDemand(List <Land> lands, HttpRequestMessage <List <Land> > request)
        {
            var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString;
            var earthwatcher     = Session.HasLoggedUser() ? new EarthwatcherRepository(connectionstring).GetEarthwatcher(Session.GetCookieInfo().EarthwatcherName, false) : null;

            var landsToConfirm = lands.Where(l => l.Reset == null || l.Reset == false).ToList();
            var landsToReset   = lands.Where(l => l.Reset.HasValue && l.Reset == true).ToList();

            try
            {
                if (landsToReset.Any())
                {
                    landRepository.ForceLandsReset(landsToReset, earthwatcher != null ? earthwatcher.Id : 0);
                }

                if (landsToConfirm.Any())
                {
                    if (landRepository.UpdateLandsDemand(lands, earthwatcher != null ? earthwatcher.Id : 0))
                    {
                        //Genero las imágenes
                        ImagesGeneratorTool.Run(landRepository, true, null);

                        //Send notification emails
                        SendEmail_GreenpeaceConfirmation(lands, earthwatcher);
                    }
                }

                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                });
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(ex.Message);
            }
        }