Ejemplo n.º 1
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);
            }
Ejemplo n.º 2
0
        public void GetValuesTest()
        {
            GetValuesDailyUSGS target = new GetValuesDailyUSGS();

            NwisWOFTest.NwisWOFService_GetValuesUSGSAccessor accessor = new NwisWOFTest.NwisWOFService_GetValuesUSGSAccessor(target);

            locationParam Location = new locationParam("NWIS:10263500");


            VariableParam Variable = new VariableParam("NWIS:00060");

            System.Nullable <WaterOneFlowImpl.W3CDateTime> BeginDateTime
                = new W3CDateTime(DateTime.Parse("2005-08-01"));


            System.Nullable <WaterOneFlowImpl.W3CDateTime> EndDateTime =
                new W3CDateTime(DateTime.Parse("2006-08-01"));


            //TimeSeriesResponseType expected = null;
            TimeSeriesResponseType actual;

            actual = accessor.GetValues(Location, Variable, BeginDateTime, EndDateTime);

            Assert.IsNotNull(actual, "NwisWOFService.GetValuesUSGS.GetValues returned null.");

            // (expected, actual, "NwisWOFService.GetValuesUSGS.GetValues did not return the expected value.");
            // Assert.Inconclusive("Verify the correctness of this test method.");
        }
            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.º 4
0
            private SiteInfoResponseType createSiteInfoResponse(locationParam[] LocationParameters, Boolean IncludeSeries)
            {
                // WSUtils.removeEmptyStrings(LocationParameters);
                /* for each site code, add a siteInfo type with a period of record
                // for each site
                 *     createSitInfoType
                 *     add to response
                 *     createPeriodOfRecord
                 *     add to response
                 * return response
                 * */
                SiteInfoResponseType response = CuahsiBuilder.CreateASetOfSiteResponses(LocationParameters.Length, 1);
                List<locationParam> lpList = new List<locationParam>(LocationParameters);

                foreach (locationParam lp in lpList)
                {
                    if (lp == null) lpList.Remove(lp);
                }
                List<SiteInfoResponseTypeSite> sitesList = new List<SiteInfoResponseTypeSite>(lpList.Count);

                foreach (SiteInfoType sit in getSiteInfoType(lpList))
                {
                    SiteInfoResponseTypeSite site = CreateSite(sit, IncludeSeries);
                    if (site != null) sitesList.Add(site);
                }

                response.site = sitesList.ToArray();

                return response;
            }
