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
{
///
/// 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.
///
[DataObject]
public static class ServiceFiche
{
public static IList GetActionEducativeByRNEAndAnnee(string codeRNE, int annee)
{
try
{
return EntrepotFactory.GetEntrepotActionEducative().GetByCodeRNEAndAnnee(codeRNE, annee);
}
catch (Exception erreur)
{
throw new Exception(erreur.ToString());
}
}
public static IList GetATCByRNE(string codeRNE)
{
try
{
return EntrepotFactory.GetEntrepotATC().GetByCodeRNE(codeRNE);
}
catch (Exception erreur)
{
throw new Exception(erreur.ToString());
}
}
public static 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 GetEquipementByRNEAndAnnee(string codeRNE, int annee)
{
try
{
return EntrepotFactory.GetEntrepotEquipement().GetByCodeRNEAndAnnee(codeRNE, annee);
}
catch (Exception erreur)
{
throw new Exception(erreur.ToString());
}
}
public static IList GetInvestissementByRNEAndAnnee(string codeRNE, int annee)
{
try
{
return EntrepotFactory.GetEntrepotInvestissement().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 GetProjetPiloteByRNEAndAnnee(string codeRNE, int annee)
{
try
{
return EntrepotFactory.GetEntrepotProjetPilote().GetByCodeRNEAndAnnee(codeRNE, annee);
}
catch (Exception erreur)
{
throw new Exception(erreur.ToString());
}
}
public static IList GetRestaurationExterneByRNEAndAnnee(string codeRNE, int annee)
{
try
{
return EntrepotFactory.GetEntrepotRestaurationExterne().GetByCodeRNEAndAnnee(codeRNE, annee);
}
catch (Exception erreur)
{
throw new Exception(erreur.ToString());
}
}
public static IList 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 GetProgTravauxByCodeRNEAndAnnee(string codeRNE, int annee)
{
try
{
return EntrepotFactory.GetEntrepotProgTravaux().GetByCodeRNEAndAnnee(codeRNE, annee);
}
catch
{
throw;
}
}
public static IList 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;
}
public static XmlNode GetFicheCollege(string codeRNE, int annee)
{
XmlDocument resultat = new XmlDocument();
Etablissement etablissement = GetEtablissementByCodeRNEAndAnnee(codeRNE, annee);
XmlNode xmlCollege = resultat.AppendChild(resultat.CreateElement("college"));
XmlNode xmlEtablissement = GetXml(etablissement, resultat);
xmlCollege.AppendChild(xmlEtablissement);
XmlNode xmlActionsEducatives = xmlEtablissement.AppendChild(resultat.CreateElement("LstActionsEducatives"));
foreach (ActionEducative ae in etablissement.LstActionEducatives)
xmlActionsEducatives = GetXml(ae, resultat);
XmlNode xmlATC = xmlEtablissement.AppendChild(resultat.CreateElement("LstATC"));
foreach (ATC atc in etablissement.LstATC)
xmlATC = GetXml(atc, resultat);
XmlNode xmlEffectifPrev = xmlEtablissement.AppendChild(resultat.CreateElement("LstEffectifPrevisionnel"));
foreach (int effectifPrev in etablissement.LstEffectifPrevisionnel)
xmlEffectifPrev= GetXml(effectifPrev , resultat);
XmlNode xmlEffectifReel = xmlEtablissement.AppendChild(resultat.CreateElement("LstEffectifReel"));
foreach (int effectifReel in etablissement.LstEffectifReel)
xmlEffectifReel = GetXml(effectifReel, resultat);
XmlNode xmlEquipement = xmlEtablissement.AppendChild(resultat.CreateElement("LstEquipement"));
foreach (Equipement equipement in etablissement.LstEquipements)
xmlEquipement = GetXml(equipement , resultat);
XmlNode xmlInvestissement = xmlEtablissement.AppendChild(resultat.CreateElement("LstInvestissement"));
foreach (Investissement investissement in etablissement.LstInvestissement)
xmlInvestissement = GetXml(investissement , resultat);
XmlNode xmlProjet = xmlEtablissement.AppendChild(resultat.CreateElement("LstProjetPilote"));
foreach (ProjetPilote projet in etablissement.LstProjetPilote)
xmlProjet = GetXml(projet , resultat);
XmlNode xmlRestructuration = xmlEtablissement.AppendChild(resultat.CreateElement("LstRestructuration"));
foreach (int restructuration in etablissement.LstRestructuration )
xmlRestructuration = GetXml(restructuration , resultat);
XmlNode xmlSecteur = xmlEtablissement.AppendChild(resultat.CreateElement("LstSecteurRecrutement"));
foreach (string secteur in etablissement.LstSecteurRecrutement)
xmlSecteur= GetXml(secteur , resultat);
XmlNode xmlTravaux = xmlEtablissement.AppendChild(resultat.CreateElement("LstTravaux"));
foreach (ProgTravaux travaux in etablissement.LstTravaux)
xmlTravaux = GetXml(travaux , resultat);
return resultat;
}
}
}