Exemplo n.º 1
0
        /// <summary>
        /// Populate
        /// </summary>
        public void Populate()
        {
            var cacheProvider = CacheFactory.Get();

            if (!cacheProvider.Exists(CacheKeys.CACHE_COUNTRIESMAP))
            {
                this.CountryRecords = new List <CountryRecordsModel>();

                Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID));
                var  countryLanguages  = CountryService.GetCountriesWithRecord(defaultLanguageID);

                //Get Minimum record
                this.MinRecord = (from cl in countryLanguages
                                  where cl.Country.Records.Count > 0
                                  select cl.Country.Records.Count).Min();

                //Get Max Record
                this.MaxRecord = (from cl in countryLanguages
                                  where cl.Country.Records.Count > 0
                                  select cl.Country.Records.Count).Max();

                foreach (var countryLanguage in countryLanguages)
                {
                    CountryRecordsModel countryRecord = new CountryRecordsModel
                    {
                        CountryCode = countryLanguage.Country.ISOCode,
                        CountryID   = countryLanguage.ID.ToString(),
                        CountryName = countryLanguage.Name,
                        RecordCount = countryLanguage.Country.Records.Count,
                        FillOpacity = GetFillOpacity(countryLanguage.Country.Records.Count),
                        GeoJSON     = GetGeoJSON(countryLanguage.Country.ISOCode),
                        MinRecord   = this.MinRecord,
                        MaxRecord   = this.MaxRecord
                    };

                    if (!string.IsNullOrEmpty(countryRecord.GeoJSON) && countryRecord.RecordCount > 0)
                    {
                        this.CountryRecords.Add(countryRecord);
                    }
                }

                //Add to cache
                cacheProvider.Add <List <CountryRecordsModel> >(this.CountryRecords, CacheKeys.CACHE_COUNTRIESMAP, SiteConstants.CacheDuration);
            }
            else
            {
                this.CountryRecords = cacheProvider.Get <List <CountryRecordsModel> >(CacheKeys.CACHE_COUNTRIESMAP);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populate
        /// </summary>
        public void Populate(string[] region, string[] country, string[] sector, string[] document, string[] year, string[] period, string[] last_Update, string[] counterpart, string[] DocCheckboxData, string[] thematicCheckboxData, string[] designProcessCheckboxData)
        {
            //var cacheProvider = CacheFactory.Get();
            //if (!cacheProvider.Exists(CacheKeys.CACHE_COUNTRIESMAP))
            //{
            this.CountryRecords = new List <CountryRecordsModel>();

            Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID));
            var  countryLanguages  = CountryService.GetCountriesWithFilterRecord(defaultLanguageID);

            //Get Minimum record
            this.MinRecord = (from cl in countryLanguages
                              where cl.Country.Records.Count > 0
                              select cl.Country.Records.Count).Min();

            //Get Max Record
            this.MaxRecord = (from cl in countryLanguages
                              where cl.Country.Records.Count > 0
                              select cl.Country.Records.Count).Max();

            foreach (var countryLanguage in countryLanguages)
            {
                CountryRecordsModel countryRecord = new CountryRecordsModel
                {
                    CountryCode = countryLanguage.Country.ISOCode,
                    CountryID   = countryLanguage.ID.ToString(),
                    CountryName = countryLanguage.Name,
                    RecordCount = countryLanguage.Country.Records.Count,
                    FillOpacity = GetFillOpacity(countryLanguage.Country.Records.Count),
                    GeoJSON     = GetGeoJSON(countryLanguage.Country.ISOCode),
                    MinRecord   = this.MinRecord,
                    MaxRecord   = this.MaxRecord
                };

                if (!string.IsNullOrEmpty(countryRecord.GeoJSON) && countryRecord.RecordCount > 0)
                {
                    this.CountryRecords.Add(countryRecord);
                }
            }

            //Add to cache
            //cacheProvider.Add<List<CountryRecordsModel>>(this.CountryRecords, CacheKeys.CACHE_COUNTRIESMAP, SiteConstants.CacheDuration);
            //}
            //else
            //{
            //    this.CountryRecords = cacheProvider.Get<List<CountryRecordsModel>>(CacheKeys.CACHE_COUNTRIESMAP);
            //}
        }
Exemplo n.º 3
0
        /// <summary>
        /// Poulate Country Map
        /// </summary>
        /// <param name="countryCodes"></param>
        /// <returns></returns>
        public void Populate(string countryCodes)
        {
            this.CountryRecords = new List <CountryRecordsModel>();

            Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID));
            var  countryLanguages  = CountryService.GetCountriesWithRecord(defaultLanguageID);

            //Get Minimum record
            this.MinRecord = (from cl in countryLanguages
                              where cl.Country.Records.Count > 0
                              select cl.Country.Records.Count).Min();

            //Get Max Record
            this.MaxRecord = (from cl in countryLanguages
                              where cl.Country.Records.Count > 0
                              select cl.Country.Records.Count).Max();

            string[] arrCountryCodes = countryCodes.Split(',');
            foreach (string countryCode in arrCountryCodes)
            {
                var countryLanguage = countryLanguages.Where(cl => cl.Country.ISOCode == countryCode).FirstOrDefault();
                if (countryLanguage != null)
                {
                    CountryRecordsModel countryRecord = new CountryRecordsModel
                    {
                        CountryCode = countryLanguage.Country.ISOCode,
                        CountryID   = countryLanguage.ID.ToString(),
                        CountryName = countryLanguage.Name,
                        RecordCount = countryLanguage.Country.Records.Count,
                        FillOpacity = GetFillOpacity(countryLanguage.Country.Records.Count),
                        GeoJSON     = GetGeoJSON(countryLanguage.Country.ISOCode),
                        MinRecord   = this.MinRecord,
                        MaxRecord   = this.MaxRecord
                    };

                    if (!string.IsNullOrEmpty(countryRecord.GeoJSON) && countryRecord.RecordCount > 0)
                    {
                        this.CountryRecords.Add(countryRecord);
                    }
                }
            }
        }