示例#1
0
        /*
         * newTable
         * creates the Data Table required by rest of program to create the XML form
         */
        private ValuesDataSet newTable(string variable, int SID, string Data)
        {
            SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter();

            scAdapater.Connection.ConnectionString = odws.Config.ODDB();
            ValuesDataSet ds            = basicValuesDataSet();
            DataTable     variableTable = ds.Tables[0];
            int           ValueID       = 0;

            foreach (string entry in Data.Split('\n'))
            {
                string[] row = entry.Split(',');
                if (row[0] != "" && row[0] != null)
                {
                    ValueID++;

                    seriesCatalogDataSet scTable = new seriesCatalogDataSet();
                    scAdapater.FillBySeriesID(scTable.SeriesCatalog, SID);
                    seriesCatalogDataSet.SeriesCatalogRow sc = scTable.SeriesCatalog[0];
                    TimeSpan utcOffset = sc.BeginDateTime.Subtract(sc.BeginDateTimeUTC);
                    variableTable.Rows.Add(ValueID, sc.SiteID, sc.VariableID, 0, 0, "nc", 0, sc.MethodID, sc.SourceID, 0, 0, sc.QualityControlLevelID, (row[0] == string.Empty) || row[1] == string.Empty ? -999999 : Convert.ToDouble(row[1]), 0, Convert.ToDateTime(row[0]), Convert.ToDateTime(row[0]).ToUniversalTime(), utcOffset.Hours);
                    /*"ValueID","SiteID","VariableID",offsetvalue, offset type id, "CensorCode","QualifierID","MethodID","SourceID","SampleID","DerivedFromID","QualityControlLevelID", "Value", "AccuracyStdDev", "DateTime","DateTimeUTC", "UTCOffset"*/
                }
            }

            return(ds);
        }
            public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset)
            {
                int variableID = row.VariableID;
                VariableInfoType       variable      = ODvariables.GetVariableByID(variableID, vds);
                Nullable <W3CDateTime> beginDateTime = null;

                if (!row.IsBeginDateTimeNull())
                {
                    TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC);
                    beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan);
                }

                Nullable <W3CDateTime> endDateTime = null;

                if (!row.IsEndDateTimeNull())
                {
                    TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC);
                    endDateTime = new W3CDateTime(row.EndDateTime, timeSpan);
                }

                Nullable <int> valueCount = null;

                if (!row.IsValueCountNull())
                {
                    valueCount = row.ValueCount;
                }

                string qualityControlLevelTerm = null;
                int?   QualityControlLevelid   = null;

                if (!row.IsQualityControlLevelIDNull())
                {
                    QualityControlLevelid = row.QualityControlLevelID;
                    ControlledVocabularyDataset.QualityControlLevelsRow qcRow =
                        vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value);
                    if (qcRow != null)
                    {
                        qualityControlLevelTerm = qcRow.Definition;
                    }
                }

                int?MethodID = null;

                if (!row.IsMethodIDNull())
                {
                    MethodID = row.MethodID;
                }

                int?SourceID = null;

                if (!row.IsSourceIDNull())
                {
                    SourceID = row.SourceID;
                }

                Nullable <Boolean> valueCountIsEstimated = false;

                /* public static seriesCatalogTypeSeries createSeriesCatalogRecord(
                 *      VariableInfoType variable,
                 *      string sampleMedium,
                 *      Nullable<W3CDateTime> beginDateTime,
                 *      Nullable<W3CDateTime> endDateTime,
                 *      Nullable<int> valueCount,
                 *       Nullable<Boolean> valueCountIsEstimated,
                 *      string dataType,
                 *      string valueType,
                 *      string generalCategory
                 *     )
                 */
                seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord(
                    variable,
                    variable.sampleMedium.ToString(),
                    beginDateTime,
                    endDateTime,
                    valueCount,
                    valueCountIsEstimated,
                    null,
                    null,
                    null,
                    false, // real time
                    null,  // string if real time
                    row.QualityControlLevelCode,
                    QualityControlLevelid,
                    row.MethodDescription,
                    MethodID, row.Organization,
                    row.SourceDescription,
                    SourceID,
                    row.Citation,
                    true, // include UTC Time
                    qualityControlLevelTerm
                    );

                return(record);
            }
        public static seriesCatalogTypeSeries row2SeriesCatalogElement(
            seriesCatalogDataSet.SeriesCatalogRow row,
            seriesCatalogDataSet ds, VariablesDataset vds)
        {
            int variableID = row.VariableID;
            VariableInfoType       variable      = ODvariables.GetVariableByID(variableID, vds);
            Nullable <W3CDateTime> beginDateTime = null;

            if (!row.IsBeginDateTimeNull())
            {
                beginDateTime = new W3CDateTime(row.BeginDateTime);
            }

            Nullable <W3CDateTime> endDateTime = null;

            if (!row.IsEndDateTimeNull())
            {
                endDateTime = new W3CDateTime(row.EndDateTime);
            }

            Nullable <int> valueCount = null;

            if (!row.IsValueCountNull())
            {
                valueCount = row.ValueCount;
            }

            int?QualityControlLevelid = null;

            if (!row.IsQualityControlLevelIDNull())
            {
                QualityControlLevelid = row.QualityControlLevelID;
            }

            int?MethodID = null;

            if (!row.IsMethodIDNull())
            {
                MethodID = row.MethodID;
            }

            int?SourceID = null;

            if (!row.IsSourceIDNull())
            {
                SourceID = row.SourceID;
            }


            Nullable <Boolean> valueCountIsEstimated = false;

            seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord(
                variable,
                variable.sampleMedium.ToString(),
                beginDateTime,
                endDateTime,
                valueCount,
                valueCountIsEstimated,
                null,
                null,
                null,
                false, // real time
                null,  // string if real time
                null,
                QualityControlLevelid,
                row.MethodDescription, MethodID,
                row.Organization, row.SourceDescription,
                SourceID,
                row.Citation);

            return(record);
        }