Example #1
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);
                }
            }
Example #2
0
            public SiteInfoResponseTypeGeneric GetSitesObject(string[] site, String authToken)
            {
                Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

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


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

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

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

                    sit.queryInfo.criteria = crit;


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

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

                    throw SoapExceptionGenerator.WOFExceptionToSoapException(we);
                }
            }