Example #1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="oFolderNode"></param>
        internal CatalogFolder(System.Xml.XmlNode oFolderNode, string strHierarchy)
        {
            System.Xml.XmlNode oAttr;

            oAttr = oFolderNode.Attributes.GetNamedItem("name");
            if (oAttr == null)
            {
                throw new ArgumentException();
            }
            m_strName      = oAttr.Value;
            m_strHierarchy = strHierarchy + '/' + m_strName;

            oAttr = oFolderNode.Attributes.GetNamedItem("value");
            if (oAttr == null)
            {
                throw new ArgumentException();
            }
            m_iTimestamp = Int32.Parse(oAttr.Value, NumberStyles.Any, CultureInfo.InvariantCulture);

            foreach (System.Xml.XmlNode oChildNode in oFolderNode.ChildNodes)
            {
                CatalogFolder oFolder;

                oFolder = new CatalogFolder(oChildNode, m_strHierarchy);
                m_oSubFolders.Add(oFolder.Name, oFolder);
            }
        }
Example #2
0
        /// <summary>
        /// Parse the catalog hierarchy
        /// </summary>
        /// <param name="oDocument"></param>
        /// <returns></returns>
        internal static CatalogFolder Parse(System.Xml.XmlDocument oDocument, out string strConfigurationEdition)
        {
            CatalogFolder oFolder = null;

            System.Xml.XmlNode     oGeosoftXmlNode;
            System.Xml.XmlNode     oCatalogHierarchyNode;
            System.Xml.XmlNode     oCatalogEditionNode;
            System.Xml.XmlNode     oAttr;
            System.Xml.XmlNodeList oNodeList;

            strConfigurationEdition = string.Empty;

            oGeosoftXmlNode = oDocument.DocumentElement;
            if (oGeosoftXmlNode == null || oGeosoftXmlNode.ChildNodes.Count == 0)
            {
                return(null);
            }

            oNodeList = oGeosoftXmlNode.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.CONFIGURATION_TAG);
            if (oNodeList == null || oNodeList.Count == 0)
            {
                return(null);
            }

            oCatalogEditionNode = oNodeList[0];
            if (oCatalogEditionNode == null)
            {
                return(null);
            }

            oAttr = oCatalogEditionNode.Attributes.GetNamedItem("version");
            if (oAttr == null)
            {
                return(null);
            }
            strConfigurationEdition = oAttr.Value;

            oNodeList = oGeosoftXmlNode.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.CATALOG_HIERARCHY_TAG);
            if (oNodeList == null || oNodeList.Count == 0)
            {
                return(null);
            }

            oCatalogHierarchyNode = oNodeList[0];
            if (oCatalogHierarchyNode == null || oCatalogHierarchyNode.ChildNodes.Count == 0)
            {
                return(null);
            }

            try
            {
                oFolder = new CatalogFolder(oCatalogHierarchyNode.ChildNodes[0], string.Empty);
                oFolder.m_strConfigurationEdition = strConfigurationEdition;
            }
            catch
            {
                return(null);
            }
            return(oFolder);
        }
