Ejemplo n.º 1
0
/// <summary>
/// Reusable functions
/// </summary>
        private void ParseSearchResults(XmlNodeList ndList, XmlNamespaceManager xnManager, int indexCatalog)
        {
            for (int i = 0; i < ndList.Count; i++)
            {
                XmlNode ndMDa = ndList.Item(i);

                switch (indexCatalog)
                {
                case 0:
                    ListDataModel aasgModel = ParseEachGeoportalSearchResult(ndMDa, xnManager);
                    Add2DaList(aasgModel);
                    break;

                case 1:
                    ListDataModel onegeologyModel = ParseEachOnegeologySearchResult(ndMDa, xnManager);
                    Add2DaList(onegeologyModel);
                    break;

                case 2:
                    ListDataModel geogovModel = ParseEachMultiDistGeoportalSearchResult(ndMDa, xnManager);
                    Add2DaList(geogovModel);
                    break;

                case 3:
                    ListDataModel usginModel = ParseEachMultiDistGeoportalSearchResult(ndMDa, xnManager);
                    Add2DaList(usginModel);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private ListDataModel ParseEachOnegeologySearchResult(XmlNode nd, XmlNamespaceManager xnManager)
        {
            ListDataModel lstData = new ListDataModel();

            ///Get record title info
            XmlNode ndTitle = nd.SelectSingleNode("dc:title", xnManager);

            lstData.Title = ndTitle.InnerText;

            ///Get metadata id info
            XmlNode ndIdentifier = nd.SelectSingleNode("dc:identifier", xnManager);

            lstData.MetadataId = ndIdentifier.InnerText;

            ///Get abstract info
            XmlNode ndAbstract = nd.SelectSingleNode("dct:abstract", xnManager);

            lstData.Abstract = ndAbstract.InnerText;

            ///Get the link of service and service type
            XmlNodeList ndRefList = nd.SelectNodes("dc:URI", xnManager);

            try
            {
                if (ndRefList != null)
                {
                    for (int iRef = 0; iRef < ndRefList.Count; iRef++)
                    {
                        XmlNode ndRef = ndRefList[iRef];
                        XmlAttributeCollection ndAttrColl = ndRef.Attributes;
                        for (int iAtt = 0; iAtt < ndAttrColl.Count; iAtt++)
                        {
                            if (ndAttrColl[iAtt].Name == "protocol" && ndRef.Attributes[0].Value.Contains("OGC:WMS")) ///Looking for wms service-
                            {
                                lstData.SvicType = "WMS";
                                if (ndRef.InnerText.Contains('?')) ///When the service url has '&' in the end
                                {
                                    lstData.SvrUrl = ndRef.InnerText;
                                    break;
                                }
                                else if (!ndRef.InnerText.Contains('?')) ///When the service url needs '?' in the end
                                {
                                    lstData.SvrUrl = ndRef.InnerText + '?';
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }


            return(lstData);
        }
Ejemplo n.º 3
0
        private void RefreshSearchResults(int currentPage, int startPosition, int numPages)
        {
            pPostDaCri.StartPosition = startPosition.ToString(); ///Set start position for the post data of request

            cCswSearch.CswRequest(pPostDaCri, cboCatalog.SelectedIndex);

            lbPage.Text = "Page " + currentPage.ToString() + "/" + numPages.ToString();

            rList = cCswSearch.DataList;
            lboxResults.Items.Clear();

            for (int i = 0; i < rList.Count; i++)
            {
                ListDataModel list = rList[i] as ListDataModel;
                lboxResults.Items.Add(list.Title); ///List search results
            }
        }
Ejemplo n.º 4
0
        private void lboxResults_SelectedIndexChanged(object sender, EventArgs e)
        {
            lboxResults.Cursor = Cursors.WaitCursor;

            ///Get info for the selected item
            selectedItem = rList[lboxResults.SelectedIndex] as ListDataModel;

            ///Add abstract into the text box
            tboxAbstract.Text = selectedItem.Abstract;

            ///Identify if the service can be added into the map
            if (selectedItem.SvicType == null || selectedItem.SvrUrl == null)
            {
                btnAdd.Enabled = false;
            }
            else if (selectedItem.SvicType == "WMS")
            {
                if (TestUrl(selectedItem.SvrUrl))
                {
                    btnAdd.Enabled         = true;
                    selectedItem.SvicType += "_Valid";
                }
                else
                {
                    btnAdd.Enabled        = false;
                    selectedItem.SvicType = null;
                }
            }
            else if (selectedItem.SvicType == "WMS_Valid")
            {
                btnAdd.Enabled = true;
            }

            ///Identify if the metadata document exists
            if (selectedItem.MetadataId == null)
            {
                btnMetaDoc.Enabled = false;
            }
            else
            {
                btnMetaDoc.Enabled = true;
            }

            lboxResults.Cursor = Cursors.Default;
        }
Ejemplo n.º 5
0
        private ListDataModel ParseEachGeoportalSearchResult(XmlNode nd, XmlNamespaceManager xnManager)
        {
            ListDataModel lstData = new ListDataModel();

            ///Get record title info
            XmlNode ndTitle = nd.SelectSingleNode("dc:title", xnManager);
            lstData.Title = ndTitle.InnerText;

            ///Get metadata id info
            XmlNodeList ndIdentifierList = nd.SelectNodes("dc:identifier", xnManager);
            for (int i = 0; i < ndIdentifierList.Count; i++)
            {
                XmlNode ndMetaDaId = ndIdentifierList[i];
                for(int j = 0; j < ndMetaDaId.Attributes.Count; j ++)
                {
                    if (ndMetaDaId.Attributes[j].Name == "scheme" && ndMetaDaId.Attributes[j].Value.Contains("DocID"))
                    { lstData.MetadataId = ndMetaDaId.InnerText; break; }
                }
            }

            ///Get abstract info
            XmlNode ndAbstract = nd.SelectSingleNode("dct:abstract", xnManager);
            lstData.Abstract = ndAbstract.InnerText;

            ///Get the link of service and service type
            XmlNodeList ndRefList = nd.SelectNodes("dct:references", xnManager);
            string urlCapabilities;
            try
            {
                if (ndRefList != null)
                {
                    for (int iRef = 0; iRef < ndRefList.Count; iRef++)
                    {
                        XmlNode ndRef = ndRefList[iRef];
                        if (ndRef.InnerText.Contains("GetCapabilities") || ndRef.InnerText.Contains("getcapabilities") || ndRef.InnerText.Contains("getCapabilities"))
                        {
                            urlCapabilities = ndRef.InnerText;

                            if (urlCapabilities.Contains("=WMS") || urlCapabilities.Contains("=wms"))
                            { lstData.SvicType = "WMS"; } ///Identify the service type
                            else { break; }

                            string[] rUrlCapabilities = urlCapabilities.Split('?');

                            lstData.SvrUrl = rUrlCapabilities[0] + '?';

                            if (rUrlCapabilities[1].Contains("map="))
                            {
                                string[] urlProperties = rUrlCapabilities[1].Split('&');
                                lstData.SvrUrl += urlProperties[0] + '&';
                            }

                            break;
                        }
                        else if (ndRef.InnerText.Contains("Capabilities") || ndRef.InnerText.Contains("capabilities"))
                        {
                            ///Write log for invalid GetCapabilities url
                            Log cLog = new Log("InvalidGetCapabilitiesUrl");
                            cLog.WriteLog(ndTitle.InnerText);
                            cLog.WriteLog(ndRef.InnerText);
                            cLog.CloseLog();
                        }
                    }
                }

            }
            catch (Exception ex)
            { throw ex; }

            return lstData;
        }
Ejemplo n.º 6
0
 private void Add2DaList(ListDataModel daModel)
 {
     rDataList.Add(daModel);
 }
Ejemplo n.º 7
0
        private ListDataModel ParseEachOnegeologySearchResult(XmlNode nd, XmlNamespaceManager xnManager)
        {
            ListDataModel lstData = new ListDataModel();

            ///Get record title info
            XmlNode ndTitle = nd.SelectSingleNode("dc:title", xnManager);
            lstData.Title = ndTitle.InnerText;

            ///Get metadata id info
            XmlNode ndIdentifier = nd.SelectSingleNode("dc:identifier", xnManager);
            lstData.MetadataId = ndIdentifier.InnerText;

            ///Get abstract info
            XmlNode ndAbstract = nd.SelectSingleNode("dct:abstract", xnManager);
            lstData.Abstract = ndAbstract.InnerText;

            ///Get the link of service and service type
            XmlNodeList ndRefList = nd.SelectNodes("dc:URI", xnManager);
            try
            {
                if (ndRefList != null)
                {
                    for (int iRef = 0; iRef < ndRefList.Count; iRef++)
                    {
                        XmlNode ndRef = ndRefList[iRef];
                        XmlAttributeCollection ndAttrColl = ndRef.Attributes;
                        for (int iAtt = 0; iAtt < ndAttrColl.Count; iAtt++)
                        {
                            if (ndAttrColl[iAtt].Name == "protocol" && ndRef.Attributes[0].Value.Contains("OGC:WMS")) ///Looking for wms service-
                            {
                                lstData.SvicType = "WMS";
                                if(ndRef.InnerText.Contains('?')) ///When the service url has '&' in the end
                                {
                                    lstData.SvrUrl = ndRef.InnerText;
                                    break;
                                }
                                else if (!ndRef.InnerText.Contains('?')) ///When the service url needs '?' in the end
                                {
                                    lstData.SvrUrl = ndRef.InnerText + '?';
                                    break;
                                }
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            { throw ex; }

            return lstData;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parse the response from Geoportal catalog, with multi distributions in the response
        /// </summary>
        private ListDataModel ParseEachMultiDistGeoportalSearchResult(XmlNode nd, XmlNamespaceManager xnManager)
        {
            ListDataModel lstData = new ListDataModel();

            ///Get record title info
            XmlNode ndTitle = nd.SelectSingleNode("dc:title", xnManager);
            lstData.Title = ndTitle.InnerText;

            ///Get metadata id info
            XmlNodeList ndIdentifierList = nd.SelectNodes("dc:identifier", xnManager);
            for (int i = 0; i < ndIdentifierList.Count; i++)
            {
                XmlNode ndMetaDaId = ndIdentifierList[i];
                if (ndMetaDaId.InnerText != null)
                {
                    lstData.MetadataId = ndMetaDaId.InnerText;
                }
                for (int j = 0; j < ndMetaDaId.Attributes.Count; j++)
                {
                    if (ndMetaDaId.Attributes[j].Name == "scheme" && ndMetaDaId.Attributes[j].Value.Contains("DocID"))
                    { lstData.MetadataId = ndMetaDaId.InnerText; break; }
                }
            }

            ///Get abstract info
            XmlNode ndAbstract = nd.SelectSingleNode("dct:abstract", xnManager);
            lstData.Abstract = ndAbstract.InnerText;

            ///Get the link of service and service type
            XmlNodeList ndRefList = nd.SelectNodes("dct:references", xnManager);
            string urlCapabilities;
            try
            {
                if (ndRefList != null)
                {
                    for (int iRef = 0; iRef < ndRefList.Count; iRef++)
                    {
                        XmlNode ndRef = ndRefList[iRef];
                        for (int iAttr = 0; iAttr < ndRef.Attributes.Count; iAttr++)
                        {
                            if (ndRef.Attributes[iAttr].Name == "scheme" && ndRef.Attributes[iAttr].Value.Contains("OGC:WMS"))
                            {
                                lstData.SvicType = "WMS";

                                urlCapabilities = ndRef.InnerText;
                                string[] rUrlCapabilities = urlCapabilities.Split('?');

                                lstData.SvrUrl = rUrlCapabilities[0] + '?';
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            { throw ex; }

            return lstData;
        }
Ejemplo n.º 9
0
        private void lboxResults_SelectedIndexChanged(object sender, EventArgs e)
        {
            lboxResults.Cursor = Cursors.WaitCursor;

            ///Get info for the selected item
            selectedItem = rList[lboxResults.SelectedIndex] as ListDataModel;

            ///Add abstract into the text box
            tboxAbstract.Text = selectedItem.Abstract;

            ///Identify if the service can be added into the map
            if (selectedItem.SvicType == null || selectedItem.SvrUrl == null)
            { btnAdd.Enabled = false; }
            else if (selectedItem.SvicType == "WMS")
            {
                if (TestUrl(selectedItem.SvrUrl))
                {
                    btnAdd.Enabled = true;
                    selectedItem.SvicType += "_Valid";
                }
                else
                {
                    btnAdd.Enabled = false;
                    selectedItem.SvicType = null;
                }
            }
            else if (selectedItem.SvicType == "WMS_Valid")
            { btnAdd.Enabled = true; }

            ///Identify if the metadata document exists
            if (selectedItem.MetadataId == null)
            { btnMetaDoc.Enabled = false; }
            else
            { btnMetaDoc.Enabled = true; }

            lboxResults.Cursor = Cursors.Default;
        }
Ejemplo n.º 10
0
        private ListDataModel ParseEachGeoportalSearchResult(XmlNode nd, XmlNamespaceManager xnManager)
        {
            ListDataModel lstData = new ListDataModel();

            ///Get record title info
            XmlNode ndTitle = nd.SelectSingleNode("dc:title", xnManager);

            lstData.Title = ndTitle.InnerText;

            ///Get metadata id info
            XmlNodeList ndIdentifierList = nd.SelectNodes("dc:identifier", xnManager);

            for (int i = 0; i < ndIdentifierList.Count; i++)
            {
                XmlNode ndMetaDaId = ndIdentifierList[i];
                for (int j = 0; j < ndMetaDaId.Attributes.Count; j++)
                {
                    if (ndMetaDaId.Attributes[j].Name == "scheme" && ndMetaDaId.Attributes[j].Value.Contains("DocID"))
                    {
                        lstData.MetadataId = ndMetaDaId.InnerText; break;
                    }
                }
            }



            ///Get abstract info
            XmlNode ndAbstract = nd.SelectSingleNode("dct:abstract", xnManager);

            lstData.Abstract = ndAbstract.InnerText;

            ///Get the link of service and service type
            XmlNodeList ndRefList = nd.SelectNodes("dct:references", xnManager);
            string      urlCapabilities;

            try
            {
                if (ndRefList != null)
                {
                    for (int iRef = 0; iRef < ndRefList.Count; iRef++)
                    {
                        XmlNode ndRef = ndRefList[iRef];
                        if (ndRef.InnerText.Contains("GetCapabilities") || ndRef.InnerText.Contains("getcapabilities") || ndRef.InnerText.Contains("getCapabilities"))
                        {
                            urlCapabilities = ndRef.InnerText;

                            if (urlCapabilities.Contains("=WMS") || urlCapabilities.Contains("=wms"))
                            {
                                lstData.SvicType = "WMS";
                            }                             ///Identify the service type
                            else
                            {
                                break;
                            }

                            string[] rUrlCapabilities = urlCapabilities.Split('?');

                            lstData.SvrUrl = rUrlCapabilities[0] + '?';

                            if (rUrlCapabilities[1].Contains("map="))
                            {
                                string[] urlProperties = rUrlCapabilities[1].Split('&');
                                lstData.SvrUrl += urlProperties[0] + '&';
                            }

                            break;
                        }
                        else if (ndRef.InnerText.Contains("Capabilities") || ndRef.InnerText.Contains("capabilities"))
                        {
                            ///Write log for invalid GetCapabilities url
                            Log cLog = new Log("InvalidGetCapabilitiesUrl");
                            cLog.WriteLog(ndTitle.InnerText);
                            cLog.WriteLog(ndRef.InnerText);
                            cLog.CloseLog();
                        }
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }


            return(lstData);
        }
Ejemplo n.º 11
0
 private void Add2DaList(ListDataModel daModel)
 {
     rDataList.Add(daModel);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Parse the response from Geoportal catalog, with multi distributions in the response
        /// </summary>
        private ListDataModel ParseEachMultiDistGeoportalSearchResult(XmlNode nd, XmlNamespaceManager xnManager)
        {
            ListDataModel lstData = new ListDataModel();

            ///Get record title info
            XmlNode ndTitle = nd.SelectSingleNode("dc:title", xnManager);

            lstData.Title = ndTitle.InnerText;

            ///Get metadata id info
            XmlNodeList ndIdentifierList = nd.SelectNodes("dc:identifier", xnManager);

            for (int i = 0; i < ndIdentifierList.Count; i++)
            {
                XmlNode ndMetaDaId = ndIdentifierList[i];
                if (ndMetaDaId.InnerText != null)
                {
                    lstData.MetadataId = ndMetaDaId.InnerText;
                }
                for (int j = 0; j < ndMetaDaId.Attributes.Count; j++)
                {
                    if (ndMetaDaId.Attributes[j].Name == "scheme" && ndMetaDaId.Attributes[j].Value.Contains("DocID"))
                    {
                        lstData.MetadataId = ndMetaDaId.InnerText; break;
                    }
                }
            }

            ///Get abstract info
            XmlNode ndAbstract = nd.SelectSingleNode("dct:abstract", xnManager);

            lstData.Abstract = ndAbstract.InnerText;

            ///Get the link of service and service type
            XmlNodeList ndRefList = nd.SelectNodes("dct:references", xnManager);
            string      urlCapabilities;

            try
            {
                if (ndRefList != null)
                {
                    for (int iRef = 0; iRef < ndRefList.Count; iRef++)
                    {
                        XmlNode ndRef = ndRefList[iRef];
                        for (int iAttr = 0; iAttr < ndRef.Attributes.Count; iAttr++)
                        {
                            if (ndRef.Attributes[iAttr].Name == "scheme" && ndRef.Attributes[iAttr].Value.Contains("OGC:WMS"))
                            {
                                lstData.SvicType = "WMS";

                                urlCapabilities = ndRef.InnerText;
                                string[] rUrlCapabilities = urlCapabilities.Split('?');

                                lstData.SvrUrl = rUrlCapabilities[0] + '?';
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }


            return(lstData);
        }
Ejemplo n.º 13
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            this.Cursor        = Cursors.WaitCursor;
            btnMetaDoc.Enabled = false;
            btnAdd.Enabled     = false;

            cCswSearch.CswUrl = tboxSearchText.Text;

            pPageSwitchCri.StartPosition = 1; ///Set the start position for page switcher

            ///Send search request////////////////////////////////////////
            if (tboxSearchText.Text == "")
            {
                tboxSearchText.Text = "*";
            }
            pPostDaCri.SearchText = tboxSearchText.Text;                   ///Set search key word
            pPostDaCri.QueryName  = cboSearchName.SelectedItem.ToString(); ///Set search name

            // CSW Servers which use pycsw need to have the namespace before the query name and are case sensitive
            if ((cCswSearch.CatalogUrl == "http://catalog.data.gov/csw?") || (cCswSearch.CatalogUrl == "http://geothermaldata.org/csw?"))
            {
                switch (pPostDaCri.QueryName)
                {
                case "AnyText":
                    pPostDaCri.QueryName = "csw:AnyText";
                    break;

                case "Title":
                    pPostDaCri.QueryName = "dc:title";
                    break;

                case "Abstract":
                    pPostDaCri.QueryName = "dct:abstract";
                    break;
                }
            }

            pPostDaCri.StartPosition = pPageSwitchCri.StartPosition.ToString(); ///Set start position for search

            ///Define if the search is only for wms service / live data
            pPostDaCri.IsWmsOnly      = IsWmsOnly(cboCatalog.SelectedIndex);      ///Define if the search is only for wms service
            pPostDaCri.IsLiveDataOnly = IsLivedataOnly(cboCatalog.SelectedIndex); ///Define if the search is only for live data

            ///Define if use the current extent
            if (cboxCurrentExtent.Checked == true)
            {
                pPostDaCri.Envelope = GetCurrentExtent();
            }
            else
            {
                pPostDaCri.Envelope = null;
            }

            cCswSearch.CswRequest(pPostDaCri, cboCatalog.SelectedIndex); ///Send request and parse response
            //////////////////////////////////////////////////////////////

            ///Set value for number of records and page switcher/////////////////////////////
            lbNumRecords.Text = "Found " + cCswSearch.NumRecords + " Records";

            int numRecords = Convert.ToInt32(cCswSearch.NumRecords);

            pPageSwitchCri.NumPages = numRecords / 15; ///Set the total number of pages for page switcher
            if (numRecords % 15 != 0)
            {
                pPageSwitchCri.NumPages++;
            }

            if (pPageSwitchCri.NumPages > 0)
            {
                lbNxtPage.Enabled = true;
            }                                                              ///Enable the next page function

            lbPage.Text = "Page" + "1" + "/" + pPageSwitchCri.NumPages.ToString();

            pPageSwitchCri.CurrentPage = 1; ///Set the current page number for page switcher
            /////////////////////////////////////////////////////////////////////////////////

            ///List Results/////////////////////////////////////////////
            rList = cCswSearch.DataList;
            lboxResults.Items.Clear();

            for (int i = 0; i < rList.Count; i++)
            {
                ListDataModel list = rList[i] as ListDataModel;
                lboxResults.Items.Add(list.Title); ///List all services
            }

            ////////////////////////////////////////////////////////////
            this.Cursor = Cursors.Default;
        }