Пример #1
0
        // Return number of records inserted or found
        public static int HandleSiteInfo(SqlConnection sqlConn, SiteInfoResponseType rt)
        {
            SitesTableAdapter stAdapter = new SitesTableAdapter();

            stAdapter.Connection = sqlConn;
            SiteInfoType stinfo;

            OD_1_1_1DataSet.SitesDataTable tblSites = new OD_1_1_1DataSet.SitesDataTable();

            Console.WriteLine(">>>Parsing and inserting SITES");
            for (int i = 0; i < rt.site.Count(); i++)
            {
                stinfo = rt.site[i].siteInfo;
                try
                {
                    if (InsertOneSite(tblSites, stinfo, sqlConn))
                    {
                        stAdapter.Update(tblSites);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to insert site {0}, completed {1} of {2}: {3}.",
                                      stinfo.siteCode, i, rt.site.Count(), e.Message);
                    return(i);
                }
            }

            // PrintTable(stAdapter, tblSites);

            return(rt.site.Count());
        }
Пример #2
0
        public void testSiteInfo()
        {
            restServiceClient.PathFormat = "Meth={0}&site={1}";

            string siteCode = "01080"; // prep for many test

            Type vType = typeof(SiteInfoResponseType);

            restServiceClient.ResponseType = vType;
            parameters    = new string[2];
            parameters[0] = "GetSiteInfo";
            parameters[1] = siteCode;

            object res = restServiceClient.GetResponseAsObject(parameters);

            Assert.IsInstanceOfType(vType, res);
            SiteInfoResponseType response = (SiteInfoResponseType)res;

            Assert.That(response.site.Length == 1, "Should only return 1 site");
            Assert.That(response.site[0].siteInfo.siteCode[0].Value == siteCode, "site code does not match");
            Assert.That(response.site[0].seriesCatalog != null, "missing series catalog");
            Assert.That(response.site[0].seriesCatalog.Length > 0, " no entries in  series catalog");
            Assert.That(response.site[0].seriesCatalog[0].series.Length > 0, " no entries in  series catalog");
            Assert.That(response.site[0].seriesCatalog[0].series[0].variable != null, " mising variable in frist entry");
            //Assert.That(response.site[0].seriesCatalog[0].series[0].variableTimeInterval != null, " no time period is specified");
            //Assert.That(response.site[0].seriesCatalog[0].series[0].valueCount != null, " no value count is specified");
        }
Пример #3
0
        public virtual string GetSiteInfo(string SiteNumber, String authToken)
        {
            SiteInfoResponseType aSite = GetSiteInfoObject(SiteNumber, null);
            string xml = WSUtils.ConvertToXml(aSite, typeof(SiteInfoResponseType));

            return(xml);
        }
Пример #4
0
            public SiteInfoResponseType GetSites(string[] locationParameters, Boolean includeSeries)
            {
                locationParameters = WSUtils.removeEmptyStrings(locationParameters);

                List <locationParam> siteCodes = new List <locationParam>(locationParameters.Length);

                foreach (String s in locationParameters)
                {
                    locationParam lp = new locationParam(s);
                    siteCodes.Add(lp);
                }
                SiteInfoType[]       sites  = ODSiteInfo.GetSitesByLocationParameters(siteCodes.ToArray());
                SiteInfoResponseType result = CreateSitesResponse(sites, includeSeries);

                if (locationParameters.Length == 0)
                {
                    result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites");
                    NoteType note = CuahsiBuilder.createNote("ALL Sites(empty request)");
                    result.queryInfo.note = CuahsiBuilder.addNote(null, note);
                }
                else
                {
                    result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites", locationParameters, null, null, null, null);
                }
                return(result);
            }
Пример #5
0
        public string GetSites(string[] SiteNumbers, String authToken)
        {
            SiteInfoResponseType aSite = GetSitesObject(SiteNumbers, null);
            string xml = WSUtils.ConvertToXml(aSite, typeof(SiteInfoResponseType));

            return(xml);
        }
