Example #1
0
 private static void InitCity()
 {
     if (StaticCalls.citylist.Count == 0)
     {
         DataTable   query = StaticCalls.GetQuery("SELECT City_ID, City_Name, Country_ID, City_Native_Name, Latitude, Longitude FROM Cities", StaticCalls.ConnectionString, null);
         List <City> list  = new List <City>();
         try
         {
             foreach (DataRow row in query.Rows)
             {
                 list.Add(new City
                 {
                     Country_ID       = (int)row[2],
                     City_ID          = (int)row[0],
                     City_Name        = (string)row[1],
                     City_Native_Name = (string)row[3],
                     Latitude         = (string)row[4],
                     Longitude        = (string)row[5]
                 });
             }
         }
         catch
         {
         }
         StaticCalls.citylist = list;
     }
 }
Example #2
0
        public static void Send_Email(string logpath)
        {
            DateTime now  = DateTime.Now;
            string   subj = "Job Report " + now.ToShortDateString();

            string[] obj = new string[5]
            {
                "<h4>Job Report</h4><br>Job Ran successfully on: ",
                null,
                null,
                null,
                null
            };
            now    = DateTime.Now;
            obj[1] = now.ToString();
            obj[2] = "<br>the log for the data inserted can be found here <a href='http://data.akaratak.com/log.txt'>Log</a><br> and can be downloaded here <a href='" + logpath + "'>";
            obj[4] = "Download Excel</a><br>this log is generated daily";
            string body = string.Concat(obj);

            StaticCalls.SendLogMail("*****@*****.**", subj, body);
            StaticCalls.SendLogMail("*****@*****.**", subj, body);
            StaticCalls.SendLogMail("*****@*****.**", subj, body);
            StaticCalls.SendLogMail("*****@*****.**", subj, body);
            StaticCalls.send_text("Email Sent : [email protected]");
            StaticCalls.send_text("Email Sent : [email protected]");
            StaticCalls.send_text("Email Sent : [email protected]");
            StaticCalls.send_text("Email Sent : [email protected]");
        }
Example #3
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);
        }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         StaticCalls.InitVars();
     }
 }
Example #5
0
 private static void InitNames()
 {
     if (StaticCalls.imagenames.Count == 0)
     {
         Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory);
         StaticCalls.imagenames = StaticCalls.GetFilesList(AppDomain.CurrentDomain.BaseDirectory + "Property_Images\\");
     }
 }
Example #6
0
 public static void UpdateProperty(Property v)
 {
     foreach (Property item in new dataDataContext(StaticCalls.ConnectionString).Properties.ToList())
     {
         if (item != null && item.Property_Id_ext == v.Property_Id_ext)
         {
             StaticCalls.UpdateObj(v, item);
         }
     }
 }
Example #7
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));
 }
Example #8
0
        public static string InsertCity(City c)
        {
            StaticCalls.SetQuery("Insert Into Cities (City_Name,City_Native_Name,City_Latin_Name,Country_ID,Latitude,Longitude) values ('" + c.City_Name + "','" + c.City_Native_Name + "','" + c.City_Latin_Name + "'," + c.Country_ID + ",'" + c.Latitude + "','" + c.Longitude + "');");
            DataTable query = StaticCalls.GetQuery("select IDENT_CURRENT('Cities') as 'id'", StaticCalls.ConnectionString, null);

            if (query == null)
            {
                return("1");
            }
            return(query.Rows[0][0].ToString());
        }
Example #9
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);
            }
        }
Example #10
0
        public static void DeleteProperties()
        {
            dataDataContext dataDataContext = new dataDataContext(StaticCalls.ConnectionString);
            List <Property> ls = (from w in dataDataContext.Properties
                                  where w.Property_Id_ext != (string)null
                                  select w).ToList();

            dataDataContext.ExecuteCommand("DELETE FROM [dbo].[Properties] WHERE [Property_Id_ext] IS NOT NULL");
            StaticCalls.send_text("\\c");
            StaticCalls.send_text("Properties Deleted");
            StaticCalls.Remove_Images(ls);
            StaticCalls.send_text("Images Deleted");
        }
