public VariablesResponseType GetVariableInfoObject(string Variable, String authToken) { try { return(ODws.GetVariableInfo(Variable)); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
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); } }
public virtual SiteInfoResponseType GetSiteInfoObject(string SiteNumber, String authToken) { try { return(ODws.GetSiteInfo(SiteNumber)); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
public VariablesResponseType GetVariableInfoObject(string Variable, String authToken) { Stopwatch timer = System.Diagnostics.Stopwatch.StartNew(); queryLog2.LogStart(Logging.Methods.GetVariables, Variable, Context.Request.UserHostName); try { VariableParam[] vars = null; if (!String.IsNullOrEmpty(Variable)) { vars = new VariableParam[1]; VariableParam vp = new VariableParam(Variable); vars[0] = vp; } VariablesResponseType res = ODws.GetVariables(vars); // don't always have variables if (res.variables != null) { queryLog2.LogEnd(Logging.Methods.GetVariables, Variable, timer.ElapsedMilliseconds.ToString(), res.variables.Length.ToString(), Context.Request.UserHostName); } else { queryLog2.LogEnd(Logging.Methods.GetVariables, Variable, timer.ElapsedMilliseconds.ToString(), "0", Context.Request.UserHostName); } return(res); } catch (Exception we) { log.Warn(we.Message); queryLog2.LogEnd(Logging.Methods.GetVariables, Variable, timer.ElapsedMilliseconds.ToString(), "-9999", Context.Request.UserHostName); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
public SiteInfoResponseType GetSiteInfoMultpleObject(string[] site, string authToken) { GlobalClass.WaterAuth.SiteInfoServiceAllowed(Context, authToken); try { return(ODws.GetSiteInfo(site, true)); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
public VariablesResponseType GetVariableInfoObject(string variable, String authToken) { GlobalClass.WaterAuth.VariableInfoServiceAllowed(Context, authToken); try { return(ODws.GetVariableInfo(variable)); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
public virtual SiteInfoResponseType GetSiteInfoObject(string SiteNumber, String authToken) { GlobalClass.WaterAuth.SiteInfoServiceAllowed(Context, authToken); try { return(ODws.GetSiteInfo(SiteNumber)); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
public string GetSourceObject(string[] source, String authToken) { GlobalClass.WaterAuth.SitesServiceAllowed(Context, authToken); try { return("");//ODws.GetSites(source); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
public virtual TimeSeriesResponseType GetValuesObject(string locationParam, 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")); } try { return(ODws.GetValues(locationParam, VariableCode, StartDate, EndDate)); } catch (Exception we) { log.Warn(we.Message); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
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); } }
public override object GetVariableInfoObject(string variable, String authToken) { Stopwatch timer = System.Diagnostics.Stopwatch.StartNew(); queryLog2.LogStart(Logging.Methods.GetVariables, variable, Context.Request.UserHostName); try { VariableParam[] vars = null; if (!String.IsNullOrEmpty(variable)) { vars = new VariableParam[1]; VariableParam vp = new VariableParam(variable); vars[0] = vp; } VariablesResponseType res = ODws.GetVariables(vars); // don't always have variables if (res.variables != null) { queryLog2.LogEnd(Logging.Methods.GetVariables, variable, timer.ElapsedMilliseconds.ToString(), res.variables.Length.ToString(), Context.Request.UserHostName); } else { queryLog2.LogEnd(Logging.Methods.GetVariables, variable, timer.ElapsedMilliseconds.ToString(), "0", Context.Request.UserHostName); } WaterOneFlow.Service.v1_0.xsd.VariablesResponse obj = new WaterOneFlow.Service.v1_0.xsd.VariablesResponse(res); // if (DEBUG) { // XmlSerializer xs = new XmlSerializer( // typeof (WaterOneFlow.Service.v1_0.xsd.VariablesResponse)); // StringBuilder sb = new StringBuilder(); // XmlWriterSettings settings = new XmlWriterSettings(); // settings.OmitXmlDeclaration = true; //// settings.ConformanceLevel = ConformanceLevel.Fragment; // XmlWriter writer = XmlWriter.Create(sb, settings); // xs.Serialize(writer, obj); //} //return res; return(new WaterOneFlow.Service.v1_0.xsd.VariablesResponse(res)); } catch (Exception we) { log.Warn(we.Message); queryLog2.LogEnd(Logging.Methods.GetVariables, variable, timer.ElapsedMilliseconds.ToString(), "-9999", Context.Request.UserHostName); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
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); } }
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); } }
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); /* Look to see if siates exist. * NCDC sends back 200k for thier rest service. * aka no errors, except as a string * */ SiteInfoType site; try { site = ODws.GetSiteInfoObject(lParam); if (site == null) { throw new WaterOneFlowException("Unknown Site Code: '" + location + "'"); } } catch (WaterOneFlowException wex) { throw new WaterOneFlowException("Unknown Site Code: '" + location + "'"); } catch (WaterOneFlowServerException wex) { log.Fatal("Database Error"); throw wex; } catch (Exception ex) { log.Error("Unhandled Exception ", ex); throw new WaterOneFlowServerException("Unhandled Error."); } VariableInfoType[] vars; try { vars = ODws.GetVariableInfoObject(vparam); if (vars.Length == 0) { throw new WaterOneFlowException("Unknown Variable Code: '" + variable + "'"); } } catch (WaterOneFlowException wex) { throw new WaterOneFlowException("Unknown Variable Code: '" + variable + "'"); } catch (WaterOneFlowServerException wex) { log.Fatal("Database Error"); throw wex; } catch (Exception ex) { log.Error("Unhandled Exception ", ex); throw new WaterOneFlowServerException("Unhandled Error."); } // moved date check after site and variable check 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)); int endDateMin = int.Parse(ConfigurationManager.AppSettings.Get("NCDCISD_EndDateMinYear")); if (endDt.Value.DateTime.Year < endDateMin) { throw new WaterOneFlowException("NCDC ISD and ISH No Data is available before: " + endDateMin); } } /*********************** * GET NCDC RESPONSE * ********************* */ TimeSeriesResponseTypeObject res = (TimeSeriesResponseTypeObject)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt); /*********************** * Add missing information from sites and variables db * ********************* */ if (vars.Length > 0) { res.timeSeries.variable = vars[0]; } if (site != null) { res.timeSeries.sourceInfo = site; } 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); } }
//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); } }
public 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 endDate, //enddate Context.Request.UserHostName); try { WaterOneFlowImpl.locationParam lParam = new locationParam(location); VariableParam vparam = new VariableParam(variable); W3CDateTime? startDt = null; W3CDateTime? endDt = null; int estimateCount = 0; if (!String.IsNullOrEmpty(startDate)) { startDt = new W3CDateTime(DateTime.Parse(startDate)); } if (!String.IsNullOrEmpty(endDate)) { endDt = new W3CDateTime(DateTime.Parse(endDate)); } try { if (startDt.HasValue && endDt.HasValue) { estimateCount = (endDt.Value - startDt.Value).Hours * 4; log.DebugFormat("{0}/{1}:estimated count: {2}", endDt.Value, startDt.Value, estimateCount); } } catch { } // USGSwebService.TimeSeriesResponseType res = //(USGSwebService.TimeSeriesResponseType)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt); TimeSeriesResponseType res = (TimeSeriesResponseType)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt); if (res.timeSeries != null && res.timeSeries.values != null && res.timeSeries.values.value != null) { queryLog2.LogValuesEnd(Logging.Methods.GetValues, location, //location variable, //variable startDate, // startdate endDate, //enddate timer.ElapsedMilliseconds, res.timeSeries.values.value.Length, Context.Request.UserHostName); } else { queryLog2.LogValuesEnd(Logging.Methods.GetValues, location, //location variable, //variable startDate, // startdate endDate, //enddate timer.ElapsedMilliseconds, estimateCount, Context.Request.UserHostName); } // return new NWISUVTimeSeriesResponse(res);// this one is an original class TrackEvent(location, variable, startDate, endDate, estimateCount, Context); return(new WaterOneFlow.Service.v1_0.xsd.TimeSeriesResponse(res)); } catch (Exception we) { log.Warn(we.Message); TrackEvent(location, variable, startDate, endDate, null, Context); //queryLog2.LogValuesEnd(Logging.Methods.GetValues, // location, //locaiton // variable, //variable // startDate, // startdate // endDate, //enddate // timer.ElapsedMilliseconds, // processing time // -9999, // count // Context.Request.UserHostName // ); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }
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); } }
public 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)); } // see using statement above for full namespace USGSwebService.TimeSeriesResponseType res = (NwisWOFService.gov.usgs.nwis.dailyValues.TimeSeriesResponseType)dvSvc.GetTimeSeries(lParam, vparam, startDt, endDt); // minor editing, add network codes. foreach (USGSwebService.TimeSeriesType ts in res.timeSeries) { if (ts.sourceInfo.GetType().Name.Contains("SiteInfoType")) { USGSwebService.SiteInfoType sit = (USGSwebService.SiteInfoType)ts.sourceInfo; foreach (USGSwebService.SiteInfoTypeSiteCode sCode in sit.siteCode) { if (sCode.network == null && string.IsNullOrEmpty(sCode.network)) { sCode.network = ODws.SiteVocabulary; } } } } // need to check is sourceInfo is of siteInfoType... but no siteInfoType //NwisWOFService.gov.usgs.nwis.dailyValues.TimeSeriesType[] tst = res.timeSeries; //if (tst[0].sourceInfo.GetType().IsInstanceOfType(NwisWOFService.gov.usgs.nwis.dailyValues.) string count = "0"; if (res != null && res.timeSeries[0] != null && res.timeSeries[0].values[0].value != null) { count = res.timeSeries[0].values[0].value.Length.ToString(); } queryLog2.LogEnd(Logging.Methods.GetValues, location, timer.ElapsedMilliseconds.ToString(), count, Context.Request.UserHostName); return(new NWISTimeSeriesResponse(res)); //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; } 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); } }
//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); } }
public SiteInfoResponseTypeGeneric GetSitesObject(string[] site, String authToken) { Stopwatch timer = System.Diagnostics.Stopwatch.StartNew(); queryLog2.LogStart(Logging.Methods.GetSites, site.ToString(), Context.Request.UserHostName); try { List <locationParam> lParams = new List <locationParam>(); foreach (String s in site) { try { if (!String.IsNullOrEmpty(s)) { locationParam lp = new locationParam(s); 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(); WaterOneFlow.Schema.v1_1. SiteInfoResponseTypeSite[] sites = new SiteInfoResponseTypeSite[siteList.Length]; for (int i = 0; i < siteList.Length; i++) { sites[i] = new SiteInfoResponseTypeSite(); sites[i].siteInfo = siteList[i]; } sit.site = sites; queryLog2.LogEnd(Logging.Methods.GetSites, site.ToString(), 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 (sites == null || sites.Length == 0) { crit.locationParam = "ALL (empty request)"; } else { crit.locationParam = sites.ToString(); } sit.queryInfo.criteria = crit; return(new WaterOneFlow.Service.v1_1.xsd.SiteInfoResponse(sit)); } catch (Exception we) { log.Warn(we.Message); queryLog2.LogEnd(Logging.Methods.GetSites, site.ToString(), timer.ElapsedMilliseconds.ToString(), "-9999", Context.Request.UserHostName ); throw SoapExceptionGenerator.WOFExceptionToSoapException(we); } }