Пример #1
0
        public override void PopulateList()
        {
            if (Countries == null)
            {
                Countries = new List <CountryModel>();
            }

            Countries.Clear();

            foreach (DataRow row in _dataTable.Select(null, "Entity_Name", DataViewRowState.CurrentRows))
            {
                CountryModel country = new CountryModel()
                {
                    Code    = (int)row.Field <Int64>("Country_Code"),
                    Name    = row.Field <string>("Entity_Name"),
                    Deleted = row.Field <bool>("Deleted")
                };

                if (country.Deleted == false || IncludeDeleted == true)
                {
                    Countries.Add(country);
                }
            }

            _dataTable = null;
        }
Пример #2
0
        public static void GetCountriesAsGenericListUsingGetFieldValue()
        {
            Countries.Clear();
            string ResultText = null;

            using (SqlConnection cnn = new SqlConnection(Config.ConnectionString))
            {
                cnn.Open();
                using (SqlCommand cmd = new SqlCommand(CountryManager.COUNTRY_SQL, cnn))
                {
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            Countries.Add(new Country
                            {
                                CountryId           = dr.GetFieldValue <int>(dr.GetOrdinal("Countryid")),
                                IsDeleted           = dr.GetFieldValue <bool>(dr.GetOrdinal("IsDeleted")),
                                CountryAbbreviation = dr.GetFieldValue <string>(dr.GetOrdinal("CountryAbbreviation")),
                                CountryName         = dr.GetFieldValue <string>(dr.GetOrdinal("CountryName")),
                                //GetFieldValue<T>() does not work on below nullable type
                                CountryCallingCode = dr.IsDBNull(dr.GetOrdinal("CountryCallingCode"))
                                                        ? "shound not be null"
                                                        : dr["CountryCallingCode"].ToString()
                            });
                        }
                    }
                }
            }
            foreach (var item in Countries)
            {
                Console.WriteLine(JsonConvert.SerializeObject(item));
            }
        }
Пример #3
0
 public new void Clear()
 {
     base.Clear();
     Categories.Clear();
     Countries.Clear();
     Actors.Clear();
 }
Пример #4
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Countries.Clear();
                var items = App.Database.GetCountries();
                foreach (var item in items.Result.OrderBy(c => c.Name))
                {
                    Countries.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #5
0
        public static void GetCountriesAsGenericListUsingCustomGetFieldValue()
        {
            Countries.Clear();
            string ResultText = null;

            using (SqlConnection cnn = new SqlConnection(Config.ConnectionString))
            {
                cnn.Open();
                using (SqlCommand cmd = new SqlCommand(CountryManager.COUNTRY_SQL, cnn))
                {
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            Countries.Add(new Country
                            {
                                CountryId           = dr.CustomGetFieldValue <int>("CountryId"),
                                IsDeleted           = dr.CustomGetFieldValue <bool>("IsDeleted"),
                                CountryAbbreviation = dr.CustomGetFieldValue <string>("CountryAbbreviation"),
                                CountryName         = dr.CustomGetFieldValue <string>("CountryName"),
                                CountryCallingCode  = dr.CustomGetFieldValue <string>("CountryCallingCode")
                            });
                        }
                    }
                }
            }
            foreach (var item in Countries)
            {
                Console.WriteLine(JsonConvert.SerializeObject(item));
            }
        }
Пример #6
0
 private void CleanLists()
 {
     Countries.Clear();
     RegionsA.Clear();
     RegionsB.Clear();
     RegionsC.Clear();
     RegionsD.Clear();
 }
Пример #7
0
 private void FillCountries()
 {
     Countries.Clear();
     foreach (var item in db.Countries.ToList())
     {
         Countries.Add(item);
     }
     CountryCount = Countries.Count;
 }
Пример #8
0
        private void ClearCountries()
        {
            foreach (var country in Countries)
            {
                country.IsSelectedChanged -= IsSelectedChanged;
            }

            Countries.Clear();
        }
