private static void ModifyPopulationDataForBuengKan(PopulationDataEntry data) { PopulationDataEntry buengKan = data.FindByCode(38); if (buengKan == null) { buengKan = new PopulationDataEntry(); buengKan.English = "Bueng Kan"; buengKan.Geocode = 38; List <Int32> buengKanAmphoeCodes = new List <int>() { 4313, 4311, 4309, 4312, 4303, 4306, 4310, 4304 }; data.SubEntities.RemoveAll(p => p == null); PopulationDataEntry nongKhai = data.FindByCode(43); foreach (Int32 code in buengKanAmphoeCodes) { PopulationDataEntry entry = nongKhai.FindByCode(code); buengKan.SubEntities.Add(entry); nongKhai.SubEntities.Remove(entry); } nongKhai.CalculateNumbersFromSubEntities(); buengKan.CalculateNumbersFromSubEntities(); data.SubEntities.Add(buengKan); data.CalculateNumbersFromSubEntities(); } }
private void ProcessAllProvinces() { PopulationDataEntry data = new PopulationDataEntry(); foreach (PopulationDataEntry entry in TambonHelper.ProvinceGeocodes) { PopulationData tempCalculator = new PopulationData(Year, entry.Geocode); tempCalculator.Process(); data.SubEntities.Add(tempCalculator.Data); } data.CalculateNumbersFromSubEntities(); _changwat = data; }
private static void ModifyPopulationDataForBuengKan(PopulationDataEntry data) { PopulationDataEntry buengKan = data.FindByCode(38); if ( buengKan == null ) { buengKan = new PopulationDataEntry(); buengKan.English = "Bueng Kan"; buengKan.Geocode = 38; List<Int32> buengKanAmphoeCodes = new List<int>() { 4313, 4311, 4309, 4312, 4303, 4306, 4310, 4304 }; data.SubEntities.RemoveAll(p => p == null); PopulationDataEntry nongKhai = data.FindByCode(43); foreach ( Int32 code in buengKanAmphoeCodes ) { PopulationDataEntry entry = nongKhai.FindByCode(code); buengKan.SubEntities.Add(entry); nongKhai.SubEntities.Remove(entry); } nongKhai.CalculateNumbersFromSubEntities(); buengKan.CalculateNumbersFromSubEntities(); data.SubEntities.Add(buengKan); data.CalculateNumbersFromSubEntities(); } }
public void CopyPopulationToConstituencies(PopulationDataEntry iPopulationSource) { PopulationDataEntry lSourcePopulationdataEntry = iPopulationSource.FindByCode(Geocode); if (lSourcePopulationdataEntry != null) { lSourcePopulationdataEntry.CalculateNumbersFromSubEntities(); CopyPopulationDataFrom(lSourcePopulationdataEntry); } Debug.Assert(lSourcePopulationdataEntry != null, "No source data entry with geocode " + Geocode.ToString()); if (lSourcePopulationdataEntry != null) { foreach (ConstituencyEntry lConstituency in ConstituencyList) { GetPopulationData(lSourcePopulationdataEntry, lConstituency.AdministrativeEntities); foreach (var lKeyValuePair in lConstituency.ExcludedAdministrativeEntities) { PopulationDataEntry lSourceSubEntity = iPopulationSource.FindByCode(lKeyValuePair.Key.Geocode); GetPopulationData(lSourceSubEntity, lKeyValuePair.Value); } foreach (var lKeyValuePair in lConstituency.SubIncludedAdministrativeEntities) { PopulationDataEntry lSourceSubEntity = iPopulationSource.FindByCode(lKeyValuePair.Key.Geocode); GetPopulationData(lSourceSubEntity, lKeyValuePair.Value); } } } Int32 lPopulation = ConstituencyList.Population(); Int32 lTotal = Total; if ((lPopulation > 0) && (lTotal > 0)) { Int32 lPopulationDiff = lPopulation - lTotal; Debug.Assert(lPopulationDiff == 0, "Population for " + English + " does not sum up, off by " + lPopulationDiff.ToString()); } }