Example #11
0
        private static void Remove_Images(List <Property> ls)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(new DirectoryInfo((HttpContext.Current != null) ? HttpContext.Current.Request.PhysicalApplicationPath : AppDomain.CurrentDomain.BaseDirectory).Parent.FullName + "\\RealEstate\\PropertyImage");

            foreach (Property l in ls)
            {
                List <string> fileNames = StaticCalls.GetFileNames(l.Property_Photo);
                File.Delete((directoryInfo.FullName + fileNames[0] != null) ? fileNames[0] : "");
                StaticCalls.send_text("Deleted: " + directoryInfo.FullName + fileNames[0]);
                File.Delete((directoryInfo.FullName + fileNames[1] != null) ? fileNames[1] : "");
                StaticCalls.send_text("Deleted: " + directoryInfo.FullName + fileNames[1]);
            }
        }
Example #12
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);
     }
 }
Example #13
0
        public static string GetName()
        {
            string text = StaticCalls.RandomString(15);

            for (int i = 0; i < StaticCalls.imagenames.Count; i++)
            {
                if (text == StaticCalls.imagenames[i])
                {
                    text = StaticCalls.RandomString(15);
                    i    = 0;
                }
            }
            StaticCalls.imagenames.Add(text);
            return(text);
        }
Example #14
0
 public static string WriteListToExcel <T>(List <T> list, string fulllPath)
 {
     try
     {
         List <string> list2 = new List <string>();
         list2.Add(string.Join(string.Empty, from i in typeof(T).GetProperties()
                               select string.Format("{0}\t", i.Name)));
         list2.AddRange(from i in (IEnumerable <T>) list
                        select string.Join <object>("\t", Enumerable.Select <PropertyInfo, object>((IEnumerable <PropertyInfo>)i.GetType().GetProperties(), (Func <PropertyInfo, object>)((PropertyInfo t) => t.GetValue((T)i, null)))));
         StaticCalls.send_text("Wrote to Excel");
         File.WriteAllLines(fulllPath, list2);
     }
     catch (Exception)
     {
         StaticCalls.send_text("Check Excel Write");
     }
     return("http://data.akaratak.com/" + fulllPath);
 }
Example #15
0
        public static string UploadImages(string img1, string img2)
        {
            string text3;
            string text2;
            string text;
            string text4 = text3 = (text2 = (text = ""));

            if (!string.IsNullOrEmpty(img1))
            {
                text4 = StaticCalls.GetName();
                if (!string.IsNullOrEmpty(img2))
                {
                    text3 = StaticCalls.GetName();
                }
                if (HttpContext.Current != null)
                {
                    text2 = HttpContext.Current.Server.MapPath("~/Property_Images/") + text4 + ".jpg";
                    text  = HttpContext.Current.Server.MapPath("~/Property_Images/") + text3 + ".jpg";
                }
                else
                {
                    text2 = HostingEnvironment.MapPath("~/Property_Images/") + text4 + ".jpg";
                    text  = HostingEnvironment.MapPath("~/Property_Images/") + text3 + ".jpg";
                }
                StaticCalls.send_text("Local Path 1: " + text2);
                StaticCalls.send_text("Local Path 2: " + text);
                using (WebClient webClient = new WebClient())
                {
                    try
                    {
                        webClient.DownloadFile(img1, text2);
                        StaticCalls.send_text(img1 + " Uoloaded to: " + text2);
                        webClient.DownloadFile(img2, text);
                        StaticCalls.send_text(img2 + " Uoloaded to: " + text2);
                    }
                    catch (Exception)
                    {
                        return("NULL");
                    }
                }
                return(text4 + ".jpg|" + ((!string.IsNullOrEmpty(text3)) ? (text3 + ".jpg|") : ""));
            }
            return("NULL");
        }
