示例#1
0
        private bool IsLocationThere(PostalAdress x, string localGroup, bool IsSph)
        {
            List<string> keys = x.Propertykeys;
            foreach (string k in keys)
            {
                if (log.propertyList.ContainsKey(k))
                {
                    Property p = log.propertyList[k];
                    string adressTemp = p.Adress.ToLower().Replace(",", "").Replace(" ", "");
                    //    string adressTemp=p.Adress.ToLower().Remove(p.Adress.Length-p.PCD.Length,p.PCD.Length).Replace(",","").Replace(" ","");
                    string localGroupTemp = localGroup.ToLower().Replace(" ", "").Replace(",", "");

                    //   string adress = (p.ORD + p.ORC + p.SBN + p.BNA + p.POB + p.NUM + p.DST + p.STM + p.DDL + p.DLO + p.PTN + p.PCD).ToLower().Replace(" ", "");
                    p.LMA = localGroupTemp;
                    if (adressTemp.Equals(localGroupTemp))
                    {
                        if (IsSph == false)
                        {
                            p.IsLandMarkCertified = true;
                            p.IsLandMarkSearched = true;

                            return true;
                        }
                        else
                        {
                            p.IsSphCertified = true;
                            p.IsSphSearched = true;

                        }
                    }
                    else
                    {
                        if (IsSph == false)
                        {
                            p.IsLandMarkCertified = false;
                            p.IsLandMarkSearched = true;

                        }
                        else
                        {
                            p.IsSphCertified = false;
                            p.IsSphSearched = true;
                        }

                    }
                }
                else
                {
                    throw new Exception("Exception Here");
                }
            }

            return false;
        }
示例#2
0
        public string FindAllProperties(PostalAdress p)
        {
            string ConsoleLog = null;
            PostalAdress po = POlog.GetObject(p.PCD);

            /*If Properties are searched this month ,no need to process again
             */

            if (DateTime.Compare(po.SearchedProperties.AddMonths(1), DateTime.Now) >= 0 && po.SearchedProperties.Equals(new DateTime(0001, 1, 1)) == false)
            {
                ConsoleLog += "Already Searched this Postal Adress in this month\n";
                return ConsoleLog;
            }
            else
            {
                ConsoleLog += "Valid Properties Searched\n";
                string ScrappedString = null;
                using (WebClient webClientObj = new WebClient())
                {
                    try
                    {
                        ScrappedString = webClientObj.DownloadString("http://www.zoopla.co.uk/home-values/" + p.PCD);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Unable to Connect Zoople" + e.Message);
                    }
                    string b = "<a *?href=\"/property/(?<data>.*?)" + p.PCD.Replace(" ", "-").ToLower() + ".*?class=\"attrProperty\".*?>(?<data2>.*?)" + p.PCD.ToUpper() + "</a>";
                    string RequiredRegex = b;
                    try
                    {
                        MatchCollection collection = Regex.Matches(ScrappedString, RequiredRegex);
                        foreach (Match m in collection)
                        {
                            Property pobj = new Property();
                            pobj.SimpleAdress = m.Groups[2].Value.TrimEnd();
                            pobj.UrlAdress = @"C:\\Users\\jafar.baltidynamolog\\Documents\\Visual Studio 2010\\Projects\\Imagenary\\Imagenary\\bin\\" + m.Groups[2].Value.TrimEnd().Replace("\\\\", "\\").Replace(",", "") + "\\";
                            // log.Add(pobj, p.PCD);
                            po.AddPropertyKey(pobj.SimpleAdress);
                            ConsoleLog += "Property Addeds..." + pobj.SimpleAdress + "\n";
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        throw new Exception("Exception while getting properties" + ex.Message);
                    }
                }
                po.SearchedProperties = DateTime.Now;
                ConsoleLog += "PostalAdress Added ...\n";
                POlog.Add(po);
            }
            return ConsoleLog;
        }
示例#3
0
        public PostalAdress GetObject(string p)
        {
            PostalAdress ResultObj;

            if (adressList.ContainsKey(p))
            {
                ResultObj = adressList[p];
            }
            else
            {
                ResultObj     = new PostalAdress();
                ResultObj.PID = p;
            }
            return(ResultObj);
        }
示例#4
0
        public bool Add(PostalAdress p)
        {
            bool Result;

            if (this.adressList.ContainsKey(p.PID))
            {
                //    adressList[p.PID] = p;
                Result = false;
            }
            else
            {
                this.adressList.Add(p.PID, p);
                Result = true;
            }
            return(Result);
        }
示例#5
0
        public bool Add(Property property, PostalAdress postaladress)
        {
            bool Result = false;

            if (propertyList.ContainsKey(property.PCD + property.URN) == false)
            {
                property.PCD       = postaladress.PCD;
                property.PID       = postaladress.PID;
                property.DateAdded = DateTime.Now;
                propertyList.Add(property.PCD, property);
                Result = false;
            }
            else
            {
                Result = true;
            }
            return(Result);
        }
示例#6
0
        public string ReadSPHFile(string FileName, PostalAdress poobj)
        {
            OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Searching SPH file" });
            string ConsoleLog = null;
            CsvFileReader handler = new CsvFileReader(FileName);
            int count = 0;
            while (handler != null)
            {

                CsvRow row = new CsvRow();
                handler.ReadRow(row);
                if (row.Count == 0)
                {
                    break;
                }
                count++;
                if (count == 1)
                {
                    continue;
                }
                //If country is there
                if (row.Count >= 14)
                {
                    OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "SPH Record No: " + count });
                    string localGroupadress = row[8] + ", " + row[9] + ", " + row[10] + ", " + row[11] + ", " + row[12] + ", " + row[13].Replace(", ,", "");
                    while (localGroupadress.StartsWith(", "))
                    {
                        localGroupadress = localGroupadress.Remove(0, 2);
                    }

                    IsLocationThere(poobj, localGroupadress, true);
                }
                else
                {
                    ConsoleLog = "Row has less element than Required";
                }
            }
            return ConsoleLog;
        }
