Exemplo n.º 1
0
        internal void Load(string strSecureToken)
        {
            string strDir = string.Empty;


            CSYS.IGetDirectory(GXNet.Constant.SYS_DIR_USER, ref strDir);
            m_strCSV = System.IO.Path.Combine(strDir, "csv\\Dap_Servers.xml");

            if (!System.IO.File.Exists(m_strCSV))
            {
                string strTemp;

                CSYS.IGetDirectory(GXNet.Constant.SYS_DIR_GEOSOFT, ref strDir);
                strTemp = System.IO.Path.Combine(strDir, "csv\\Dap_Servers.xml");


                // --- Copy file to user directory ---

                if (System.IO.File.Exists(strTemp))
                {
                    System.IO.File.Copy(strTemp, m_strCSV, true);
                }
            }

            UpgradeList();
            LoadInternal(strSecureToken);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update with any required new servers on upgrades
        /// </summary>
        protected void UpgradeList(int iMajorVersion, int iMinorVersion, int iSPVersion, System.Collections.Generic.Dictionary <string, ServerUpgradeInfo> URLs)
        {
            XmlDocument  oDoc;
            XmlNode      oNode, oRoot;
            XmlAttribute oAttr;

            try
            {
                string strDir = string.Empty;
                CSYS.IGetDirectory(GXNet.Constant.SYS_DIR_USER, ref strDir);
                string strUpdated = System.IO.Path.Combine(strDir, string.Format("csv\\Dap_Servers{0}{1}{2}.updated", iMajorVersion, iMinorVersion, iSPVersion));

                // --- Only update once per version ---
                if (!System.IO.File.Exists(strUpdated))
                {
                    bool bFound;

                    oDoc = new XmlDocument();
                    oDoc.Load(m_strCSV);
                    oRoot = oDoc.DocumentElement;


                    // --- See if the URL has not been added manually already ---
                    foreach (string strURL in URLs.Keys)
                    {
                        bFound = false;
                        foreach (XmlNode oServerNode in oRoot.ChildNodes)
                        {
                            oNode = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.Url);
                            if (oNode == null)
                            {
                                throw new ApplicationException("Missing url attribute in server node");
                            }
                            if (String.Compare(oNode.Value, strURL, true) == 0)
                            {
                                bFound = true;
                                break;
                            }
                        }
                        if (!bFound)
                        {
                            // --- Add the server ---

                            XmlNode oServerNode = oRoot.OwnerDocument.CreateElement(Constant.Xml.Tag.Server);

                            oAttr       = oRoot.OwnerDocument.CreateAttribute(Constant.Xml.Attr.Name);
                            oAttr.Value = URLs[strURL].Name;
                            oServerNode.Attributes.Append(oAttr);

                            oAttr       = oRoot.OwnerDocument.CreateAttribute(Constant.Xml.Attr.Url);
                            oAttr.Value = strURL;
                            oServerNode.Attributes.Append(oAttr);

                            oAttr       = oRoot.OwnerDocument.CreateAttribute(Constant.Xml.Attr.Status);
                            oAttr.Value = URLs[strURL].eStatus.ToString();
                            oServerNode.Attributes.Append(oAttr);

                            oAttr       = oRoot.OwnerDocument.CreateAttribute(Constant.Xml.Attr.Major_Version);
                            oAttr.Value = URLs[strURL].iMajorVersion.ToString();
                            oServerNode.Attributes.Append(oAttr);

                            oAttr       = oRoot.OwnerDocument.CreateAttribute(Constant.Xml.Attr.Minor_Version);
                            oAttr.Value = URLs[strURL].iMinorVersion.ToString();
                            oServerNode.Attributes.Append(oAttr);

                            oAttr       = oRoot.OwnerDocument.CreateAttribute(Constant.Xml.Attr.CacheVersion);
                            oAttr.Value = "";
                            oServerNode.Attributes.Append(oAttr);

                            oRoot.AppendChild(oServerNode);
                        }
                    }

                    oDoc.Save(m_strCSV);

                    // --- Only update once per version ---
                    using (StreamWriter sw = new StreamWriter(strUpdated))
                        sw.WriteLine();
                }
            }
            catch
            {
            }
        }