Exemplo n.º 1
0
        public static void WriteListToDatabase(List <Property_Nestoria> list, string garden, string city_id, string country_id, bool buy, string userID, HttpContext context)
        {
            List <string> list2 = null;

            if (context != null)
            {
                list2 = (context.Session["idlist"] as List <string>);
            }
            if (list2 == null)
            {
                list2 = StaticCalls.GetPropertyIDList();
                if (context != null)
                {
                    context.Session.Add("idlist", list2);
                }
            }
            List <string>   list3 = list2;
            List <Property> list4 = new List <Property>();

            foreach (Property_Nestoria item in list)
            {
                Property property = Nestoria.NestoriaToAkaratak(item, garden, city_id, country_id, userID, buy);
                property.Property_Photo = StaticCalls.UploadImages(item.img_u, item.thumb_u);
                if (list3.Contains(item.pr_id))
                {
                    StaticCalls.UpdateProperty(property);
                }
                else
                {
                    list4.Add(property);
                }
                StaticCalls.send_text("p Added =" + property.Property_Id_ext);
            }
            StaticCalls.InsertProperties(list4);
        }
Exemplo n.º 2
0
 private static string GetCity(string place_name, string country)
 {
     foreach (City city in StaticCalls.GetCityList(Nestoria.GetCountry(false, country)))
     {
         if (city.City_Name == place_name)
         {
             return(city.City_ID.ToString());
         }
     }
     return(Nestoria.InsertCity(place_name, country));
 }
Exemplo n.º 3
0
        private static void Write_Log_Txt(string path, string place_name, string listing_type, string count, string keywords, string country, bool head)
        {
            string[] obj = new string[15]
            {
                "-------------------------------------------------------------------------------------------------------------------------\r\n                             -------------------------------------- ",
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null
            };
            DateTime now = DateTime.Now;

            obj[1]  = now.ToShortDateString();
            obj[2]  = "  |  ";
            now     = DateTime.Now;
            obj[3]  = now.ToShortTimeString();
            obj[4]  = " (";
            obj[5]  = Nestoria.GetCountry(true, country);
            obj[6]  = ", ";
            obj[7]  = place_name;
            obj[8]  = ", ";
            obj[9]  = listing_type;
            obj[10] = ", ";
            obj[11] = count;
            obj[12] = ", ";
            obj[13] = keywords;
            obj[14] = ")------------------------------------------";
            string text  = string.Concat(obj);
            string text2 = "------------------------------------------------------------------------------------------------------------------------------------\r\n                              ------------------------------------------------------------------------------------------------------------------------------------";

            if (head)
            {
                StaticCalls.send_text(text);
                StaticCalls.send_text("Sending Requst....");
                StaticCalls.send_text("File Recived: ");
                StaticCalls.send_text(File.ReadAllText(path));
            }
            else
            {
                StaticCalls.send_text(text2);
            }
        }
Exemplo n.º 4
0
 public static void RunTask()
 {
     StaticCalls.send_text("\\c");
     foreach (Setting_Nestoria parameter in Nestoria.Get_Parameters())
     {
         StaticCalls.InitVars();
         string path = Nestoria.LoadList(parameter.Country, parameter.Place_Name, parameter.Listing_Type, parameter.Count, parameter.Keywords, File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/Temp/Nestoria.xml") ? (AppDomain.CurrentDomain.BaseDirectory + "/Temp/Nestoria.xml") : File.Create(AppDomain.CurrentDomain.BaseDirectory + "/Temp/Nestoria.xml").Name);
         Nestoria.Write_Log_Txt(path, parameter.Place_Name, parameter.Listing_Type, parameter.Count, parameter.Keywords, parameter.Country, true);
         List <Property_Nestoria> list = Nestoria.ProccessData(path, parameter.Place_Name, parameter.Listing_Type, parameter.Count, parameter.Keywords, parameter.Country);
         StaticCalls.Move_Images();
         Nestoria.Send_Email(Nestoria.WriteListToExcel(list, "/Logs/log " + DateTime.Now.ToShortDateString().Replace("/", "-") + ".xls"));
         Nestoria.Write_Log_Txt(path, parameter.Place_Name, parameter.Listing_Type, parameter.Count, parameter.Keywords, parameter.Country, false);
     }
 }
Exemplo n.º 5
0
        private static List <Property_Nestoria> ProccessData(string path, string place_name, string listing_type, string count, string keywords, string country)
        {
            StaticCalls.send_text("Diagnostic Data");
            StaticCalls.send_text("Converting XML to List !");
            List <Property_Nestoria> list = Nestoria.writeXmlToList(path);

            if (list.Count > 0)
            {
                StaticCalls.send_text("-----------------------------------------------------");
                StaticCalls.send_text("Writing List to Database !");
                Nestoria.WriteListToDatabase(list, Nestoria.GetGarden(keywords), Nestoria.GetCity(place_name, country), Nestoria.GetCountry(false, country), Nestoria.GetBuy(listing_type), Nestoria.User_ID, HttpContext.Current);
                StaticCalls.send_text("-----------------------------------------------------");
                StaticCalls.send_text("Done !");
            }
            else
            {
                StaticCalls.send_text("Check Parameters");
            }
            return(list);
        }
Exemplo n.º 6
0
 public static string LoadList(string country, string place_name, string listing_type, string num_res, string keywords, string path)
 {
     return(Nestoria.writeTempFile(StaticCalls.URLToString("http://api.nestoria." + country + "/api" + "?action=search_listings" + "&encoding=xml" + "&place_name=" + place_name + "&listing_type=" + listing_type + "&number_of_results=" + num_res + "&keywords=" + keywords), path));
 }
Exemplo n.º 7
0
 private static string InsertCity(string city_Name, string country)
 {
     return(StaticCalls.InsertCity(StaticCalls.GetCityData(Nestoria.GetCountry(true, country), city_Name, Nestoria.GetCountry(false, country))));
 }
Exemplo n.º 8
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);
        }