Example #3
0
        internal FolderDatasetList GetDatasets(Server oServer, CatalogFolder oFolder, BoundingBox oBounds, bool bAOIFilter, bool bTextFilter, string strSearchString)
        {
            FolderDatasetList oRet = null;

            string strKey = oServer.Url + ':' + oFolder.Hierarchy;

            if (bTextFilter)
            {
                strKey += "_" + strSearchString;
            }
            if (bAOIFilter)
            {
                strKey += "_" + oBounds.GetHashCode().ToString(CultureInfo.InvariantCulture);
            }

            string strFile = Path.Combine(oServer.CacheDir, strKey.GetHashCode().ToString(CultureInfo.InvariantCulture) + ".dap_datasetlist.gz");

            if (File.Exists(strFile))
            {
                try
                {
                    // --- Use SOAP formatting and GZip compression to disk  ---
                    // --- This way we have a nice human readable format and ---
                    // --- we may later move caching to database based.      ---
                    SoapFormatter formatter = new SoapFormatter();
                    formatter.Binder = new FolderDatasetListDeserializationBinder();

                    using (Stream stream = new FileStream(strFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (GZipStream compStream = new GZipStream(stream, CompressionMode.Decompress))
                        {
                            oRet = (FolderDatasetList)formatter.Deserialize(compStream);
                            compStream.Close();
                            stream.Close();
                        }
                    }
                }
                catch
                {
                    oRet = null;

                    try
                    {
                        if (File.Exists(strFile))
                        {
                            File.Delete(strFile);
                        }
                    }
                    catch (IOException) { }                     // Bug report where this delete failed; suppress failed deletions.
                }
            }

            if (oRet != null && oRet.Timestamp == oFolder.Timestamp && strKey == oRet.Key)
            {
                return(oRet);
            }
            return(null);
        }
Example #4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="oFolderNode"></param>
        internal CatalogFolder(System.Xml.XmlNode oFolderNode, string strHierarchy)
        {
            System.Xml.XmlNode oAttr;

             oAttr = oFolderNode.Attributes.GetNamedItem("name");
             if (oAttr == null) throw new ArgumentException();
             m_strName = oAttr.Value;
             m_strHierarchy = strHierarchy + '/' + m_strName;

             oAttr = oFolderNode.Attributes.GetNamedItem("value");
             if (oAttr == null) throw new ArgumentException();
            m_iTimestamp = Int32.Parse(oAttr.Value, NumberStyles.Any, CultureInfo.InvariantCulture);

             foreach (System.Xml.XmlNode oChildNode in oFolderNode.ChildNodes)
             {
            CatalogFolder oFolder;

            oFolder = new CatalogFolder(oChildNode, m_strHierarchy);
            m_oSubFolders.Add(oFolder.Name, oFolder);
             }
        }
Example #5
0
        internal DapDirectoryModelNode(DappleModel oModel, CatalogFolder oFolder)
            : base(oModel)
        {
            m_oFolder = oFolder;

            foreach (CatalogFolder oSubFolder in m_oFolder.Folders)
            {
                AddChildSilently(new DapDirectoryModelNode(m_oModel, oSubFolder));
            }
        }
Example #6
0
        /// <summary>
        /// Parse the catalog hierarchy 
        /// </summary>
        /// <param name="oDocument"></param>
        /// <returns></returns>
        internal static CatalogFolder Parse(System.Xml.XmlDocument oDocument, out string strConfigurationEdition)
        {
            CatalogFolder oFolder = null;
             System.Xml.XmlNode oGeosoftXmlNode;
             System.Xml.XmlNode oCatalogHierarchyNode;
             System.Xml.XmlNode oCatalogEditionNode;
             System.Xml.XmlNode oAttr;
             System.Xml.XmlNodeList oNodeList;

             strConfigurationEdition = string.Empty;

             oGeosoftXmlNode = oDocument.DocumentElement;
             if (oGeosoftXmlNode == null || oGeosoftXmlNode.ChildNodes.Count == 0) return null;

             oNodeList = oGeosoftXmlNode.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.CONFIGURATION_TAG);
             if (oNodeList == null || oNodeList.Count == 0) return null;

             oCatalogEditionNode = oNodeList[0];
             if (oCatalogEditionNode == null) return null;

             oAttr = oCatalogEditionNode.Attributes.GetNamedItem("version");
             if (oAttr == null) return null;
             strConfigurationEdition = oAttr.Value;

             oNodeList = oGeosoftXmlNode.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.CATALOG_HIERARCHY_TAG);
             if (oNodeList == null || oNodeList.Count == 0) return null;

             oCatalogHierarchyNode = oNodeList[0];
             if (oCatalogHierarchyNode == null || oCatalogHierarchyNode.ChildNodes.Count == 0) return null;

             try
             {
            oFolder = new CatalogFolder(oCatalogHierarchyNode.ChildNodes[0], string.Empty);
            oFolder.m_strConfigurationEdition = strConfigurationEdition;
             }
             catch
             {
            return null;
             }
             return oFolder;
        }
Example #7
0
        /// <summary>
        /// Clear the current catalog that we have displayed
        /// </summary>
        protected void ClearCatalog()
        {
            m_oCatalog = null;
             m_oCatalogHierarchyRoot = null;
             m_oAsyncQueue.Clear();

             if (this.InvokeRequired)
            this.Invoke(new MethodInvoker(ClearTree));
             else
            ClearTree();
        }
Example #8
0
 internal FolderDatasetList GetDatasets(CatalogFolder oFolder)
 {
     return m_oCacheManager.GetDatasets(m_oCurServer, oFolder, m_oCatalogBoundingBox, m_bAOIFilter, m_bTextFilter, m_strSearchString);
 }