Пример #6
0
        private int SiteData(L1HarvestList series)
        {
            this.ws.Url = series.WebServiceURL;

            // save siteInfo
            SiteInfoResponseType responsesite = this.ws.GetSiteInfoObject(series.SiteCode, string.Empty);
            SiteInfoType         site         = responsesite.site[0].siteInfo;
            LatLonPointType      latlon       = (LatLonPointType)site.geoLocation.geogLocation;
            int localx = site.geoLocation.localSiteXY == null ? 0 : (int)site.geoLocation.localSiteXY[0].X; /*(int)DBNull.Value*/
            int localy = site.geoLocation.localSiteXY == null ? 0 : (int)site.geoLocation.localSiteXY[0].Y;

            string state  = string.Empty;
            string county = string.Empty;

            if (site.siteProperty != null)
            {
                foreach (PropertyType s in site.siteProperty)
                {
                    if (s.name == "State")
                    {
                        state = s.Value;
                    }
                    else if (s.name == "County")
                    {
                        county = s.Value;
                    }
                }
            }

            return(this.db.TooDB.SaveSite(site.siteCode[0].Value, site.siteName.ToString(), Convert.ToDouble(latlon.longitude), Convert.ToDouble(latlon.latitude), 0, Convert.ToDouble(site.elevation_m), site.verticalDatum, localx, localy, 0, 0, state, county /*"county"*/, string.Empty /*"comments"*/, series.SiteType));
        }
Пример #7
0
            public SiteInfoResponseType GetSitesInBox(
                float west, float south, float east, float north,
                Boolean IncludeSeries
                )
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                box queryBox = new box(west, south, east, north);

                queryLog2.LogStart(CustomLogging.Methods.GetSitesInBoxObject, queryBox.ToString(),
                                   appContext.Request.UserHostName);

                SiteInfoResponseType resp = new SiteInfoResponseType();

                resp.site = WebServiceUtils.GetSitesByBox(queryBox, IncludeSeries);

                //set query info
                resp.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSitesInBox");
                NoteType note = CuahsiBuilder.createNote("box");

                resp.queryInfo.note = CuahsiBuilder.addNote(null, note);

                queryLog2.LogEnd(CustomLogging.Methods.GetSitesInBoxObject,
                                 queryBox.ToString(),
                                 timer.ElapsedMilliseconds.ToString(),
                                 resp.site.Length.ToString(),
                                 appContext.Request.UserHostName);
                return(resp);
            }
Пример #8
0
            public SiteInfoResponseType GetSites(string[] locationIDs)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogStart(CustomLogging.Methods.GetSites, locationIDs.ToString(),
                                   appContext.Request.UserHostName);

                SiteInfoResponseType result = new SiteInfoResponseType();

                result.site = WebServiceUtils.GetSitesFromDb();

                //set query info
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites");
                NoteType note = CuahsiBuilder.createNote("ALL Sites(empty request)");

                result.queryInfo.note = CuahsiBuilder.addNote(null, note);

                queryLog2.LogEnd(CustomLogging.Methods.GetSites,
                                 locationIDs.ToString(),
                                 timer.ElapsedMilliseconds.ToString(),
                                 result.site.Length.ToString(),
                                 appContext.Request.UserHostName);

                return(result);
            }
        private SiteInfoResponseType createSiteInfoResponse(locationParam[] LocationParameters)
        {
            /* for each site code, add a siteInfo type with a period of record
             * for each site
             *     createSitInfoType
             *     add to response
             *     createPeriodOfRecord
             *     add to response
             * return response
             * */
            SiteInfoResponseType response = CuahsiBuilder.CreateASetOfSiteResponses(LocationParameters.Length, 1);

            for (int i = 0; i < LocationParameters.Length; i++)
            {
                if (LocationParameters[i] == null)
                {
                    continue;
                }

                response.site[i].siteInfo = getSiteInfoType(LocationParameters[i]);
                if (response.site[i].siteInfo != null)
                {
                    String aSiteID = null;

                    Nullable <int> siteIDint = null;
                    try
                    {
                        aSiteID = response.site[i].siteInfo.siteCode[0].siteID;
                    }
                    catch (NullReferenceException e)
                    {
                        String error = " no site code returned for sitecode" + LocationParameters[i];
                        log.Warn(error);
                        response.site[i].seriesCatalog = CreateSeriesCatalogRecord(LocationParameters[i], null);
                    }

                    try
                    {
                        siteIDint = Convert.ToInt32(aSiteID);
                        response.site[i].seriesCatalog = CreateSeriesCatalogRecord(LocationParameters[i], siteIDint);
                    }
                    catch (InvalidCastException e)
                    {
                        String error = " siteID was not an integer" + LocationParameters[i];
                        log.Warn(error);
                        response.site[i].seriesCatalog = CreateSeriesCatalogRecord(LocationParameters[i], null);
                    }
                }
                else
                {
                    String error = " no site code returned for sitecode" + LocationParameters[i];
                    log.Warn(error);
                }
            }

            return(response);
        }