Пример #9
0
        private void ExecuteSearchCountryCommand()
        {
            var cultureInfoPtBR = App.AppCultureInfo.Equals("pt");
            IEnumerable <Country> countries;

            if (string.IsNullOrEmpty(SearchText))
            {
                ItemTreshold = 1;
                Countries.Clear();

                if (cultureInfoPtBR)
                {
                    countries = _db.FindAll().OrderBy(p => p.countryPtBR).Take(20);
                }
                else
                {
                    countries = _db.FindAll().OrderBy(p => p.country).Take(20);
                }

                foreach (var item in _db.FindAll().Take(20))
                {
                    Countries.Add(item);
                }
            }
            else
            {
                ItemTreshold = -1;
                Countries.Clear();

                try
                {
                    if (cultureInfoPtBR)
                    {
                        countries = _db.FindAll()
                                    .Where(p => p.countryPtBR.ToLower().RemoveAccents().Contains(SearchText.ToLower().RemoveAccents()))
                                    .OrderBy(p => p.countryPtBR)
                                    .ToList();
                    }
                    else
                    {
                        countries = _db.FindAll()
                                    .Where(p => p.country.ToLower().Contains(SearchText.ToLower()))
                                    .ToList();
                    }

                    foreach (var item in countries)
                    {
                        Countries.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    var error = ex.Message;
                }
            }
        }
Пример #10
0
        private void ContinentFilterSelected()
        {
            Countries.Clear();
            foreach (var country in CountriesRaw.Where(IsCountryBelongToSelectedContinent))
            {
                Countries.Add(country);
            }

            SelectedCountry = Countries[0];
        }
Пример #11
0
        private async void UpdateCountries()
        {
            var CountriesAPIList = await RapidFutballHelper.GetCountries();

            Countries.Clear();
            Teams.Clear();
            foreach (var Country in CountriesAPIList)
            {
                Countries.Add(Country);
            }
        }
Пример #12
0
 public void Dispose()
 {
     if (Countries != null)
     {
         Countries.Clear();
     }
     if (Cities != null)
     {
         Cities.Clear();
     }
 }
Пример #13
0
        public async void MakeRequest()
        {
            Info info = await CovidHelper.GetInfo();

            Global = info.Global;
            Countries.Clear();
            foreach (var item in info.Countries)
            {
                Countries.Add(item);
            }
        }
Пример #14
0
        private void GetAllCountries()
        {
            Countries.Clear();
            IEnumerable <Country> countries;

            countries = App.AppCultureInfo.Equals("pt") ? _db.FindAll().OrderBy(p => p.countryPtBR).Take(20) : _db.FindAll().Take(20);
            foreach (var item in countries)
            {
                Countries.Add(item);
            }
        }
Пример #15
0
        public async void Load()
        {
            var result = await client.GetCountries();

            Countries.Clear();

            foreach (var item in result)
            {
                Countries.Add(item);
            }
            IsBusy = false;
        }
Пример #16
0
        public void Update()
        {
            IEnumerable <string> countryNames = facade.GetAll();

            Countries.Clear();
            foreach (string countryName in countryNames)
            {
                Countries.Add(countryName);
            }

            RaisePropertyChangedEvent("SelectedCountry");
        }
Пример #17
0
        public async void Load()
        {
            var result = await _client.GetCountries();

            Countries.Clear();

            foreach (var item in result.OrderBy(a => a.Region).ThenBy(a => a.Name))
            {
                Countries.Add(item);
            }

            IsBusy = false;
        }
Пример #18
0
        private async void GetCountries()
        {
            var drzave = await _apiCountries.Get <List <Model.Drzava> >(null);

            Countries.Clear();
            foreach (var item in drzave)
            {
                Countries.Add(new ComboBoxItem()
                {
                    Content = item.Naziv
                });
            }
            CountriesIsEnabled = true;
        }
Пример #19
0
        public static void GetMultipleResultSets()
        {
            Countries.Clear();
            string sql = CountryManager.COUNTRY_SQL;

            sql += ";" + CountryManager.STATE_SQL;
            Console.WriteLine(sql);
            using (SqlConnection cnn = new SqlConnection(Config.ConnectionString))
            {
                cnn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, cnn))
                {
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            Countries.Add(new Country
                            {
                                CountryId           = dr.CustomGetFieldValue <int>("CountryId"),
                                IsDeleted           = dr.CustomGetFieldValue <bool>("IsDeleted"),
                                CountryAbbreviation = dr.CustomGetFieldValue <string>("CountryAbbreviation"),
                                CountryName         = dr.CustomGetFieldValue <string>("CountryName"),
                                CountryCallingCode  = dr.CustomGetFieldValue <string>("CountryCallingCode")
                            });
                        }
                        dr.NextResult();//move to next result set
                        while (dr.Read())
                        {
                            States.Add(new State
                            {
                                CountryId         = dr.CustomGetFieldValue <int>("CountryId"),
                                IsDeleted         = dr.CustomGetFieldValue <bool>("IsDeleted"),
                                StateAbbreviation = dr.CustomGetFieldValue <string>("StateAbbreviation"),
                                StateName         = dr.CustomGetFieldValue <string>("StateName")
                            });
                        }
                    }
                }
            }
            foreach (var item in Countries)
            {
                Console.WriteLine(JsonConvert.SerializeObject(item));
            }
            foreach (var item in States)
            {
                Console.WriteLine(JsonConvert.SerializeObject(item));
            }
        }
