Наследование: BaseUnit
 public ScenarioPassengerDemand(double factor, DateTime enddate, Country country, Airport airport)
 {
     Country = country;
     Factor = factor;
     EndDate = enddate;
     Airport = airport;
 }
Пример #2
0
 public Manufacturer(string name, string shortname, Country country, bool isReal)
 {
     Name = name;
     ShortName = shortname;
     Country = country;
     IsReal = isReal;
 }
Пример #3
0
        public static HolidayYearEvent GetHoliday(Country country, DateTime date)
        {
            var currentDate = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);

            return
                Holidays.Find(
                    h => h.Date <= currentDate && h.Date.AddDays(h.Length) > currentDate && h.Holiday.Country == country);
        }
Пример #4
0
 public Holiday(string section, string uid, HolidayType type, string name, TravelType travel, Country country)
 {
     Type = type;
     LongName = name;
     Travel = travel;
     Country = country;
     Uid = uid;
     Section = section;
 }
Пример #5
0
        //returns a random last name
        public string GetRandomLastName(Country country)
        {
            if (!_lastNames.ContainsKey(country))
            {
                IEnumerable<Country> countries = _firstNames.Select(n => n.Key);
                var enumerable = countries as Country[] ?? countries.ToArray();
                country = enumerable.ElementAt(_rnd.Next(enumerable.Count()));
            }

            return GetRandomElement(_lastNames[country]);
        }
 public WeatherAverage(
     int month,
     double temperatureMin,
     double temperatureMax,
     int precipitation,
     Weather.eWindSpeed windspeedMin,
     Weather.eWindSpeed windspeedMax,
     Country country)
     : this(month, temperatureMin, temperatureMax, precipitation, windspeedMin, windspeedMax, country, null, null)
 {
 }
 public WeatherAverage(
     int month,
     double temperatureMin,
     double temperatureMax,
     int precipitation,
     Weather.eWindSpeed windspeedMin,
     Weather.eWindSpeed windspeedMax,
     Country country,
     Town town,
     Airport airport)
 {
     Month = month;
     Airport = airport;
     Country = country;
     Town = town;
     TemperatureMin = temperatureMin;
     TemperatureMax = temperatureMax;
     WindSpeedMax = windspeedMax;
     WindSpeedMin = windspeedMin;
     Precipitation = precipitation;
 }
 //returns if there is flight restrictions for airlines to one of the destinations
 public static bool HasRestriction(Airline airline, Country dest1, Country dest2, DateTime date)
 {
     return HasRestriction(airline.Profile.Country, dest2, date, FlightRestriction.RestrictionType.Airlines)
            || HasRestriction(airline.Profile.Country, dest1, date, FlightRestriction.RestrictionType.Airlines);
 }
Пример #9
0
 //returns if a union has a country as member
 public bool IsMember(Country country, DateTime date)
 {
     return Members.Find(m => m.Country == country && m.MemberFromDate < date && m.MemberToDate > date)
            != null;
 }
Пример #10
0
 //return all unions for a country
 public static List<Union> GetUnions(Country country, DateTime date)
 {
     return
         unions.FindAll(
             u =>
             u.Members.Find(um => um.Country == country) != null && u.CreationDate < date
             && u.ObsoleteDate > date);
 }
 public CountryTailNumber(Country country)
 {
     Country = country;
 }