Ejemplo n.º 5
0
            private string locationToUvRest(locationParam vp)
            {
                // code already has an agency. pass it through
                if (vp.SiteCode.Contains(":"))
                {
                    return(vp.SiteCode);
                }

                /*  he site number may be optionally prefixed by the agency code followed by a colon, which ensures the site is unique. Examples: ?site=06306300 or ?sites=USGS:06306300. There is no default if this parameter is used. For real-time streamflow sites, the site number is normally 8 characters. Site numbers range from 8 to 15 character.
                 */

                string usgsAgencyCode = agencyCodeDefault;

                if (vp.options.ContainsKey("agency"))
                {
                    usgsAgencyCode = vp.options["agency"];
                }
                if (usgsAgencyCode.Equals("USGS", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(vp.SiteCode);
                }
                else
                {
                    return(string.Format("{0}:{1}", usgsAgencyCode, vp.SiteCode));
                }
            }
Ejemplo n.º 6
0
            private static SiteInfoType getSiteInfoType(locationParam LocationParameter)
            {
                SiteInfoType sit;

                //   look in memory
                //           sit = (SiteInfoType)appCache[sitCache + siteCode];
                //         if (sit != null) return sit;

                //ok, try the database
                SiteInfoType[] sites = ODSiteInfo.GetSitesByLocationParameters(new locationParam[] { LocationParameter });
                if (sites == null || sites.Length == 0)
                {
                    return(null);
                }
                else

                if (sites != null && sites.Length == 1)
                {
                    return(sites[0]);
                }
                else
                {
                    // had better be only one
                    String error = "More than one site with SiteCode '" + LocationParameter + "'";
                    log.Error(error);
                    throw new WaterOneFlowException(error);
                }



                return(sit);
            }
        // create period of record
        private seriesCatalogType[] CreateSeriesCatalogRecord(locationParam LocationParameter, int?siteID)
        {
            // need the siteID for the DB sites, and the siteCode for retrival from the service

            if (siteID.HasValue)
            {
                seriesCatalogDataSet seriesDataset = ODSeriesCatalog.GetSeriesCatalogDataSet(siteID.Value);
                if (seriesDataset != null && seriesDataset.SeriesCatalog.Rows.Count > 0)
                {
                    if (seriesDataset.SeriesCatalog.Rows.Count > 0)
                    {
                        seriesCatalogType[] seriesFromDB =
                            ODSeriesCatalog.dataSet2SeriesCatalog(seriesDataset, variablesDs);
                        if (seriesFromDB != null && seriesFromDB.Length > 0)
                        {
                            return(seriesFromDB);
                        }
                    }
                }
            }

            // send back empty catalog
            List <seriesCatalogType> seriesList = new List <seriesCatalogType>();

            seriesList.Add(new seriesCatalogType());
            return(seriesList.ToArray());
        }
Ejemplo n.º 8
0
            public SiteInfoResponseType GetSiteInfoResponse(locationParam[] LocationParameters, Boolean IncludeSeries)
            {
                SiteInfoResponseType result = createSiteInfoResponse(LocationParameters, IncludeSeries);
                string[] lps = Array.ConvertAll<locationParam, string>(LocationParameters, Convert.ToString);
                //result.queryInfo = CreateQueryInfo(lps);
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", lps, null, null, null, null);

                return result;
            }
Ejemplo n.º 9
0
            public override object GetTimeSeries(
                locationParam lp,
                VariableParam vp,
                Nullable <W3CDateTime> startDate,
                Nullable <W3CDateTime> endDate)
            {
                if (lp.isGeometry)
                {
                    throw new WaterOneFlowException("Geometry not supported ");
                }

                TimeSeriesResponseType result = null;

                string[] StationsList = new string[] { lp.SiteCode };

                result = CuahsiBuilder.CreateTimeSeriesObject();

                result.queryInfo.criteria.locationParam = lp.ToString();
                result.queryInfo.criteria.variableParam = vp.ToString();

                result.timeSeries.sourceInfo = DataInfoService.GetSite(lp);

                // not fully correct, but just choose the first one.
                VariableInfoType[] vits = DataInfoService.GetVariableInfoObject(vp);
                result.timeSeries.variable = vits[0];
                string aURL = InstantaneousData(startDate, endDate,
                                                new string[] { vp.Code }, StationsList, USGSCommon.option2AgencyCode(lp));

                try
                {
                    result.timeSeries.values =
                        CreateWQTimeSeriesObject(vp, aURL);
                }
                catch (WaterOneFlowException e)
                {
                    throw;
                }
                catch (WaterOneFlowSourceException e)
                {
                    throw;
                }
                catch (Exception e)
                {
                    log.Error(e.Message + e.StackTrace);
                    throw new WaterOneFlowException("An External resource failed.", e);
                }

                List <NoteType> notes   = new List <NoteType>();
                NoteType        urlNote = new NoteType();

                urlNote.title = "USGS URL";
                urlNote.Value = aURL;
                notes.Add(urlNote);
                result.queryInfo.note = notes.ToArray();

                return(result);
            }
Ejemplo n.º 10
0
            public static string option2AgencyCode(locationParam vp)
            {
                string usgsAgencyCode = agencyCodeDefault;

                if (vp.options.ContainsKey("agency"))
                {
                    usgsAgencyCode = vp.options["agency"];
                }
                return(usgsAgencyCode);
            }
Ejemplo n.º 11
0
            private string option2AgencyCode(locationParam vp)
            {
                string AgencyCode = agencyCodeDefault;

                if (vp.options.ContainsKey("agency"))
                {
                    AgencyCode = vp.options["agency"];
                }
                return(AgencyCode);
            }
Ejemplo n.º 12
0
        public SiteInfoResponseType GetSiteInfo(string locationParameter)
        {
            Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

            queryLog2.LogStart(Logging.Methods.GetSiteInfo, locationParameter,
                               appContext.Request.UserHostName);
            locationParam lp = null;

            try
            {
                lp = new locationParam(locationParameter);
                if (lp.isGeometry)
                {
                    String error = "Location by Geometry not accepted: " + locationParameter;
                    log.Debug(error);
                    throw new WaterOneFlowException(error);
                }
            }
            catch (WaterOneFlowException we)
            {
                //waterLog.WriteEntry("Bad SiteID:" + siteId, EventLogEntryType.Information);
                log.Error(we.Message);
                throw;
            }
            catch (Exception e)
            {
                // waterLog.WriteEntry("Uncaught exception:" + e.Message, EventLogEntryType.Error);
                String error =
                    "Sorry. Your submitted site ID for this getSiteInfo request caused an problem that we failed to catch programmatically: " +
                    e.Message;
                log.Error(error);
                throw new WaterOneFlowException(error);
            }
            GetSiteInfoOD getSiteInfo = new GetSiteInfoOD();

            SiteInfoResponseType resp = getSiteInfo.GetSiteInfo(lp);

            // add service location using the app context
            // for ODM, we one only seriesCatalog
            // String serviceName = (String) appContext.Session["serviceName"];
            // String serviceUrl = (String) appContext.Session["serviceUrl"];
            if (resp.site[0].seriesCatalog.Length > 0)
            {
                resp.site[0].seriesCatalog[0].menuGroupName = serviceName;
                resp.site[0].seriesCatalog[0].serviceWsdl   = serviceUrl;
            }
            queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                             locationParameter,
                             timer.ElapsedMilliseconds.ToString(),
                             resp.site.Length.ToString(),
                             appContext.Request.UserHostName);

            return(resp);
        }
Ejemplo n.º 13
0
            private static locationParam GetLocationParameter(string SiteNumber)
            {
                locationParam sq;

                sq = new locationParam(SiteNumber);

                if (sq.isGeometry)
                {
                    throw new WaterOneFlowException("Location by Geometry not accepted: " + SiteNumber);
                }
                return(sq);
            }
Ejemplo n.º 14
0
            public override TimeSeriesResponseTypeGeneric GetValuesObject(string location, string variable, string startDate, string endDate, String authToken)
            {
                if (!useODForValues)
                {
                    throw new SoapException("GetValues implemented external to this service. Call GetSiteInfo, and SeriesCatalog includes the service Wsdl for GetValues. Attribute:serviceWsdl on Element:seriesCatalog XPath://seriesCatalog/[@serviceWsdl]", new XmlQualifiedName("ServiceException"));
                }

                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogValuesStart(Logging.Methods.GetValues, // method
                                         location,                  //location
                                         variable,                  //variable
                                         startDate,                 // startdate
                                         startDate,                 //enddate
                                         Context.Request.UserHostName);

                try
                {
                    WaterOneFlowImpl.locationParam lParam = new locationParam(location);
                    VariableParam vparam  = new VariableParam(variable);
                    W3CDateTime?  startDt = null;
                    W3CDateTime?  endDt   = null;
                    if (!String.IsNullOrEmpty(startDate))
                    {
                        startDt = new W3CDateTime(DateTime.Parse(startDate));
                    }
                    if (!String.IsNullOrEmpty(endDate))
                    {
                        endDt = new W3CDateTime(DateTime.Parse(endDate));
                    }


                    TimeSeriesResponseTypeObject res = (TimeSeriesResponseTypeObject)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt);

                    return(new xsd.TimeSeriesResponse(res));

                    //throw new NotImplementedException("Reimplement 1.1");
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                           location,                  //locaiton
                                           variable,                  //variable
                                           startDate,                 // startdate
                                           startDate,                 //enddate
                                           timer.ElapsedMilliseconds, // processing time
                                           -9999,                     // count
                                           Context.Request.UserHostName
                                           );
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 15
0
 private static string GetAgencyEpaSiteCode(locationParam lp)
 {
     if (lp.options.ContainsKey("agency"))
     {
         return(lp.options["agency"]);
     }
     else
     {
         string   code  = lp.SiteCode;
         string[] parts = code.Split(':');
         return(parts[0]);
     }
 }
