Esempio n. 1
0
            public SiteInfoResponseType GetSitesInBox(
                float west, float south, float east, float north,
                Boolean IncludeSeries
                )
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                box queryBox = new box(west, south, east, north);

                queryLog2.LogStart(CustomLogging.Methods.GetSitesInBoxObject, queryBox.ToString(),
                                   appContext.Request.UserHostName);

                SiteInfoResponseType resp = new SiteInfoResponseType();

                resp.site = WebServiceUtils.GetSitesByBox(queryBox, IncludeSeries);

                //set query info
                resp.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSitesInBox");
                NoteType note = CuahsiBuilder.createNote("box");

                resp.queryInfo.note = CuahsiBuilder.addNote(null, note);

                queryLog2.LogEnd(CustomLogging.Methods.GetSitesInBoxObject,
                                 queryBox.ToString(),
                                 timer.ElapsedMilliseconds.ToString(),
                                 resp.site.Length.ToString(),
                                 appContext.Request.UserHostName);
                return(resp);
            }
Esempio n. 2
0
            public SiteInfoResponseType GetSites(string[] locationParameters, Boolean includeSeries)
            {
                locationParameters = WSUtils.removeEmptyStrings(locationParameters);

                List <locationParam> siteCodes = new List <locationParam>(locationParameters.Length);

                foreach (String s in locationParameters)
                {
                    locationParam lp = new locationParam(s);
                    siteCodes.Add(lp);
                }
                SiteInfoType[]       sites  = ODSiteInfo.GetSitesByLocationParameters(siteCodes.ToArray());
                SiteInfoResponseType result = CreateSitesResponse(sites, includeSeries);

                if (locationParameters.Length == 0)
                {
                    result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites");
                    NoteType note = CuahsiBuilder.createNote("ALL Sites(empty request)");
                    result.queryInfo.note = CuahsiBuilder.addNote(null, note);
                }
                else
                {
                    result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites", locationParameters, null, null, null, null);
                }
                return(result);
            }
Esempio n. 3
0
            public SiteInfoResponseType GetSites(string[] locationIDs)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogStart(CustomLogging.Methods.GetSites, locationIDs.ToString(),
                                   appContext.Request.UserHostName);

                SiteInfoResponseType result = new SiteInfoResponseType();

                result.site = WebServiceUtils.GetSitesFromDb();

                //set query info
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites");
                NoteType note = CuahsiBuilder.createNote("ALL Sites(empty request)");

                result.queryInfo.note = CuahsiBuilder.addNote(null, note);

                queryLog2.LogEnd(CustomLogging.Methods.GetSites,
                                 locationIDs.ToString(),
                                 timer.ElapsedMilliseconds.ToString(),
                                 result.site.Length.ToString(),
                                 appContext.Request.UserHostName);

                return(result);
            }
Esempio n. 4
0
            private static void AddQueryInfo(string StartDate, string EndDate, string Variable, string SiteNumber, TimeSeriesResponseType response)
            {
                response.queryInfo          = new QueryInfoType();
                response.queryInfo.criteria = new QueryInfoTypeCriteria();

                response.queryInfo.creationTime           = DateTime.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);
            }