Пример #12
0
        private static void LoadCountries()
        {
            var territoryElements = new List<XmlElement>();

            var doc = new XmlDocument();
            doc.Load(AppSettings.GetDataPath() + "\\countries.xml");
            XmlElement root = doc.DocumentElement;

            XmlNodeList countriesList = root?.SelectNodes("//country");
            if (countriesList != null)
                foreach (XmlElement element in countriesList)
                {
                    var territoryElement = (XmlElement) element.SelectSingleNode("territoryof");

                    if (territoryElement != null)
                    {
                        territoryElements.Add(element);
                    }
                    else
                    {
                        string section = root.Name;
                        string uid = element.Attributes["uid"].Value;
                        string shortname = element.Attributes["shortname"].Value;
                        string flag = element.Attributes["flag"].Value;
                        Region region = Regions.GetRegion(element.Attributes["region"].Value);
                        string tailformat = element.Attributes["tailformat"].Value;

                        var country = new Country(section, uid, shortname, region, tailformat) {Flag = AppSettings.GetDataPath() + "\\graphics\\flags\\" + flag + ".png"};

                        Countries.AddCountry(country);

                        XmlNodeList currenciesList = element.SelectNodes("currency");

                        if (currenciesList != null)
                            foreach (XmlElement currencyElement in currenciesList)
                            {
                                string currencySymbol = currencyElement.Attributes["symbol"].Value;
                                double currencyRate = Convert.ToDouble(
                                    currencyElement.Attributes["rate"].Value,
                                    CultureInfo.GetCultureInfo("en-US").NumberFormat);
                                var currencyPosition =
                                    (CountryCurrency.CurrencyPosition)
                                        Enum.Parse(
                                            typeof (CountryCurrency.CurrencyPosition),
                                            currencyElement.Attributes["position"].Value);

                                var currencyFromDate = new DateTime(1900, 1, 1);
                                var currencyToDate = new DateTime(2199, 12, 31);

                                if (currencyElement.HasAttribute("from"))
                                {
                                    currencyFromDate = Convert.ToDateTime(currencyElement.Attributes["from"].Value);
                                }

                                if (currencyElement.HasAttribute("to"))
                                {
                                    currencyToDate = Convert.ToDateTime(currencyElement.Attributes["to"].Value);
                                }

                                //country.AddCurrency(
                                //    new CountryCurrency(
                                //        currencyFromDate,
                                //        currencyToDate,
                                //        currencySymbol,
                                //        currencyPosition,
                                //        currencyRate));
                            }

                        if (element.SelectSingleNode("translations") != null)
                        {
                            Translator.GetInstance()
                                .AddTranslation(
                                    root.Name,
                                    element.Attributes["uid"].Value,
                                    element.SelectSingleNode("translations"));
                        }
                    }
                }
            //reads all countries which is a territory for another
            foreach (XmlElement element in territoryElements)
            {
                if (root != null)
                {
                    string section = root.Name;
                    string uid = element.Attributes["uid"].Value;
                    string shortname = element.Attributes["shortname"].Value;
                    string flag = element.Attributes["flag"].Value;
                    Region region = Regions.GetRegion(element.Attributes["region"].Value);
                    string tailformat = element.Attributes["tailformat"].Value;

                    var territoryElement = (XmlElement) element.SelectSingleNode("territoryof");

                    if (territoryElement != null)
                    {
                        Country territoryOf = Countries.GetCountry(territoryElement.Attributes["uid"].Value);

                        Country country = new TerritoryCountry(section, uid, shortname, region, tailformat, territoryOf);

                        country.Flag = AppSettings.GetDataPath() + "\\graphics\\flags\\" + flag + ".png";
                        Countries.AddCountry(country);
                    }
                }

                    if (element.SelectSingleNode("translations") != null)
                    {
                        if (root != null)
                            Translator.GetInstance()
                                      .AddTranslation(
                                          root.Name,
                                          element.Attributes["uid"].Value,
                                          element.SelectSingleNode("translations"));
                    }
            }
        }
Пример #13
0
 public TerritoryCountry(
     string section,
     string uid,
     string shortName,
     Region region,
     string tailNumberFormat,
     Country mainCountry)
     : base(section, uid, shortName, region, tailNumberFormat)
 {
     MainCountry = mainCountry;
 }
 //returns if there is flight restrictions between two countries
 public static bool HasRestriction(Country country1, Country country2, DateTime date)
 {
     return HasRestriction(country1, country2, date, FlightRestriction.RestrictionType.Flights)
            || HasRestriction(country2, country1, date, FlightRestriction.RestrictionType.Flights);
 }
Пример #15
0
 //returns all holidays for a country
 public static List<HolidayYearEvent> GetHolidays(Country country)
 {
     return Holidays.FindAll(h => h.Holiday.Country == country);
 }
        //returns if there is flight restrictions from one country to another
        public static bool HasRestriction(
            Country from,
            Country to,
            DateTime date,
            FlightRestriction.RestrictionType type)
        {
            FlightRestriction restriction =
                GetRestrictions()
                    .Find(
                        r =>
                        (r.From == from || (r.From is Union && ((Union) r.From).IsMember(from, date)))
                        && (r.To == to || (r.To is Union && ((Union) r.To).IsMember(to, date)))
                        && (date >= r.StartDate && date <= r.EndDate) && r.Type == type);

            //FlightRestriction res = GetRestrictions().Find(r => r.From == from && r.To == to && r.Type == type);

            return restriction != null;
        }
        //returns a temporary country which a country is a part of
        public static TemporaryCountry GetTemporaryCountry(Country country, DateTime date)
        {
            if (country == null)
            {
                return null;
            }

            TemporaryCountry tCountry =
                Countries.Find(
                    c =>
                    c.StartDate < date && c.EndDate > date
                    && (c.CountryBefore == country || c.CountryAfter == country
                        || c.Countries.Find(tc => tc.Country.Uid == country.Uid) != null));
            return tCountry;
        }
        //public override void GetObjectData(SerializationInfo info, StreamingContext context)
        //{
        //    info.AddValue("version", 1);
        //    base.GetObjectData(info, context);
        //}
        public Country GetCurrentCountry(DateTime date, Country originalCountry)
        {
            if (Type == TemporaryType.ManyToOne)
            {
                if (date < StartDate)
                {
                    return CountryBefore;
                }
                if (date >= StartDate && date <= EndDate)
                {
                    return this;
                }
                if (date > EndDate)
                {
                    return CountryAfter;
                }
            }
            if (Type == TemporaryType.OneToMany)
            {
                OneToManyCountry tCountry = Countries.Find(c => c.Country == originalCountry);

                if (tCountry == null)
                {
                    return originalCountry;
                }

                if (date >= tCountry.StartDate && date <= tCountry.EndDate)
                {
                    return this;
                }
                return originalCountry;
            }
            return null;
        }
 public OneToManyCountry(Country country, DateTime startDate, DateTime endDate)
 {
     StartDate = startDate;
     EndDate = endDate;
     Country = country;
 }
 //: base(Section, country.Uid, country.ShortName, country.Region, country.TailNumberFormat)
 public TemporaryCountry(TemporaryType type, Country country, DateTime startDate, DateTime endDate)
 {
     Type = type;
     StartDate = startDate;
     EndDate = endDate;
     Countries = new List<OneToManyCountry>();
     CountryAfter = this;
     CountryBefore = this;
 }
