示例#1
0
        private static AddressHolder Decompose(string address)
        {
            var match = AddressRegex.Match(address);

            var holder = new AddressHolder
            {
                InParts  = match.Groups["in"].Captures.Cast <Capture>().Select(capture => capture.Value).ToList(),
                OutParts = match.Groups["out"].Captures.Cast <Capture>().Select(capture => capture.Value).ToList()
            };

            return(holder);
        }
示例#2
0
        public static string GetAddress(string uuid, bool raw)
        {
            InspectorService service = new InspectorService();

            if (raw)
            {
                return(service.ReadAddressRaw(uuid));
            }

            AddressHolder address = service.ReadAddressObject(uuid);

            return(ParserUtils.SerializeObject(address));
        }
示例#3
0
        // filter the records into new altered record objects and return in list
        public List <AlteredRecord> CleanRecords(List <Record> list)
        {
            List <AlteredRecord> altered = new List <AlteredRecord>();

            foreach (Record r in list)
            {
                AlteredRecord ar = new AlteredRecord();
                ar.SoldOn = r.SoldDate;
                ar.County = r.County;
                // take '?' of front of price and change to double
                // no need to catch format exception
                string sub   = r.Price.Substring(1);
                double price = Convert.ToDouble(sub);
                ar.Price = price;
                // take first char from string for NFMP
                ar.NotFullMP = r.NMFP[0];
                // shorten description to char of N/S (new/second hand)
                if (r.Description.StartsWith("N"))
                {
                    ar.Description = 'N';
                }
                if (r.Description.StartsWith("S"))
                {
                    ar.Description = 'S';
                }
                // take vat column out and phase it into the price (if No then take 13.5% off price)
                if (r.VAT.StartsWith("N"))
                {
                    price    = price * 0.865;
                    ar.Price = price;
                }
                // sort address and postal code if Dublin
                AddressHolder addresssorted = CleanAddress(r.Address, r.County, r.PostalCode);
                ar.Address  = addresssorted.Address;
                ar.PostCode = addresssorted.PostalCode;
                // add altered record to altered record list
                altered.Add(ar);
            }
            return(altered);
        }
        /// <summary>
        /// Resolve a host and port.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="port">The port</param>
        /// <returns>An <see cref="IPEndPoint"/> enumerator.</returns>
        /// <since>12.2.1</since>
        protected IEnumerator <IPEndPoint> ResolveAddress(string host, int port)
        {
            IPAddress[] arrAddr;

            try
            {
                arrAddr = "localhost".Equals(host)
                    ? new IPAddress[] { NetworkUtils.GetLocalHostAddress(RequestTimeout) }
                    : CollectionUtils.Randomize(NetworkUtils.GetAllAddresses(host, RequestTimeout));
            }
            catch (Exception e)
            {
                if (m_isSafe)
                {
                    // Failed to resolve the host.  Return an empty list.
                    arrAddr = new IPAddress[] { };

                    AddressHolder holder = f_listHolders[m_last];
                    if (!holder.IsReported)
                    {
                        holder.IsReported = true;
                        CacheFactory.Log("The ConfigurableAddressProvider got an exception: " +
                                         e + " when resolving address; " +
                                         "skipping the unresolveable address \"" + host +
                                         "\".", CacheFactory.LogLevel.Info);
                    }
                }
                else
                {
                    throw e;
                }
            }

            foreach (IPAddress addr in arrAddr)
            {
                yield return(new IPEndPoint(addr, port));
            }
        }
