Beispiel #1
0
        public static Site FromXML(XElement xsite)
        {
            List <NAE> naes = new List <NAE>();

            foreach (XElement xnae in xsite.Element("NAEs").Elements())
            {
                naes.Add(NAE.FromXML(xnae));
            }

            Site site = new Site {
                Name = xsite.Attribute("Name").Value,
                NAEs = naes
            };

            return(site);
        }
Beispiel #2
0
 private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.treeSites.SelectedNode != null)
     {
         if (!String.IsNullOrEmpty(Clipboard.GetText()))
         {
             try
             {
                 TreeNodeCollection nodes = this.treeSites.SelectedNode.Nodes;
                 XElement           xnae  = XElement.Parse(Clipboard.GetText());
                 FormHandler.AddNAEToTree(nodes, NAE.FromXML(xnae));
             }
             catch (Exception ex)
             {
                 Logger.WriteMessage("Error in pasting NAE.");
                 Logger.WriteException(ex);
                 Logger.PromptLogReview("Failed to paste the NAE, the data in the clipboard may be corrupt.");
             }
         }
     }
 }
Beispiel #3
0
        private void importNAEToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "XML Files (*.xml)|*.xml";
            openFileDialog.FilterIndex      = 2;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    XElement xnae = XDocument.Load(openFileDialog.FileName).Root;
                    FormHandler.AddNAEToTree(this.treeSites.SelectedNode.Nodes, NAE.FromXML(xnae));
                }
                catch (Exception ex)
                {
                    Logger.WriteMessage("Failed to load XML file: " + openFileDialog.FileName);
                    Logger.WriteException(ex);
                    Logger.PromptLogReview("An error occurred in loading the file, it may be corrupted.");
                }
            }
        }