Esempio n. 5
0
            public TimeSeriesResponseType GetValuesForSiteVariable(string SiteNumber, string StartDate, string EndDate)
            {
                TimeSeriesResponseType response = new TimeSeriesResponseType();

                response.timeSeries = new List <TimeSeriesType>(
                    GetTimesSeriesTypeForSiteVariable(SiteNumber, StartDate, EndDate)).ToArray();


                response.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetValuesForASite", new string[] { SiteNumber },
                                                                       null, null, StartDate, EndDate);
                CuahsiBuilder.addNote(response.queryInfo.note,
                                      CuahsiBuilder.createNote("AllValuesForASite"));

                return(response);
            }
        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 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;

                Response.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetVariableInfo", null, null,
                                                                       new string[] { Variable }, null, null);

                if (String.IsNullOrEmpty(Variable))
                {
                    CuahsiBuilder.addNote(Response.queryInfo.note,
                                          CuahsiBuilder.createNote("(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);
            }
Esempio n. 8
0
            /// <summary>
            /// GetVariableInfo
            /// </summary>
            /// <param name="VariableParameter">full variable code in format vocabulary:VariableCode</param>
            /// <returns>the VariableInfo object</returns>
            public VariablesResponseType GetVariableInfo(String VariableParameter)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();


                queryLog2.LogStart(CustomLogging.Methods.GetVariables, VariableParameter,
                                   appContext.Request.UserHostName);

                VariablesResponseType resp;

                if (string.IsNullOrEmpty(VariableParameter))
                {
                    resp           = new VariablesResponseType();
                    resp.variables = WebServiceUtils.GetVariablesFromDb();

                    //setup query info
                    resp.queryInfo = CuahsiBuilder.CreateQueryInfoType
                                         ("GetVariableInfo", null, null, new string[] { string.Empty }, null, null);
                    CuahsiBuilder.addNote(resp.queryInfo.note,
                                          CuahsiBuilder.createNote("(Request for all variables"));
                }
                else
                {
                    resp              = new VariablesResponseType();
                    resp.variables    = new VariableInfoType[1];
                    resp.variables[0] = WebServiceUtils.GetVariableInfoFromDb(VariableParameter);
                    //setup query info
                    resp.queryInfo = CuahsiBuilder.CreateQueryInfoType
                                         ("GetVariableInfo", null, null, new string[] { VariableParameter }, null, null);
                }

                queryLog2.LogEnd(CustomLogging.Methods.GetVariables,
                                 VariableParameter,
                                 timer.ElapsedMilliseconds.ToString(),
                                 resp.variables.Length.ToString(),
                                 appContext.Request.UserHostName);


                return(resp);
            }
Esempio n. 9
0
        public static SiteInfoType row2SiteInfoElement(siteInfoDataSet.sitesRow row, siteInfoDataSet ds)
        {
            SiteInfoType sit = CuahsiBuilder.CreateASiteInfoTypeWithLatLongPoint();

            sit.siteName = !String.IsNullOrEmpty(row.SiteName) ? row.SiteName : null;

            // sit created with a single siteCode
            sit.siteCode[0].siteID = row.SiteID.ToString();
            sit.siteCode[0].Value  = !String.IsNullOrEmpty(row.SiteCode) ? row.SiteCode : null;
            string siteNetwork = System.Configuration.ConfigurationManager.AppSettings["network"];

            sit.siteCode[0].network = siteNetwork;

            // we have a point
            ((LatLonPointType)sit.geoLocation.geogLocation).latitude  = row.Latitude;
            ((LatLonPointType)sit.geoLocation.geogLocation).longitude = row.Longitude;
            if (row.LatLongDatumID == 0)
            {
                ((LatLonPointType)sit.geoLocation.geogLocation).srs =
                    ConfigurationManager.AppSettings["defaultSpatialReferenceSystemSRS"];
            }
            else
            {
                siteInfoDataSet.SpatialReferencesRow[] datum =
                    (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LatLongDatumID);
                if (datum.Length > 0 && !datum[0].IsSRSIDNull())
                {
                    ((LatLonPointType)sit.geoLocation.geogLocation).srs =
                        ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID;
                }
            }

            if (!row.IsElevation_mNull())
            {
                sit.elevation_m          = row.Elevation_m;
                sit.elevation_mSpecified = true;

                if (!row.IsVerticalDatumNull())
                {
                    sit.verticalDatum = row.VerticalDatum;
                }
            }


            if (!row.IsLocalXNull() && !row.IsLocalYNull() && !row.IsLocalProjectionIDNull())
            {
                sit.geoLocation.localSiteXY = new SiteInfoTypeGeoLocationLocalSiteXY[1];
                SiteInfoTypeGeoLocationLocalSiteXY xy = new SiteInfoTypeGeoLocationLocalSiteXY();
                xy.X = row.LocalX;
                xy.Y = row.LocalY;
                //@TODO local XY
                siteInfoDataSet.SpatialReferencesRow[] datum =
                    (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LocalProjectionID);
                if (datum.Length > 0)
                {
                    if (!String.IsNullOrEmpty(datum[0].SRSName))
                    {
                        xy.projectionInformation = datum[0].SRSName;
                    }
                    else
                    {
                        xy.projectionInformation = ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID;
                    }
                }

                sit.geoLocation.localSiteXY[0] = xy;
            }
            if (!row.IsCountyNull())
            {
                NoteType aNote =
                    CuahsiBuilder.createNote(row.County, "County", null);
                sit.note = CuahsiBuilder.addNote(sit.note, aNote);
            }
            if (!row.IsStateNull())
            {
                NoteType aNote =
                    CuahsiBuilder.createNote(row.State, "State", null);
                sit.note = CuahsiBuilder.addNote(sit.note, aNote);
            }
            if (!row.IsCommentsNull())
            {
                NoteType aNote =
                    CuahsiBuilder.createNote(row.Comments, "Site Comments", null);
                sit.note = CuahsiBuilder.addNote(sit.note, aNote);
            }
            return(sit);
        }
Esempio n. 10
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);
        }