Пример #20
0
        private void UpdateCountries()
        {
            Countries.Clear();

            var allCountries = from c in dataService.GetAllCountries()
                               orderby c.Name
                               select new CountryListItemViewModel(c, this.dataService, this.validPointValues.Count);

            foreach (var country in allCountries)
            {
                Countries.Add(country);
            }

            CountryIssuingVotes = null;
            UpdateShowResultsButton();
        }
 void SearchCountry(string text)
 {
     Countries.Clear();
     if (string.IsNullOrEmpty(text))
     {
         foreach (var item in _tmpCountriesUI)
         {
             Countries.Add(item);
         }
     }
     else
     {
         IEnumerable <Models.Country> results = _tmpCountries.Where(s => s.country.Contains(text));
         foreach (var item in results)
         {
             Countries.Add(item);
         }
     }
 }
        private void TreeSearch(string search)
        {
            Countries.Clear();
            LoadCountries();

            if (String.IsNullOrWhiteSpace(search))
            {
                return;
            }

            ObservableCollection <Region> filteredRegions = new ObservableCollection <Region>();
            List <Country> emptyCountries = new List <Country>();

            for (int c = 0; c < Countries.Count; c++)
            {
                filteredRegions.Clear();
                foreach (var region in Countries[c].Regions)
                {
                    if (region.Name.ToLower()
                        .Contains(search.ToLower()))
                    {
                        filteredRegions.Add(region);
                    }
                }
                Countries[c].Regions.Clear();
                if (filteredRegions.Count > 0)
                {
                    foreach (var item in filteredRegions)
                    {
                        Countries[c].Regions.Add(item);
                    }
                }
                else
                {
                    emptyCountries.Add(Countries[c]);
                }
            }

            foreach (var c in emptyCountries)
            {
                Countries.Remove(c);
            }
        }
Пример #23
0
        private async void LoadCountries()
        {
            if (Countries.Any())
            {
                Indicator.IsVisible = false;
            }
            LoadButton.Text = "Atualizando";
            IsBusy          = true;
            List.IsVisible  = true;
            Response.Text   = string.Empty;

            try
            {
                var result = await DataService.GetCountries();

                Countries.Clear();

                foreach (var item in result)
                {
                    Countries.Add(new CountryViewModel(item)
                    {
                        FlagSource    = ImageSource.FromUri(DataService.GetFlagSource(item.Alpha2Code)),
                        BrowseCommand = new Command <CountryViewModel>(BrowseCountry)
                    });
                }
                Response.Text         = string.Empty;
                StatusPanel.IsVisible = false;
            }
            catch (Exception ex)
            {
                Response.Text         = ex.Message;
                StatusPanel.IsVisible = true;
                List.IsVisible        = false;
            }
            finally
            {
                IsBusy          = false;
                LoadButton.Text = "Atualizar";
            }
        }