Ejemplo n.º 16
0
            public IEnumerable <TimeSeriesType> GetTimesSeriesTypeForSiteVariable(string SiteNumber, string StartDate, string EndDate)
            {
                W3CDateTime?BeginDateTime;
                W3CDateTime?EndDateTime;
                int?        variableId = null;
                int?        siteID;

                VariableInfoType varInfoType = null;
                SiteInfoType     siteType    = null;

                BeginDateTime = GetBeginDateTime(StartDate);

                EndDateTime = GetEndDateTime(EndDate);

                locationParam sq = GetLocationParameter(SiteNumber);

                siteInfoDataSet sitDs = ODSiteInfo.GetSiteInfoDataSet(sq);

                if (sitDs != null && sitDs.sites.Count > 0)
                {
                    siteID = sitDs.sites[0].SiteID;
                    ValuesDataSet valuesDs      = getValuesDataset(siteID, null, BeginDateTime, EndDateTime);
                    DataTable     variableTable = DataSetHelper.SelectDistinct("variableIds", valuesDs.DataValues, "VariableID");

                    if (variableTable.Rows.Count == 0)
                    {
                        throw new WaterOneFlowException("No Data Available for Time Period.");
                    }

                    foreach (DataRow dataRow in variableTable.Rows)
                    {
                        TimeSeriesType timeSeries = new TimeSeriesType();

                        timeSeries.sourceInfo = ODSiteInfo.row2SiteInfoElement(sitDs.sites[0], sitDs);

                        int id = (int)dataRow[0];
                        VariableInfoType vit = ODvariables.GetVariableByID(id, variableDs);
                        timeSeries.variable = vit;


                        // DataView view = new DataView(valuesDs.DataValues, "VariableId = " + id, " DateTime ASC", DataViewRowState.CurrentRows);

                        timeSeries.values = getValues(valuesDs, null, id);

                        yield return(timeSeries);
                    }
                }
            }
Ejemplo n.º 17
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;

                BeginDateTime = GetBeginDateTime(StartDate);

                EndDateTime = GetEndDateTime(EndDate);

                VariableParam vp = GetVariableParameter(Variable, ref variableId, ref varInfoType);
                locationParam sq = GetLocationParameter(SiteNumber);

                siteInfoDataSet sitDs = ODSiteInfo.GetSiteInfoDataSet(sq);

                response = CuahsiBuilder.CreateTimeSeriesObjectSingleValue(1);

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

                    response.timeSeries[0].values = getValues(valuesDs, vp, variableId);

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

                    response.timeSeries[0].sourceInfo = ODSiteInfo.row2SiteInfoElement(sitDs.sites[0], sitDs);
                }

                // AddQueryInfo(StartDate, EndDate, Variable, SiteNumber, response);

                response.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetValues",
                                                                       new string[] { SiteNumber }, null, new string[] { Variable }, StartDate, EndDate);

                return(response);
            }
Ejemplo n.º 18
0
            public override object GetTimeSeries(locationParam location, VariableParam variable, W3CDateTime?startDate, W3CDateTime?endDate)
            {
                if (DataInfoService == null)
                {
                    throw new Exception("You Must set the DataInfoService");
                }

                /* get SiteID and VariableID from dataInfoService
                 * Setup Query
                 * If boths dates valid use one query
                 * Else use second
                 *
                 */
                using (sqlConn)
                {
                    throw new System.NotImplementedException();
                }
            }
Ejemplo n.º 19
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");
                }
            }
        public SiteInfoResponseType GetSites(string[] locationParameters)
        {
            XmlDocument XMLResponse = new XmlDocument();

            locationParameters = WSUtils.removeEmptyStrings(locationParameters);
            //string[] siteCodes = Array.ConvertAll(locationParameters, new Converter<string, string>(locationParam.getSiteCode));
            List <locationParam> siteCodes = new List <locationParam>(locationParameters.Length);

            foreach (String s in locationParameters)
            {
                locationParam lp = new locationParam(s);
                siteCodes.Add(lp);
            }

            SiteInfoResponseType result = CreateSitesResponse(siteCodes.ToArray());


            return(result);
        }
