Ejemplo n.º 1
0
        public static void LivrableXml(Livrable L, string fichierCible)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlNode baseNode = xmlDoc.CreateElement("Livrable");
            XmlNode typeNode = xmlDoc.CreateElement("Type");

            typeNode.InnerText = L.Type;
            XmlNode dateNode = xmlDoc.CreateElement("Date");

            dateNode.InnerText = L.DateRendu.ToString();
            XmlNode noteNode = xmlDoc.CreateElement("Note");

            noteNode.InnerText = L.Note.ToString();
            baseNode.AppendChild(typeNode);
            baseNode.AppendChild(dateNode);
            baseNode.AppendChild(noteNode);

            if (File.Exists(fichierCible))
            {
                xmlDoc.Load(fichierCible);
                XmlNode rootNode = xmlDoc.SelectSingleNode("//Livrables");
                rootNode.AppendChild(baseNode);
            }
            else
            {
                XmlNode rootNode = xmlDoc.CreateElement("Livrables");
                xmlDoc.AppendChild(rootNode);
                rootNode.AppendChild(baseNode);
            }

            xmlDoc.Save(fichierCible);
        }
Ejemplo n.º 2
0
 public void RetraitLivrable(Livrable L)
 {
     if (ListeLivrables.Contains(L))
     {
         ListeLivrables.Remove(L);
     }
     else
     {
         Console.WriteLine("Ce livrable n'existe pas dans ce projet");
     }
 }
Ejemplo n.º 3
0
        //Fonctions reconstruction
        public static Projet ReconstructionProjet(XmlDocument xmlDoc, XmlNode baseNode)
        {
            //Le XmlNode en entrée doit correspondre au noeud <Projet>
            XmlNode  idNode        = baseNode.SelectSingleNode("Id");
            int      id            = int.Parse(idNode.InnerText);
            XmlNode  nameNode      = baseNode.SelectSingleNode("Nom");
            string   nom           = nameNode.InnerText;
            XmlNode  subjectNode   = baseNode.SelectSingleNode("Sujet");
            string   sujet         = subjectNode.InnerText;
            XmlNode  dateStartNode = baseNode.SelectSingleNode("DateDebut");
            DateTime dateStart     = DateTime.Parse(dateStartNode.InnerText);
            XmlNode  dateFinNode   = baseNode.SelectSingleNode("DateFin");
            DateTime dateFin       = DateTime.Parse(dateFinNode.InnerText);
            XmlNode  typeNode      = baseNode.SelectSingleNode("Type");
            string   type          = typeNode.InnerText;

            Projet P = new Projet(nom, sujet, dateStart, dateFin, type, id);

            //Participants
            XmlNode     basePartiNode = baseNode.SelectSingleNode("Participants");
            XmlNodeList partiNodes    = basePartiNode.SelectNodes("Participant");

            foreach (XmlNode partiNode in partiNodes)
            {
                XmlNode partiNameNode    = partiNode.SelectSingleNode("Nom");
                string  partiName        = partiNameNode.InnerText;
                XmlNode partiSurnameNode = partiNode.SelectSingleNode("Prenom");
                string  partiSurname     = partiSurnameNode.InnerText;
                XmlNode partiRoleNode    = partiNode.SelectSingleNode("Role");
                string  partiRole        = partiRoleNode.InnerText;
                if (partiNode.Attributes["Eleve"] != null)
                {
                    XmlNode partiPromoNode = partiNode.SelectSingleNode("Promotion");
                    int     partiPromo     = int.Parse(partiPromoNode.InnerText);
                    Eleve   E = new Eleve(partiName, partiSurname, partiPromo);
                    P.AjoutParticipant(E, partiRole);
                }
                else if (partiNode.Attributes["Exterieur"] != null)
                {
                    XmlNode   partiCieNode = partiNode.SelectSingleNode("Entreprise");
                    string    partiCie     = partiCieNode.InnerText;
                    Exterieur E            = new Exterieur(partiName, partiSurname, partiCie);
                    P.AjoutParticipant(E, partiRole);
                }
                else if (partiNode.Attributes["Enseignant"] != null)
                {
                    Enseignant  E             = new Enseignant(partiName, partiSurname);
                    XmlNode     partiMatsNode = partiNode.SelectSingleNode("Matieres");
                    XmlNodeList partiMatNodes = partiMatsNode.SelectNodes("Matiere");
                    foreach (XmlNode partiMatNode in partiMatNodes)
                    {
                        E.AjoutMatiere(partiMatNode.InnerText);
                    }
                    P.AjoutParticipant(E, partiRole);
                }
            }



            //Livrables
            XmlNode     livsNode = baseNode.SelectSingleNode("Livrables");
            XmlNodeList livNodes = livsNode.SelectNodes("Livrable");

            foreach (XmlNode livNode in livNodes)
            {
                XmlNode  livTypeNode = livNode.SelectSingleNode("Type");
                XmlNode  livDateNode = livNode.SelectSingleNode("Date");
                XmlNode  livNoteNode = livNode.SelectSingleNode("Note");
                Livrable L           = new Livrable(DateTime.Parse(livDateNode.InnerText), livTypeNode.InnerText, int.Parse(livNoteNode.InnerText));
                P.AjoutLivrable(L);
            }

            //Matieres
            XmlNode     matsNode = baseNode.SelectSingleNode("Matieres");
            XmlNodeList matNodes = matsNode.SelectNodes("Matiere");

            foreach (XmlNode matNode in matNodes)
            {
                P.AjoutMatiere(matNode.InnerText);
            }

            //Renouvellement
            XmlNode renewNode = baseNode.SelectSingleNode("RenouvellementDe");

            P.SuiteDe(int.Parse(renewNode.InnerText));

            return(P);
        }
Ejemplo n.º 4
0
 public void AjoutLivrable(Livrable L)
 {
     ListeLivrables.Add(L);
 }