Exemplo n.º 1
0
        private static void addIndicators(DbConnection conn, Provider p, IEnumerable<ExtendedSubTheme> subthemes, INEService.Statistics ine)
        {
            Console.WriteLine(":::::::::: Adding indicatores :::::::::");

            var indicatorDAO = new IndicatorDAO(conn);

            foreach (var subtheme in subthemes)
            {
                INEService.IndicatorPlus indicators = ine.GetIndicatorsByTheme(GEOVERSION, subtheme.SourceThemeCode, LANGUAGE, 2, 1, 10000);
                foreach (var indicator in indicators.Indicators)
                {
                    Console.WriteLine("... Adding indicator: {0} ....", subtheme.NameAbbr);

                    Indicator convertedIndicator = new Indicator
                    {
                        Name = indicator.Designation,
                        NameAbbr = indicator.Abbreviation,
                        Provider = p,
                        SourceID = indicator.Code,
                        SubThemeID = subtheme.ID,
                        ThemeID = subtheme.ThemeID
                    };
                    convertedIndicator.ID = indicatorDAO.AddIndicator(convertedIndicator);

                    addConfiguration(conn, convertedIndicator, indicator.GeoLevelCode);
                }
            }
        }
Exemplo n.º 2
0
 public int AddProvider(Provider p)
 {
     using (ProviderDAO.Connection = ConnectionSettings.CreateDBConnection())
     {
         return ProviderDAO.AddProvider(p);
     }
 }
Exemplo n.º 3
0
 public int AddProvider(Provider p)
 {
     return DbTemplateHelper<int>.GetValueByProcedure(
         Connection,
         "config.insertprovider",
         new DbParameterHelper[]
         {
             new DbParameterHelper(DbType.String, "p_name", p.Name),
             new DbParameterHelper(DbType.String, "p_nameAbbr", p.NameAbbr),
             new DbParameterHelper(DbType.String, "p_serviceUrl", p.ServiceURL),
             new DbParameterHelper(DbType.String, "p_url", p.URL),
         });
 }
Exemplo n.º 4
0
 public void GetProvidersTest()
 {
     ProviderDAO target = new ProviderDAO(connnetion);
     Nullable<int> page = new Nullable<int>(1);
     Nullable<int> recordsPerPage = new Nullable<int>(1);
     Provider expected = new Provider
     {
         ID = 1,
         Name = "Instituto Nacional de Estatística",
         NameAbbr = "INE",
         ServiceURL = "http://localhost:42136/INEStatisticsProvider.svc",
         URL = "http://www.ine.pt"
     };
     IEnumerable<Provider> actual;
     actual = target.GetProviders(page, recordsPerPage);
     Assert.AreEqual(1, actual.Count());
     Assert.AreEqual(expected, actual.ElementAt(0));
 }
Exemplo n.º 5
0
        static Provider addProvider(DbConnection conn)
        {
            Console.WriteLine(":::::::::: Adding provider :::::::::");

            Provider p = new Provider
            {
                Name = "Instituto Nacional de Estatística",
                NameAbbr = "INE",
                ServiceURL = "http://localhost:42136/INEStatisticsProvider.svc",
                URL = "http://www.ine.pt"
            };

            ProviderDAO provider = new ProviderDAO(conn);
            p.ID = provider.AddProvider(p);

            return p;
        }
Exemplo n.º 6
0
        static IEnumerable<ExtendedSubTheme> AddThemes(DbConnection conn, Provider p, INEService.Statistics ine)
        {
            Console.WriteLine(":::::::::: Adding themes :::::::::");

            var themesDAO = new ThemesDAO(conn);

            var insertedThemes = new List<ExtendedTheme>();
            var insertedSubThemes = new List<ExtendedSubTheme>();

            INEService.Theme[] themes = ine.GetThemes(GEOVERSION, 2, LANGUAGE, 1, 100000);
            var filteredThemes = themes.Where(t => t.ThemeLevel == 2);
            foreach (var theme in filteredThemes)
            {
                Console.WriteLine("... Adding theme: {0} ....", theme.Designation);

                ExtendedTheme t = new ExtendedTheme
                {
                    Name = theme.Designation,
                    NameAbbr = theme.Designation,
                    ProviderID = p.ID,
                    SourceThemeCode = theme.Code
                };
                t.ID = themesDAO.AddTheme(t);

                insertedThemes.Add(t);
            }

            // subthemes
            var filteredSubThemes = themes.Where(t => t.ThemeLevel == 3);
            foreach (var subtheme in filteredSubThemes)
            {
                Console.WriteLine("... Adding subtheme: {0} ....", subtheme.Designation);

                ExtendedSubTheme sub = new ExtendedSubTheme
                {
                    Name = subtheme.Designation,
                    NameAbbr = subtheme.Designation,
                    ProviderID = p.ID,
                    ThemeID = insertedThemes.Where(it => it.SourceThemeCode == subtheme.ParentCode).First().ID,
                    SourceThemeCode = subtheme.Code
                };

                sub.ID = themesDAO.AddSubTheme(sub);
                insertedSubThemes.Add(sub);
            }

            return insertedSubThemes;
        }