Ejemplo n.º 1
0
            public override VariableInfoType[] GetVariableInfoObject(VariableParam[] variables)
            {
                BaseRestClient restServiceClient = GetNewBaseClient();

                string[] parameters;

                {
                    restServiceClient.PathFormat = "Meth={0}&variable={1}";


                    Type vType = typeof(VariablesResponseType);
                    restServiceClient.ResponseType = vType;
                    parameters    = new string[5];
                    parameters[0] = "getVariableInfo";
                    if (variables == null || variables.Length == 0)
                    {
                        parameters[1] = String.Empty;
                    }
                    else
                    {
                        parameters[1] = variables[0].Code;
                    }

                    VariablesResponseType res = (VariablesResponseType)restServiceClient.GetResponseAsObject(parameters);
                    return(res.variables);
                }
            }
            public override object GetTimeSeries(locationParam location, VariableParam variable, W3CDateTime?startDate, W3CDateTime?endDate)
            {
                BaseRestClient restServiceClient;

                string[] parameters;

                {
                    restServiceClient            = new BaseRestClient();
                    restServiceClient.BaseUrl    = "http://www2.mvr.usace.army.mil/watercontrol/webservices/rest/webserviceWaterML.cfm?";
                    restServiceClient.PathFormat = "Meth={0}&site={1}&variable={2}&beginDate={3}&endDate={4}";

                    string varCode  = variable.Code; // prep for many test
                    string siteCode = location.SiteCode;


                    Type vType = typeof(TimeSeriesResponseType);
                    restServiceClient.ResponseType = vType;
                    parameters    = new string[5];
                    parameters[0] = "getValues";
                    parameters[1] = siteCode;
                    parameters[2] = varCode;
                    parameters[3] = startDate.Value.DateTime.ToString("yyyy-MM-dd");
                    parameters[4] = endDate.Value.DateTime.ToString("yyyy-MM-dd");

                    object res = restServiceClient.GetResponseAsObject(parameters);
                    return(res);
                }
            }
Ejemplo n.º 3
0
            public override SiteInfoType[] GetSiteInfoObjects(locationParam[] sites)
            {
                BaseRestClient restServiceClient = GetNewBaseClient();

                string[] parameters;
                Type     vType = typeof(SiteInfoResponseType);

                restServiceClient.ResponseType = vType;

                if (sites == null || sites.Length == 0)
                {
                    restServiceClient.PathFormat = "Meth={0}";
                    parameters    = new string[1];
                    parameters[0] = "GetSiteInfo";
                }
                else
                {
                    restServiceClient.PathFormat = "Meth={0}";
                    int len = sites.Length;
                    parameters    = new string[sites.Length + 1];
                    parameters[0] = "GetSiteInfo";
                    for (int i = 0; i < sites.Length; i++)
                    {
                        parameters[i + 1]             = sites[i].SiteCode;
                        restServiceClient.PathFormat += "&sid={" + i + 1 + "}";
                    }
                }


                object res = restServiceClient.GetResponseAsObject(parameters);


                SiteInfoResponseType response = (SiteInfoResponseType)res;

                if (response != null && response.site != null)
                {
                    List <SiteInfoType> siteInfoTypes = new List <SiteInfoType>();
                    foreach (site s in response.site)
                    {
                        siteInfoTypes.Add(s.siteInfo);
                    }
                    return(siteInfoTypes.ToArray());
                }
                else
                {
                    throw new WaterOneFlowSourceException("No Sites Returned");
                }
            }
Ejemplo n.º 4
0
        public void testVariables()
        {
            restServiceClient.PathFormat = "Meth={0}&variable={1}";

            string varCode = "HG"; // prep for many test

            Type vType = typeof(VariablesResponseType);

            restServiceClient.ResponseType = vType;
            parameters    = new string[2];
            parameters[0] = "getVariableInfo";
            parameters[1] = varCode;

            object res = restServiceClient.GetResponseAsObject(parameters);

            Assert.IsInstanceOfType(vType, res);
            VariablesResponseType variablesResponse = (VariablesResponseType)res;

            Assert.That(variablesResponse.variables.Length == 1, "Should only return 1 variable");
            Assert.That(variablesResponse.variables[0].variableCode[0].Value.Equals(varCode));
        }
Ejemplo n.º 5
0
            public override seriesCatalogType[] GetSeries(locationParam site, TimeSeriesTypeEnum seriesType)
            {
                BaseRestClient restServiceClient = GetNewBaseClient();

                string[] parameters;
                Type     vType = typeof(SiteInfoResponseType);

                restServiceClient.ResponseType = vType;

                if (site != null)
                {
                    restServiceClient.PathFormat = "Meth={0}&site={1}";
                    parameters    = new string[2];
                    parameters[0] = "GetSiteInfo";
                    parameters[1] = site.SiteCode;
                }
                else
                {
                    return(null);
                }

                object res = restServiceClient.GetResponseAsObject(parameters);


                SiteInfoResponseType response = (SiteInfoResponseType)res;

                if (response != null && response.site != null)
                {
                    WaterOneFlow.Schema.v1.site s = response.site[0];
                    if (s.seriesCatalog != null)
                    {
                        return(s.seriesCatalog);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    throw new WaterOneFlowSourceException("No Site Returned");
                }
            }