Example #9
0
        /// <summary>
        /// Get the catalog hierarchy
        /// </summary>
        internal void GetCatalogHierarchy()
        {
            string strConfigurationEdition = string.Empty;

             if (m_oCurServer == null)
            return;

             if (!(m_oCurServer.Enabled))
             {
            m_oCatalogHierarchyRoot = null;

            if (this.InvokeRequired)
            {
               try
               {
                  this.Invoke(new MethodInvoker(this.RefreshResults));
               }
               catch
               {
               }
            }
            else
               RefreshResults();

            return;
             }

             if (m_bEntireCatalogMode)
             {
            Catalog oCatalog = null;

            try
            {
               if (!m_bAOIFilter && !m_bTextFilter)
                  oCatalog = m_oCurServer.CatalogCollection.GetCatalog(null, string.Empty);
               else if (!m_bAOIFilter && m_bTextFilter)
                  oCatalog = m_oCurServer.CatalogCollection.GetCatalog(null, m_strSearchString);
               else if (m_bAOIFilter && !m_bTextFilter)
                  oCatalog = m_oCurServer.CatalogCollection.GetCatalog(m_oCatalogBoundingBox, string.Empty);
               else if (m_bAOIFilter && m_bTextFilter)
                  oCatalog = m_oCurServer.CatalogCollection.GetCatalog(m_oCatalogBoundingBox, m_strSearchString);
            }
            catch (DapException)
            {
               oCatalog = null;
            }

            if (oCatalog == null)
            {
               // --- do something to disable server ---
               NoResponseError(m_oCurServer);
               return;
            }
            else
            {
               // --- Looks like the server is online now ---
               ReenableServer(m_oCurServer);
               m_oCatalog = oCatalog.Document;
               strConfigurationEdition = oCatalog.ConfigurationEdition;
            }
             }
             else
             {
            bool bEntireCatalog;
            m_oCatalogHierarchyRoot = null;

            try
            {
               m_oCatalogHierarchyRoot = m_oCacheManager.GetCatalogHierarchyRoot(m_oCurServer, m_oCatalogBoundingBox, m_bAOIFilter, m_bTextFilter, m_strSearchString, out bEntireCatalog, out strConfigurationEdition);
            }
            catch
            {
               // Assumed that the server does not support this request, revert to old method
               bEntireCatalog = true;
            }

            if (m_oCatalogHierarchyRoot == null && bEntireCatalog)
            {
               m_bEntireCatalogMode = true;
               GetCatalogHierarchy();
               return;
            }
             }

             if (strConfigurationEdition != m_oCurServer.CacheVersion)
             {
            OnServerCachedChanged(m_oCurServer);
            return;
             }

             if (this.InvokeRequired)
             {
            try
            {
               this.Invoke(new MethodInvoker(this.RefreshResults));
            }
            catch
            {
            }
             }
             else
            RefreshResults();
        }
Example #10
0
      internal FolderDatasetList GetDatasets(Server oServer, CatalogFolder oFolder, BoundingBox oBounds, bool bAOIFilter, bool bTextFilter, string strSearchString)
      {
         FolderDatasetList oRet = null;

         string strKey = oServer.Url + ':' + oFolder.Hierarchy;

         if (bTextFilter)
            strKey += "_" + strSearchString;
         if (bAOIFilter)
				strKey += "_" + oBounds.GetHashCode().ToString(CultureInfo.InvariantCulture);

			string strFile = Path.Combine(oServer.CacheDir, strKey.GetHashCode().ToString(CultureInfo.InvariantCulture) + ".dap_datasetlist.gz");

         if (File.Exists(strFile))
         {
            try
            {
               // --- Use SOAP formatting and GZip compression to disk  ---
               // --- This way we have a nice human readable format and ---
               // --- we may later move caching to database based.      ---
               SoapFormatter formatter = new SoapFormatter();
               formatter.Binder = new FolderDatasetListDeserializationBinder();
               
               using (Stream stream = new FileStream(strFile, FileMode.Open, FileAccess.Read, FileShare.Read))
               {
                  using (GZipStream compStream = new GZipStream(stream, CompressionMode.Decompress))
                  {
                     oRet = (FolderDatasetList)formatter.Deserialize(compStream);
                     compStream.Close();
                     stream.Close();
                  }
               }
            }
            catch
            {
               oRet = null;

					try
					{
						if (File.Exists(strFile))
							File.Delete(strFile);
					}
					catch (IOException) { } // Bug report where this delete failed; suppress failed deletions.
            }
         }

         if (oRet != null && oRet.Timestamp == oFolder.Timestamp && strKey == oRet.Key)
            return oRet;
         return null;
      }
