コード例 #1
0
        public static Property NestoriaToAkaratak(Property_Nestoria item, string garden, string city_id, string country_id, string userid, bool buy)
        {
            Property property = new Property();

            property.Property_Category_ID = 1;
            property.Property_Type_ID     = 1;
            property.Property_Size        = int.Parse(item.size);
            property.Date_Added           = DateTime.UtcNow;
            property.Floor         = int.Parse(item.floor);
            property.Has_Garden    = ((byte)((garden == "1") ? 1 : 0) != 0);
            property.Has_Garage    = ((byte)((item.car_s.Length > 0) ? 1 : 0) != 0);
            property.Num_Bedrooms  = int.Parse(item.bed_n);
            property.Num_Bathrooms = int.Parse(item.bath_n);
            property.Expire_Date   = DateTime.UtcNow.AddMonths(3);
            property.Contract_Type = 1;
            property.City_ID       = int.Parse(city_id);
            property.Country_ID    = int.Parse(country_id);
            property.Address       = item.title;
            property.Location      = item.lat + "," + item.lng + "," + item.loc_a;
            property.Zip_Code      = "";
            property.Other_Details = item.summary + "\n" + item.keywrd;
            try
            {
                property.Sale_Price = (buy ? Convert.ToInt32(item.price.Substring(0, item.price.Length - 3)) : 0);
                property.Rent_Price = ((!buy) ? Convert.ToInt32(item.price.Substring(0, item.price.Length - 3)) : 0);
            }
            catch
            {
                property.Sale_Price = 0;
                property.Rent_Price = 0;
            }
            property.Num_Floors      = null;
            property.User_ID         = userid;
            property.Url_ext         = item.lister_u;
            property.Property_Id_ext = item.pr_id;
            return(property);
        }
コード例 #2
0
        public static List <Property_Nestoria> writeXmlToList(string path)
        {
            string text = File.ReadAllText(path);

            if (text.Length <= 0)
            {
                StaticCalls.send_text("Check Xml to List");
                return(new List <Property_Nestoria>());
            }
            XDocument xDocument           = XDocument.Parse(text);
            List <Property_Nestoria> list = new List <Property_Nestoria>();

            foreach (XElement item in xDocument.Root.DescendantNodes().OfType <XElement>())
            {
                if (item.Name == (XName)"listings")
                {
                    try
                    {
                        Property_Nestoria property_Nestoria = new Property_Nestoria();
                        property_Nestoria.bath_n      = ((item.Attribute("bathroom_number") != null) ? item.Attribute("bathroom_number").Value : "0");
                        property_Nestoria.bed_n       = ((item.Attribute("bedroom_number") != null) ? item.Attribute("bedroom_number").Value : "0");
                        property_Nestoria.car_s       = ((item.Attribute("car_spaces") != null) ? item.Attribute("car_spaces").Value : "0");
                        property_Nestoria.comm        = ((item.Attribute("datasource_name") != null) ? item.Attribute("datasource_name").Value : "0");
                        property_Nestoria.constr_y    = ((item.Attribute("datasource_name") != null) ? item.Attribute("datasource_name").Value : "0");
                        property_Nestoria.data_s      = ((item.Attribute("datasource_name") != null) ? item.Attribute("datasource_name").Value : "none");
                        property_Nestoria.floor       = ((item.Attribute("floor") != null) ? item.Attribute("floor").Value : "0");
                        property_Nestoria.img_h       = ((item.Attribute("img_height") != null) ? item.Attribute("img_height").Value : "0");
                        property_Nestoria.img_u       = ((item.Attribute("img_url") != null) ? item.Attribute("img_url").Value : "0");
                        property_Nestoria.img_w       = ((item.Attribute("img_width") != null) ? item.Attribute("img_width").Value : "0");
                        property_Nestoria.keywrd      = ((item.Attribute("keywords") != null) ? item.Attribute("keywords").Value : "none");
                        property_Nestoria.lat         = ((item.Attribute("latitude") != null) ? item.Attribute("latitude").Value : "0");
                        property_Nestoria.lister_u    = ((item.Attribute("lister_url") != null) ? item.Attribute("lister_url").Value : "0");
                        property_Nestoria.list_t      = ((item.Attribute("listing_type") != null) ? item.Attribute("listing_type").Value : "buy");
                        property_Nestoria.loc_a       = ((item.Attribute("location_accuracy") != null) ? item.Attribute("location_accuracy").Value : "0");
                        property_Nestoria.lng         = ((item.Attribute("longitude") != null) ? item.Attribute("longitude").Value : "0");
                        property_Nestoria.price       = ((item.Attribute("price") != null) ? item.Attribute("price").Value : "0");
                        property_Nestoria.price_c     = ((item.Attribute("price_formatted") != null) ? item.Attribute("price_formatted").Value : "$");
                        property_Nestoria.price_f     = ((item.Attribute("price_formatted") != null) ? item.Attribute("price_formatted").Value : "0");
                        property_Nestoria.price_h     = ((item.Attribute("price_currency") != null) ? item.Attribute("price_currency").Value : "0");
                        property_Nestoria.price_l     = ((item.Attribute("price_currency") != null) ? item.Attribute("price_currency").Value : "0");
                        property_Nestoria.price_t     = ((item.Attribute("price_currency") != null) ? item.Attribute("price_currency").Value : "0");
                        property_Nestoria.property_t  = ((item.Attribute("property_type") != null) ? item.Attribute("property_type").Value : "house");
                        property_Nestoria.size        = ((item.Attribute("size") != null) ? item.Attribute("size").Value : "0");
                        property_Nestoria.size_t      = ((item.Attribute("size_type") != null) ? item.Attribute("size_type").Value : "0");
                        property_Nestoria.summary     = ((item.Attribute("summary") != null) ? item.Attribute("summary").Value : "none");
                        property_Nestoria.thumb_h     = ((item.Attribute("thumb_height") != null) ? item.Attribute("thumb_height").Value : "0");
                        property_Nestoria.thumb_u     = ((item.Attribute("thumb_url") != null) ? item.Attribute("thumb_url").Value : "0");
                        property_Nestoria.thumb_w     = ((item.Attribute("thumb_width") != null) ? item.Attribute("thumb_width").Value : "0");
                        property_Nestoria.title       = ((item.Attribute("title") != null) ? item.Attribute("title").Value : "none");
                        property_Nestoria.updated_d   = ((item.Attribute("updated_in_days") != null) ? item.Attribute("updated_in_days").Value : "0");
                        property_Nestoria.updated_d_f = ((item.Attribute("updated_in_days_formatted") != null) ? item.Attribute("updated_in_days_formatted").Value : "0");
                        property_Nestoria.url         = ((item.Attribute("lister_url") != null) ? item.Attribute("lister_url").Value : "none");
                        property_Nestoria.pr_id       = ((item.Attribute("lister_url") != null) ? Nestoria.GetId(item.Attribute("lister_url").Value) : "0");
                        list.Add(property_Nestoria);
                    }
                    catch (Exception)
                    {
                        StaticCalls.send_text("Check Xml to List");
                    }
                }
            }
            StaticCalls.send_text("Wrote Xml to List");
            return(list);
        }