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 static ValuesDataSet GetValuesDataSet(int siteID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); SitesTableAdapter siteAdapter = new SitesTableAdapter(); VariablesTableAdapter vAdapter = new VariablesTableAdapter(); siteAdapter.Connection.ConnectionString = odws.Config.ODDB(); vAdapter.Connection.ConnectionString = odws.Config.ODDB(); //DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); //valuesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); //try //{ // valuesTableAdapter.FillBySiteIDBetweenDates(ds.DataValues, siteID, BeginDateTime.DateTime, // EndDateTime.DateTime); //} //catch (Exception e) //{ // log.Fatal("Cannot retrieve information from database: " + e.Message); // //+ valuesTableAdapter.Connection.DataSource //} //return ds; siteAdapter.FillBySiteID(ds.Sites, siteID); vAdapter.FillBySiteID(ds.Variables, ds.Sites[0].SiteID); foreach (VariableInfoType variable in ds.Variables.Rows) { ds.DataValues.Rows.Add(getDataValues(ds, BeginDateTime.DateTime, BeginDateTime.DateTime)); } return(ds); }
public void Able_To_Parse_Dates_Before_1000AD_Test() { var date = W3CDateTime.Parse("0001-01-01"); Assert.AreEqual(new DateTime(1, 1, 1), date.DateTime); date = W3CDateTime.Parse("0200-02-02"); Assert.AreEqual(new DateTime(200, 2, 2), date.DateTime); }
public static void TestPlaylist(Playlist playlist) { Assert.AreEqual("Playlist Title", playlist.Title); Assert.AreEqual("Aaron Bockover", playlist.Creator); Assert.AreEqual("Comment", playlist.Annotation); Uri uri = new Uri("http://abock.org/"); Assert.AreEqual(uri, playlist.Location); Assert.AreEqual(uri, playlist.Identifier); Assert.AreEqual(uri, playlist.Image); Assert.AreEqual(uri, playlist.License); Assert.AreEqual(W3CDateTime.Parse("2005-01-08T17:10:47-05:00").LocalTime, playlist.Date); Assert.AreEqual(2, playlist.Meta.Count); foreach (MetaEntry meta in playlist.Meta) { Assert.AreEqual(new Uri("http://abock.org/fruit"), meta.Rel); if (meta.Value != "Apples" && meta.Value != "Oranges") { Assert.Fail("Expected one of 'Apples' or 'Oranges'"); } } Assert.AreEqual(2, playlist.Links.Count); foreach (LinkEntry link in playlist.Links) { if (!link.Rel.AbsoluteUri.StartsWith("http://abock.org")) { Assert.Fail("Incorrect rel, expected it to start with http://abock.org"); } if (!link.Value.AbsoluteUri.StartsWith("http://abock.org")) { Assert.Fail("Incorrect content, expected it to start with http://abock.org"); } } Assert.AreEqual(1, playlist.Tracks.Count); Track track = playlist.Tracks[0]; Assert.AreEqual("Track 1", track.Title); Assert.AreEqual("Aaron Bockover", track.Creator); Assert.AreEqual("Comment", track.Annotation); Assert.AreEqual("Album", track.Album); Assert.AreEqual(uri, track.Info); Assert.AreEqual(uri, track.Image); Assert.AreEqual(11, track.TrackNumber); Assert.AreEqual(TimeSpan.FromMilliseconds(5159), track.Duration); Assert.AreEqual(2, track.Locations.Count); }
public static ValuesDataSet GetValuesDataSet(int?siteID, int?VariableID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); if (!siteID.HasValue || !VariableID.HasValue) { return(ds); } return(getDataValues(siteID.Value, VariableID.Value, BeginDateTime.DateTime, EndDateTime.DateTime)); }
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 static ValuesDataSet GetValuesDataSet(int?siteID, int?VariableID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); if (!siteID.HasValue || !VariableID.HasValue) { return(ds); } ValuesDataSetTableAdapters.DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); valuesTableAdapter.Connection.ConnectionString = Config.ODDB(); valuesTableAdapter.FillBySiteIdVariableIDBetweenDates(ds.DataValues, siteID.Value, VariableID.Value, BeginDateTime.DateTime, EndDateTime.DateTime); return(ds); }
public static ValuesDataSet GetValuesDataSet(int siteID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); VariablesTableAdapter variablesTableAdapter = new VariablesTableAdapter(); variablesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); DataTable Variables = variablesTableAdapter.GetDataBySiteID(siteID); foreach (DataRow row in Variables.Rows) { return(getDataValues(siteID, 1, BeginDateTime.DateTime, EndDateTime.DateTime)); } return(ds); }
public ValuesDataSet getValuesDataset(int?siteId, int?variableId, W3CDateTime?BeginDateTime, W3CDateTime?EndDateTime) { ValuesDataSet valuesDs; if (!variableId.HasValue && !BeginDateTime.HasValue && !EndDateTime.HasValue) { valuesDs = ODValues.GetValuesDataSet(siteId.Value); } else if (!variableId.HasValue && BeginDateTime.HasValue && EndDateTime.HasValue) { valuesDs = ODValues.GetValuesDataSet(siteId.Value, BeginDateTime.Value, EndDateTime.Value); } else if (variableId.HasValue && !BeginDateTime.HasValue && !EndDateTime.HasValue) { valuesDs = ODValues.GetValuesDataSet(siteId, variableId); } else if (variableId.HasValue && BeginDateTime.HasValue && !EndDateTime.HasValue) { EndDateTime = W3CDateTime.Now; valuesDs = ODValues.GetValuesDataSet(siteId, variableId, BeginDateTime.Value, EndDateTime.Value // set above ); } else if (variableId.HasValue && !BeginDateTime.HasValue && EndDateTime.HasValue) { BeginDateTime = W3CDateTime.Parse(ConfigurationManager.AppSettings["MinimalSQLDate"]); valuesDs = ODValues.GetValuesDataSet(siteId, variableId, BeginDateTime.Value, // set above EndDateTime.Value ); } else { valuesDs = ODValues.GetValuesDataSet(siteId, variableId, BeginDateTime.Value, EndDateTime.Value ); } return(valuesDs); }
private void CheckForUpdates(bool force) { if (!force && LastUpdateCheck - (DateTime.Now - check_timeout) > TimeSpan.Zero) { return; } Playlist playlist = new Playlist(); playlist.Load(CreateXspfWebStream(master_xspf_uri)); DateTime master_last_modified = DateTime.MinValue; MetaEntry meta = playlist.FindMetaEntry("/BansheeXSPF:last_modified"); if (!meta.Equals(MetaEntry.Zero)) { master_last_modified = W3CDateTime.Parse(meta.Value).LocalTime; } if (!force && master_last_modified <= LastUpdated) { return; } try { Directory.CreateDirectory(stations_path); foreach (string xspf_file in Directory.GetFiles(stations_path, "*.xspf")) { File.Delete(xspf_file); } } catch { } foreach (Track station in playlist.Tracks) { DownloadStation(station.Locations[0]); } LastUpdated = master_last_modified; LastUpdateCheck = DateTime.Now; }
/// <summary> /// Maps the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="value">The value.</param> /// <returns>Mapped <see cref="object" />.</returns> /// <exception cref="System.FormatException">cannot convert '{0}' to DateTime.FormatString(dateValue)</exception> public override object Map(Type type, object value) { W3CDateTime dateTime; string dateValue = Convert.ToString(value); if (W3CDateTime.TryParse(dateValue, out dateTime)) { return(dateTime.LocalDateTime); } DateTime date; if (DateTime.TryParse(dateValue, out date)) { return(date); } throw new FormatException("cannot convert '{0}' to DateTime".FormatString(dateValue)); }
public static ValuesDataSet GetValuesDataSet(int?siteID, int?VariableID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); SitesTableAdapter siteAdapter = new SitesTableAdapter(); VariablesTableAdapter vAdapter = new VariablesTableAdapter(); siteAdapter.Connection.ConnectionString = odws.Config.ODDB(); vAdapter.Connection.ConnectionString = odws.Config.ODDB(); //if (!siteID.HasValue || !VariableID.HasValue) return ds; //DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); //valuesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); //valuesTableAdapter.FillBySiteIdVariableIDBetweenDates(ds.DataValues, siteID.Value, VariableID.Value, BeginDateTime.DateTime, EndDateTime.DateTime); //return ds; siteAdapter.FillBySiteID(ds.Sites, siteID.Value); vAdapter.FillByVariableID(ds.Variables, VariableID.Value); return(getDataValues(ds, BeginDateTime.DateTime, EndDateTime.DateTime)); }
public static ValuesDataSet GetValuesDataSet(int siteID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); valuesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); try { valuesTableAdapter.FillBySiteIDBetweenDates(ds.DataValues, siteID, BeginDateTime.DateTime, EndDateTime.DateTime); } catch (Exception e) { log.Fatal("Cannot retrieve information from database: " + e.Message); //+ valuesTableAdapter.Connection.DataSource } return ds; }
public static ValuesDataSet GetValuesDataSet(int?siteID, int?VariableID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); //if (!siteID.HasValue || !VariableID.HasValue) return ds; //ValuesDataSetTableAdapters.DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); //valuesTableAdapter.Connection.ConnectionString = Config.ODDB(); //valuesTableAdapter.FillBySiteIdVariableIDBetweenDates(ds.DataValues, siteID.Value, VariableID.Value, BeginDateTime.DateTime, EndDateTime.DateTime); //return ds; //style 2 // return getDataValues(db.getSiteCode(siteID.Value), db.getVariableCode(VariableID.Value), BeginDateTime.DateTime, EndDateTime.DateTime); siteAdapter.FillBySiteID(ds.Sites, siteID.Value); vAdapter.FillBySiteID(ds.Variables, ds.Sites[0].SiteID); return(getDataValues(ds, new DateTime(1900, 01, 01), DateTime.Now)); }
private W3CDateTime?GetBeginDateTime(string StartDate) { W3CDateTime?BeginDateTime; if (!String.IsNullOrEmpty(StartDate)) { try { BeginDateTime = W3CDateTime.Parse(StartDate); } catch { throw new WaterOneFlowException("Improper BeginDate '" + StartDate + "' Must be YYYY-MM-DD"); } } else { BeginDateTime = null; } return(BeginDateTime); }
private static W3CDateTime?GetEndDateTime(string EndDate) { W3CDateTime?EndDateTime; if (!String.IsNullOrEmpty(EndDate)) { try { EndDateTime = W3CDateTime.Parse(EndDate); } catch { throw new WaterOneFlowException("Improper EndDate '" + EndDate + "' Must be YYYY-MM-DD"); } } else { EndDateTime = null; } return(EndDateTime); }
public static ValuesDataSet GetValuesDataSet(int siteID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); valuesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); try { valuesTableAdapter.FillBySiteIDBetweenDates(ds.DataValues, siteID, BeginDateTime.DateTime, EndDateTime.DateTime); } catch (Exception e) { log.Fatal("Cannot retrieve information from database: " + e.Message); //+ valuesTableAdapter.Connection.DataSource } return(ds); }
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 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 static ValuesDataSet GetValueDataSet(int? siteID, int? VariableID, int? MethodID, int? SourceID, int? QualityControlLevelID, W3CDateTime BeginDateTime, W3CDateTime EndDateTime) { ValuesDataSet ds = basicValuesDataSet(); if (!siteID.HasValue || !VariableID.HasValue) return ds; DataValuesTableAdapter valuesTableAdapter = new DataValuesTableAdapter(); valuesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); valuesTableAdapter.FillBySiteIdVariableIDBetweenDates(ds.DataValues, siteID.Value, VariableID.Value, BeginDateTime.DateTime, EndDateTime.DateTime); return ds; }
public static seriesCatalogTypeSeries CreateSeriesRecord(VariableInfoType variable, string sampleMedium, W3CDateTime? beginDateTime, W3CDateTime? endDateTime, int? valueCount, bool? valueCountIsEstimated, string dataType, string valueType, string generalCategory, bool realTime, string realTimeInterval, string QualityControlLevelTerm, int? qualityControlLevelid, string methodName, int? methodID, string organization, string sourceDescription, int? sourceID, string citation) { /* don't forget to check the VariableInfoType for the * dataType,ValueType and General Category * */ /* * logic * create seriesCatalogTypeSeries * if variable != null use it. if null, make an empty variable * if variable != null * and sampleMedium,dataType,valueType or generalCategory is null * try to get value from variable * add datTime interface logic * */ seriesCatalogTypeSeries series = new seriesCatalogTypeSeries(); series.variable = variable != null ? variable : CreateVariableDescriptionType(); if (valueCount.HasValue) { series.valueCount = new seriesCatalogTypeSeriesValueCount(); series.valueCount.Value = valueCount.Value; } // if begin time and end time are the same use single if (beginDateTime.HasValue) { TimeIntervalType tm = new TimeIntervalType(); // tm.beginDateTime = new DateTimeOffset(beginDateTime.Value.DateTime); tm.beginDateTime = beginDateTime.Value.DateTime; if (endDateTime.HasValue) { // tm.endDateTime = new DateTimeOffset(endDateTime.Value.DateTime); tm.endDateTime = endDateTime.Value.DateTime; } else { tm.endDateTime = tm.beginDateTime; } series.variableTimeInterval = tm; } if (realTime) { TimePeriodRealTimeType rt = new TimePeriodRealTimeType(); rt.realTimeDataPeriod = realTimeInterval; // 31 day Period //rt.beginDateTime = new DateTimeOffset(DateTime.Today.AddDays(-31)); //rt.endDateTime = new DateTimeOffset(DateTime.Today); rt.beginDateTime = DateTime.Today.AddDays(-31); rt.endDateTime = DateTime.Today; series.variableTimeInterval = rt; } /* TODO: fully populate * These need to use ID< and fully populat from database */ if (qualityControlLevelid.HasValue || !String.IsNullOrEmpty(QualityControlLevelTerm)) { series.QualityControlLevel = new QualityControlLevelType(); // need to have a dataset with an enum so we can // SetEnumFromText(qsds,row,series.QualityControlLevel, typeof(QualityControlLevelEnum)); if (qualityControlLevelid.HasValue) { series.QualityControlLevel.qualityControlLevelID = qualityControlLevelid.Value; series.QualityControlLevel.qualityControlLevelIDSpecified = true; } if (!String.IsNullOrEmpty(QualityControlLevelTerm)) { series.QualityControlLevel.Value = QualityControlLevelTerm; // originally defined as an enum, but enums cannot be empty, and we have an id // QualityControlLevelTerm = QualityControlLevelTerm.Replace(" ", ""); // if (Enum.IsDefined(typeof(QualityControlLevelEnum), QualityControlLevelTerm)) // { // object aEnum = Enum.Parse(typeof(QualityControlLevelEnum), QualityControlLevelTerm); // series.QualityControlLevel.Value = (QualityControlLevelEnum)aEnum; // } } } /* TODO: fully populate * These need to use ID< and fully populat from database */ if (!String.IsNullOrEmpty(methodName) || methodID.HasValue) { MethodType method = new MethodType(); if ( !String.IsNullOrEmpty(methodName) ) { method.MethodDescription = methodName; } if (methodID.HasValue) { method.methodID = methodID.Value; method.methodIDSpecified = true; } series.Method = method; } if (!String.IsNullOrEmpty(sourceDescription) || !String.IsNullOrEmpty(organization) || sourceID.HasValue) { SourceType source = new SourceType(); if (!String.IsNullOrEmpty(sourceDescription) || !String.IsNullOrEmpty(organization) ) { source.SourceDescription = sourceDescription; source.Organization = organization; } if (sourceID.HasValue) { source.sourceID = sourceID.Value; source.sourceIDSpecified = true; } series.Source = source; } return series; }
public ValuesDataSet getValuesDataset(int? siteId, int? variableId, W3CDateTime? BeginDateTime, W3CDateTime? EndDateTime) { ValuesDataSet valuesDs; if (!variableId.HasValue && !BeginDateTime.HasValue && !EndDateTime.HasValue) { valuesDs = ODValues.GetValuesDataSet(siteId.Value); } else if (!variableId.HasValue && BeginDateTime.HasValue && EndDateTime.HasValue) { valuesDs = ODValues.GetValuesDataSet(siteId.Value, BeginDateTime.Value, EndDateTime.Value); } else if (variableId.HasValue && !BeginDateTime.HasValue && !EndDateTime.HasValue) { valuesDs = ODValues.GetValuesDataSet(siteId, variableId); } else if (variableId.HasValue && BeginDateTime.HasValue && !EndDateTime.HasValue) { EndDateTime = W3CDateTime.Now; valuesDs = ODValues.GetValuesDataSet(siteId, variableId, BeginDateTime.Value, EndDateTime.Value // set above ); } else if (variableId.HasValue && !BeginDateTime.HasValue && EndDateTime.HasValue) { BeginDateTime = W3CDateTime.Parse(ConfigurationManager.AppSettings["MinimalSQLDate"]); valuesDs = ODValues.GetValuesDataSet(siteId, variableId, BeginDateTime.Value, // set above EndDateTime.Value ); } else { valuesDs = ODValues.GetValuesDataSet(siteId, variableId, BeginDateTime.Value, EndDateTime.Value ); } return valuesDs; }
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 GetTimeSeries( locationParam Location, VariableParam Variable, W3CDateTime?BeginDateTime, W3CDateTime?EndDateTime) { string siteNum; string parameterCode; string statisticCode; string agencyCode = "USGS"; W3CDateTime startDateTime; W3CDateTime endDateTime; if (Location.isGeometry) { throw new WaterOneFlowException("Geometry not supported "); } if (Location != null) { siteNum = Location.SiteCode; agencyCode = option2AgencyCode(Location); } else { throw new WaterOneFlowException("Missing SiteCode "); } if (Variable != null) { parameterCode = Variable.Code; statisticCode = option2UsgsStatCode(Variable); //agencyCode = option2AgencyCode(Variable); } else { throw new WaterOneFlowException("Missing Parameter "); } W3CDateTime startMinDate = W3CDateTime.Now.AddDays(-maxRequestDays); startDateTime = startMinDate; if (BeginDateTime.HasValue) { startDateTime = BeginDateTime.Value; if (startDateTime <= startMinDate) { startDateTime = startMinDate; } } W3CDateTime endDateMax = W3CDateTime.Now; endDateTime = endDateMax; if (EndDateTime.HasValue) { endDateTime = EndDateTime.Value; if (endDateTime >= endDateMax) { endDateTime = endDateMax; } } if (endDateTime < W3CDateTime.Now.AddDays(-maxRequestDays)) { throw new WaterOneFlowException("Only Properties.Settings.Default.UVDaysAvailable days back is supported in the NWIS UV service"); } if (endDateTime < startDateTime) { endDateTime = W3CDateTime.Now; } //TimeSpan span = endDateTime - startDateTime; //if (span.Days > 31 ) //{ // span = new TimeSpan(31, 0, 0); //} //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}"; /* 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 urlFormat = "{0}?sites={1}¶meterCd={2}&startDT={3}&endDT={4}"; string url = string.Format(urlFormat, USGSUVBaseUrl, locationToUvRest(Location), parameterCode, startDateTime.ToString("W"), // startDateTime.ToString("yyyy-MM-dd"), endDateTime.ToString("W") // endDateTime.ToString("yyyy-MM-dd") ); try { Uri uri = new Uri(url); using (WebClient web = new WebClient()) { TimeSeriesResponseType response; using (XmlReader reader = new XmlTextReader(web.OpenRead(url))) { XmlWriter writer = null; MemoryStream memoryStream = new MemoryStream(); try { writer = XmlWriter.Create(memoryStream); // Create the XsltArgumentList. XsltArgumentList argList = new XsltArgumentList(); argList.AddParam("network", "", Location.Network); argList.AddParam("vocabulary", "", Variable.Vocabulary); argList.AddParam("location", "", Location.ToString()); argList.AddParam("variable", "", Variable.ToString()); argList.AddParam("starttime", "", startDateTime.ToString("W")); argList.AddParam("endtime", "", endDateTime.ToString("W")); xslt.Transform(reader, argList, writer); memoryStream.Position = 0; using (var reader2 = XmlReader.Create(memoryStream)) { response = (TimeSeriesResponseType)serializer.Deserialize(reader2); } } finally { memoryStream.Close(); } } //TimeSeriesResponseType response // = new Passthrough(web.OpenRead(url)); return(response); } } catch (WebException ex) { if (ex.Response is HttpWebResponse) { switch (((HttpWebResponse)ex.Response).StatusCode) { case HttpStatusCode.NotFound: log.Info("USGS Not Found" + ex.Message); throw new WaterOneFlowSourceException("USGS Site/Variable combination Not Found"); break; case HttpStatusCode.ServiceUnavailable: log.Info("USGS Service Not Available " + ex.Message); throw new WaterOneFlowSourceException("USGS Service Not Available. Please try later"); break; default: log.Info("USGS Connection Error " + ex.Message); throw new WaterOneFlowSourceException("Error connecting to USGS"); } } log.Info("USGS Connection Error " + ex.Message); throw new WaterOneFlowSourceException("Error connecting to USGS: WebException: " + url); } catch (XmlException ex) { log.Info("Error in communication with USGS " + ex.Message); throw new WaterOneFlowSourceException("Error in communication with USGS: XmlExpcetion "); } catch (XsltException ex) { log.Info("Error in communication with USGS " + ex.Message); throw new WaterOneFlowSourceException("Error in communication with USGS: XsltException "); } catch (Exception ex) { log.Info("Error in communication with USGS " + ex.Message); throw new WaterOneFlowSourceException("Error in communication with USGS: Unknown Exception "); } }
public TimeSeriesResponseType getValues(string SiteNumber, string Variable, string StartDate, string EndDate) { // convert dates // get site info // get site ID // return value dataset TimeSeriesResponseType response; W3CDateTime? BeginDateTime; W3CDateTime? EndDateTime; int?variableId = null; int?siteID; VariableInfoType varInfoType = null; SiteInfoType siteType = null; if (!String.IsNullOrEmpty(StartDate)) { try { BeginDateTime = W3CDateTime.Parse(StartDate); } catch { throw new WaterOneFlowException("Improper BeginDate '" + StartDate + "' Must be YYYY-MM-DD"); } } else { BeginDateTime = null; } if (!String.IsNullOrEmpty(EndDate)) { try { EndDateTime = W3CDateTime.Parse(EndDate); } catch { throw new WaterOneFlowException("Improper EndDate '" + EndDate + "' Must be YYYY-MM-DD"); } } else { EndDateTime = null; } VariableParam vp; if (Variable != null) { vp = new VariableParam(Variable); VariableInfoType[] v = ODvariables.getVariable(vp, variableDs); if (v != null && v.Length > 0) { variableId = Convert.ToInt16(v[0].variableCode[0].variableID); varInfoType = v[0]; } else { throw new WaterOneFlowException("Variable parameter not found: " + Variable); } } else { throw new WaterOneFlowException("Variable parameter is required "); } locationParam sq; sq = new locationParam(SiteNumber); if (sq.isGeometry) { throw new WaterOneFlowException("Location by Geometry not accepted: " + SiteNumber); } siteInfoDataSet sitDs = ODSiteInfo.GetSiteInfoDataSet(sq); if (sitDs != null && sitDs.sites.Count > 0) { siteID = sitDs.sites[0].SiteID; ValuesDataSet valuesDs = getValuesDataset(siteID, variableId, BeginDateTime, EndDateTime, vp); response = getValues(valuesDs, vp); // above is the values, add the site, and variables response.timeSeries.variable = varInfoType; if (varInfoType != null) { if (varInfoType.units != null) { response.timeSeries.values.unitsAbbreviation = varInfoType.units.unitsAbbreviation; response.timeSeries.values.unitsCode = varInfoType.units.unitsCode; if (varInfoType.units.unitsType != null) { response.timeSeries.values.unitsType = varInfoType.units.unitsType; response.timeSeries.values.unitsTypeSpecified = true; } response.timeSeries.values.unitsAreConverted = false; } } response.timeSeries.sourceInfo = ODSiteInfo.row2SiteInfoElement(sitDs.sites[0], sitDs); } else { response = CuahsiBuilder.CreateTimeSeriesObject(); } // add query info response.queryInfo.creationTime = DateTime.UtcNow; //response.queryInfo.creationTime = DateTimeOffset.UtcNow; response.queryInfo.creationTimeSpecified = true; response.queryInfo.criteria.locationParam = SiteNumber; response.queryInfo.criteria.variableParam = Variable; response.queryInfo.criteria.timeParam = CuahsiBuilder.createQueryInfoTimeCriteria(StartDate, EndDate); NoteType sourceNote = CuahsiBuilder.createNote("OD Web Service"); response.queryInfo.note = CuahsiBuilder.addNote(response.queryInfo.note, sourceNote); return(response); }
public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset) { int variableID = row.VariableID; VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds); Nullable <W3CDateTime> beginDateTime = null; if (!row.IsBeginDateTimeNull()) { TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC); beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan); } Nullable <W3CDateTime> endDateTime = null; if (!row.IsEndDateTimeNull()) { TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC); endDateTime = new W3CDateTime(row.EndDateTime, timeSpan); } Nullable <int> valueCount = null; if (!row.IsValueCountNull()) { valueCount = row.ValueCount; } string qualityControlLevelTerm = null; int? QualityControlLevelid = null; if (!row.IsQualityControlLevelIDNull()) { QualityControlLevelid = row.QualityControlLevelID; ControlledVocabularyDataset.QualityControlLevelsRow qcRow = vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value); if (qcRow != null) { qualityControlLevelTerm = qcRow.Definition; } } int?MethodID = null; if (!row.IsMethodIDNull()) { MethodID = row.MethodID; } int?SourceID = null; if (!row.IsSourceIDNull()) { SourceID = row.SourceID; } Nullable <Boolean> valueCountIsEstimated = false; /* public static seriesCatalogTypeSeries createSeriesCatalogRecord( * VariableInfoType variable, * string sampleMedium, * Nullable<W3CDateTime> beginDateTime, * Nullable<W3CDateTime> endDateTime, * Nullable<int> valueCount, * Nullable<Boolean> valueCountIsEstimated, * string dataType, * string valueType, * string generalCategory * ) */ seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord( variable, variable.sampleMedium.ToString(), beginDateTime, endDateTime, valueCount, valueCountIsEstimated, null, null, null, false, // real time null, // string if real time row.QualityControlLevelCode, QualityControlLevelid, row.MethodDescription, MethodID, row.Organization, row.SourceDescription, SourceID, row.Citation, true, // include UTC Time qualityControlLevelTerm ); return(record); }
public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset) { int variableID = row.VariableID; VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds); Nullable<W3CDateTime> beginDateTime = null; if (!row.IsBeginDateTimeNull()) { TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC); beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan); } Nullable<W3CDateTime> endDateTime = null; if (!row.IsEndDateTimeNull()) { TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC); endDateTime = new W3CDateTime(row.EndDateTime, timeSpan); } Nullable<int> valueCount = null; if (!row.IsValueCountNull()) valueCount = row.ValueCount; string qualityControlLevelTerm = null; int? QualityControlLevelid = null; if (!row.IsQualityControlLevelIDNull()) { QualityControlLevelid = row.QualityControlLevelID; ControlledVocabularyDataset.QualityControlLevelsRow qcRow = vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value); if (qcRow != null ) { qualityControlLevelTerm = qcRow.Definition; } } int? MethodID = null; if (!row.IsMethodIDNull()) MethodID = row.MethodID; int? SourceID = null; if (!row.IsSourceIDNull()) SourceID = row.SourceID; Nullable<Boolean> valueCountIsEstimated = false; /* public static seriesCatalogTypeSeries createSeriesCatalogRecord( VariableInfoType variable, string sampleMedium, Nullable<W3CDateTime> beginDateTime, Nullable<W3CDateTime> endDateTime, Nullable<int> valueCount, Nullable<Boolean> valueCountIsEstimated, string dataType, string valueType, string generalCategory ) */ seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord( variable, variable.sampleMedium.ToString(), beginDateTime, endDateTime, valueCount, valueCountIsEstimated, null, null, null, false, // real time null, // string if real time row.QualityControlLevelCode, QualityControlLevelid, row.MethodDescription, MethodID, row.Organization, row.SourceDescription, SourceID, row.Citation, true, // include UTC Time qualityControlLevelTerm ); return record; }
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 static seriesCatalogTypeSeries CreateSeriesRecord(VariableInfoType variable, string sampleMedium, W3CDateTime? beginDateTime, W3CDateTime? endDateTime, int? valueCount, bool? valueCountIsEstimated, string dataType, string valueType, string generalCategory, bool realTime, string realTimeInterval, string qualityControlLevelCode, int? qualityControlLevelid, string methodName, int? methodID, string organization, string sourceDescription, int? sourceID, string citation) { return CreateSeriesRecord(variable, sampleMedium, beginDateTime, endDateTime, valueCount, valueCountIsEstimated, dataType, valueType, generalCategory, realTime, realTimeInterval, qualityControlLevelCode, qualityControlLevelid, methodName, methodID, organization, sourceDescription, sourceID, citation, false, null); }
//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); } }
private static seriesCatalogTypeSeries row2Series(UsgsDbDailyValues.seriesCatalogRow aRow) { if (aRow.IsVariableCodeNull()) { return(null); } string VariableCode = aRow.VariableCode; string VariableName = null; string VariableUnitName = null; string VariableUnitAbrreviation = null; string VariableUnitCode = null; string sampleMedium = null; string dataType = null; string valueType = null; string generalCategory = null; W3CDateTime?beginDateTime = null, endDateTime = null; int? valueCount = null; bool? valueCountIsEstimated = null; int? TimeInterval = null; string TimeIntervalUnits = null; bool isRealTime = false; string QualityControlLevelTerm = null; string methodName = null; string organization = null; string sourceDescription = null; if (!aRow.IsVariableNameNull()) { VariableName = aRow.VariableName; } if (!aRow.IsVariableUnitsAbbreviationNull()) { VariableUnitAbrreviation = aRow.VariableUnitsAbbreviation; } if (!aRow.IsVariableUnitsNameNull()) { VariableUnitName = aRow.VariableUnitsName; } if (!aRow.IsDataTypeNull()) { dataType = aRow.DataType; } if (!aRow.IsValueTypeNull()) { valueType = aRow.ValueType; } if (!aRow.IsGeneralCategoryNull()) { generalCategory = aRow.GeneralCategory; } if (!aRow.IsSampleMediumNull()) { sampleMedium = aRow.SampleMedium; } if (!aRow.IsMethodNameNull()) { methodName = aRow.MethodName; } if (!aRow.IsSourceDescriptionNull()) { sourceDescription = aRow.SourceDescription; } if (!aRow.IsOrganizationNull()) { organization = aRow.Organization; } if (!aRow.IsValueCountNull()) { int v; if (Int32.TryParse(aRow.ValueCount, out v)) { valueCount = v; } } if (!aRow.IsBeginDateTimeNull()) { beginDateTime = new W3CDateTime(aRow.BeginDateTime); } if (!aRow.IsEndDateTimeNull()) { endDateTime = new W3CDateTime(aRow.EndDateTime); } if (!aRow.IsTimeSupportNull()) { TimeInterval = aRow.TimeSupport; if (!aRow.IsTimeUnitsNameNull()) { TimeIntervalUnits = aRow.TimeUnitsName; } } // public static seriesCatalogTypeSeries CreateSeriesRecord( // string VariableCode, // string VariableName, // string VariableUnitName, // string VariableUnitAbrreviation, // string VariableUnitCode, // string sampleMedium, // string dataType, // string valueType, // string generalCategory, // W3CDateTime? beginDateTime, W3CDateTime? endDateTime, // int? valueCount, bool? valueCountIsEstimated, // string TimeInterval, // string TimeIntervalUnits, // bool isRealTime, // string QualityControlLevelTerm, // string methodName, // string organization, string sourceDescription //) seriesCatalogTypeSeries aSeries = CoreBuilder.CreateSeriesRecord( VariableCode, VariableName, VariableUnitName, VariableUnitAbrreviation, VariableUnitCode, sampleMedium, dataType, valueType, generalCategory, beginDateTime, endDateTime, valueCount, valueCountIsEstimated, TimeInterval, TimeIntervalUnits, isRealTime, QualityControlLevelTerm, methodName, organization, sourceDescription, "NWIS"); // add usgs statistic code options if (!aRow.Isusgs_stat_cdNull()) { List <option> opts = new List <option>(1); option opt = new option(); opt.name = "statistic"; opt.optionCode = aRow.usgs_stat_cd; opts.Add(opt); aSeries.variable.options = opts.ToArray(); } return(aSeries); }
public override string ToString() { var _strBuilder = new StringBuilder(); //field[0]: Connected Call length var _length = leg2End.Subtract(leg2Start.ToLocalTime()); _strBuilder.Append(_length.TotalSeconds.ToString("0")); _strBuilder.Append("|"); //field[1]: Start Time var _w3CDateTime = new W3CDateTime(callStart.ToLocalTime()); _strBuilder.Append(_w3CDateTime.ToString("X")); _strBuilder.Append("|"); //field[2]: Stop Time _w3CDateTime = new W3CDateTime(callEnd.ToLocalTime()); _strBuilder.Append(_w3CDateTime.ToString("X")); _strBuilder.Append("|"); //field[3]: OrigIPAddress _strBuilder.Append(origIPAddress); _strBuilder.Append(":5070"); //TODO: add real orig port _strBuilder.Append("|"); //field[4]: empty field: usually SIP user ID _strBuilder.Append("|"); //field[5]: DestIPAddress _strBuilder.Append(destIPAddress); _strBuilder.Append("|"); //field[6]: usually caller ID, we put SerialNumber _strBuilder.Append(string.Format("{0}{1}", SERIAL_NUMBER_PREFIX, SerialNumber)); _strBuilder.Append("|"); //field[7]: DestNumber _strBuilder.Append(DestNumber); _strBuilder.Append("|"); //field[8]: ANI _strBuilder.Append(string.Format("{0}{1}", ANI, ANI_SUFIX)); _strBuilder.Append("|"); //field[9]: empty field: usually GkID, we put DNIS _strBuilder.Append(string.Format("{0}{1}", DNIS_PREFIX, AccessNumber)); _strBuilder.Append("|"); //field[10]: RetailAccId _strBuilder.Append(RetailAcctId.ToString()); _strBuilder.Append("|"); //field[11]: CustomerId _strBuilder.Append(CustomerAcctId.ToString()); _strBuilder.Append("|"); //field[12]: CarrierId _strBuilder.Append(carrierAcctId.ToString()); _strBuilder.Append("|"); //field[13]: RouteId _strBuilder.Append(customerBaseRouteId.ToString()); _strBuilder.Append("|"); //field[14]: CarrierRouteID _strBuilder.Append(carrierBaseRouteId.ToString()); _strBuilder.Append("|"); //field[15]: DisconnectCause _strBuilder.Append(disconnectCause.ToString()); _strBuilder.Append("|"); //field[16]: DisconnectSource _strBuilder.Append(disconnectSource.ToString()); _strBuilder.Append("|"); //field[17]: RbrResult _strBuilder.Append(rbrResult.ToString()); _strBuilder.Append("|"); //field[18]: MappedDisconnectCause _strBuilder.Append(mappedDisconnectCause.ToString()); _strBuilder.Append("|"); //field[19]: InfoDigits _strBuilder.Append(InfoDigits.ToString("D2")); _strBuilder.Append(";"); return(_strBuilder.ToString()); }
public static seriesCatalogTypeSeries row2SeriesCatalogElement( seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds) { int variableID = row.VariableID; VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds); Nullable <W3CDateTime> beginDateTime = null; if (!row.IsBeginDateTimeNull()) { beginDateTime = new W3CDateTime(row.BeginDateTime); } Nullable <W3CDateTime> endDateTime = null; if (!row.IsEndDateTimeNull()) { endDateTime = new W3CDateTime(row.EndDateTime); } Nullable <int> valueCount = null; if (!row.IsValueCountNull()) { valueCount = row.ValueCount; } int?QualityControlLevelid = null; if (!row.IsQualityControlLevelIDNull()) { QualityControlLevelid = row.QualityControlLevelID; } int?MethodID = null; if (!row.IsMethodIDNull()) { MethodID = row.MethodID; } int?SourceID = null; if (!row.IsSourceIDNull()) { SourceID = row.SourceID; } Nullable <Boolean> valueCountIsEstimated = false; seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord( variable, variable.sampleMedium.ToString(), beginDateTime, endDateTime, valueCount, valueCountIsEstimated, null, null, null, false, // real time null, // string if real time null, QualityControlLevelid, row.MethodDescription, MethodID, row.Organization, row.SourceDescription, SourceID, row.Citation); return(record); }