Esempio n. 1
0
        public void LoadXML(string fileName)
        {
            try {
                FileHeader header = new FileHeader();
                Clear();

                Stream @is = NWResourceManager.LoadStream(fileName);

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(@is);

                XmlNode root = xmlDocument.DocumentElement;
                if (!root.Name.Equals("RDB"))
                {
                    throw new Exception("Its not RDB!");
                }

                XmlNode vers = root.SelectSingleNode("Version");
                if (vers == null)
                {
                    //throw new RuntimeException("Not found version!");
                }

                XmlNode entries = root.SelectSingleNode("Entries");
                if (entries == null)
                {
                    //throw new RuntimeException("Not found entries!");
                }

                fEntriesCount = Convert.ToInt32(entries.Attributes["Count"].InnerText);
                fEntries      = new DataEntry[fEntriesCount];

                XmlNodeList nl = entries.ChildNodes;
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode el = nl[i];
                    if (el.Name.Equals("Entry"))
                    {
                        string val = "";
                        try {
                            sbyte kind = DataEntry.ParseEntryKind(el.Attributes["Kind"].InnerText);
                            int   id   = Convert.ToInt32(el.Attributes["GUID"].InnerText);

                            DataEntry entry = null;
                            if (kind != DataEntry.ek_Unknown)
                            {
                                entry      = CreateEntry(kind);
                                entry.Kind = kind;
                                entry.LoadXML(el, header.Version);
                            }
                            fEntries[id] = entry;
                        } catch (Exception ex) {
                            Logger.Write("LoadXML.1(" + val + "): " + ex.Message);
                        }
                    }
                }

                Logger.Write("dbLoad(): ok");
            } catch (Exception ex) {
                Logger.Write("LoadXML(): " + ex.Message);
            }
        }