示例#5
0
        // clean address and postal code
        public AddressHolder CleanAddress(string address, string county, string pc)
        {
            AddressHolder add = new AddressHolder();

            // break the address up into its parts separated by a comma, make all lowercase
            string[] parts = address.Split(',').Select(sValue => sValue.Trim().ToLower()).ToArray();
            // change to lowercase
            string countyLower = county.ToLower();
            string pcLower     = pc.ToLower();

            add.PostalCode = pcLower;
            // number elements in array
            int num = parts.Length;

            // not for Dublin check if last element of address matches the county, if so get rid of
            if (!countyLower.Equals("dublin"))
            {
                if (parts[num - 1].Equals(countyLower) || parts[num - 1].Equals("co " + countyLower) ||
                    parts[num - 1].Equals("co. " + countyLower) || parts[num - 1].Equals("county " + countyLower) ||
                    parts[num - 1].Equals("co." + countyLower))
                {
                    num--; // take last element away
                }
            }
            else // Sort out Dublin
            {
                if (parts[num - 1].Equals(countyLower) || parts[num - 1].Equals("co " + countyLower) ||
                    parts[num - 1].Equals("co. " + countyLower) || parts[num - 1].Equals("county " + countyLower) ||
                    parts[num - 1].Equals(pcLower) || parts[num - 1].Equals("co." + countyLower))
                {
                    if (parts[num - 1].Any(char.IsDigit)) // if it contains numbers its the postal code
                    {
                        add.PostalCode = parts[num - 1];
                    }
                    num--;
                }
                // try find postal code from address if does not already have a value for it
                if (add.PostalCode.Equals(""))
                {
                    if (FindPostalCode(parts[num - 1]) != null)
                    {
                        add.PostalCode = FindPostalCode(parts[num - 1]);
                    }
                    else // check if post code is in address at end of address line
                    {
                        string last       = parts[num - 1];
                        int    lastLenght = last.Length;
                        if (lastLenght >= 6)
                        {
                            last = parts[num - 1].Substring(0, 6);
                        }
                        if (last.Equals("dublin"))
                        {
                            add.PostalCode = parts[num - 1];
                            num--;
                        }
                    }
                }
            }
            // put address back together
            string complete = "";

            for (int i = 0; i < num; i++)
            {
                complete += parts[i] + ",";
            }
            add.Address = complete.Remove(complete.Length - 1); // take away last comma
            // return address
            return(add);
        }
 // clean address and postal code
 public AddressHolder CleanAddress(string address, string county, string pc)
 {
     AddressHolder add = new AddressHolder();
     // break the address up into its parts separated by a comma, make all lowercase
     string[] parts = address.Split(',').Select(sValue => sValue.Trim().ToLower()).ToArray();
     // change to lowercase
     string countyLower = county.ToLower();
     string pcLower = pc.ToLower();
     add.PostalCode = pcLower;
     // number elements in array
     int num = parts.Length;
     // not for Dublin check if last element of address matches the county, if so get rid of
     if (!countyLower.Equals("dublin"))
     {
         if (parts[num - 1].Equals(countyLower) || parts[num - 1].Equals("co " + countyLower) ||
             parts[num - 1].Equals("co. " + countyLower) || parts[num - 1].Equals("county " + countyLower)
             || parts[num - 1].Equals("co." + countyLower))
         {
             num--; // take last element away
         }
     }
     else // Sort out Dublin
     {
         if (parts[num - 1].Equals(countyLower) || parts[num - 1].Equals("co " + countyLower) ||
             parts[num - 1].Equals("co. " + countyLower) || parts[num - 1].Equals("county " + countyLower)
             || parts[num - 1].Equals(pcLower) || parts[num - 1].Equals("co." + countyLower))
         {
             if (parts[num - 1].Any(char.IsDigit)) // if it contains numbers its the postal code
             {
                 add.PostalCode = parts[num - 1];
             }
             num--;
         }
         // try find postal code from address if does not already have a value for it
         if (add.PostalCode.Equals(""))
         {
             if (FindPostalCode(parts[num - 1]) != null)
             {
                 add.PostalCode = FindPostalCode(parts[num - 1]);
             }
             else // check if post code is in address at end of address line
             {
                 string last = parts[num - 1];
                 int lastLenght = last.Length;
                 if (lastLenght >= 6)
                 {
                     last = parts[num - 1].Substring(0, 6);
                 }
                 if (last.Equals("dublin"))
                 {
                     add.PostalCode = parts[num - 1];
                     num--;
                 }
             }
         }
     }
     // put address back together
     string complete = "";
     for (int i = 0; i < num; i++)
     {
         complete += parts[i] + ",";
     }
     add.Address = complete.Remove(complete.Length - 1); // take away last comma
     // return address
     return add;
 }
示例#7
0
        private static AddressHolder XmlConvertToAddress(XmlNode sp, int carrier)
        {
            AddressHolder address = new AddressHolder();

            address.DropPointCode = loadXmlValue(sp, "Number");
            address.Address1 = loadXmlValue(sp, "Streetname");
            address.City = loadXmlValue(sp, "CityName");
            address.Country = loadXmlValue(sp, "CountryCodeISO3166A2");
            address.Name = loadXmlValue(sp, "CompanyName");
            address.Zip = loadXmlValue(sp, "ZipCode");
            address.Latitude = loadXmlDouble("Latitude", sp);
            address.Longitude = loadXmlDouble("Longitude", sp);
            address.SrId = loadXmlValue(sp, "coordinates/coordinate[0]/srId");
            address.Opening = sp.SelectSingleNode("OpeningHours").InnerXml;
            List<String> ziplist = new List<String>();
            address.ZipCode = ziplist;

            return address;
        }