示例#1
0
        public List <HostingUnitXML> GetHostingunits()
        {
            HostingUnitRoot = XElement.Load(HostingUnitPath);
            List <HostingUnitXML> hostingunits;

            try
            {
                hostingunits = (from HU in HostingUnitRoot.Elements()
                                select new HostingUnitXML()
                {
                    Key = int.Parse(HU.Element("Key").Value),
                    Owner = int.Parse(HU.Element("Owner").Value),
                    PricePerNight = int.Parse(HU.Element("PricePerNight").Value),
                    HostingUnitName = HU.Element("HostingUnitName").Value,
                    Area = (DO.Location)Enum.Parse(typeof(DO.Location), HU.Element("Area").Value),
                    Diary_XML = (from boolean in HU.Element("Diary").Elements()
                                 select bool.Parse(boolean.Value)).ToArray(),
                    Status = (DO.Status)Enum.Parse(typeof(DO.Status), HU.Element("Status").Value),
                    WIFI = bool.Parse(HU.Element("WIFI").Value),
                    SwimmingPool = bool.Parse(HU.Element("SwimmingPool").Value),
                    Kitchen = bool.Parse(HU.Element("Kitchen").Value),
                    TV = bool.Parse(HU.Element("TV").Value),
                    Jacuzzi = bool.Parse(HU.Element("Jacuzzi").Value),
                    ImageLink1 = HU.Element("ImageLink1").Value,
                    ImageLink2 = HU.Element("ImageLink2").Value,
                    ImageLink3 = HU.Element("ImageLink3").Value
                }).ToList();
            }
            catch (Exception)
            {
                throw;
            }

            return(hostingunits);
        }
示例#2
0
        public HostingUnit RecieveHostingUnit(int key)
        {
            HostingUnitRoot = XElement.Load(HostingUnitPath);
            HostingUnitXML hostingUnitXML = new HostingUnitXML();

            try
            {
                hostingUnitXML = (from HU in HostingUnitRoot.Elements()
                                  where int.Parse(HU.Element("Key").Value) == key
                                  select new HostingUnitXML()
                {
                    Key = int.Parse(HU.Element("Key").Value),
                    Owner = int.Parse(HU.Element("Owner").Value),
                    PricePerNight = int.Parse(HU.Element("PricePerNight").Value),
                    HostingUnitName = HU.Element("HostingUnitName").Value,
                    Area = (DO.Location)Enum.Parse(typeof(DO.Location), HU.Element("Area").Value),
                    Diary_XML = (from boolean in HU.Element("Diary").Elements()
                                 select bool.Parse(boolean.Value)).ToArray(),
                    Status = (DO.Status)Enum.Parse(typeof(DO.Status), HU.Element("Status").Value),
                    WIFI = bool.Parse(HU.Element("WIFI").Value),
                    SwimmingPool = bool.Parse(HU.Element("SwimmingPool").Value),
                    Kitchen = bool.Parse(HU.Element("Kitchen").Value),
                    TV = bool.Parse(HU.Element("TV").Value),
                    Jacuzzi = bool.Parse(HU.Element("Jacuzzi").Value),
                    ImageLink1 = HU.Element("ImageLink1").Value,
                    ImageLink2 = HU.Element("ImageLink2").Value,
                    ImageLink3 = HU.Element("ImageLink3").Value
                }).FirstOrDefault();
            }
            catch
            {
                return(null);
            }
            return(hostingUnitXML == null ? null : hostingUnitXML.ConvertToDO());
        }
示例#3
0
 private void CreateRequestAndResponse()
 {
     request = HU.Create(URL, Data);
     //从当前位置开始下载
     request.AddRange(CurrPostion);
     response = (HttpWebResponse)request.GetResponse();
     //if (response.StatusCode != HttpStatusCode.OK)//未请求成功
     //    throw new HttpListenerException(T.ToInt(response.StatusCode), HU.GetResponseStreamData(response));
     if (string.IsNullOrWhiteSpace(response.Headers["Content-Disposition"]))
     {
         //不是一个文件
         throw new Exception("this url is not a file");
     }
     if (response.ContentLength == 0)//空文件
     {
         throw new Exception("empty file");
     }
 }
示例#4
0
        public void RemoveHostingUnit(int key)
        {
            HostingUnitRoot = XElement.Load(HostingUnitPath);
            XElement Temp;

            try
            {
                Temp = (from HU in HostingUnitRoot.Elements()
                        where int.Parse(HU.Element("Key").Value) == key
                        select HU).FirstOrDefault();
            }
            catch (Exception)
            {
                throw new Exception("הייתה תקלה  במחיקת ישות מסוג יחידת אירוח");
            }
            Temp.Remove();
            HostingUnitRoot.Save(HostingUnitPath);
        }
示例#5
0
 public IEnumerable <HostingUnit> GetHostingUnitsList(Func <HostingUnit, bool> predicate)//
 {
     return(DataSource.hostingUnits.Where(predicate).Select(HU => HU.Clone()));
 }
示例#6
0
        /// <summary>
        /// Validates VAT number
        /// </summary>
        /// <returns>Corrected VAT number in VatNumber object</returns>
        public static VatNumber Validate(string vat, EUCountry euCountry)
        {
            string countryCode = euCountry.ToString().ToUpper();

            vat = vat.ToUpper();

            CountryBase countryBase;

            switch (euCountry)
            {
            case EUCountry.AT:
                countryBase = new AT();
                break;

            case EUCountry.BE:
                countryBase = new BE();
                break;

            case EUCountry.BG:
                countryBase = new BG();
                break;

            case EUCountry.CY:
                countryBase = new CY();
                break;

            case EUCountry.CZ:
                countryBase = new CZ();
                break;

            case EUCountry.DE:
                countryBase = new DE();
                break;

            case EUCountry.DK:
                countryBase = new DK();
                break;

            case EUCountry.EE:
                countryBase = new EE();
                break;

            case EUCountry.EL:
                countryBase = new EL();
                break;

            case EUCountry.ES:
                countryBase = new ES();
                break;

            case EUCountry.FI:
                countryBase = new FI();
                break;

            case EUCountry.FR:
                countryBase = new FR();
                break;

            case EUCountry.GB:
                countryBase = new GB();
                break;

            case EUCountry.HR:
                countryBase = new HR();
                break;

            case EUCountry.HU:
                countryBase = new HU();
                break;

            case EUCountry.IE:
                countryBase = new IE();
                break;

            case EUCountry.IT:
                countryBase = new IT();
                break;

            case EUCountry.LT:
                countryBase = new LT();
                break;

            case EUCountry.LU:
                countryBase = new LU();
                break;

            case EUCountry.LV:
                countryBase = new LV();
                break;

            case EUCountry.MT:
                countryBase = new MT();
                break;

            case EUCountry.NL:
                countryBase = new NL();
                break;

            case EUCountry.PL:
                countryBase = new PL();
                break;

            case EUCountry.PT:
                countryBase = new PT();
                break;

            case EUCountry.RO:
                countryBase = new RO();
                break;

            case EUCountry.SE:
                countryBase = new SE();
                break;

            case EUCountry.SI:
                countryBase = new SI();
                break;

            case EUCountry.SK:
                countryBase = new SK();
                break;

            default:
                throw new InvalidCountryException();
            }

            if (countryBase.StripLetters)
            {
                return(new VatNumber(euCountry, countryBase.Validate(Strip(vat))));
            }

            return(new VatNumber(euCountry, countryBase.Validate(StripNoLetters(vat, countryCode))));
        }