Beispiel #1
0
        public static void LoadFromFile()
        {
            String fileName = System.IO.Path.Combine(System.IO.Path.Combine(EnterpriseFactory.AppDataDirectory, "Config.xml"));

            if (File.Exists(fileName))
            {
                XmlDocument data = new XmlDocument();
                data.Load(fileName);

                XmlNode rootNode = data.SelectSingleNode("AllData");
                if (rootNode != null && rootNode is XmlElement)
                {
                    try
                    {
                        foreach (XmlNode child in rootNode.SelectSingleNode("Experts"))
                        {
                            Expert exp = new Expert(0);
                            exp.DeserializeProperties(child);
                            EnterpriseFactory.Instance.Experts.Add(exp);
                        }
                        foreach (XmlNode child in rootNode.SelectSingleNode("Risks"))
                        {
                            Risk rsk = new Risk(0);
                            rsk.DeserializeProperties(child);
                            EnterpriseFactory.Instance.Risks.Add(rsk);
                        }
                        foreach (XmlNode child in rootNode.SelectSingleNode("Assessments"))
                        {
                            Assessment ass = new Assessment(0);
                            ass.DeserializeProperties(child);
                            EnterpriseFactory.Instance.Assessments.Add(ass);
                        }
                    }
                    catch
                    { }

                    //foreach (XmlNode tagNode in rootNode.SelectNodes("Tag"))
                    //{
                    //    if (!(tagNode is XmlElement))
                    //        continue;
                    //    ScadaDeviceUpdateQuery query = new ScadaDeviceUpdateQuery();
                    //    query.ScadaGuid = Shared.Helpers.Xml_Helper.GetValueGuid(tagNode, "Guid").Value;
                    //    query.DeserializeProperties(tagNode);

                    //    Add(query);
                    //}
                }
            }
        }