Пример #10
0
            public SiteInfoResponseType GetSiteInfoResponse(locationParam[] LocationParameters, Boolean IncludeSeries)
            {
                SiteInfoResponseType result = createSiteInfoResponse(LocationParameters, IncludeSeries);

                string[] lps = Array.ConvertAll <locationParam, string>(LocationParameters, Convert.ToString);
                //result.queryInfo = CreateQueryInfo(lps);
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", lps, null, null, null, null);

                return(result);
            }
Пример #11
0
        public SiteInfoResponseType GetSiteInfo(string locationParameter)
        {
            Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

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

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

            SiteInfoResponseType resp = getSiteInfo.GetSiteInfo(lp);

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

            return(resp);
        }
Пример #12
0
            public SiteInfoResponseType GetSiteInfo(string locationParameter)
            {
                string siteId = locationParameter.Substring(locationParameter.LastIndexOf(":") + 1);

                SiteInfoResponseType resp = new SiteInfoResponseType();

                resp.site    = new SiteInfoResponseTypeSite[1];
                resp.site[0] = new SiteInfoResponseTypeSite();
                resp.site[0] = WebServiceUtils.GetSiteFromDb(siteId, true);

                resp.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", new string[] { locationParameter }, null, null, null, null);

                return(resp);
            }
Пример #13
0
        public static SiteInfoResponseType ReadSiteInfoObject(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }

            BinaryFormatter formatter = new BinaryFormatter();

            using (FileStream s = File.OpenRead(fileName))
            {
                SiteInfoResponseType rt = (SiteInfoResponseType)formatter.Deserialize(s);
                return(rt);
            }
        }
Пример #14
0
            public SiteInfoResponseType GetSitesByBox(box queryBox, Boolean includeSeries)
            {
                IEnumerable <SiteInfoType> sites  = ODSiteInfo.GetSitesByBox(queryBox);
                SiteInfoResponseType       result = CreateSitesResponse(sites, includeSeries);

                // result.queryInfo = CreateQueryInfo(new string[] { queryBox.ToString() });
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSitesByBox");
                CuahsiBuilder.AddQueryInfoParameter(result.queryInfo, "north", queryBox.North.ToString());
                CuahsiBuilder.AddQueryInfoParameter(result.queryInfo, "south", queryBox.South.ToString());
                CuahsiBuilder.AddQueryInfoParameter(result.queryInfo, "east", queryBox.East.ToString());
                CuahsiBuilder.AddQueryInfoParameter(result.queryInfo, "west", queryBox.West.ToString());
                CuahsiBuilder.AddQueryInfoParameter(result.queryInfo, "includeSeries", includeSeries.ToString());

                return(result);
            }