Ejemplo n.º 21
0
 private static string GetSiteIDEpaSiteCode(locationParam lp)
 {
     if (lp.options.ContainsKey("agency"))
     {
         string   code  = lp.SiteCode;
         string[] parts = code.Split(':');
         // assme that if there is an agency,
         // then there may be one or two parts to the EPA site code
         if (parts.Length > 1)
         {
             return(parts[1]);
         }
         else
         {
             return(parts[0]);
         }
     }
     else
     {
         // must be two parts to EPA site code agency:sitecode
         // full code is EPA:agency:sitecode
         string   code  = lp.SiteCode;
         string[] parts = code.Split(':');
         if (parts.Length == 2)
         {
             return(parts[1]);
         }
         else
         {
             if (parts.Length == 1)
             {
                 log.Error("EPA too few  site code should be agency:site" + lp.SiteCode);
                 throw  new WaterOneFlowException("EPA too few  site code should be agency:site" + lp.SiteCode);
             }
             else if (parts.Length > 2)
             {
             }
             log.Error("EPA too  many parts to site codeshould be EPA:agency:site" + lp.SiteCode);
             throw  new WaterOneFlowException("EPA too  many parts to site codeshould be EPA:agency:site" +
                                              lp.SiteCode);
         }
     }
 }
            public static siteInfoDataSet GetSiteInfoDataSet(locationParam[] LocationParameters)
            {
                siteInfoDataSet ds = CreateBaseSiteInfoDataset();

                if (LocationParameters[0].isGeometry)
                {
                    if (LocationParameters[0].Geometry.GetType().Equals(typeof(box)))
                    {
                        box queryBox = (box)LocationParameters[0].Geometry;
                        GetSiteInfoDataSet(queryBox, ds);
                    }
                }
                else
                {
                    sitesTableAdapter sitesTableAdapter = CreateSitesTableAdapter();
                    foreach (locationParam s in LocationParameters)
                    {
                        try
                        {
                            siteInfoDataSet.sitesDataTable aSitetable = new siteInfoDataSet.sitesDataTable();

                            if (s.IsId)
                            {
                                int siteID = int.Parse(s.SiteCode);
                                sitesTableAdapter.FillBySiteID(aSitetable, siteID);
                            }
                            else
                            {
                                sitesTableAdapter.FillBySiteCode(aSitetable, s.SiteCode);
                            }
                            ds.sites.Merge(aSitetable);
                        }
                        catch (Exception e)
                        {
                            log.Fatal("Cannot connect to database " + e.Message);
                            //+ sitesTableAdapter.Connection.DataSource
                            throw new WaterOneFlowServerException(e.Message);
                        }
                    }
                }
                return ds;
            }
        public SiteInfoResponseType GetSiteInfo(locationParam locationParameter)
        {
            string Network;
            string SiteCode;

            SiteInfoResponseType result = createSiteInfoResponse(new locationParam[] { locationParameter });

            // put a no result check here
            result.queryInfo.criteria.locationParam = locationParameter.ToString(); // to string returns orignal string
            if (result.site[0].siteInfo != null)
            {
                result.site[0].siteInfo.siteCode[0].network =
                    System.Configuration.ConfigurationManager.AppSettings["network"];
            }
            else
            {
                // we only have one site... so throw the exception
                throw new WaterOneFlowException("Site '" + locationParameter.ToString() + "' Not Found");
            }
            return(result);
        }
Ejemplo n.º 24
0
 public override SiteInfoType GetSite(locationParam site)
 {
     locationParam[] sites;
     if (site == null)
     {
         sites = new locationParam[0];
     }
     else
     {
         sites    = new locationParam[1];
         sites[0] = site;
     }
     SiteInfoType[] siteInfoTypes = GetSites(sites);
     if (siteInfoTypes == null || siteInfoTypes.Length == 0)
     {
         return(null);
     }
     else
     {
         return(siteInfoTypes[0]);
     }
 }
Ejemplo n.º 25
0
        // do one at a time

        public seriesCatalogType[] GetSeries(locationParam lp)
        {
            // for this we are only doing one, but multiple can come back
            List <seriesCatalogType> seriesCatalogs = new List <seriesCatalogType>();

// seriesCatalog is built from array of series
            #region build series
            {
                List <seriesCatalogTypeSeries>           series = new List <seriesCatalogTypeSeries>();
                UsgsDbDailyValues.seriesCatalogDataTable scDs   = new UsgsDbDailyValues.seriesCatalogDataTable();
                UsgsDbDailyValuesTableAdapters.seriesCatalogTableAdapter tableAdaptor = new seriesCatalogTableAdapter();


                if (lp != null)
                {
                    if (lp.SiteCode != null)
                    {
                        tableAdaptor.FillBySiteCode(scDs, lp.SiteCode);
                    }
                }


                foreach (UsgsDbDailyValues.seriesCatalogRow row in scDs.Rows)
                {
                    seriesCatalogTypeSeries s = row2Series(row);
                    if (s != null)
                    {
                        series.Add(s);
                    }
                }

                // add the list of series to the
                seriesCatalogType aCatalog = new seriesCatalogType();
                aCatalog.series = series.ToArray();
                seriesCatalogs.Add(aCatalog);
            }
            #endregion
            return(seriesCatalogs.ToArray());
        }
Ejemplo n.º 26
0
            public SiteInfoResponseType GetSiteInfoResponse(locationParam locationParameter)
            {
                string Network;
                string SiteCode;

                SiteInfoResponseType result = createSiteInfoResponse(new locationParam[] { locationParameter }, true);
                // put a no result check here

                //result.queryInfo.criteria.locationParam = locationParameter.ToString(); // to string returns orignal string
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", new string[] { locationParameter.ToString() }, null, null, null, null);
                if (result.site[0].siteInfo != null)
                {
                    result.site[0].siteInfo.siteCode[0].network =
                        System.Configuration.ConfigurationManager.AppSettings["network"];
                }
                else
                {
                    // we only have one site... so throw the exception
                    //  result.queryInfo.note = CuahsiBuilder.addNote(result.queryInfo.note,CuahsiBuilder.createNote("Site not found"));
                    throw new WaterOneFlowException("Site '" + locationParameter.ToString() + "' Not Found");

                }
                return result;
            }
Ejemplo n.º 27
0
            public SiteInfoResponseType GetSiteInfoResponse(locationParam locationParameter)
            {
                string Network;
                string SiteCode;

                SiteInfoResponseType result = createSiteInfoResponse(new locationParam[] { locationParameter }, true);

                // put a no result check here

                //result.queryInfo.criteria.locationParam = locationParameter.ToString(); // to string returns orignal string
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", new string[] { locationParameter.ToString() }, null, null, null, null);
                if (result.site[0].siteInfo != null)
                {
                    result.site[0].siteInfo.siteCode[0].network =
                        System.Configuration.ConfigurationManager.AppSettings["network"];
                }
                else
                {
                    // we only have one site... so throw the exception
                    //  result.queryInfo.note = CuahsiBuilder.addNote(result.queryInfo.note,CuahsiBuilder.createNote("Site not found"));
                    throw new WaterOneFlowException("Site '" + locationParameter.ToString() + "' Not Found");
                }
                return(result);
            }
