public TimeSeriesResponse(string timeSeriesResponseTypeXml)
                {
                    TextReader    reader     = new StringReader(timeSeriesResponseTypeXml);
                    XmlSerializer serializer = WOFXmlSerializerFactory.GetSerializer(typeof(TimeSeriesResponseTypeObject));

                    responseObject = (TimeSeriesResponseTypeObject)serializer.Deserialize(reader);
                }
Example #2
0
            public override TimeSeriesResponseTypeGeneric GetValuesObject(string location, string variable, string startDate, string endDate, String authToken)
            {
                if (!useODForValues)
                {
                    throw new SoapException("GetValues implemented external to this service. Call GetSiteInfo, and SeriesCatalog includes the service Wsdl for GetValues. Attribute:serviceWsdl on Element:seriesCatalog XPath://seriesCatalog/[@serviceWsdl]", new XmlQualifiedName("ServiceException"));
                }

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

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

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


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

                    return(new xsd.TimeSeriesResponse(res));

                    //throw new NotImplementedException("Reimplement 1.1");
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                           location,                  //locaiton
                                           variable,                  //variable
                                           startDate,                 // startdate
                                           startDate,                 //enddate
                                           timer.ElapsedMilliseconds, // processing time
                                           -9999,                     // count
                                           Context.Request.UserHostName
                                           );
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
 void IXmlSerializable.ReadXml(XmlReader reader)
 {
     responseObject = (TimeSeriesResponseTypeObject)serializer.Deserialize(reader);
 }
 public TimeSeriesResponse(TimeSeriesResponseTypeObject timeSeriesResponseObject)
 {
     responseObject = timeSeriesResponseObject;
 }
                public TimeSeriesResponse(string timeSeriesResponseTypeXml)
                {
                    TextReader reader = new StringReader(timeSeriesResponseTypeXml);

                    responseObject = (TimeSeriesResponseTypeObject)serializer.Deserialize(reader);
                }
 public TimeSeriesResponse()
 {
     responseObject = null;
 }
Example #7
0
            public override object GetValuesObject(string location, string variable, string startDate, string endDate, String authToken)
            {
                if (!useODForValues)
                {
                    throw new SoapException("GetValues implemented external to this service. Call GetSiteInfo, and SeriesCatalog includes the service Wsdl for GetValues. Attribute:serviceWsdl on Element:seriesCatalog XPath://seriesCatalog/[@serviceWsdl]", new XmlQualifiedName("ServiceException"));
                }

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

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

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


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

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

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

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

                    //res.queryInfo.criteria = crit;


                    //return res;
                    return(new WaterOneFlow.Service.v1_0.xsd.TimeSeriesResponse(res));
                }
                catch (Exception we)
                {
                    log.Warn(we.Message);
                    queryLog2.LogValuesEnd(Logging.Methods.GetValues,
                                           location,                  //locaiton
                                           variable,                  //variable
                                           startDate,                 // startdate
                                           startDate,                 //enddate
                                           timer.ElapsedMilliseconds, // processing time
                                           -9999,                     // count
                                           Context.Request.UserHostName
                                           );
                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Example #8
0
            public override object GetValuesObject(string location, string variable, string startDate, string endDate, String authToken)
            {
                if (!useODForValues)
                {
                    throw new SoapException("GetValues implemented external to this service. Call GetSiteInfo, and SeriesCatalog includes the service Wsdl for GetValues. Attribute:serviceWsdl on Element:seriesCatalog XPath://seriesCatalog/[@serviceWsdl]", new XmlQualifiedName("ServiceException"));
                }

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

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

                try
                {
                    WaterOneFlowImpl.locationParam lParam = new locationParam(location);
                    VariableParam vparam = new VariableParam(variable);

                    /* 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);
                }
            }
                void IXmlSerializable.ReadXml(XmlReader reader)
                {
                    XmlSerializer serializer = WOFXmlSerializerFactory.GetSerializer(typeof(TimeSeriesResponseTypeObject));

                    responseObject = (TimeSeriesResponseTypeObject)serializer.Deserialize(reader);
                }