Пример #15
0
            public override SiteInfoType[] GetSiteInfoObjects(locationParam[] sites)
            {
                BaseRestClient restServiceClient = GetNewBaseClient();

                string[] parameters;
                Type     vType = typeof(SiteInfoResponseType);

                restServiceClient.ResponseType = vType;

                if (sites == null || sites.Length == 0)
                {
                    restServiceClient.PathFormat = "Meth={0}";
                    parameters    = new string[1];
                    parameters[0] = "GetSiteInfo";
                }
                else
                {
                    restServiceClient.PathFormat = "Meth={0}";
                    int len = sites.Length;
                    parameters    = new string[sites.Length + 1];
                    parameters[0] = "GetSiteInfo";
                    for (int i = 0; i < sites.Length; i++)
                    {
                        parameters[i + 1]             = sites[i].SiteCode;
                        restServiceClient.PathFormat += "&sid={" + i + 1 + "}";
                    }
                }


                object res = restServiceClient.GetResponseAsObject(parameters);


                SiteInfoResponseType response = (SiteInfoResponseType)res;

                if (response != null && response.site != null)
                {
                    List <SiteInfoType> siteInfoTypes = new List <SiteInfoType>();
                    foreach (site s in response.site)
                    {
                        siteInfoTypes.Add(s.siteInfo);
                    }
                    return(siteInfoTypes.ToArray());
                }
                else
                {
                    throw new WaterOneFlowSourceException("No Sites Returned");
                }
            }
            /// <summary>
            /// Creates a set of site responses.
            /// </summary>
            /// <param name="numberOfSites">The number of sites.</param>
            /// <param name="numberOfLocationsPerSite">The number of locations.</param>
            /// <returns></returns>
            public static SiteInfoResponseType CreateASetOfSiteResponses(int numberOfSites, int numberOfLocationsPerSite)
            {
                SiteInfoResponseType aSite = new SiteInfoResponseType();
                aSite.queryInfo = new QueryInfoType();
                aSite.queryInfo.criteria = new QueryInfoTypeCriteria();
                // can we set up as a list, and cast to array later?
                aSite.site = new site[numberOfSites];
                for (int count = 0; count < numberOfSites; count++)
                {
                aSite.site[count] = new site();

                aSite.site[count].siteInfo = CreateASiteInfoTypeWithLatLongPoint(numberOfLocationsPerSite);

                }
                return aSite;
            }
Пример #17
0
            /// <summary>
            /// Creates a set of site responses.
            /// </summary>
            /// <param name="numberOfSites">The number of sites.</param>
            /// <param name="numberOfLocationsPerSite">The number of locations.</param>
            /// <returns></returns>
            public static SiteInfoResponseType CreateASetOfSiteResponses(int numberOfSites, int numberOfLocationsPerSite)
            {
                SiteInfoResponseType aSite = new SiteInfoResponseType();

                aSite.queryInfo          = new QueryInfoType();
                aSite.queryInfo.criteria = new QueryInfoTypeCriteria();
                // can we set up as a list, and cast to array later?
                aSite.site = new site[numberOfSites];
                for (int count = 0; count < numberOfSites; count++)
                {
                    aSite.site[count] = new site();

                    aSite.site[count].siteInfo = CreateASiteInfoTypeWithLatLongPoint(numberOfLocationsPerSite);
                }
                return(aSite);
            }
Пример #18
0
            public SiteInfoResponseType GetSites(string[] locationIDs)
            {
                Stopwatch     timer = System.Diagnostics.Stopwatch.StartNew();
                GetSiteInfoOD obj   = new GetSiteInfoOD();


                queryLog2.LogStart(Logging.Methods.GetSites, locationIDs.ToString(),
                                   appContext.Request.UserHostName);

                SiteInfoResponseType resp = obj.GetSites(locationIDs, false);

                queryLog2.LogEnd(Logging.Methods.GetSites,
                                 locationIDs.ToString(),
                                 timer.ElapsedMilliseconds.ToString(),
                                 resp.site.Length.ToString(),
                                 appContext.Request.UserHostName);

                return(resp);
            }