示例#7
0
        private bool IsLocationThere2(PostalAdress x,string Document)
        {
            bool Result = false;

            List<string> keys = x.Propertykeys;
            foreach (string k in keys)
            {
                if (log.propertyList.ContainsKey(k))
                {
                    Property p = log.propertyList[k];
                    string adressTemp = p.Adress.ToLower().Replace(",", "").Replace(" ", "");
                    string DocumentHtml = Document.Replace(" ", "").Replace(",","").ToLower();
                    if (DocumentHtml.Contains(adressTemp))
                    {
                        p.IsLandMarkCertified = true;
                        p.IsLandMarkSearched = true;
                        Result = true;
                    }
    OnInformationDownload(new EventArguments() { Name = "SETRICHBOX", Time = DateTime.Now, Details = ": LMA= " + p.IsLandMarkCertified + "  -SPH=" + p.IsSphCertified + "  -  " + p.PID + " - " + p.Adress + "\n" });
                }
            }

            return Result;
        }
示例#8
0
        public string ReadPAFFileSingle(string fileName, string sheetName, PostalAdress poobj)
        {
            string ConsoleLog       = null;
            string ConnectionString = GetConnectionString(fileName);

            using (OleDbConnection conn = new OleDbConnection(ConnectionString))
            {
                conn.Open();
                cmd.Connection = conn;
                //+"."+ sheetName +
                string query = "SELECT * FROM [" + Path.GetFileName(fileName) + "] WHERE  = '" + poobj.PCD.ToUpper() + "'";
                cmd = new OleDbCommand(query, conn);

                //                cmd.Parameters.AddWithValue("@p1",Path.GetFileName(fileName));
                //              cmd.Parameters.AddWithValue("@p2", poobj.PCD.ToUpper());

                var x = cmd.ExecuteReader();
                while (x.Read())
                {
                    if (String.IsNullOrWhiteSpace(x[11].ToString()) == false)
                    {
                        Property p = new Property();
                        p.DateAdded = DateTime.Now;
                        try
                        {
                            p.ORD       = x[0].ToString();
                            ConsoleLog += "Added" + p.ORD + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.ORC = x[1].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.SBN = x[2].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.BNA = x[3].ToString();
                            //      ConsoleLog += "Added" + p.BNA + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.POB = x[4].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.NUM = x[5].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DST = x[6].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.STM = x[7].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DDL = x[8].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DLO = x[9].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.PTN = x[10].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.PCD = x[11].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.CTA = x[12].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.CTP = x[13].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.CTT = x[14].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.SCD = x[15].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.CAT = x[16].ToString();
                            //             ConsoleLog += "Added" + p.CAT + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.NDP = x[17].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DPX = x[18].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.URN = x[19].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }


                        try
                        {
                            p.PID = poobj.PID;
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }



                        PropertiesObj.Add(p);
                        PostalAdressObj.Add(p);
                        //adressList.Add(p.PID, p);
                        PostalAdressObj.adressList[p.PID].AddPropertyKey(p.PID);
                    }
                }
                cmd = null;
                conn.Close();
            }
            return(ConsoleLog);
        }
示例#9
0
        public void ReadPAFFile(string FileName, PostalAdress poobj)
        {
            string ConsoleLog = null;
            CsvFileReader handler = new CsvFileReader(FileName);

            while (handler != null)
            {
                CsvRow row = new CsvRow();
                handler.ReadRow(row);
                if (row.Count == 0)
                {
                    break;
                }
                if (row[11].Equals(poobj.PCD.ToUpper()) == false)
                {
                    OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Searching " + poobj.PCD.ToUpper() + "==" + row[11].ToUpper() });
                    continue;
                }
                else
                {
                    OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Found Property " + poobj.PCD });

                    if (String.IsNullOrWhiteSpace(row[11].ToString()) == false)
                    {
                        Property p = new Property();
                        p.DateAdded = DateTime.Now;
                        try
                        {
                            p.ORD = row[0].ToString();
                            ConsoleLog += "Added" + p.ORD + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.ORC = row[1].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.SBN = row[2].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.BNA = row[3].ToString();
                            //      ConsoleLog += "Added" + p.BNA + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.POB = row[4].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.NUM = row[5].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DST = row[6].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.STM = row[7].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DDL = row[8].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DLO = row[9].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.PTN = row[10].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.PCD = row[11].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.CTA = row[12].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.CTP = row[13].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.CTT = row[14].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.SCD = row[15].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.CAT = row[16].ToString();
                            //             ConsoleLog += "Added" + p.CAT + "\n";

                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.NDP = row[17].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DPX = row[18].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.URN = row[19].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }


                        try
                        {
                            p.PID = poobj.PID;
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        p.SetAdressAutomatically();
                        log.Add(p);

                        POlog.Add(p);
                        //adressList.Add(p.PID, p);

                        POlog.adressList[p.PID].AddPropertyKey(p.PCD + p.URN);
                    }
                }
            }
        }
示例#10
0
        public string FilterByLandMark(PostalAdress x)
        {
            string ConsoleLog = null;
            PostalAdress po = POlog.GetObject(x.PID);

            if (DateTime.Compare(x.SearchedLandMark.AddMonths(1), DateTime.Now) >= 0 || x.SearchedProperties.Equals(new DateTime(0001, 1, 1)) == false)
            {
                OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Trace:   Already Searched LandMark by this Postal Adress in this month\n" });
                ConsoleLog += "Trace:   Already Searched LandMark by this Postal Adress in this month\n";
                return ConsoleLog;
            }
            else
            {
                x.SearchedLandMark = DateTime.Now;
                HttpWebRequest request1 = null;
                Stream dataStream = null;
                string PostCode = "postcode=" + x.PCD.Replace(" ", "+").Trim();
                //          OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Creating LandMarkRequest\n" });
                request1 = (HttpWebRequest)HttpWebRequest.Create("https://www.epcregister.com/reportSearchAddressByPostcode.html");
                request1.UserAgent = " Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36";
                request1.ContentType = "application/x-www-form-urlencoded";
                request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
                request1.Referer = "https://www.epcregister.com/reportSearchAddressByPostcode.html";
                request1.Host = "www.epcregister.com";
                request1.Headers.Add("Accept-Encoding", " gzip,deflate,sdch");
                request1.Headers.Add("Accept-Language", " en-US,en;q=0.8");
                request1.Headers.Add("Origin", " https://www.epcregister.com");
                request1.Method = "POST";
                //   request.HttpMethod = WebRequestMethods.Http.Post;
                string postData = PostCode;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                dataStream = request1.GetRequestStream();


                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);

                // Close the Stream object.
                //  dataStream.Close();
                WebResponse response = null;
                try
                {
                    response = request1.GetResponse();
                }
                catch (WebException)
                {
                    return "ERROR";
                    //                    throw new Exception("Error:  Can not Find Adress  --  " + ex.Message);
                }
                string responseFromServer = null;
                Uri responseUri = null;
                try
                {
                    string Status = ((HttpWebResponse)response).StatusDescription;

                    // Get the stream containing all content returned by the requested server.
                    dataStream = response.GetResponseStream();

                    // Open the stream using a StreamReader for easy access.
                    StreamReader reader = new StreamReader(dataStream);

                    // Read the content fully up to the end.
                    responseFromServer = reader.ReadToEnd();
                    responseUri = response.ResponseUri;
                    // Clean up the streams.
                    reader.Close();
                    dataStream.Close();
                    response.Close();
                }
                catch (Exception)
                {
                    return "ERROR2";
                }
                OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Link found for LandMarks\n" });
                List<Property> LandMarkCertifiedList = new List<Property>();

                using (WebClient c = new WebClient())
                {
                    string ResponseString = null;
                    try
                    {
                        ResponseString = c.DownloadString(responseUri);
                    }
                    catch (Exception)
                    {

                        OnInformationDownload(new EventArguments() { Name = "ERROR: ", Time = DateTime.Now, Details = "Exception while Reading File\n" });
                        ConsoleLog += "Exception Occured in Downloading LandMark string \n\n";
                        return ConsoleLog;
                    }

                    IsLocationThere2(x,ResponseString);

                    //try
                    //{
                    //    MatchCollection collection = Regex.Matches(ResponseString, "<a href=\\\"reportSearchAddressSelectAddress.*?>(?<data>.*?)</a>");

                    //    foreach (Match m in collection)
                    //    {
                    //        string localGroup = m.Groups["data"].Value;

                    //        IsLocationThere(x, localGroup, false);
                    //        //   OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "LandMark does not Matched\n" + x.PID + "\n\n" });


                    //    }
                    //}
                    //catch (ArgumentException ex)
                    //{
                    //    throw new Exception("Error: Can not Find LandMark Properties --" + ex.Message);
                    //}
                    return ConsoleLog;
                }
            }
        }