Пример #1
0
        private PopulationChangeEntry ParseAdditionalJson(JsonObject data)
        {
            var result = new PopulationChangeEntry();

            var actualData = data.get("aaData");

            if (actualData != null)
            {
                var array = actualData.asArray();
                foreach (JsonArray item in array)
                {
                    var parsedData = new List <String>();
                    foreach (JsonValue dataPoint in item)
                    {
                        var strippedText = Regex.Replace(dataPoint.asString(), "<.*?>", string.Empty).Replace(",", String.Empty);
                        if (strippedText == "-")
                        {
                            strippedText = "0";
                        }
                        parsedData.Add(strippedText);
                    }
                    var firstLine = parsedData.First();
                    if (firstLine == "00")
                    {
                        result.male   = Convert.ToInt32(parsedData.ElementAt(2), CultureInfo.InvariantCulture);
                        result.female = Convert.ToInt32(parsedData.ElementAt(3), CultureInfo.InvariantCulture);
                        result.total  = Convert.ToInt32(parsedData.ElementAt(4), CultureInfo.InvariantCulture);
                    }
                }
            }
            return(result);
        }
Пример #2
0
        private void AddOtherData(PopulationData populationData, UInt32 geocode, DopaStatisticsType dataType)
        {
            var jsonData = GetDataFromDopa(geocode, dataType);

            if (populationData.register == null)
            {
                populationData.register = new RegisterData();
            }

            PopulationChangeEntry otherData = ParseAdditionalJson(jsonData);

            otherData.type = _populationChangeType[dataType];
            populationData.register.change.Add(otherData);
        }