Пример #19
0
            public override seriesCatalogType[] GetSeries(locationParam site, TimeSeriesTypeEnum seriesType)
            {
                BaseRestClient restServiceClient = GetNewBaseClient();

                string[] parameters;
                Type     vType = typeof(SiteInfoResponseType);

                restServiceClient.ResponseType = vType;

                if (site != null)
                {
                    restServiceClient.PathFormat = "Meth={0}&site={1}";
                    parameters    = new string[2];
                    parameters[0] = "GetSiteInfo";
                    parameters[1] = site.SiteCode;
                }
                else
                {
                    return(null);
                }

                object res = restServiceClient.GetResponseAsObject(parameters);


                SiteInfoResponseType response = (SiteInfoResponseType)res;

                if (response != null && response.site != null)
                {
                    WaterOneFlow.Schema.v1.site s = response.site[0];
                    if (s.seriesCatalog != null)
                    {
                        return(s.seriesCatalog);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    throw new WaterOneFlowSourceException("No Site Returned");
                }
            }
        public SiteInfoResponseType GetSites(string[] locationParameters)
        {
            XmlDocument XMLResponse = new XmlDocument();

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

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

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


            return(result);
        }
Пример #21
0
        public void testSitesAll()
        {
            restServiceClient.PathFormat = "Meth={0}&sites={1}";

            string varCode = "ALL"; // prep for many test

            Type vType = typeof(SiteInfoResponseType);

            restServiceClient.ResponseType = vType;
            parameters    = new string[2];
            parameters[0] = "GetSites";
            parameters[1] = varCode;

            object res = restServiceClient.GetResponseAsObject(parameters);

            Assert.IsInstanceOfType(vType, res);
            SiteInfoResponseType response = (SiteInfoResponseType)res;

            Assert.That(response.site.Length > 0, "No sites returned");
        }
Пример #22
0
        public void testSites()
        {
            restServiceClient.PathFormat = "Meth={0}&site={1}";

            string siteCode = "01080"; // prep for many test

            Type vType = typeof(SiteInfoResponseType);

            restServiceClient.ResponseType = vType;
            parameters    = new string[2];
            parameters[0] = "GetSites";
            parameters[1] = siteCode;

            object res = restServiceClient.GetResponseAsObject(parameters);

            Assert.IsInstanceOfType(vType, res);
            SiteInfoResponseType response = (SiteInfoResponseType)res;

            Assert.That(response.site.Length == 1, "Should only return 1 site");
            Assert.That(response.site[0].siteInfo.siteCode[0].Value == siteCode, "site code does not match");
        }
        public SiteInfoResponseType GetSiteInfo(locationParam locationParameter)
        {
            string Network;
            string SiteCode;

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

            // put a no result check here
            result.queryInfo.criteria.locationParam = locationParameter.ToString(); // to string returns orignal string
            if (result.site[0].siteInfo != null)
            {
                result.site[0].siteInfo.siteCode[0].network =
                    System.Configuration.ConfigurationManager.AppSettings["network"];
            }
            else
            {
                // we only have one site... so throw the exception
                throw new WaterOneFlowException("Site '" + locationParameter.ToString() + "' Not Found");
            }
            return(result);
        }
Пример #24
0
            public SiteInfoResponseType GetSitesInBox(
                float west, float south, float east, float north,
                Boolean IncludeSeries
                )
            {
                Stopwatch     timer = System.Diagnostics.Stopwatch.StartNew();
                GetSiteInfoOD obj   = new GetSiteInfoOD();

                box queryBox = new box(west, south, east, north);

                queryLog2.LogStart(Logging.Methods.GetSitesInBoxObject, queryBox.ToString(),
                                   appContext.Request.UserHostName);

                SiteInfoResponseType resp = obj.GetSitesByBox(queryBox, IncludeSeries);

                queryLog2.LogEnd(Logging.Methods.GetSitesInBoxObject,
                                 queryBox.ToString(),
                                 timer.ElapsedMilliseconds.ToString(),
                                 resp.site.Length.ToString(),
                                 appContext.Request.UserHostName);
                return(resp);
            }
Пример #25
0
            private SiteInfoResponseType createSiteInfoResponse(locationParam[] LocationParameters, Boolean IncludeSeries)
            {
                // WSUtils.removeEmptyStrings(LocationParameters);

                /* for each site code, add a siteInfo type with a period of record
                 * // for each site
                 *     createSitInfoType
                 *     add to response
                 *     createPeriodOfRecord
                 *     add to response
                 * return response
                 * */
                SiteInfoResponseType response = CuahsiBuilder.CreateASetOfSiteResponses(LocationParameters.Length, 1);
                List <locationParam> lpList   = new List <locationParam>(LocationParameters);

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

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

                response.site = sitesList.ToArray();

                return(response);
            }
Пример #26
0
        /// <summary>
        /// saves or gathers site information  SiteData
        /// </summary>
        /// <param name="series">object from the database that contains all the details of the series we are trying to gather data for</param>
        /// <returns>the SiteId from the database</returns>
        private int SiteData(L1HarvestList series)
        {
            SiteInfoType site;

            this.ws.Url = series.WebServiceURL;
            try
            {
                // save siteInfo
                SiteInfoResponseType responsesite = this.ws.GetSiteInfoObject(series.SiteCode, string.Empty);
                site = responsesite.site[0].siteInfo;
            }
            catch
            {
                TimeSeriesResponseType response = this.ws.GetValuesObject(series.SiteCode, series.VariableCode, "1900-01-01", "1900-01-01", string.Empty);
                site = (SiteInfoType)response.timeSeries.sourceInfo; // site[0].siteInfo;
            }

            LatLonPointType latlon = (LatLonPointType)site.geoLocation.geogLocation;
            int             localx = site.geoLocation.localSiteXY == null ? 0 : (int)site.geoLocation.localSiteXY[0].X; /*(int)DBNull.Value*/
            int             localy = site.geoLocation.localSiteXY == null ? 0 : (int)site.geoLocation.localSiteXY[0].Y;

            // note 1 contains county information but not all sites contain a note 1.
            return(this.db.TooDB.SaveSite(site.siteCode[0].Value, site.siteName.ToString(), Convert.ToDouble(latlon.longitude), Convert.ToDouble(latlon.latitude), 0 /*lat long datum id*/, Convert.ToDouble(site.elevation_m), site.verticalDatum, localx, localy, 0 /*local projection id*/, 0 /*Position Accuracy*/, site.note[0].Value.Length == 2 ? site.note[0].Value : string.Empty /*"state"*/, string.Empty /*"county"*/, string.Empty /*"comments"*/, series.SiteType));
        }
Пример #27
0
            public SiteInfoResponseType GetSiteInfoResponse(locationParam locationParameter)
            {
                string Network;
                string SiteCode;

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

                // put a no result check here

                //result.queryInfo.criteria.locationParam = locationParameter.ToString(); // to string returns orignal string
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", new string[] { locationParameter.ToString() }, null, null, null, null);
                if (result.site[0].siteInfo != null)
                {
                    result.site[0].siteInfo.siteCode[0].network =
                        System.Configuration.ConfigurationManager.AppSettings["network"];
                }
                else
                {
                    // we only have one site... so throw the exception
                    //  result.queryInfo.note = CuahsiBuilder.addNote(result.queryInfo.note,CuahsiBuilder.createNote("Site not found"));
                    throw new WaterOneFlowException("Site '" + locationParameter.ToString() + "' Not Found");
                }
                return(result);
            }
            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 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);
                }
            }
