コード例 #1
0
        private Dimension LoadYears()
        {
            ReportStatus("Reading years...");

            Dimension dimension = new Dimension(YEARS);

            var allYears = new Element("0", YEARS_ALL_YEARS);

            dimension.Add("0", allYears);

            ReportReadingInput(true);

            //DbDataReader reader = new OleDbCommand("SELECT * FROM [" + FACTS_SHEET_NAME + "]", InputFileConnection).ExecuteReader();

            var reader = _inputFileDataSet.Tables[FACTS_SHEET_NAME].CreateDataReader();

            Element node;
            IDictionary <string, Element> parentNode = allYears;

            for (int i = 0; i < reader.FieldCount; i++)
            {
                int yearOut;
                if (int.TryParse(reader.GetName(i), out yearOut))
                {
                    var year = yearOut.ToString();
                    node = new Element(year, year);

                    parentNode.Add(year, node);
                }
            }

            ReportReadingInput(false);
            ReportStatus("Done reading years.");

            return(dimension);
        }
コード例 #2
0
        private Dimension LoadIndicators()
        {
            ReportStatus("Reading indicators...");

            Dimension dimension = new Dimension(INDICATORS);

            var allIndicators = new Element(INDICATORS_ALL_INDICATORS, INDICATORS_ALL_INDICATORS);

            dimension.Add(INDICATORS_ALL_INDICATORS, allIndicators);

            ReportReadingInput(true);

            //DbDataReader reader = new OleDbCommand("SELECT * FROM [" + INDICATORS_SHEET_NAME + "]", InputFileConnection).ExecuteReader();

            var reader = _inputFileDataSet.Tables[INDICATORS_SHEET_NAME].CreateDataReader();

            while (reader.Read())
            {
                string id         = GetString(reader, INDICATORS_COLUMN_Id);
                string caption    = GetString(reader, INDICATORS_COLUMN_Caption);
                string topic      = GetString(reader, INDICATORS_COLUMN_Topic).TrimEnd(new char[] { ':', ' ' });
                string definition = GetString(reader, INDICATORS_COLUMN_Definition);
                if (definition.Length >= 254)
                {
                    definition = definition.Remove(253);
                }
                string source = GetString(reader, INDICATORS_COLUMN_Source);
                if (source.Length >= 254)
                {
                    source = source.Remove(253);
                }
                string periodicity       = GetString(reader, INDICATORS_COLUMN_Periodicity);
                string aggregationMethod = GetString(reader, INDICATORS_COLUMN_AggregationMethod);

                Element node;
                IDictionary <string, Element> parentNode = allIndicators;
                if (topic.Length > 0)
                {
                    string[] topicPathArray = topic.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string item in topicPathArray)
                    {
                        string topicName = item.Trim();
                        if (parentNode.ContainsKey(topicName))
                        {
                            node = parentNode[topicName];
                        }
                        else
                        {
                            node = new Element(topicName, topicName);
                            parentNode.Add(topicName, node);
                        }
                        parentNode = node;
                    }
                }

                if (id == null)
                {
                    continue;
                }

                node = new Element(id, caption);

                if (definition != null)
                {
                    node.SetAttributeValue(INDICATORS_COLUMN_Definition, definition);
                }

                if (source != null)
                {
                    node.SetAttributeValue(INDICATORS_COLUMN_Source, source);
                }

                if (periodicity != null)
                {
                    node.SetAttributeValue(INDICATORS_COLUMN_Periodicity, periodicity);
                }

                if (aggregationMethod != null)
                {
                    node.SetAttributeValue(INDICATORS_COLUMN_AggregationMethod, aggregationMethod);
                }

                parentNode.Add(id, node);
            }

            ReportReadingInput(false);
            ReportStatus("Done reading indicators.");

            return(dimension);
        }
コード例 #3
0
        private Dimension LoadCountries()
        {
            ReportStatus("Reading countries...");

            var dimension = new Dimension(COUNTRIES);

            var regionsTopNode = new Element(COUNTRIES_REGIONS, COUNTRIES_REGIONS);

            dimension.Add(COUNTRIES_REGIONS, regionsTopNode);

            var aggregatesTopNode = new Element(COUNTRIES_AGGREGATES, COUNTRIES_AGGREGATES);

            dimension.Add(COUNTRIES_AGGREGATES, aggregatesTopNode);

            ReportReadingInput(true);

            //DbDataReader reader = new OleDbCommand("SELECT * FROM [" + COUNTRIES_SHEET_NAME + "]", InputFileConnection).ExecuteReader();

            var reader = _inputFileDataSet.Tables[COUNTRIES_SHEET_NAME].CreateDataReader();

            while (reader.Read())
            {
                string id                    = GetString(reader, COUNTRIES_COLUMN_Id);
                string parent                = GetString(reader, COUNTRIES_COLUMN_Parent);
                string caption               = GetString(reader, COUNTRIES_COLUMN_Caption);
                string currencyUnit          = GetString(reader, COUNTRIES_COLUMN_CurrencyUnit);
                string ISO_3166_numeric_code = GetString(reader, COUNTRIES_COLUMN_ISO_3166_numeric_code);
                string ISO_3166_alpha_2_code = GetString(reader, COUNTRIES_COLUMN_ISO_3166_alpha_2_code);
                string WB_2_code             = GetString(reader, COUNTRIES_COLUMN_WB_2_code);
                string ISO_3166_alpha_3_code = GetString(reader, COUNTRIES_COLUMN_ISO_3166_alpha_3_code);
                string WB_3_code             = GetString(reader, COUNTRIES_COLUMN_WB_3_code);

                Element node;
                IDictionary <string, Element> parentNode;
                if (parent == null)
                {
                    parentNode = aggregatesTopNode;
                }
                else
                {
                    parentNode = regionsTopNode;

                    if (parentNode.ContainsKey(parent))
                    {
                        node = parentNode[parent];
                    }
                    else
                    {
                        node = new Element(parent, parent);
                        parentNode.Add(parent, node);
                    }

                    parentNode = node;
                }

                if (id == null)
                {
                    continue;
                }

                node = new Element(id, caption);

                if (currencyUnit != null)
                {
                    node.SetAttributeValue(COUNTRIES_COLUMN_CurrencyUnit, currencyUnit);
                }

                if (ISO_3166_numeric_code != null)
                {
                    node.SetAttributeValue(COUNTRIES_COLUMN_ISO_3166_numeric_code, ISO_3166_numeric_code);
                }

                if (ISO_3166_alpha_2_code != null)
                {
                    node.SetAttributeValue(COUNTRIES_COLUMN_ISO_3166_alpha_2_code, ISO_3166_alpha_2_code);
                }

                if (WB_2_code != null)
                {
                    node.SetAttributeValue(COUNTRIES_COLUMN_WB_2_code, WB_2_code);
                }

                if (ISO_3166_alpha_3_code != null)
                {
                    node.SetAttributeValue(COUNTRIES_COLUMN_ISO_3166_alpha_3_code, ISO_3166_alpha_3_code);
                }

                if (WB_3_code != null)
                {
                    node.SetAttributeValue(COUNTRIES_COLUMN_WB_3_code, WB_3_code);
                }

                parentNode.Add(id, node);
            }

            ReportReadingInput(false);
            ReportStatus("Done reading countries.");

            return(dimension);
        }