Ejemplo n.º 28
0
            //public virtual string GetValues(string locationParam, string VariableCode, string StartDate, string EndDate, String authToken)
            //{
            //    TimeSeriesResponseType aSite = GetValuesObject(locationParam, VariableCode, StartDate, EndDate, null);
            //    return WSUtils.ConvertToXml(aSite, typeof(TimeSeriesResponseType));
            //}

            public virtual TimeSeriesResponseType GetValuesObject(string LP, string VariableCode, string StartDate, string EndDate, String authToken)
            {
                if (!useODForValues)
                {
                    throw new SoapException("GetValues implemented external to this service. Call GetSiteInfo, and SeriesCatalog includes the service Wsdl for GetValues. Attribute:serviceWsdl on Element:seriesCatalog XPath://seriesCatalog/[@serviceWsdl]", new XmlQualifiedName("ServiceException"));
                }

                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogValuesStart(Logging.Methods.GetValues, // method
                                         LP,                        //location
                                         VariableCode,              //variable
                                         StartDate,                 // startdate
                                         StartDate,                 //enddate
                                         Context.Request.UserHostName);

                try
                {
                    WaterOneFlowImpl.locationParam lParam = new locationParam(LP);
                    VariableParam vparam  = new VariableParam(VariableCode);
                    W3CDateTime?  startDt = null;
                    W3CDateTime?  endDt   = null;
                    if (!String.IsNullOrEmpty(StartDate))
                    {
                        startDt = new W3CDateTime(DateTime.Parse(StartDate));
                    }
                    if (!String.IsNullOrEmpty(EndDate))
                    {
                        endDt = new W3CDateTime(DateTime.Parse(EndDate));
                    }


                    TimeSeriesResponseType res = (TimeSeriesResponseType)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt);

                    if (res != null && res.timeSeries != null &&
                        res.timeSeries.values != null &&
                        res.timeSeries.values.value != null)
                    {
                        queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                               LP,                                 //locaiton
                                               VariableCode,                       //variable
                                               StartDate,                          // startdate
                                               StartDate,                          //enddate
                                               timer.ElapsedMilliseconds,          // processing time
                                               res.timeSeries.values.value.Length, // count
                                               Context.Request.UserHostName
                                               );
                    }
                    else
                    {
                        queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                               LP,                        //locaiton
                                               VariableCode,              //variable
                                               StartDate,                 // startdate
                                               StartDate,                 //enddate
                                               timer.ElapsedMilliseconds, // processing time
                                               0,                         // count
                                               Context.Request.UserHostName
                                               );
                    }

                    return(res);
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                           LP,                        //locaiton
                                           VariableCode,              //variable
                                           StartDate,                 // startdate
                                           StartDate,                 //enddate
                                           timer.ElapsedMilliseconds, // processing time
                                           -9999,                     // count
                                           Context.Request.UserHostName
                                           );
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 29
0
            public virtual SiteInfoResponseType GetSiteInfoObject(string SiteNumber, String authToken)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogStart(Logging.Methods.GetSiteInfo, SiteNumber,
                                   Context.Request.UserHostName);

                try
                {
                    if (String.IsNullOrEmpty(SiteNumber))
                    {
                        throw new WaterOneFlowException("Bad Location parameter submitted:'" +
                                                        SiteNumber + "'");
                    }

                    List <locationParam> lParams = new List <locationParam>();
                    //foreach (String site in SiteNumbers)
                    //{
                    try
                    {
                        locationParam lp = new locationParam(SiteNumber);
                        lParams.Add(lp);
                    }
                    catch
                    {
                        // only one here
                        log.Info("Bad Location parameter submitted:'" +
                                 SiteNumber + "'");
                        throw new WaterOneFlowException("Bad Location parameter submitted:'" +
                                                        SiteNumber + "'");
                    }
                    //}
                    if (lParams.Count > 0)
                    {
                        SiteInfoType[]       siteList = ODws.GetSites(lParams.ToArray());
                        SiteInfoResponseType sit      = new SiteInfoResponseType();
                        site[] sites = new site[siteList.Length];
                        // only one site
                        sites[0]          = new site();
                        sites[0].siteInfo = siteList[0];
                        // now add series
                        sites[0].seriesCatalog = ODws.GetSeries(lParams[0]);

                        sit.site = sites;
                        queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                         SiteNumber,
                                         timer.ElapsedMilliseconds.ToString(),
                                         sit.site.Length.ToString(),
                                         Context.Request.UserHostName);

                        return(sit);
                    }
                    else
                    {
                        queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                         SiteNumber,
                                         timer.ElapsedMilliseconds.ToString(),
                                         "-9999",
                                         Context.Request.UserHostName);
                        throw new WaterOneFlowException("No Valid Site Code submitted");
                    }
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                     SiteNumber,
                                     timer.ElapsedMilliseconds.ToString(),
                                     "-9999",
                                     Context.Request.UserHostName);
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 30
0
            //public string GetSitesXml(string[] SiteNumbers, String authToken)
            //{
            //    SiteInfoResponseType aSite = GetSites(SiteNumbers, null);
            //    string xml = WSUtils.ConvertToXml(aSite, typeof(SiteInfoResponseType));
            //    return xml;

            //}

            //public virtual string GetSiteInfo(string SiteNumber, String authToken)
            //{
            //    SiteInfoResponseType aSite = GetSiteInfoObject(SiteNumber, null);
            //    string xml = WSUtils.ConvertToXml(aSite, typeof(SiteInfoResponseType));
            //    return xml;
            //}

            //public string GetVariableInfo(string Variable, String authToken)
            //{
            //    VariablesResponseType aVType = GetVariableInfoObject(Variable, null);
            //    string xml = WSUtils.ConvertToXml(aVType, typeof(VariablesResponseType));
            //    return xml;
            //}


            public SiteInfoResponseType GetSites(string[] SiteNumbers, String authToken)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogStart(Logging.Methods.GetSites, SiteNumbers.ToString(),
                                   Context.Request.UserHostName);
                try
                {
                    List <locationParam> lParams = new List <locationParam>();
                    foreach (String site in SiteNumbers)
                    {
                        try
                        {
                            if (!String.IsNullOrEmpty(site))
                            {
                                locationParam lp = new locationParam(site);
                                lParams.Add(lp);
                            }
                        }
                        catch
                        {
                            log.Info("Bad Location parameter submitted");
                        }
                    }
                    SiteInfoType[] siteList;
                    if (lParams.Count > 0)
                    {
                        siteList = ODws.GetSites(lParams.ToArray());
                    }
                    else
                    {
                        siteList = ODws.GetSites(null);
                    }
                    SiteInfoResponseType sit = new SiteInfoResponseType();
                    site[] sites             = new site[siteList.Length];
                    for (int i = 0; i < siteList.Length; i++)
                    {
                        sites[i]          = new site();
                        sites[i].siteInfo = siteList[i];
                    }
                    sit.site = sites;

                    queryLog2.LogEnd(Logging.Methods.GetSites,
                                     SiteNumbers.ToString(),
                                     timer.ElapsedMilliseconds.ToString(),
                                     sit.site.Length.ToString(),
                                     Context.Request.UserHostName);

                    return(sit);
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);

                    queryLog2.LogEnd(Logging.Methods.GetSites,
                                     SiteNumbers.ToString(),
                                     timer.ElapsedMilliseconds.ToString(),
                                     "-9999",
                                     Context.Request.UserHostName
                                     );

                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 31