Пример #30
0
            public override object GetSiteInfoObject(string site, String authToken)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

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

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

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

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

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

                        sit.queryInfo.criteria = crit;

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

                string siteListString;

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

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

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

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

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

                    sit.queryInfo.criteria = crit;


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

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

                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }
Пример #32
0
            public SiteInfoResponseType GetSiteInfo(string[] locationParameter, Boolean IncludeSeries)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();
                 if (locationParameter != null)
                {
                    queryLog2.LogStart(CustomLogging.Methods.GetSiteInfo, locationParameter.ToString(),
                                       appContext.Request.UserHostName);
                }
                else
                {
                    queryLog2.LogStart(CustomLogging.Methods.GetSiteInfo, "NULL",
                                       appContext.Request.UserHostName);

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

                        if (l.isGeometry)
                        {
                            String error = "Location by Geometry not accepted: " + locationParameter;
                            log.Debug(error);
                            throw new WaterOneFlowException(error);
                        }
                        else
                        {
                            lpList.Add(l);
                        }
                    }
                }
                catch (WaterOneFlowException we)
                {
                    log.Error(we.Message);
                    throw;
                }
                catch (Exception e)
                {
                    String error =
                        "Sorry. Your submitted site ID for this getSiteInfo request caused an problem that we failed to catch programmatically: " +
                        e.Message;
                    log.Error(error);
                    throw new WaterOneFlowException(error);
                }
                SiteInfoResponseType resp = new SiteInfoResponseType();
                resp.site = new SiteInfoResponseTypeSite[locationParameter.Length];
                for (int i = 0; i < locationParameter.Length; i++)
                {
                    resp.site[i] = WebServiceUtils.GetSiteFromDb(locationParameter[0], true);
                }

                foreach (SiteInfoResponseTypeSite site in resp.site)
                {
                    foreach (seriesCatalogType catalog in site.seriesCatalog)
                    {
                        catalog.menuGroupName = serviceName;
                        catalog.serviceWsdl = serviceUrl;
                    }
                }

                if (locationParameter != null)
                {

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

                return resp;
            }
