コード例 #1
0
        public void NotificarSobreInmueble(Interesado interesado, decimal cotizacion)
        {
            if (!interesado.Disponible)
            {
                return;
            }

            if (cotizacion == 0)
            {
                cotizacion = GetDolar();
            }

            try
            {
                List <Inmueble> inmuebles = InmuebleDAO.GetInmueblesParaInteresado(interesado, cotizacion);
                if (inmuebles.Count > 0)
                {
                    EmailHelper.SendInmueblesInEmail(inmuebles, interesado);
                }
            }
            catch (Exception ex)
            {
                EmailHelper.EnviarNotificacion(ex);
            }
        }
コード例 #2
0
        public bool SubirInmuebleWeb(int inmuebleId)
        {
            try
            {
                WebHelper       helper    = new WebHelper();
                List <Inmueble> inmuebles = InmuebleDAO.GetInmuebles();
                Inmueble        inmueble  = inmuebles.Find(x => x.Id == inmuebleId);
                int             webId     = helper.InsertInmueble(inmueble);

                inmueble.WebId = webId;
                InmuebleDAO.GuardarInmueble(inmueble);

                List <Foto> fotos = FotoDAO.GetFotosDelInmueble(inmueble.Id);
                foreach (Foto foto in fotos)
                {
                    helper.InsertFoto(foto, inmueble.WebId);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(true);
        }
コード例 #3
0
 public Inmueble[] BuscarInmuebles(Inmueble inmueble, decimal?precioDesde, decimal?precioHasta)
 {
     try
     {
         return(InmuebleDAO.BuscarInmuebles(inmueble, precioDesde, precioHasta).ToArray());
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #4
0
 public Inmueble[] GetInmueblesParaInteresado(Interesado interesado, decimal cotizacion)
 {
     try
     {
         return(InmuebleDAO.GetInmueblesParaInteresado(interesado, cotizacion).ToArray());
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #5
0
        public void Test2()
        {
            List <Inmueble> inmuebles = InmuebleDAO.GetInmuebles();

            decimal cotizacion = GetDolar();

            foreach (Inmueble inmueble in inmuebles)
            {
                NotificarSobreInteresado(inmueble, cotizacion);
            }
        }
コード例 #6
0
 public int GuardarInmueble(Inmueble inmueble)
 {
     try
     {
         return(InmuebleDAO.GuardarInmueble(inmueble));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #7
0
 public Inmueble[] GetInmuebles()
 {
     try
     {
         return(InmuebleDAO.GetInmuebles().ToArray());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #8
0
 public void TestNotificarSobreInteresado()
 {
     //Este metodo es para probar el envio de los interesados para el inmueble que se detalla abajo
     try
     {
         List <Inmueble> inmuebles = InmuebleDAO.GetInmuebles();
         NotificarSobreInteresado(inmuebles.Find(x => x.Numero == "234"), GetDolar());
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #9
0
 public bool EliminarInmueble(Inmueble inmueble)
 {
     try
     {
         bool respuesta = InmuebleDAO.DeleteInmueble(inmueble);
         return(respuesta);
         //return DAOBase.DeleteEntity(inmueble);
     }
     catch (Exception ex)
     {
         EmailHelper.EnviarNotificacion(ex);
         throw ex;
     }
 }
コード例 #10
0
        public void GetInmueblesWeb()
        {
            WebClient syncClient = new WebClient();
            //syncClient.Headers.Add("application / json");
            var contentString = syncClient.DownloadString("http://www.moranvilla.com.ar/webservice");
            //var contentData = syncClient.DownloadData("http://localhost/service/info.php");

            // deserialize from json
            DataContractJsonSerializer ser =
                new DataContractJsonSerializer(typeof(List <Rootobject>));

            // put the downloaded data in a memory stream
            //MemoryStream ms = new MemoryStream();
            //ms = new MemoryStream(Encoding.Unicode.GetBytes(contentString));

            //MemoryStream ms1 = new MemoryStream();
            //ms1 = new MemoryStream(contentData);
            ////ms = new MemoryStream(content);


            //List<Rootobject> result = ser.ReadObject(ms) as List<Rootobject>;
            //List<Rootobject> result1 = ser.ReadObject(ms1) as List<Rootobject>;


            // Create the Json serializer and parse the response
            Rootobject weatherData = new Rootobject();
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Rootobject));

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(contentString)))
            {
                weatherData = (Rootobject)serializer.ReadObject(ms);
            }

            List <Info> inmueblesWeb = weatherData.info.ToList();

            List <Inmueble> inmuebles = InmuebleDAO.GetInmuebles();

            foreach (Info inmuebleWeb in inmueblesWeb)
            {
                Inmueble inmueble      = new Inmueble();
                string   observaciones = string.Empty;
                observaciones         += "Nombre en la web: " + inmuebleWeb.nombre_identitario + Environment.NewLine;
                observaciones         += "Comentarios en la web: " + inmuebleWeb.comentarios + Environment.NewLine;
                observaciones         += "Comentarios Internos: " + inmuebleWeb.comentarios_internos + Environment.NewLine;
                inmueble.Observaciones = observaciones;
                inmueble.Id            = Convert.ToInt32(inmuebleWeb.id);
                //inmueble.Dormitorios = inmuebleWeb.ambientes;
                inmueble.Calle     = inmuebleWeb.direccion;
                inmueble.Fecha     = Convert.ToDateTime(inmuebleWeb.fecha);
                inmueble.Tipo      = Convert.ToInt32(inmuebleWeb.tipo_inmueble);
                inmueble.Operacion = Convert.ToInt32(inmuebleWeb.tipo_operacion);

                if (!inmuebles.Exists(x => x.Id == inmueble.Id))
                {
                    InmuebleDAO.GuardarInmueble(inmueble, true);
                }
            }

            //HttpClient client = new HttpClient();
            //client.BaseAddress = new Uri(URL);

            //// Add an Accept header for JSON format.
            //client.DefaultRequestHeaders.Accept.Add(
            //new MediaTypeWithQualityHeaderValue("application/json"));

            //// List data response.
            //HttpResponseMessage response = client.GetAsync(urlParameters).Result;  // Blocking call!
            //if (response.IsSuccessStatusCode)
            //{
            //    // Parse the response body. Blocking!
            //    var dataObjects = response.Content.ReadAsAsync<IEnumerable<DataObject>>().Result;
            //    foreach (var d in dataObjects)
            //    {
            //        Console.WriteLine("{0}", d.Name);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            //}



            // web client
            //WebClient client = new WebClient();
            //client.Headers["Content-type"] = "application/json";

            //// invoke the REST method
            //byte[] data = client.DownloadData("http://localhost/service/info.php");

            //// put the downloaded data in a memory stream
            //MemoryStream ms = new MemoryStream();
            //ms = new MemoryStream(data);

            //// deserialize from json
            //DataContractJsonSerializer ser =
            //       new DataContractJsonSerializer(typeof(List<InmuebleWeb>));

            //List<InmuebleWeb> result = ser.ReadObject(ms) as List<InmuebleWeb>;

            //return result;
        }