0
            public override object GetTimeSeries(
                locationParam Location,
                VariableParam Variable,
                W3CDateTime?BeginDateTime, W3CDateTime?EndDateTime)
            {
                string siteNum;

                string   parameterCode;
                string   statisticCode;
                string   agencyCode;
                DateTime startDateTime;
                DateTime endDateTime;

                if (Location.isGeometry)
                {
                    throw new WaterOneFlowException("Geometry not supported ");
                }

                if (Location != null)
                {
                    siteNum = Location.SiteCode;
                }
                else
                {
                    throw new WaterOneFlowException("Missing SiteCode ");
                }

                if (Variable != null)
                {
                    parameterCode = Variable.Code;
                    statisticCode = option2UsgsStatCode(Variable);
                    agencyCode    = option2AgencyCode(Variable);
                }
                else
                {
                    throw new WaterOneFlowException("Missing Parameter ");
                }

                DateTime startMinDate = DateTime.Now.AddDays(-maxRequestDays);

                startDateTime = startMinDate;
                if (BeginDateTime.HasValue)
                {
                    startDateTime = BeginDateTime.Value.DateTime;
                    if (startDateTime <= startMinDate)
                    {
                        startDateTime = startMinDate;
                    }
                }



                DateTime endDateMax = DateTime.Now;

                endDateTime = endDateMax;
                if (EndDateTime.HasValue)
                {
                    endDateTime = EndDateTime.Value.DateTime;
                    if (endDateTime >= endDateMax)
                    {
                        endDateTime = endDateMax;
                    }
                }
                if (endDateTime < DateTime.Now.AddDays(-maxRequestDays))
                {
                    throw new WaterOneFlowException("Only Properties.Settings.Default.UVDaysAvailable days back is supported in the NWIS UV service");
                }
                if (endDateTime < startDateTime)
                {
                    endDateTime = DateTime.Now;
                }

                //TimeSpan span = endDateTime - startDateTime;
                //if (span.Days > 31 )
                //{
                //    span = new TimeSpan(31, 0, 0);
                //}
                try
                {
                    //http://waterservices.usgs.gov/WOF/InstantaneousValues?location=06869950&variable=00065&period=P1D
                    //string urlFormat = "http://{0}/{1}?location={2}&variable={3}&period=P{4}D";
                    //string url = string.Format(urlFormat, "waterservices.usgs.gov",
                    //                           "WOF/InstantaneousValues",
                    //                           siteNum,
                    //                           parameterCode,
                    //                           span.Days);
                    //   string urlFormat = "{0}?location={1}&variable={2}&startDate={3}&endDate={4}";
                    string urlFormat = "{0}?sites={1}&parameterCd={2}&startDT={3}&endDT={4}";
                    string url       = string.Format(urlFormat, USGSUVBaseUrl,
                                                     siteNum,
                                                     parameterCode,
                                                     startDateTime.ToString("yyyy-MM-dd"),
                                                     endDateTime.ToString("yyyy-MM-dd"));
                    Uri uri = new Uri(url);
                    using (WebClient web = new WebClient())
                    {
                        XmlReader    reader       = new XmlTextReader(web.OpenRead(url));
                        MemoryStream memoryStream = new MemoryStream();
                        XmlWriter    writer       = XmlWriter.Create(memoryStream);
                        xslt.Transform(reader, writer);
                        memoryStream.Position = 0;
                        reader = XmlReader.Create(memoryStream);
                        TimeSeriesResponseType response
                            = (TimeSeriesResponseType)serializer.Deserialize(reader);

                        //TimeSeriesResponseType response
                        //    = new Passthrough(web.OpenRead(url));
                        return(response);
                    }
                }


                catch (Exception ex)
                {
                    log.Info("USGS  Connection Error " + ex.Message);
                    throw new WaterOneFlowSourceException("Error connecting to USGS");
                }
            }
Ejemplo n.º 32
0
            private static locationParam GetLocationParameter(string SiteNumber)
            {
                locationParam sq;
                sq = new locationParam(SiteNumber);

                if (sq.isGeometry)
                {
                    throw new WaterOneFlowException("Location by Geometry not accepted: " + SiteNumber);
                }
                return sq;
            }
