// No one single data source provides enough data for Sources table,
        // so try all resources to put them together.
        public static void HandleSourceInfo(SqlConnection sqlConn,
                                            SiteInfoType stinfo, seriesCatalogTypeSeries scts, TimeSeriesType tst)
        {
            string cond = "SourceID = " + scts.source.sourceID;

            if (OD_Utils.Exists("Sources", cond, sqlConn))
            {
                return;
            }

            SourcesTableAdapter srcAdapter = new SourcesTableAdapter();

            srcAdapter.Connection = sqlConn;
            int    metadataID = 0;
            string title      = "Unknown";

            OD_1_1_1DataSet.SourcesDataTable tblSources = new OD_1_1_1DataSet.SourcesDataTable();

            // We currently don't have any information about ISOMetaDataTable. Just create
            // an unkown entry to resolve foreign key dependency.
            if (scts.source.metadata != null)
            {
                title = scts.source.metadata.title;
            }
            cond       = string.Format("Title = '{0}'", title);
            metadataID = OD_Utils.GetPrimaryKey("ISOMetadata", "MetadataID", cond, sqlConn);
            if (metadataID < 0)
            {
                InsertOneMetadata(scts.source.metadata, sqlConn);
                metadataID = OD_Utils.GetPrimaryKey("ISOMetadata", "MetadataID", cond, sqlConn);
            }


            Console.WriteLine(">>>Parsing and inserting SOURCES");
            InsertOneSource(tblSources, stinfo, scts, tst, metadataID, sqlConn);

            //srcAdapter.Update(tblSources);

            //PrintTable(srcAdapter, tblSites);
        }
Exemple #2
0
        // fills dataset with basic tables
        private static ValuesDataSet basicValuesDataSet()
        {
            ValuesDataSet ds = new ValuesDataSet();

            UnitsTableAdapter unitsTableAdapter =
                new UnitsTableAdapter();

            unitsTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            OffsetTypesTableAdapter offsetTypesTableAdapter =
                new OffsetTypesTableAdapter();

            offsetTypesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            QualityControlLevelsTableAdapter qualityControlLevelsTableAdapter =
                new QualityControlLevelsTableAdapter();

            qualityControlLevelsTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            MethodsTableAdapter methodsTableAdapter =
                new MethodsTableAdapter();

            methodsTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            SamplesTableAdapter samplesTableAdapter =
                new SamplesTableAdapter();

            samplesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();


            SourcesTableAdapter sourcesTableAdapter =
                new SourcesTableAdapter();

            sourcesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            QualifiersTableAdapter qualifiersTableAdapter =
                new QualifiersTableAdapter();

            qualifiersTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            CensorCodeCVTableAdapter censorCodeCvTableAdapter =
                new CensorCodeCVTableAdapter();

            censorCodeCvTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            ISOMetadataTableAdapter IsoMetadataTableAdapter =
                new ISOMetadataTableAdapter();

            IsoMetadataTableAdapter.Connection.ConnectionString = odws.Config.ODDB();


            unitsTableAdapter.Fill(ds.Units);
            offsetTypesTableAdapter.Fill(ds.OffsetTypes);
            qualityControlLevelsTableAdapter.Fill(ds.QualityControlLevels);
            methodsTableAdapter.Fill(ds.Methods);
            samplesTableAdapter.Fill(ds.Samples);
            sourcesTableAdapter.Fill(ds.Sources);
            qualifiersTableAdapter.Fill(ds.Qualifiers);
            censorCodeCvTableAdapter.Fill(ds.CensorCodeCV);
            IsoMetadataTableAdapter.Fill(ds.ISOMetadata);

            return(ds);
        }
            //public static ValuesDataSet GetValueDataSet(int? siteID, int? VariableID, int? MethodID, int? SourceID, int? QualityControlLevelID)
            //{
            //    ValuesDataSet ds = basicValuesDataSet();
            //    if (!siteID.HasValue || !VariableID.HasValue) return ds;
            //    ValuesDataSetTableAdapters.DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter();
            //    valuesTableAdapter.FillBySiteIdVariableIDBetweenDates(ds.DataValues, siteID.Value, VariableID.Value, BeginDateTime.DateTime, EndDateTime.DateTime);
            //    return ds;
            //}

            #endregion odm 1 series based

            // fills dataset with basic tables
            private static ValuesDataSet basicValuesDataSet()
            {
                ValuesDataSet ds = new ValuesDataSet();

                UnitsTableAdapter unitsTableAdapter =
                    new UnitsTableAdapter();
                unitsTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                OffsetTypesTableAdapter offsetTypesTableAdapter =
                    new OffsetTypesTableAdapter();
                offsetTypesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                QualityControlLevelsTableAdapter qualityControlLevelsTableAdapter =
                    new QualityControlLevelsTableAdapter();
                qualityControlLevelsTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                MethodsTableAdapter methodsTableAdapter =
                    new MethodsTableAdapter();
                methodsTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                SamplesTableAdapter samplesTableAdapter =
                    new SamplesTableAdapter();
                samplesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                SourcesTableAdapter sourcesTableAdapter =
                    new SourcesTableAdapter();
                sourcesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                QualifiersTableAdapter qualifiersTableAdapter =
                    new QualifiersTableAdapter();
                qualifiersTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                CensorCodeCVTableAdapter censorCodeCvTableAdapter =
                    new CensorCodeCVTableAdapter();
                censorCodeCvTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                ISOMetadataTableAdapter IsoMetadataTableAdapter =
                 new ISOMetadataTableAdapter();
                IsoMetadataTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                unitsTableAdapter.Fill(ds.Units);
                offsetTypesTableAdapter.Fill(ds.OffsetTypes);
                qualityControlLevelsTableAdapter.Fill(ds.QualityControlLevels);
                methodsTableAdapter.Fill(ds.Methods);
                samplesTableAdapter.Fill(ds.Samples);
                sourcesTableAdapter.Fill(ds.Sources);
                qualifiersTableAdapter.Fill(ds.Qualifiers);
                censorCodeCvTableAdapter.Fill(ds.CensorCodeCV);
                IsoMetadataTableAdapter.Fill(ds.ISOMetadata);

                return ds;
            }