| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.ComponentModel;
- using System.Reflection;
- using System.Xml;
- using System.Xml.Serialization;
- using CG67.FicheCollege.Domaine;
- using CG67.FicheCollege.Entrepot;
- using CG67.FicheCollege.Interface;
- using System.Collections;
- namespace CG67.FicheCollege.Service
- {
- /// <summary>
- /// Une méthode est déclarée pour chaque Entrepot, ceci permet l'appel en static depuis n'importe où
- /// y compris depuis une page ASP.
- /// </summary>
- [DataObject]
- public static class ServiceFiche
- {
- public static IList<ActionEducative> GetActionEducativeByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotActionEducative().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<ClasseDecouverte> GetClasseDecouverteByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotClasseDecouverte().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<ATC> GetATCByRNE(string codeRNE)
- {
- try
- {
- return EntrepotFactory.GetEntrepotATC().GetByCodeRNE(codeRNE);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<ContratAide> GetContratAideByRNE(string codeRNE)
- {
- try
- {
- return EntrepotFactory.GetEntrepotContratAide().GetByCodeRNE(codeRNE);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<Bilinguisme> GetBilinguismeByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotBilinguisme().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static Dotation GetDotationByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotDotation().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<InvestissementDCE> GetEquipementByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotEquipement().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<Investissement> GetInvestissementByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotInvestissement().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<EffectifDetail> GetEffectifDetailByCodeRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotEffectifDetail().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static Logement GetLogementByRNE(string codeRNE)
- {
- try
- {
- return EntrepotFactory.GetEntrepotLogement().GetByCodeRNE(codeRNE);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static MCG GetMCGByRNE(string codeRNE)
- {
- try
- {
- return EntrepotFactory.GetEntrepotMCG().GetByCodeRNE(codeRNE);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<ProjetPilote> GetProjetPiloteByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotProjetPilote().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<RestaurationExterne> GetRestaurationExterneByRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotRestaurationExterne().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static IList<Contact> GetContactByRNE(string codeRNE)
- {
- try
- {
- return EntrepotFactory.GetEntrepotContact().GetByCodeRNE(codeRNE);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static ChiffresSignificatifs GetChiffresSignificatifsByAnnee(int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotChiffresSignificatifs().GetByAnnee(annee);
- }
- catch (Exception erreur)
- {
- throw new Exception(erreur.ToString());
- }
- }
- public static Commentaires GetCommentairesByCodeRNE(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotCommentaires().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch
- {
- throw;
- }
- }
- public static Restauration GetRestaurationByCodeRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotRestauration().GetByRNEAndAnnee(codeRNE, annee);
- }
- catch
- {
- throw;
- }
- }
- public static IList<ProgTravaux> GetProgTravauxByCodeRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotProgTravaux().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch
- {
- throw;
- }
- }
- public static IList<Etablissement> GetAllEtablissement()
- {
- try
- {
- return EntrepotFactory.GetEntrepotEtablissement().GetAll();
- }
- catch
- {
- throw;
- }
- }
- public static Etablissement GetEtablissementByCodeRNEAndAnnee(string codeRNE, int annee)
- {
- try
- {
- return EntrepotFactory.GetEntrepotEtablissement().GetByCodeRNEAndAnnee(codeRNE, annee);
- }
- catch
- {
- throw;
- }
- }
- private static XmlNode GetXml(Object aSerialiser,XmlDocument document)
- {
- XmlNode resultat = document.CreateElement(aSerialiser.GetType().Name);
- foreach (PropertyInfo pi in aSerialiser.GetType().GetProperties())
- {
- if (pi.PropertyType.IsSerializable)
- {
- object valeur = pi.GetValue(aSerialiser, null);
- resultat.AppendChild(document.CreateElement(pi.Name)).InnerXml = valeur == null ? string.Empty : valeur.ToString() ;
- }
-
-
- }
- return resultat;
- }
- static XmlNode Serializer(Object objet, XmlDocument doc)
- {
-
- XmlNode resultat = doc.CreateElement(objet.GetType().Name);
-
- foreach (PropertyInfo pi in objet.GetType().GetProperties())
- {
- // Si la propriété comporte une méthode "count" je considère c'est une Liste
- if (pi.GetValue(objet, null) != null)
- {
- MethodInfo mi = pi.GetValue(objet, null).GetType().GetMethod("get_Count");
- if (mi != null)
- {
- object objListe = pi.GetValue(objet, null);
- int nb = (int)(mi.Invoke(objListe, null));
- // a revoir
- XmlElement element = doc.CreateElement(pi.Name);
- // element.Normalize();
- XmlNode item = resultat.AppendChild(element);
- for (int i = 0; i < nb; i++)
- { // on sérialise tous les items de la liste
- object obj = objListe.GetType().GetMethod("get_Item").Invoke(objListe, new Object[] { i });
- item.AppendChild(Serializer(obj, doc));
- }
- }
- else // c'est pas une Liste
- {
- switch (pi.GetValue(objet, null).GetType().Name)
- { // si c'est une type de "base" on l'affiche
- case "String":
- case "Int16":
- case "Int32":
- case "Double":
- case "Single":
- case "Boolean":
- resultat.AppendChild(doc.CreateElement(pi.Name)).InnerXml = pi.GetValue(objet, null).ToString();
- break;
- default: // sinon on le décompose recursivement
- resultat.AppendChild(Serializer(pi.GetValue(objet, null), doc));
- break;
- }
- }
- }
- }
- return resultat;
- }
-
- public static XmlNode GetFicheCollege(string codeRNE, int annee)
- {
-
- XmlDocument resultat = new XmlDocument();
- XmlNode xmlCollege = resultat.AppendChild(resultat.CreateElement("college"));
-
- Etablissement etablissement = GetEtablissementByCodeRNEAndAnnee(codeRNE, annee);
- xmlCollege.AppendChild(Serializer(etablissement,resultat));
- ChiffresSignificatifs chiffres = GetChiffresSignificatifsByAnnee(annee);
- xmlCollege.AppendChild(Serializer(chiffres,resultat));
- return resultat;
-
- }
-
-
- }
- }
|