Ejemplo n.º 33
0
            public override object GetValuesObject(string location, string variable, string startDate, string endDate, String authToken)
            {
                if (!useODForValues)
                {
                    throw new SoapException("GetValues implemented external to this service. Call GetSiteInfo, and SeriesCatalog includes the service Wsdl for GetValues. Attribute:serviceWsdl on Element:seriesCatalog XPath://seriesCatalog/[@serviceWsdl]", new XmlQualifiedName("ServiceException"));
                }

                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogValuesStart(Logging.Methods.GetValues, // method
                                         location,                  //location
                                         variable,                  //variable
                                         startDate,                 // startdate
                                         startDate,                 //enddate
                                         Context.Request.UserHostName);

                try
                {
                    WaterOneFlowImpl.locationParam lParam = new locationParam(location);
                    VariableParam vparam  = new VariableParam(variable);
                    W3CDateTime?  startDt = null;
                    W3CDateTime?  endDt   = null;
                    if (!String.IsNullOrEmpty(startDate))
                    {
                        startDt = new W3CDateTime(DateTime.Parse(startDate));
                    }
                    if (!String.IsNullOrEmpty(endDate))
                    {
                        endDt = new W3CDateTime(DateTime.Parse(endDate));
                    }


                    TimeSeriesResponseTypeObject res = (TimeSeriesResponseTypeObject)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt);

                    //if (res != null && res.timeSeries != null &&
                    //    res.timeSeries.values != null &&
                    //    res.timeSeries.values.value != null)
                    //{
                    //    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                    //          location, //locaiton
                    //        variable, //variable
                    //        startDate, // startdate
                    //        startDate, //enddate
                    //        timer.ElapsedMilliseconds, // processing time
                    //        res.timeSeries.values.value.Length, // count
                    //         Context.Request.UserHostName
                    //         );
                    //}
                    //else
                    //{
                    //    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                    //             location, //locaiton
                    //             variable, //variable
                    //             startDate, // startdate
                    //             startDate, //enddate
                    //             timer.ElapsedMilliseconds, // processing time
                    //             0, // count
                    //             Context.Request.UserHostName
                    //             );
                    //}

                    //// add query info
                    //if (res.queryInfo == null) res.queryInfo = new QueryInfoType();
                    //res.queryInfo.creationTime = DateTime.Now.ToLocalTime();
                    //res.queryInfo.creationTimeSpecified = true;
                    //QueryInfoTypeCriteria crit = new QueryInfoTypeCriteria();
                    //if (String.IsNullOrEmpty(location))
                    //{
                    //    crit.locationParam = "none";
                    //}
                    //else
                    //{
                    //    crit.locationParam = location;
                    //}

                    //if (String.IsNullOrEmpty(variable))
                    //{
                    //    crit.locationParam = "none";
                    //}
                    //else
                    //{
                    //    crit.variableParam = variable;
                    //}
                    //crit.timeParam =
                    //    CuahsiBuilder.createQueryInfoTimeCriteria(startDate, endDate);

                    //res.queryInfo.criteria = crit;


                    //return res;
                    return(new WaterOneFlow.Service.v1_0.xsd.TimeSeriesResponse(res));
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                           location,                  //locaiton
                                           variable,                  //variable
                                           startDate,                 // startdate
                                           startDate,                 //enddate
                                           timer.ElapsedMilliseconds, // processing time
                                           -9999,                     // count
                                           Context.Request.UserHostName
                                           );
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 34
0
            public override object GetSiteInfoObject(string site, String authToken)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogStart(Logging.Methods.GetSiteInfo, site,
                                   Context.Request.UserHostName);

                try
                {
                    if (String.IsNullOrEmpty(site))
                    {
                        throw new WaterOneFlowException("Bad Location parameter submitted:'" +
                                                        site + "'");
                    }

                    List <locationParam> lParams = new List <locationParam>();
                    //foreach (String site in SiteNumbers)
                    //{
                    try
                    {
                        locationParam lp = new locationParam(site);
                        lParams.Add(lp);
                    }
                    catch
                    {
                        // only one here
                        log.Info("Bad Location parameter submitted:'" +
                                 site + "'");
                        throw new WaterOneFlowException("Bad Location parameter submitted:'" +
                                                        site + "'");
                    }
                    //}
                    if (lParams.Count > 0)
                    {
                        SiteInfoType[]       siteList = ODws.GetSites(lParams.ToArray());
                        SiteInfoResponseType sit      = new SiteInfoResponseType();
                        site[] sites = new site[siteList.Length];
                        // only one site
                        sites[0]          = new site();
                        sites[0].siteInfo = siteList[0];
                        // now add series
                        sites[0].seriesCatalog = ODws.GetSeries(lParams[0]);

                        sit.site = sites;
                        queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                         site,
                                         timer.ElapsedMilliseconds.ToString(),
                                         sit.site.Length.ToString(),
                                         Context.Request.UserHostName);

                        // add query info
                        if (sit.queryInfo == null)
                        {
                            sit.queryInfo = new QueryInfoType();
                        }
                        sit.queryInfo.creationTime          = DateTime.Now.ToLocalTime();
                        sit.queryInfo.creationTimeSpecified = true;
                        QueryInfoTypeCriteria crit = new QueryInfoTypeCriteria();
                        if (String.IsNullOrEmpty(site))
                        {
                            crit.locationParam = "none";
                        }
                        else
                        {
                            crit.locationParam = site;
                        }

                        sit.queryInfo.criteria = crit;

                        //return sit;
                        return(new WaterOneFlow.Service.v1_0.xsd.SiteInfoResponse(sit));
                    }
                    else
                    {
                        queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                         site,
                                         timer.ElapsedMilliseconds.ToString(),
                                         "-9999",
                                         Context.Request.UserHostName);
                        throw new WaterOneFlowException("No Valid Site Code submitted");
                    }
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                     site,
                                     timer.ElapsedMilliseconds.ToString(),
                                     "-9999",
                                     Context.Request.UserHostName);
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 35
0
            public override object GetSites(
                [XmlArray("site"), XmlArrayItem("string", typeof(string))]
                string[] site,
                String authToken)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                string siteListString;

                if (site != null)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (string s in site)
                    {
                        sb.AppendFormat("{0};", s);
                    }
                    siteListString = sb.ToString();
                }
                else
                {
                    siteListString = "All Sites";
                }

                queryLog2.LogStart(Logging.Methods.GetSites, siteListString,
                                   Context.Request.UserHostName);
                try
                {
                    List <locationParam> lParams             = new List <locationParam>();
                    StringBuilder        siteNumbersAsString = new StringBuilder();
                    if (site != null)
                    {
                        foreach (String s in site)
                        {
                            try
                            {
                                if (!String.IsNullOrEmpty(s))
                                {
                                    locationParam lp = new locationParam(s);
                                    lParams.Add(lp);
                                    siteNumbersAsString.AppendFormat("{0};", s);
                                }
                            }
                            catch
                            {
                                log.Info("Bad Location parameter submitted");
                            }
                        }
                    }
                    SiteInfoType[] siteList;
                    if (lParams.Count > 0)
                    {
                        siteList = ODws.GetSites(lParams.ToArray());
                    }
                    else
                    {
                        siteList = ODws.GetSites(null);
                    }

                    SiteInfoResponseType sit = new SiteInfoResponseType();
                    site[] sites             = new site[siteList.Length];
                    for (int i = 0; i < siteList.Length; i++)
                    {
                        sites[i]          = new site();
                        sites[i].siteInfo = siteList[i];
                    }
                    sit.site = sites;

                    queryLog2.LogEnd(Logging.Methods.GetSites,
                                     siteListString,
                                     timer.ElapsedMilliseconds.ToString(),
                                     sit.site.Length.ToString(),
                                     Context.Request.UserHostName);

                    // add query info
                    if (sit.queryInfo == null)
                    {
                        sit.queryInfo = new QueryInfoType();
                    }
                    sit.queryInfo.creationTime          = DateTime.Now.ToLocalTime();
                    sit.queryInfo.creationTimeSpecified = true;
                    QueryInfoTypeCriteria crit = new QueryInfoTypeCriteria();
                    if (site == null || site.Length == 0)
                    {
                        crit.locationParam = "ALL (empty request)";
                    }
                    else
                    {
                        crit.locationParam = siteNumbersAsString.ToString();
                    }

                    sit.queryInfo.criteria = crit;


                    // return sit;
                    return(new WaterOneFlow.Service.v1_0.xsd.SiteInfoResponse(sit));
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);

                    queryLog2.LogEnd(Logging.Methods.GetSites,
                                     siteListString,
                                     timer.ElapsedMilliseconds.ToString(),
                                     "-9999",
                                     Context.Request.UserHostName
                                     );

                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Ejemplo n.º 36