Пример #33
0
            public SiteInfoResponseType GetSites(string[] locationIDs)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                queryLog2.LogStart(CustomLogging.Methods.GetSites, locationIDs.ToString(),
                    appContext.Request.UserHostName);

                SiteInfoResponseType result = new SiteInfoResponseType();
                result.site = WebServiceUtils.GetSitesFromDb();

                //set query info
                result.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSites");
                NoteType note = CuahsiBuilder.createNote("ALL Sites(empty request)");
                result.queryInfo.note = CuahsiBuilder.addNote(null, note);

                queryLog2.LogEnd(CustomLogging.Methods.GetSites,
                    locationIDs.ToString(),
                    timer.ElapsedMilliseconds.ToString(),
                    result.site.Length.ToString(),
                    appContext.Request.UserHostName);

                return result;
            }
Пример #34
0
            public SiteInfoResponseType GetSitesInBox(
                float west, float south, float east, float north,
                Boolean IncludeSeries
                )
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

                box queryBox = new box(west, south, east, north);

                queryLog2.LogStart(CustomLogging.Methods.GetSitesInBoxObject, queryBox.ToString(),
                     appContext.Request.UserHostName);

                SiteInfoResponseType resp = new SiteInfoResponseType();
                    resp.site = WebServiceUtils.GetSitesByBox(queryBox, IncludeSeries);

                    //set query info
                    resp.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSitesInBox");
                    NoteType note = CuahsiBuilder.createNote("box");
                    resp.queryInfo.note = CuahsiBuilder.addNote(null, note);

                queryLog2.LogEnd(CustomLogging.Methods.GetSitesInBoxObject,
                      queryBox.ToString(),
                     timer.ElapsedMilliseconds.ToString(),
                     resp.site.Length.ToString(),
                     appContext.Request.UserHostName);
                return resp;
            }
Пример #35
0
            public SiteInfoResponseType GetSiteInfo(string locationParameter)
            {
                string siteId = locationParameter.Substring(locationParameter.LastIndexOf(":")+1);

                SiteInfoResponseType resp = new SiteInfoResponseType();
                resp.site = new SiteInfoResponseTypeSite[1];
                resp.site[0] = new SiteInfoResponseTypeSite();
                resp.site[0] = WebServiceUtils.GetSiteFromDb(siteId, true);

                resp.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", new string[] { locationParameter }, null, null, null, null);

                return resp;
            }