Example #16
0
 private static void InitPropertyIDList()
 {
     if (StaticCalls.propertyidlist.Count == 0)
     {
         DataTable     query = StaticCalls.GetQuery("SELECT Properties.Property_Id_ext from Properties;", StaticCalls.ConnectionString, null);
         List <string> list  = new List <string>();
         try
         {
             foreach (DataRow row in query.Rows)
             {
                 list.Add(string.Concat(row["Property_Id_ext"]));
             }
         }
         catch
         {
         }
         StaticCalls.propertyidlist = list;
     }
 }
Example #17
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);
        }
Example #18
0
 private static List <string> Get_Property_List()
 {
     if (StaticCalls.propertyidlist.Count == 0)
     {
         DataTable     query = StaticCalls.GetQuery("SELECT Properties.Property_Photo from Properties;", StaticCalls.ConnectionString, null);
         List <string> list  = new List <string>();
         try
         {
             foreach (DataRow row in query.Rows)
             {
                 list.Add(string.Concat(row["Property_Photo"]));
             }
             return(list);
         }
         catch
         {
             return(new List <string>());
         }
     }
     return(new List <string>());
 }
Example #19
0
        public static List <Setting_Nestoria> Get_Parameters()
        {
            DataTable query = StaticCalls.GetQuery("SELECT        Nestoria.place, Nestoria.listing, Nestoria.count, Country.country_code, Nestoria.keywords\r\n                           FROM            Country INNER JOIN\r\n                           Nestoria ON Country.country_id = Nestoria.country_id", "SettingsConnectionString", null);
            List <Setting_Nestoria> list = new List <Setting_Nestoria>();

            if (query.Rows != null)
            {
                foreach (DataRow row in query.Rows)
                {
                    list.Add(new Setting_Nestoria
                    {
                        Place_Name   = row["place"].ToString(),
                        Country      = row["country_code"].ToString(),
                        Keywords     = row["keywords"].ToString(),
                        Listing_Type = row["listing"].ToString(),
                        Count        = row["count"].ToString()
                    });
                }
            }
            return(list);
        }
Example #20
0
        public static void Move_Images()
        {
            DirectoryInfo directoryInfo = new DirectoryInfo((HttpContext.Current != null) ? HttpContext.Current.Request.PhysicalApplicationPath : AppDomain.CurrentDomain.BaseDirectory);
            DirectoryInfo sourc         = new DirectoryInfo(directoryInfo.FullName + "\\Property_Images");
            DirectoryInfo dest          = new DirectoryInfo(directoryInfo.Parent.FullName + "\\RealEstate\\PropertyImage");

            FileInfo[]    files_source = sourc.GetFiles();
            int           source_count = files_source.Length;
            List <string> ls           = Get_Property_List();

            foreach (FileInfo fileInfo in files_source)
            {
                if (File.Exists(fileInfo.FullName))
                {
                    if (!HttpContext.Current.Request.Url.Authority.Contains("localhost"))
                    {
                        if (ls.Contains(fileInfo.Name))
                        {
                            File.Move(fileInfo.FullName, dest + "\\" + fileInfo.Name);
                        }
                    }
                }
                else
                {
                    StaticCalls.send_text("Check Image move Path");
                }
            }
            if (source_count > 0)
            {
                files_source = sourc.GetFiles();
                for (int i = 0; i < files_source.Length; i++)
                {
                    files_source[i].Delete();
                }
            }
            StaticCalls.send_text(source_count + " Images Moved");
        }
Example #21
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);
        }
Example #22
0
 public static void SendLogMail(string txtTo, string subj, string body)
 {
     StaticCalls.SendMail(StaticCalls.InfoUserName, StaticCalls.InfoPassword, StaticCalls.MailServer, subj, body, txtTo);
 }
Example #23
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))));
 }
Example #24
0
 public static void InitVars()
 {
     StaticCalls.InitCity();
     StaticCalls.InitNames();
     StaticCalls.InitPropertyIDList();
 }
Example #25
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));
 }