Пример #21
0
 //returns if there is a for a given date and country
 public static bool IsHoliday(Country country, DateTime date)
 {
     return GetHoliday(country, date) != null;
 }
Пример #22
0
 public UnionMember(Country country, DateTime memberFromDate, DateTime memberToDate)
 {
     Country = country;
     MemberFromDate = memberFromDate;
     MemberToDate = memberToDate;
 }
Пример #23
0
        /*!loads the countries.
         */
        /*! loads the temporary countries
         */
        private static void LoadTemporaryCountries()
        {
            var doc = new XmlDocument();
            doc.Load(AppSettings.GetDataPath() + "\\temporary countries.xml");
            XmlElement root = doc.DocumentElement;

            XmlNodeList countriesList = root?.SelectNodes("//country");
            if (countriesList != null)
                foreach (XmlElement element in countriesList)
                {
                    string section = root.Name;
                    string uid = element.Attributes["uid"].Value;
                    string shortname = element.Attributes["shortname"].Value;
                    string flag = element.Attributes["flag"].Value;
                    Region region = Regions.GetRegion(element.Attributes["region"].Value);
                    string tailformat = element.Attributes["tailformat"].Value;
                    var tempType =
                        (TemporaryCountry.TemporaryType)
                            Enum.Parse(typeof (TemporaryCountry.TemporaryType), element.Attributes["type"].Value);

                    var periodElement = (XmlElement) element.SelectSingleNode("period");
                    if (periodElement != null)
                    {
                        DateTime startDate = Convert.ToDateTime(
                            periodElement.Attributes["start"].Value,
                            new CultureInfo("en-US", false));
                        DateTime endDate = Convert.ToDateTime(
                            periodElement.Attributes["end"].Value,
                            new CultureInfo("en-US", false));

                        var country = new Country(section, uid, shortname, region, tailformat);

                        if (element.SelectSingleNode("translations") != null)
                        {
                            Translator.GetInstance()
                                .AddTranslation(
                                    root.Name,
                                    element.Attributes["uid"].Value,
                                    element.SelectSingleNode("translations"));
                        }

                        var historyElement = (XmlElement) element.SelectSingleNode("history");

                        var tCountry = new TemporaryCountry(tempType, country, startDate, endDate);

                        if (tempType == TemporaryCountry.TemporaryType.ManyToOne)
                        {
                            if (historyElement != null)
                            {
                                Country before = Countries.GetCountry(historyElement.Attributes["before"].Value);
                                Country after = Countries.GetCountry(historyElement.Attributes["after"].Value);

                                tCountry.CountryBefore = before;
                                tCountry.CountryAfter = after;
                            }
                        }
                        if (tempType == TemporaryCountry.TemporaryType.OneToMany)
                        {
                            XmlNodeList tempCountriesList = historyElement?.SelectNodes("tempcountries/tempcountry");

                            if (tempCountriesList != null)
                                foreach (XmlElement tempCountryElement in tempCountriesList)
                                {
                                    Country tempCountry = Countries.GetCountry(tempCountryElement.Attributes["id"].Value);
                                    DateTime cStartDate = Convert.ToDateTime(
                                        tempCountryElement.Attributes["start"].Value,
                                        new CultureInfo("en-US", false));
                                    DateTime cEndDate = Convert.ToDateTime(
                                        tempCountryElement.Attributes["end"].Value,
                                        new CultureInfo("en-US", false));

                                    tCountry.Countries.Add(new OneToManyCountry(tempCountry, cStartDate, cEndDate));
                                }
                        }

                        tCountry.Flag = AppSettings.GetDataPath() + "\\graphics\\flags\\" + flag + ".png";

                        TemporaryCountries.AddCountry(tCountry);
                    }
                }
        }
 public void AddCountry(Country country)
 {
     Countries.Add(country);
 }
Пример #25
0
 public static void AddCountry(Country country)
 {
     _countries.Add(country.Uid, country);
 }
Пример #26
0
 //returns all airports from a specific country
 public static List<Airport> GetAirports(Country country)
 {
     return GetAirports(airport => airport.Profile.Country == country);
 }