Пример #24
0
        //[DataMember] private bool? _Favorite;
        public override void DefaultFilters()
        {
            _supressPublish = true;

            Name       = null;
            Player     = null;
            MinPlayers = 0;
            MaxPlayers = 0;
            MaxPing    = 0;
            Mod        = null;

            Continent = null;
            if (Countries == null)
            {
                Countries = new ReactiveList <string>();
                Countries.CollectionChanged += Countries_CollectionChanged;
            }
            else
            {
                Countries.Clear();
            }

            Protection = -1;

            IncompatibleServers = true;
            Modded                = true;
            HideEmpty             = false;
            HideFull              = false;
            HideUnofficial        = false;
            HideNeverJoined       = false;
            HidePasswordProtected = true;
            HideUnresponsive      = false;
            HideWrongGameVersion  = true;

            DefaultMissionFilters();

            _supressPublish = false;

            base.DefaultFilters();
        }
        private void LoadResources()
        {
            Action loadResources = async() =>
            {
                User user = UnitOfWork.UserRepository.GetUser();

                if (user == null)
                {
                    // App used for the first time.
                    ShowLoader(AppResources.SplashLoaderTextRegistration);

                    CountrySelection = AppResources.SplashButtonTextSelectCountry;

                    try
                    {
                        cancellationTokenSource = new CancellationTokenSource();

                        LoaderText = AppResources.SplashLoaderTextCountries;

                        Countries.Clear();
                        Countries.AddRange(await BumbleApiService.Countries());

                        ShowCountrySelector();
                    }
                    catch (Exception e)
                    {
                        base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);

                        ShowRetryResources();
                    }
                }
                else if (user.Country == null)
                {
                    // Changed country.
                    ShowLoader(AppResources.SplashLoaderTextRegistration);

                    CountrySelection = AppResources.SplashButtonTextSelectCountry;

                    try
                    {
                        LoaderText = AppResources.SplashLoaderTextCountries;

                        Countries.Clear();
                        Countries.AddRange(await BumbleApiService.Countries());

                        ShowCountrySelector();
                    }
                    catch (Exception e)
                    {
                        base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);

                        ShowRetryResources();
                    }
                }
                else
                {
                    ShowLoader(AppResources.SplashLoaderTextCheckingForUpdates);

                    SetUserPopupStates(user);

                    // App loaded, check cache if expired.
                    foreach (CacheSetting cacheSetting in UnitOfWork.CacheSettingRepository.GetAllCacheSettings())
                    {
                        if (cacheSetting.LastRefreshedDateUtc == null || cacheSetting.LastRefreshedDateUtc.Value.AddSeconds(cacheSetting.CacheValidDurationInSeconds) < DateTime.UtcNow)
                        {
                            switch (cacheSetting.ResourceType)
                            {
                            case ResourceType.Operators:
                                try
                                {
                                    await DownloadCountryData(user.Country, cacheSetting.LastRefreshedDateUtc);
                                }
                                catch (Exception e)
                                {
                                    base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);

                                    ShowRetryResources();

                                    return;
                                }
                                break;
                            }
                        }
                    }

                    //LoaderText = AppResources.SplashLoaderTextComplete;

                    TryNavigateToStartPage();
                }
            };

            DispatcherHelper.CheckBeginInvokeOnUI(loadResources);
        }
