public GetVariablesOD()
 {
     //
     // TODO: Add constructor logic here
     //
     Variables = ODvariables.GetVariableDataSet();
 }
Esempio n. 2
0
 public GetValuesOD()
 {
     //
     // TODO: Add constructor logic here
     //
     variableDs         = ODvariables.GetVariableDataSet();
     unitsDs            = ODUnits.getUnitsDataset();
     oDconnectionString = ConfigurationManager.ConnectionStrings["ODDB"];
 }
        public VariablesResponseType GetVariableInfo(string Variable)
        {
            VariableInfoType[] variableList;
            if (String.IsNullOrEmpty(Variable))
            {
                variableList = ODvariables.getVariables(new VariableParam[0], Variables);
            }
            else
            {
                VariableParam vp;
                vp           = new VariableParam(Variable);
                variableList = ODvariables.getVariable(vp, Variables);
            }

            if (variableList == null)
            {
                throw new WaterOneFlowException("Variable Not Found");
            }
            VariablesResponseType Response = new VariablesResponseType();

            Response.variables = variableList;

            if (Response.queryInfo == null)
            {
                Response.queryInfo          = new QueryInfoType();
                Response.queryInfo.criteria = new QueryInfoTypeCriteria();
            }
            Response.queryInfo.creationTime          = DateTime.UtcNow;
            Response.queryInfo.creationTimeSpecified = true;
            if (String.IsNullOrEmpty(Variable))
            {
                Response.queryInfo.criteria.variableParam = "NULL (Request for all variables";
            }
            else
            {
                Response.queryInfo.criteria.variableParam = Variable;
            }

            NoteType sourceNote = CuahsiBuilder.createNote("OD Web Service");

            Response.queryInfo.note = CuahsiBuilder.addNote(Response.queryInfo.note,
                                                            sourceNote);
            return(Response);
        }
        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);
        }
Esempio n. 5
0
        public TimeSeriesResponseType getValues(string SiteNumber, string Variable, string StartDate, string EndDate)
        {
            // convert dates
            // get site info
            // get site ID
            // return value dataset

            TimeSeriesResponseType response;
            W3CDateTime?           BeginDateTime;
            W3CDateTime?           EndDateTime;
            int?variableId = null;
            int?siteID;

            VariableInfoType varInfoType = null;
            SiteInfoType     siteType    = null;

            if (!String.IsNullOrEmpty(StartDate))
            {
                try
                {
                    BeginDateTime = W3CDateTime.Parse(StartDate);
                }
                catch
                {
                    throw new WaterOneFlowException("Improper BeginDate '" +
                                                    StartDate + "' Must be YYYY-MM-DD");
                }
            }
            else
            {
                BeginDateTime = null;
            }

            if (!String.IsNullOrEmpty(EndDate))
            {
                try
                {
                    EndDateTime = W3CDateTime.Parse(EndDate);
                }
                catch
                {
                    throw new WaterOneFlowException("Improper EndDate '" +
                                                    EndDate + "' Must be YYYY-MM-DD");
                }
            }
            else
            {
                EndDateTime = null;
            }
            VariableParam vp;

            if (Variable != null)
            {
                vp = new VariableParam(Variable);
                VariableInfoType[] v = ODvariables.getVariable(vp, variableDs);
                if (v != null && v.Length > 0)
                {
                    variableId  = Convert.ToInt16(v[0].variableCode[0].variableID);
                    varInfoType = v[0];
                }
                else
                {
                    throw new WaterOneFlowException("Variable parameter not found: " + Variable);
                }
            }
            else
            {
                throw new WaterOneFlowException("Variable parameter is required ");
            }
            locationParam sq;

            sq = new locationParam(SiteNumber);

            if (sq.isGeometry)
            {
                throw new WaterOneFlowException("Location by Geometry not accepted: " + SiteNumber);
            }

            siteInfoDataSet sitDs = ODSiteInfo.GetSiteInfoDataSet(sq);

            if (sitDs != null && sitDs.sites.Count > 0)
            {
                siteID = sitDs.sites[0].SiteID;
                ValuesDataSet valuesDs = getValuesDataset(siteID, variableId, BeginDateTime, EndDateTime, vp);

                response = getValues(valuesDs, vp);

                // above is the values, add the site, and variables
                response.timeSeries.variable = varInfoType;

                if (varInfoType != null)
                {
                    if (varInfoType.units != null)
                    {
                        response.timeSeries.values.unitsAbbreviation = varInfoType.units.unitsAbbreviation;
                        response.timeSeries.values.unitsCode         = varInfoType.units.unitsCode;

                        if (varInfoType.units.unitsType != null)
                        {
                            response.timeSeries.values.unitsType          = varInfoType.units.unitsType;
                            response.timeSeries.values.unitsTypeSpecified = true;
                        }
                        response.timeSeries.values.unitsAreConverted = false;
                    }
                }

                response.timeSeries.sourceInfo = ODSiteInfo.row2SiteInfoElement(sitDs.sites[0], sitDs);
            }
            else
            {
                response = CuahsiBuilder.CreateTimeSeriesObject();
            }
            // add query info
            response.queryInfo.creationTime = DateTime.UtcNow;
            //response.queryInfo.creationTime = DateTimeOffset.UtcNow;
            response.queryInfo.creationTimeSpecified  = true;
            response.queryInfo.criteria.locationParam = SiteNumber;
            response.queryInfo.criteria.variableParam = Variable;
            response.queryInfo.criteria.timeParam     = CuahsiBuilder.createQueryInfoTimeCriteria(StartDate, EndDate);
            NoteType sourceNote = CuahsiBuilder.createNote("OD Web Service");

            response.queryInfo.note = CuahsiBuilder.addNote(response.queryInfo.note,
                                                            sourceNote);


            return(response);
        }
 public GetSiteInfoOD()
 {
     variablesDs = ODvariables.GetVariableDataSet();
 }