0
            private static SiteInfoType getSiteInfoType(locationParam LocationParameter)
            {
                SiteInfoType sit;

                //   look in memory
                //           sit = (SiteInfoType)appCache[sitCache + siteCode];
                //         if (sit != null) return sit;

                //ok, try the database
                SiteInfoType[] sites = ODSiteInfo.GetSitesByLocationParameters(new locationParam[] { LocationParameter });
                if (sites == null || sites.Length == 0)
                {
                    return null;
                }
                else

                    if (sites != null && sites.Length == 1)
                    {
                        return sites[0];
                    }
                    else
                    {
                        // had better be only one
                        String error = "More than one site with SiteCode '" + LocationParameter + "'";
                        log.Error(error);
                        throw new WaterOneFlowException(error);
                    }

                return sit;
            }
Ejemplo n.º 37
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;
            }
            public static SiteInfoType[] GetSitesByLocationParameters(locationParam[] locationParameters)
            {
                siteInfoDataSet sDS;
                if (locationParameters.Length > 0)
                {
                    sDS = GetSiteInfoDataSet(locationParameters);

                }
                else
                {
                    sDS = GetSiteInfoDataSet();
                }
                List<SiteInfoType> sites = new List<SiteInfoType>(locationParameters.Length);

                foreach (siteInfoDataSet.sitesRow s in sDS.sites)
                {
                    SiteInfoType sit = row2SiteInfoElement(s, sDS);
                    sites.Add(sit);

                }

                return sites.ToArray();
            }
            public SiteInfoResponseType GetSiteInfo(string[] locationParameter, Boolean IncludeSeries)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();
                 if (locationParameter != null)
                {
                    queryLog2.LogStart(Logging.Methods.GetSiteInfo, locationParameter.ToString(),
                                       appContext.Request.UserHostName);
                }
                else
                {
                    queryLog2.LogStart(Logging.Methods.GetSiteInfo, "NULL",
                                       appContext.Request.UserHostName);

                }
                List<locationParam> lpList = new List<locationParam>();
                try
                {
                    foreach (string s in locationParameter)
                    {
                        locationParam l = new locationParam(s);

                        if (l.isGeometry)
                        {
                            String error = "Location by Geometry not accepted: " + locationParameter;
                            log.Debug(error);
                            throw new WaterOneFlowException(error);
                        }
                        else
                        {
                            lpList.Add(l);
                        }
                    }
                }
                catch (WaterOneFlowException we)
                {
                    log.Error(we.Message);
                    throw;
                }
                catch (Exception e)
                {
                    String error =
                        "Sorry. Your submitted site ID for this getSiteInfo request caused an problem that we failed to catch programmatically: " +
                        e.Message;
                    log.Error(error);
                    throw new WaterOneFlowException(error);
                }
                GetSiteInfoOD getSiteInfo = new GetSiteInfoOD();
                SiteInfoResponseType resp = null;
                resp = getSiteInfo.GetSiteInfoResponse(lpList.ToArray(), true);
                foreach (SiteInfoResponseTypeSite site in resp.site)
                {
                    foreach (seriesCatalogType catalog in site.seriesCatalog)
                    {
                        catalog.menuGroupName = serviceName;
                        catalog.serviceWsdl = serviceUrl;
                    }
                }

                if (locationParameter != null)
                {

                    queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                     locationParameter.ToString(),
                                     timer.ElapsedMilliseconds.ToString(),
                                     resp.site.Length.ToString(),
                                     appContext.Request.UserHostName);
                }
                else
                {
                    queryLog2.LogEnd(Logging.Methods.GetSiteInfo,
                                   "NULL",
                                   timer.ElapsedMilliseconds.ToString(),
                                   resp.site.Length.ToString(),
                                   appContext.Request.UserHostName);
                }

                return resp;
            }
 public static siteInfoDataSet GetSiteInfoDataSet(locationParam LocationParam)
 {
     return GetSiteInfoDataSet(new locationParam[] { LocationParam });
 }