Exemple #1
0
            public static seriesCatalogTypeSeries CreateSeriesRecord(VariableInfoType variable, string sampleMedium, W3CDateTime?beginDateTime, W3CDateTime?endDateTime, int?valueCount, bool?valueCountIsEstimated, string dataType, string valueType, string generalCategory, bool realTime, string realTimeInterval, string QualityControlLevelTerm, int?qualityControlLevelid, string methodName, int?methodID, string organization, string sourceDescription, int?sourceID)
            {
                /* don't forget to check the VariableInfoType for the
                 * dataType,ValueType and General Category
                 *
                 */
                /*
                 * logic
                 * create seriesCatalogTypeSeries
                 * if variable != null use it. if null, make an empty variable
                 * if variable != null
                 *    and sampleMedium,dataType,valueType or generalCategory is null
                 *    try to get value from variable
                 * add datTime interface logic
                 *
                 */
                seriesCatalogTypeSeries series = new seriesCatalogTypeSeries();

                series.variable = variable != null ? variable : CreateVariableDescriptionType();
                if (valueCount.HasValue)
                {
                    series.valueCount       = new seriesCatalogTypeSeriesValueCount();
                    series.valueCount.Value = valueCount.Value;
                }



                // if begin time and end time are the same use single

                if (beginDateTime.HasValue)
                {
                    TimeIntervalType tm = new TimeIntervalType();

                    tm.beginDateTime = beginDateTime.Value.DateTime;

                    if (endDateTime.HasValue)
                    {
                        tm.endDateTime = endDateTime.Value.DateTime;
                    }
                    else
                    {
                        tm.endDateTime = tm.beginDateTime;
                    }
                    series.variableTimeInterval = tm;
                }


                if (realTime)
                {
                    TimePeriodRealTimeType rt = new TimePeriodRealTimeType();
                    rt.realTimeDataPeriod       = realTimeInterval; // 31 day Period
                    rt.beginDateTime            = DateTime.Today.AddDays(-31);
                    rt.endDateTime              = DateTime.Today;
                    series.variableTimeInterval = rt;
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (qualityControlLevelid.HasValue || !String.IsNullOrEmpty(QualityControlLevelTerm))
                {
                    series.QualityControlLevel = new QualityControlLevelType();
                    // need to have a dataset with an enum so we can
                    // SetEnumFromText(qsds,row,series.QualityControlLevel, typeof(QualityControlLevelEnum));
                    if (qualityControlLevelid.HasValue)
                    {
                        series.QualityControlLevel.qualityControlLevelID          = qualityControlLevelid.Value;
                        series.QualityControlLevel.qualityControlLevelIDSpecified = true;
                    }
                    if (!String.IsNullOrEmpty(QualityControlLevelTerm))
                    {
                        series.QualityControlLevel.Value = QualityControlLevelTerm;

                        // originally defined as an enum, but enums cannot be empty, and we have an id
                        // QualityControlLevelTerm = QualityControlLevelTerm.Replace(" ", "");
                        // if (Enum.IsDefined(typeof(QualityControlLevelEnum), QualityControlLevelTerm))
                        // {
                        //     object aEnum = Enum.Parse(typeof(QualityControlLevelEnum), QualityControlLevelTerm);
                        //     series.QualityControlLevel.Value = (QualityControlLevelEnum)aEnum;
                        // }
                    }
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (!String.IsNullOrEmpty(methodName) || methodID.HasValue)
                {
                    MethodType method = new MethodType();
                    if (!String.IsNullOrEmpty(methodName))
                    {
                        method.MethodDescription = methodName;
                    }
                    if (methodID.HasValue)
                    {
                        method.methodID = methodID.Value;
                    }
                    series.Method = method;
                }
                if (!String.IsNullOrEmpty(sourceDescription) ||
                    !String.IsNullOrEmpty(organization) ||
                    sourceID.HasValue)
                {
                    SourceType source = new SourceType();
                    if (!String.IsNullOrEmpty(sourceDescription) ||
                        !String.IsNullOrEmpty(organization))
                    {
                        source.SourceDescription = sourceDescription;
                        source.Organization      = organization;
                    }
                    if (sourceID.HasValue)
                    {
                        source.sourceID = sourceID.Value;
                    }
                    series.Source = source;
                }

                return(series);
            }
Exemple #2
0
            public static seriesCatalogTypeSeries CreateSeriesRecord(string VariableCode, string VariableName, string VariableUnitName, string VariableUnitAbrreviation, string VariableUnitCode, string sampleMedium, string dataType, string valueType, string generalCategory, W3CDateTime?beginDateTime, W3CDateTime?endDateTime, int?valueCount, bool?valueCountIsEstimated, int?TimeInterval, string TimeIntervalUnits, bool isRealTime, string QualityControlLevelTerm, string methodName, string organization, string sourceDescription, string VariableVocabulary)
            {
                /* don't forget to check the VariableInfoType for the
                 * dataType,ValueType and General Category
                 *
                 */
                /*
                 * logic
                 * create seriesCatalogTypeSeries
                 * if variable != null use it. if null, make an empty variable
                 * if variable != null
                 *    and sampleMedium,dataType,valueType or generalCategory is null
                 *    try to get value from variable
                 * add datTime interface logic
                 *
                 */
                seriesCatalogTypeSeries series = new seriesCatalogTypeSeries();


                //series.variable = variable != null ? variable : CreateVariableDescriptionType();
                //VariableInfoType vdt = new VariableInfoType();
                //variableCode[] var = new variableCode[1];
                //var[0] = new variableCode();
                //vdt.variableCode = var;
                //vdt.units = new units();
                //return vdt;

                // create a VariablesRow, fill it. pass it to row2Variable()
                CoreTables.VariablesDataTable vDs = new CoreTables.VariablesDataTable();
                CoreTables.VariablesRow       row = vDs.NewVariablesRow();
                row.VariableCode              = VariableCode;
                row.VariableName              = VariableName;
                row.VariableUnitsName         = VariableUnitName;
                row.VariableUnitsAbbreviation = VariableUnitAbrreviation;
                row.ValueType          = valueType;
                row.DataType           = dataType;
                row.SampleMedium       = sampleMedium;
                row.GeneralCategory    = generalCategory;
                row.VariableVocabulary = VariableVocabulary;
                vDs.Rows.Add(row);
                vDs.AcceptChanges();

                series.variable = CreateVariableRecord(row);

                if (valueCount.HasValue)
                {
                    series.valueCount       = new seriesCatalogTypeSeriesValueCount();
                    series.valueCount.Value = valueCount.Value;
                }



                //set the time interval

                if (isRealTime)
                {
                    TimePeriodRealTimeType rt = new TimePeriodRealTimeType();
                    rt.realTimeDataPeriod       = TimeInterval.ToString(); // 31 day Period
                    rt.beginDateTime            = DateTime.Today.AddDays(-31);
                    rt.endDateTime              = DateTime.Today;
                    series.variableTimeInterval = rt;
                }
                else
                {
                    if (beginDateTime.HasValue)
                    {
                        TimeIntervalType tm = new TimeIntervalType();

                        tm.beginDateTime = beginDateTime.Value.DateTime;

                        if (endDateTime.HasValue)
                        {
                            tm.endDateTime = endDateTime.Value.DateTime;
                        }
                        else
                        {
                            tm.endDateTime = tm.beginDateTime;
                        }
                        series.variableTimeInterval = tm;
                    }
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (!String.IsNullOrEmpty(QualityControlLevelTerm))
                {
                    series.qualityControlLevel = new QualityControlLevelType();
                    // need to have a dataset with an enum so we can
                    // SetEnumFromText(qsds,row,series.QualityControlLevel, typeof(QualityControlLevelEnum));


                    if (!String.IsNullOrEmpty(QualityControlLevelTerm))
                    {
                        series.qualityControlLevel.definition = QualityControlLevelTerm;

                        // originally defined as an enum, but enums cannot be empty, and we have an id
                        // QualityControlLevelTerm = QualityControlLevelTerm.Replace(" ", "");
                        // if (Enum.IsDefined(typeof(QualityControlLevelEnum), QualityControlLevelTerm))
                        // {
                        //     object aEnum = Enum.Parse(typeof(QualityControlLevelEnum), QualityControlLevelTerm);
                        //     series.QualityControlLevel.Value = (QualityControlLevelEnum)aEnum;
                        // }
                    }
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (!String.IsNullOrEmpty(methodName))
                {
                    MethodType method = new MethodType();
                    if (!String.IsNullOrEmpty(methodName))
                    {
                        method.methodDescription = methodName;
                    }

                    series.method = method;
                }
                if (!String.IsNullOrEmpty(sourceDescription) ||
                    !String.IsNullOrEmpty(organization))
                {
                    SourceType source = new SourceType();
                    if (!String.IsNullOrEmpty(sourceDescription) ||
                        !String.IsNullOrEmpty(organization))
                    {
                        source.sourceDescription = sourceDescription;
                        source.organization      = organization;
                    }

                    series.source = source;
                }

                return(series);
            }
            public static seriesCatalogTypeSeries CreateSeriesRecord(VariableInfoType variable, string sampleMedium, W3CDateTime? beginDateTime, W3CDateTime? endDateTime, int? valueCount, bool? valueCountIsEstimated, string dataType, string valueType, string generalCategory, bool realTime, string realTimeInterval, string QualityControlLevelTerm, int? qualityControlLevelid, string methodName, int? methodID, string organization, string sourceDescription, int? sourceID, string citation)
            {
                /* don't forget to check the VariableInfoType for the
                 * dataType,ValueType and General Category
                 *
                 */
                /*
                 * logic
                 * create seriesCatalogTypeSeries
                 * if variable != null use it. if null, make an empty variable
                 * if variable != null
                 *    and sampleMedium,dataType,valueType or generalCategory is null
                 *    try to get value from variable
                 * add datTime interface logic
                 *
                 */
                seriesCatalogTypeSeries series = new seriesCatalogTypeSeries();
                series.variable = variable != null ? variable : CreateVariableDescriptionType();
                if (valueCount.HasValue)
                {
                series.valueCount = new seriesCatalogTypeSeriesValueCount();
                series.valueCount.Value = valueCount.Value;
                }

                // if begin time and end time are the same use single

                if (beginDateTime.HasValue)
                {
                TimeIntervalType tm = new TimeIntervalType();

                   // tm.beginDateTime = new DateTimeOffset(beginDateTime.Value.DateTime);
                tm.beginDateTime = beginDateTime.Value.DateTime;

                if (endDateTime.HasValue)
                {
                  //  tm.endDateTime = new DateTimeOffset(endDateTime.Value.DateTime);
                    tm.endDateTime = endDateTime.Value.DateTime;
                }
                else
                {
                    tm.endDateTime = tm.beginDateTime;
                }
                series.variableTimeInterval = tm;
                }

                if (realTime)
                {
                TimePeriodRealTimeType rt = new TimePeriodRealTimeType();
                rt.realTimeDataPeriod = realTimeInterval; // 31 day Period
                //rt.beginDateTime = new DateTimeOffset(DateTime.Today.AddDays(-31));
                //rt.endDateTime = new DateTimeOffset(DateTime.Today);
                rt.beginDateTime = DateTime.Today.AddDays(-31);
                rt.endDateTime = DateTime.Today;
                series.variableTimeInterval = rt;
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (qualityControlLevelid.HasValue || !String.IsNullOrEmpty(QualityControlLevelTerm))
                {
                series.QualityControlLevel = new QualityControlLevelType();
                // need to have a dataset with an enum so we can
                // SetEnumFromText(qsds,row,series.QualityControlLevel, typeof(QualityControlLevelEnum));
                if (qualityControlLevelid.HasValue)
                {
                    series.QualityControlLevel.qualityControlLevelID = qualityControlLevelid.Value;
                    series.QualityControlLevel.qualityControlLevelIDSpecified = true;
                }
                if (!String.IsNullOrEmpty(QualityControlLevelTerm))
                {
                    series.QualityControlLevel.Value = QualityControlLevelTerm;

                  // originally defined as an enum, but enums cannot be empty, and we have an id
                    // QualityControlLevelTerm = QualityControlLevelTerm.Replace(" ", "");
                   // if (Enum.IsDefined(typeof(QualityControlLevelEnum), QualityControlLevelTerm))
                   // {
                   //     object aEnum = Enum.Parse(typeof(QualityControlLevelEnum), QualityControlLevelTerm);
                   //     series.QualityControlLevel.Value = (QualityControlLevelEnum)aEnum;
                   // }

                }
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (!String.IsNullOrEmpty(methodName) || methodID.HasValue)
                {
                MethodType method = new MethodType();
                if ( !String.IsNullOrEmpty(methodName)  )
                { method.MethodDescription = methodName;
                }
                if (methodID.HasValue) {
                    method.methodID = methodID.Value;
                    method.methodIDSpecified = true;

                }
                series.Method = method;
                }
                if (!String.IsNullOrEmpty(sourceDescription) ||
                !String.IsNullOrEmpty(organization) ||
                sourceID.HasValue)
                {
                SourceType source = new SourceType();
                if (!String.IsNullOrEmpty(sourceDescription) ||
                !String.IsNullOrEmpty(organization) )
                {
                    source.SourceDescription = sourceDescription;
                source.Organization = organization;

                }
                if (sourceID.HasValue)
                {
                    source.sourceID = sourceID.Value;
                    source.sourceIDSpecified = true;
                }
                series.Source = source;
                }

                return series;
            }
Exemple #4
0
            public static seriesCatalogTypeSeries CreateSeriesRecord(DataRow row)
            {
                seriesCatalogTypeSeries series = new seriesCatalogTypeSeries();

                CoreTables.SeriesCatalogDataTable scDt = new CoreTables.SeriesCatalogDataTable();
                scDt.ImportRow(row);

                CoreTables.SeriesCatalogRow scRow = (CoreTables.SeriesCatalogRow)scDt.Rows[0];
                //series.variable = variable != null ? variable : CreateVariableDescriptionType();
                //VariableInfoType vdt = new VariableInfoType();
                //variableCode[] var = new variableCode[1];
                //var[0] = new variableCode();
                //vdt.variableCode = var;
                //vdt.units = new units();
                //return vdt;

                // create a VariablesRow, fill it. pass it to row2Variable()
                CoreTables.VariablesDataTable vDt = new CoreTables.VariablesDataTable();
                vDt.ImportRow(row);

                series.variable = CreateVariableRecord(row);


                if (!scRow.IsValueCountNull())
                {
                    series.valueCount       = new seriesCatalogTypeSeriesValueCount();
                    series.valueCount.Value = scRow.ValueCount;
                }



                //set the time interval

                // if (isRealTime)
                if (!scRow.IsRealTimeStationNull() &&
                    scRow.RealTimeStation)
                {
                    TimePeriodRealTimeType rt = new TimePeriodRealTimeType();
                    int timeInterval          = 0;
                    if (!scRow.IsRealTimeAvailabilityInDaysNull())
                    {
                        rt.realTimeDataPeriod = scRow.RealTimeAvailabilityInDays.ToString(); // 31 day Period

                        rt.beginDateTime = DateTime.Today.AddDays((-1) * scRow.RealTimeAvailabilityInDays);
                    }
                    else
                    {
                        rt.realTimeDataPeriod = "31"; // 31 day Period
                        rt.beginDateTime      = DateTime.Today.AddDays(-31);
                    }

                    rt.endDateTime = DateTime.Today;
                    series.variableTimeInterval = rt;
                }
                else
                {
                    if (!scRow.IsBeginDateTimeNull())
                    {
                        TimeIntervalType tm = new TimeIntervalType();

                        tm.beginDateTime = DateTime.Parse(scRow.BeginDateTime);

                        if (!scRow.IsEndDateTimeNull())
                        {
                            tm.endDateTime = DateTime.Parse(scRow.EndDateTime);;
                        }
                        else
                        {
                            tm.endDateTime = tm.beginDateTime;
                        }
                        series.variableTimeInterval = tm;
                    }
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                // if (!String.IsNullOrEmpty(QualityControlLevelTerm))
                if (!scRow.IsQualityControlLevelIDNull() ||
                    !scRow.IsQualityControlLevelTermNull())
                {
                    series.qualityControlLevel = new QualityControlLevelType();
                    // need to have a dataset with an enum so we can
                    // SetEnumFromText(qsds,row,series.QualityControlLevel, typeof(QualityControlLevelEnum));


                    if (!scRow.IsQualityControlLevelTermNull())
                    {
                        series.qualityControlLevel.definition = scRow.QualityControlLevelTerm;

                        // originally defined as an enum, but enums cannot be empty, and we have an id
                        // QualityControlLevelTerm = QualityControlLevelTerm.Replace(" ", "");
                        // if (Enum.IsDefined(typeof(QualityControlLevelEnum), QualityControlLevelTerm))
                        // {
                        //     object aEnum = Enum.Parse(typeof(QualityControlLevelEnum), QualityControlLevelTerm);
                        //     series.QualityControlLevel.Value = (QualityControlLevelEnum)aEnum;
                        // }
                    }
                    else
                    {
                        // hard code conversion to term
                        int qcId = scRow.QualityControlLevelID;
                        switch (qcId)
                        {
                        case 0:
                            series.qualityControlLevel.definition = "Raw data";
                            break;

                        case 1:
                            series.qualityControlLevel.definition = "Quality controlled data";
                            break;

                        case 2:
                            series.qualityControlLevel.definition = "Derived products";
                            break;

                        case 3:
                            series.qualityControlLevel.definition = "Interpreted products";
                            break;

                        case 4:
                            series.qualityControlLevel.definition = "Knowledge products";
                            break;

                        case -9999:
                        default:
                            series.qualityControlLevel.definition = "Unknown";
                            break;
                        }
                    }
                }
                else
                {
                    series.qualityControlLevel            = new QualityControlLevelType();
                    series.qualityControlLevel.definition = "Unknown";
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (!scRow.IsMethodNameNull())
                {
                    MethodType method = new MethodType();
                    if (!String.IsNullOrEmpty(scRow.MethodName))
                    {
                        method.methodDescription = scRow.MethodName;
                    }

                    series.method = method;
                }

                if (!scRow.IsSourceDescriptionNull() ||
                    !scRow.IsOrganizationNull())
                {
                    SourceType source = new SourceType();
                    if (!scRow.IsSourceDescriptionNull())
                    {
                        source.sourceDescription = scRow.SourceDescription;
                    }
                    if (!scRow.IsOrganizationNull())
                    {
                        source.organization = scRow.Organization;
                    }

                    series.source = source;
                }
                return(series);
            }
            public static seriesCatalogTypeSeries CreateSeriesRecord(VariableInfoType variable, string sampleMedium, W3CDateTime?beginDateTime, W3CDateTime?endDateTime, int?valueCount, bool?valueCountIsEstimated, string dataType, string valueType, string generalCategory, bool realTime, string realTimeInterval, string qualityControlLevelCode, int?qualityControlLevelid, string methodName, int?methodID, string organization, string sourceDescription, int?sourceID, string citation, bool addUtCDateTime, string qualityControlLevelTerm)
            {
                /* don't forget to check the VariableInfoType for the
                 * dataType,ValueType and General Category
                 *
                 */
                /*
                 * logic
                 * create seriesCatalogTypeSeries
                 * if variable != null use it. if null, make an empty variable
                 * if variable != null
                 *    and sampleMedium,dataType,valueType or generalCategory is null
                 *    try to get value from variable
                 * add datTime interface logic
                 *
                 */
                seriesCatalogTypeSeries series = new seriesCatalogTypeSeries();

                series.variable = variable != null ? variable : CreateVariableDescriptionType();
                if (valueCount.HasValue)
                {
                    series.valueCount       = new seriesCatalogTypeSeriesValueCount();
                    series.valueCount.Value = valueCount.Value;
                }



                // if begin time and end time are the same use single

                if (beginDateTime.HasValue)
                {
                    TimeIntervalType tm = new TimeIntervalType();

                    //tm.beginDateTime = new DateTimeOffset(beginDateTime.Value.DateTime);
                    tm.beginDateTime = beginDateTime.Value.DateTime;
                    if (addUtCDateTime)
                    {
                        tm.beginDateTimeUTC          = beginDateTime.Value.UtcTime;
                        tm.beginDateTimeUTCSpecified = true;
                    }

                    if (endDateTime.HasValue)
                    {
                        //tm.endDateTime = new DateTimeOffset(endDateTime.Value.DateTime);
                        tm.endDateTime = endDateTime.Value.DateTime;
                        if (addUtCDateTime)
                        {
                            tm.endDateTimeUTC          = endDateTime.Value.UtcTime;
                            tm.endDateTimeUTCSpecified = true;
                        }
                    }
                    else
                    {
                        tm.endDateTime = tm.beginDateTime;
                        if (addUtCDateTime)
                        {
                            tm.endDateTimeUTC          = tm.beginDateTimeUTC;
                            tm.endDateTimeUTCSpecified = true;
                        }
                    }

                    series.variableTimeInterval = tm;
                }


                if (realTime)
                {
                    TimePeriodRealTimeType rt = new TimePeriodRealTimeType();
                    rt.realTimeDataPeriod = realTimeInterval; // 31 day Period
                    //rt.beginDateTime = new DateTimeOffset(DateTime.Today.AddDays(-31));
                    //rt.endDateTime = new DateTimeOffset(DateTime.Today);
                    rt.beginDateTime            = DateTime.Today.AddDays(-31);
                    rt.endDateTime              = DateTime.Today;
                    series.variableTimeInterval = rt;
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (qualityControlLevelid.HasValue ||
                    !String.IsNullOrEmpty(qualityControlLevelCode))
                {
                    series.qualityControlLevel = new QualityControlLevelType();
                    // need to have a dataset with an enum so we can
                    // SetEnumFromText(qsds,row,series.QualityControlLevel, typeof(QualityControlLevelEnum));
                    if (qualityControlLevelid.HasValue)
                    {
                        series.qualityControlLevel.qualityControlLevelID          = qualityControlLevelid.Value;
                        series.qualityControlLevel.qualityControlLevelIDSpecified = true;
                    }
                    if (!String.IsNullOrEmpty(qualityControlLevelCode))
                    {
                        if (!String.IsNullOrEmpty(qualityControlLevelCode))
                        {
                            series.qualityControlLevel.qualityControlLevelCode = qualityControlLevelCode;
                        }
                    }
                    if (!String.IsNullOrEmpty(qualityControlLevelTerm))
                    {
                        series.qualityControlLevel.definition = qualityControlLevelTerm;
                    }
                }

                /* TODO: fully populate
                 * These need to use ID< and fully populat from database
                 */
                if (!String.IsNullOrEmpty(methodName) || methodID.HasValue)
                {
                    MethodType method = new MethodType();
                    if (!String.IsNullOrEmpty(methodName))
                    {
                        method.methodDescription = methodName;
                    }
                    if (methodID.HasValue)
                    {
                        method.methodID          = methodID.Value;
                        method.methodIDSpecified = true;
                    }
                    series.method = method;
                }
                if (!String.IsNullOrEmpty(sourceDescription) ||
                    !String.IsNullOrEmpty(organization) ||
                    !String.IsNullOrEmpty(citation) ||
                    sourceID.HasValue)
                {
                    SourceType source = new SourceType();
                    if (!String.IsNullOrEmpty(sourceDescription) ||
                        !String.IsNullOrEmpty(organization))
                    {
                        source.sourceDescription = sourceDescription;
                        source.organization      = organization;
                        source.citation          = citation;
                    }
                    if (sourceID.HasValue)
                    {
                        source.sourceID          = sourceID.Value;
                        source.sourceIDSpecified = true;
                    }
                    series.source = source;
                }

                return(series);
            }