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 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 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 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); } }