Пример #26
0
        public static void Load()
        {
            //TODO MUST making the xml called data.dat and encryption
            if (File.Exists("Data.dat"))
            {
                using (XmlReader reader = XmlReader.Create("Data.dat"))
                {
                    Countries.Clear();
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name == "Data")
                            {
                                FirstRun          = bool.Parse(reader.GetAttribute("FirstRun"));
                                CurrentMacAddress = reader.GetAttribute("MacAddress");
                                CommitteeName     = reader.GetAttribute("CommitteeName");
                                GSLAgenda         = reader.GetAttribute("GSLAgenda");
                                SSLAgenda         = reader.GetAttribute("SSLAgenda");
                                RollCallDone      = bool.Parse(reader.GetAttribute("RollCallDone"));
                                ExtraData         = reader.GetAttribute("ExtraData");
                            }
                            else if (reader.Name == "Country")
                            {
                                Country country = new Country();
                                country.Name = reader.GetAttribute("Name");
                                country.Flag = reader.GetAttribute("Flag");
                                switch (reader.GetAttribute("Attendance"))
                                {
                                case "PresentAndVoting":
                                    country.Attendance = Attendance.PresentAndVoting;
                                    break;

                                case "Present":
                                    country.Attendance = Attendance.Present;
                                    break;

                                default:
                                case "Absent":
                                    country.Attendance = Attendance.Absent;
                                    break;
                                }
                                country.GSL = int.Parse(reader.GetAttribute("GSL"));
                                country.SSL = int.Parse(reader.GetAttribute("SSL"));
                                if (!Countries.Contains(country))
                                {
                                    Countries.Add(country);
                                }
                            }
                            else if (reader.Name == "Topics")
                            {
                                using (XmlReader topicsReader = reader.ReadSubtree())
                                {
                                    while (topicsReader.Read())
                                    {
                                        if (topicsReader.NodeType == XmlNodeType.Element && topicsReader.Name == "Topic")
                                        {
                                            Topic topic = new Topic();
                                            topic.Heading    = topicsReader.GetAttribute("Heading");
                                            topic.Passed     = bool.Parse(topicsReader.GetAttribute("Passed"));
                                            topic.ProposedBy = FindCountry(topicsReader.GetAttribute("ProposedBy"));
                                            using (XmlReader speakersReader = topicsReader.ReadSubtree())
                                            {
                                                while (speakersReader.Read())
                                                {
                                                    if (speakersReader.NodeType == XmlNodeType.Element && speakersReader.Name == "Country")
                                                    {
                                                        topic.SpeakingCountries.Add(FindCountry(speakersReader.ReadElementContentAsString()));
                                                    }
                                                }
                                            }
                                            if (!topic.ProposedBy.MC.Contains(topic))
                                            {
                                                topic.ProposedBy.MC.Add(topic);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                FirstRun          = true;
                CurrentMacAddress = string.Empty;
                Countries         = GetDefaultCountries();
                CommitteeName     = "Committee";
                GSLAgenda         = "GSL Agenda";
                SSLAgenda         = "SSL Agenda";
                RollCallDone      = false;
                ExtraData         = string.Empty;
            }
        }
Пример #27
0
        protected void FillSearchCriterias()
        {
            SortAscending = false;
            Countries.Clear();
            Groups.Clear();
            Genders.Clear();
            CalendarPrivacy.Clear();
            MeasurementPrivacy.Clear();
            Photos.Clear();
            Plans.Clear();
            SearchStatus = string.Empty;
            SortOrders.Clear();

            foreach (var test in Country.Countries)
            {
                CheckListItem <Country> item = new CheckListItem <Country>(test.DisplayName, test);
                Countries.Add(item);
            }

            foreach (UserSearchGroup test in Enum.GetValues(typeof(UserSearchGroup)))
            {
                var item = new CheckListItem <UserSearchGroup>(EnumLocalizer.Default.Translate(test), test);
                Groups.Add(item);
            }

            foreach (Gender test in Enum.GetValues(typeof(Gender)))
            {
                var item = new CheckListItem <Gender>(EnumLocalizer.Default.Translate(test), test);
                Genders.Add(item);
            }

            foreach (PrivacyCriteria test in Enum.GetValues(typeof(PrivacyCriteria)))
            {
                var item = new CheckListItem <PrivacyCriteria>(EnumLocalizer.Default.Translate(test), test);
                CalendarPrivacy.Add(item);
            }
            foreach (PrivacyCriteria test in Enum.GetValues(typeof(PrivacyCriteria)))
            {
                var item = new CheckListItem <PrivacyCriteria>(EnumLocalizer.Default.Translate(test), test);
                MeasurementPrivacy.Add(item);
            }

            foreach (UsersSortOrder test in Enum.GetValues(typeof(UsersSortOrder)))
            {
                var item = new CheckListItem <UsersSortOrder>(EnumLocalizer.Default.Translate(test), test);
                SortOrders.Add(item);
            }

            foreach (PictureCriteria test in Enum.GetValues(typeof(PictureCriteria)))
            {
                var item = new CheckListItem <PictureCriteria>(EnumLocalizer.Default.Translate(test), test);
                Photos.Add(item);
            }
            foreach (UserPlanCriteria test in Enum.GetValues(typeof(UserPlanCriteria)))
            {
                var item = new CheckListItem <UserPlanCriteria>(EnumLocalizer.Default.Translate(test), test);
                Plans.Add(item);
            }


            SelectedCalendarPrivacy    = PrivacyCriteria.All;
            SelectedMeasurementPrivacy = PrivacyCriteria.All;
            SelectedPhoto     = PictureCriteria.All;
            SelectedPlan      = UserPlanCriteria.All;
            SelectedSortOrder = UsersSortOrder.ByLastLoginDate;
        }
Пример #28
0
        /// <summary>
        /// retrieve the cases number for all countries
        /// </summary>
        public void GetCountries()
        {
            if (_html == null)
            {
                return;
            }

            Countries.Clear();

            var rows = _html.DocumentNode.SelectNodes("//table[@id='main_table_countries_today']/tbody/tr");

            foreach (var row in rows)
            {
                var cells   = row.SelectNodes(".//td");
                var country = new Country();

                // the first cell is country name, it may or may not contain a hyper link
                var a = cells.FirstOrDefault(x => x.ChildNodes.Count > 1);
                if (a != null)
                {
                    country.Name = a.ChildNodes[1].InnerText;
                }
                else
                {
                    country.Name = cells[0].InnerText;
                }

                int temp;

                int.TryParse(cells[1].InnerText.Trim(), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.TotalCases = temp;

                int.TryParse(cells[2].InnerText.Trim().Trim('+'), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.NewCases = temp;

                int.TryParse(cells[3].InnerText.Trim(), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.TotalDeaths = temp;

                int.TryParse(cells[4].InnerText.Trim().Trim('+'), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.NewDeaths = temp;

                int.TryParse(cells[5].InnerText.Trim(), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.TotalRecovered = temp;

                int.TryParse(cells[6].InnerText.Trim(), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.ActiveCases = temp;

                int.TryParse(cells[7].InnerText.Trim(), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.SeriousCritical = temp;

                int.TryParse(cells[7].InnerText.Trim(), NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out temp);
                country.TotalCasesPer1MPop = temp;

                if (row == rows.Last())
                {
                    CountryTotal = country;
                }
                else
                {
                    Countries.Add(country);
                }
            }
        }
 public void Clear() => Countries.Clear();