public CVFormationAcademiqueController()
 {
     utilisateurGraphRepository       = new UtilisateurGraphRepository();
     editionObjectGraphRepository     = new EditionObjectGraphRepository();
     formationScolaireGraphRepository = new FormationScolaireGraphRepository();
     instituitionGraphRepository      = new InstituitionGraphRepository();
 }
Esempio n. 2
0
        private void AssamblerFormations(CVSection sectionFormation)
        {
            FormationScolaireGraphRepository formationScolaireGraphRepository = new FormationScolaireGraphRepository();
            InstituitionGraphRepository      instituitionGraphRepository      = new InstituitionGraphRepository();

            string nomInstituition = string.Empty, nomDiplome = string.Empty;

            XmlDocTable            tableFormation      = (XmlDocTable)sectionFormation.Nodes.First(x => x is XmlDocTable);
            List <XmlDocParagraph> formationParagraphs = tableFormation.GetParagraphsFromColumn(1).Skip(1).ToList();

            formationParagraphs.RemoveAll(x => string.IsNullOrEmpty(x.GetParagraphText()));

            List <WordLine> Lines = new List <WordLine>();

            for (int i = 0; i < formationParagraphs.Count; i++)
            {
                Lines.AddRange(formationParagraphs[i].GetLines());
            }

            StringBuilder sb = new StringBuilder();
            WordLine      currentLine;

            while (Lines.Count > 0)
            {
                currentLine = Lines.First();

                if (currentLine.IsBold())
                {
                    if (!string.IsNullOrEmpty(nomDiplome))
                    {
                        nomInstituition = sb.ToString();

                        FormationScolaire item;
                        Instituition      inst;

                        inst = instituitionGraphRepository.CreateIfNotExists(new Dictionary <string, object> {
                            { "Nom", nomInstituition }
                        });

                        item = formationScolaireGraphRepository.CreateIfNotExists(new Dictionary <string, object> {
                            { "Diplome", nomDiplome }, { "Niveau", NiveauScolarite.Nule }
                        });
                        item.Ecole = inst;

                        conseiller.FormationsScolaires.Add(item);

                        nomDiplome      = string.Empty;
                        nomInstituition = string.Empty;
                        sb.Clear();
                    }

                    sb.Append(currentLine.GetText());
                    Lines.Remove(currentLine);
                }
                else
                {
                    if (string.IsNullOrEmpty(nomDiplome))
                    {
                        nomDiplome = sb.ToString();
                        sb.Clear();
                    }

                    sb.Append(currentLine.GetText());
                    Lines.Remove(currentLine);
                }
            }

            if (!string.IsNullOrEmpty(nomDiplome) && !string.IsNullOrEmpty(sb.ToString()))
            {
                nomInstituition = sb.ToString();

                FormationScolaire item;
                Instituition      inst;

                inst = instituitionGraphRepository.CreateIfNotExists(new Dictionary <string, object> {
                    { "Nom", nomInstituition }
                });

                item = formationScolaireGraphRepository.CreateIfNotExists(new Dictionary <string, object> {
                    { "Diplome", nomDiplome }, { "Niveau", NiveauScolarite.Nule }
                });
                item.Ecole = inst;

                conseiller.FormationsScolaires.Add(item);
            }
        }