1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
public static List<Projet> recupMesProjet()
{
chargementFichierProjetsXml();
List<Projet> lesProjets = new List<Projet>();
XmlNodeList noeudsLesProjets = FichierProjetsXml.SelectNodes("//projets//projet");
// Variables concernant les details d'un projet
// ********************************************
int numProjet;
string titreProjet = "";
string descriptionProjet;
string prioriteProjet;
string statutProjet;
int budgetProjet;
string dateDebutProjet;
string dateFinProjet;
// Variables concernant les détails d'une tache
// ********************************************
string nomTache;
string descriptionTache;
string prioriteTache;
int coutTache;
string statutTache;
// ° Pour une tache interne
int numService;
string nomService;
// ° Pour une tache sous-traitée
int idEntreprise = -1;
string raisonSocial;
string specialite;
foreach (XmlNode noeudLeProjet in noeudsLesProjets)
{
List<Tache> mesTaches = new List<Tache>();
numProjet = Int32.Parse(noeudLeProjet.Attributes["projetid"].InnerText);
titreProjet = noeudLeProjet.SelectSingleNode("titre").InnerText;
descriptionProjet = noeudLeProjet.SelectSingleNode("description").InnerText;
prioriteProjet = noeudLeProjet.SelectSingleNode("priorite").InnerText;
statutProjet = noeudLeProjet.SelectSingleNode("statut").InnerText;
budgetProjet = Int32.Parse(noeudLeProjet.SelectSingleNode("budget").InnerText);
dateDebutProjet = noeudLeProjet.SelectSingleNode("datedebut").InnerText;
dateFinProjet = noeudLeProjet.SelectSingleNode("datefin").InnerText;
XmlNodeList noeudsLesTaches = noeudLeProjet.SelectNodes("//taches//tache");
foreach(XmlNode noeudLaTache in noeudsLesTaches)
{
nomTache = noeudLaTache.SelectSingleNode("nom").InnerText;
descriptionTache = noeudLaTache.SelectSingleNode("description").InnerText;
prioriteTache = noeudLaTache.SelectSingleNode("priorite").InnerText;
coutTache = Int32.Parse(noeudLaTache.SelectSingleNode("cout").InnerText);
statutTache = noeudLaTache.SelectSingleNode("statut").InnerText;
if (noeudLaTache.Attributes["id"].Value.ToString() == "sous_traitees")
{
// On affecte les valeurs du fichier xml aux variables
idEntreprise = Int32.Parse(noeudLaTache.SelectSingleNode("//sousTraitee").Attributes["identreprise"].InnerText);
raisonSocial = noeudLaTache.SelectSingleNode("//sousTraitee//raison").InnerText;
specialite = noeudLaTache.SelectSingleNode("//sousTraitee//specialite").InnerText;
// On crée une list d'entreprise
List<Entreprise> listEntreprise = new List<Entreprise>();
// On crée un objet entreprise et on l'initialise
Entreprise monEntreprise = new Entreprise(idEntreprise, raisonSocial, specialite);
// On garni la list d'entreprise avec l'objet entreprise
listEntreprise.Add(monEntreprise);
// On crée un objet tachesoustraitee et on l'initialise avec les valeurs précedement obtenue
TacheSousTraite maTacheSousTraitee = new TacheSousTraite(nomTache, descriptionTache, prioriteTache, coutTache, statutTache, listEntreprise);
// On garni la list de taches avec l'objet maTacheSousTraitee
mesTaches.Add(maTacheSousTraitee);
int t = mesTaches.Count;
}
else if (noeudLaTache.Attributes["id"].Value.ToString() == "interne")
{
numService = Int32.Parse(noeudLaTache.SelectSingleNode("//equipes//equipe").Attributes["idequipe"].InnerText);
nomService = noeudLaTache.SelectSingleNode("//equipes//equipe").InnerText;
List<Service> listServices = new List<Service>();
Service monService = new Service(numService, nomService);
listServices.Add(monService);
TacheInterne maTacheInterne = new TacheInterne(nomTache, descriptionTache, prioriteTache, coutTache, statutTache, listServices);
mesTaches.Add(maTacheInterne);
int t = mesTaches.Count;
}
else { }
}
Projet monProjet = new Projet(numProjet, titreProjet, descriptionProjet, prioriteProjet, statutProjet, budgetProjet, mesTaches, dateDebutProjet, dateFinProjet);
lesProjets.Add(monProjet);
}
return lesProjets; |
Partager