Example #11
0
        /// <summary>
        /// Get the root catalog hierarchy for a particular path
        /// </summary>
        /// <param name="oServer"></param>
        /// <param name="oBounds"></param>
        /// <param name="bAOIFilter"></param>
        /// <param name="bTextFilter"></param>
        /// <param name="strSearchString"></param>
        /// <returns>The hierarchy as a CatalogFolder</returns>
        internal CatalogFolder GetCatalogHierarchyRoot(Server oServer, BoundingBox oBounds, bool bAOIFilter, bool bTextFilter, string strSearchString, out bool bEntireCatalogMode, out string strEdition)
        {
            XmlDocument oDoc = null;

            strEdition         = "";
            bEntireCatalogMode = false;

            string strKey = oServer.Url;

            if (bTextFilter)
            {
                strKey += "_" + strSearchString;
            }
            if (bAOIFilter)
            {
                strKey += "_" + oBounds.GetHashCode().ToString(CultureInfo.InvariantCulture);
            }
            string strFile = Path.Combine(oServer.CacheDir, strKey.GetHashCode().ToString(CultureInfo.InvariantCulture) + ".dap_cataloghierarchy.gz");

            if (File.Exists(strFile))
            {
                try
                {
                    // --- Use GZip compression to disk  ---
                    using (Stream stream = new FileStream(strFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (GZipStream compStream = new GZipStream(stream, CompressionMode.Decompress))
                        {
                            oDoc = new XmlDocument();
                            oDoc.Load(compStream);
                            compStream.Close();
                            stream.Close();

                            CatalogFolder oCatalogFolder = CatalogFolder.Parse(oDoc, out strEdition);
                            if (oCatalogFolder != null && strEdition == oServer.CacheVersion)
                            {
                                return(oCatalogFolder);
                            }
                            oDoc = null;
                        }
                    }
                }
                catch
                {
                    oDoc = null;

                    if (File.Exists(strFile))
                    {
                        File.Delete(strFile);
                    }
                }
            }

            if (oDoc == null)
            {
                try
                {
                    if (!bAOIFilter && !bTextFilter)
                    {
                        oDoc = oServer.Command.GetCatalogHierarchy();
                    }
                    else if (!bAOIFilter && bTextFilter)
                    {
                        oDoc = oServer.Command.GetCatalogHierarchy(strSearchString);
                    }
                    else if (bAOIFilter && !bTextFilter)
                    {
                        oDoc = oServer.Command.GetCatalogHierarchy(oBounds);
                    }
                    else if (bAOIFilter && bTextFilter)
                    {
                        oDoc = oServer.Command.GetCatalogHierarchy(strSearchString, oBounds);
                    }
                }
                catch (DapException)
                {
                    // Assume the server is older
                    bEntireCatalogMode = true;
                    return(null);
                }
                catch
                {
                    oDoc = null;
                }

                if (oDoc == null)
                {
                    // --- do something to disable server ---

#if !DAPPLE
                    m_oServerTree.NoResponseError();
#else
                    if (m_oServerTree != null)
                    {
                        m_oServerTree.NoResponseError(oServer);
                    }
#endif
                    return(null);
                }

#if DAPPLE
                // --- Looks like the server is online now ---
                if (m_oServerTree != null)
                {
                    m_oServerTree.ReenableServer(oServer);
                }
#endif
                CatalogFolder oCatalogFolder = CatalogFolder.Parse(oDoc, out strEdition);

                if (oCatalogFolder == null)
                {
                    // --- check to see if this is an unknown request ---

                    System.Xml.XmlNodeList oNodeList;
                    System.Xml.XmlNode     oNode;

                    oNodeList = oDoc.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.ERROR_TAG);
                    if (oNodeList != null && oNodeList.Count > 0)
                    {
                        oNode = oNodeList[0];
                        if (oNode != null && oNode.InnerText.ToLower() == "unknown request.")
                        {
                            bEntireCatalogMode = true;
                        }
                    }
                }
                else
                {
                    if (strEdition != oServer.CacheVersion)
                    {
                        oServer.UpdateConfiguration();
                        return(null);
                    }

                    try
                    {
                        if (File.Exists(strFile))
                        {
                            File.Delete(strFile);
                        }

                        // --- Use GZip compression to disk  ---
                        using (Stream stream = new FileStream(strFile, FileMode.Create, FileAccess.Write, FileShare.None))
                        {
                            using (GZipStream compStream = new GZipStream(stream, CompressionMode.Compress, true))
                            {
                                XmlWriter writer = XmlWriter.Create(compStream);
                                oDoc.Save(writer);
                                compStream.Close();
                                stream.Close();
                            }
                        }
                    }
                    catch
                    {
                    }

                    return(oCatalogFolder);
                }
            }

            return(null);
        }