Пример #1
0
        public static Enseignant ReconstructionEnseignant(XmlDocument xmlDoc, XmlNode baseNode)
        {
            //Le XmlNode en entrée doit correspondre au noeud <Enseignant>
            XmlNode     idNode      = baseNode.SelectSingleNode("Id");
            int         id          = int.Parse(idNode.InnerText);
            XmlNode     nameNode    = baseNode.SelectSingleNode("Nom");
            string      nom         = nameNode.InnerText;
            XmlNode     surnameNode = baseNode.SelectSingleNode("Prenom");
            string      surname     = surnameNode.InnerText;
            Enseignant  E           = new Enseignant(nom, surname, id);
            XmlNode     matsNode    = baseNode.SelectSingleNode("Matieres");
            XmlNodeList matNodes    = matsNode.SelectNodes("Matiere");

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

            return(E);
        }
Пример #2
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);
        }