Esempio n. 1
0
        private void AssemblerBio(CVSection sectionIdentification)
        {
            FonctionGraphRepository fonctionGraphRepository = new FonctionGraphRepository();
            XmlDocNode identification = sectionIdentification.Nodes.First();

            Fonction fonction = new Fonction();
            CV       cv       = new CV();

            if (identification is XmlDocTable)
            {
                var           paragraphs = ((XmlDocTable)identification).GetParagraphsFromColumn(2);
                List <string> identLines = new List <string>();
                if (paragraphs.Count() == 1)
                {
                    XmlDocParagraph paragraph = paragraphs.First <XmlDocParagraph>();
                    identLines.AddRange(paragraph.GetLinesText());
                }
                else
                {
                    foreach (var paragragh in paragraphs)
                    {
                        identLines.AddRange(paragragh.GetLinesText());
                    }
                }


                utilisateur     = new Utilisateur();
                utilisateur.Nom = identLines.First();
                fonction        = fonctionGraphRepository.CreateIfNotExists(new Dictionary <string, object> {
                    { "Description", identLines.Last() }
                });
            }

            string description = string.Empty;
            List <XmlDocParagraph> descriptionParagraphs = sectionIdentification.Nodes.Skip(2).Cast <XmlDocParagraph>().ToList();

            descriptionParagraphs.ForEach(x => description = $"{description}\n{x.GetText()}");

            cv.ResumeExperience = description;
            cv.Status           = StatusCV.Nouveau;


            utilisateur.Conseiller = conseiller;
            conseiller.Fonction    = fonction;
            conseiller.CVs.Add(cv);
        }
Esempio n. 2
0
        private Mandat AssemblerMandat(List <XmlDocNode> mandatNodes)
        {
            ProjetGraphRepository      projetGraphRepository      = new ProjetGraphRepository();
            FonctionGraphRepository    fonctionGraphRepository    = new FonctionGraphRepository();
            TechnologieGraphRepository technologieGraphRepository = new TechnologieGraphRepository();

            Mandat      mandat      = new Mandat();
            Projet      projet      = new Projet();
            Technologie technologie = null;

            int    parseInt = 0, mois, annee;
            string concatenatedString, envergureText, environnement, tech;

            string[] periode, debut, fin, splitedString, technologies;

            List <XmlDocParagraph> infoParagraphs = new List <XmlDocParagraph>(), infoParagraphsSecondColumn = new List <XmlDocParagraph>();

            XmlDocTable infoTable = (XmlDocTable)mandatNodes.First(x => x is XmlDocTable);

            infoParagraphs.AddRange(infoTable.GetParagraphsFromColumn(1));
            infoParagraphsSecondColumn.AddRange(infoTable.GetParagraphsFromColumn(2));

            for (int i = 0; i < infoParagraphs.Count; i++)
            {
                concatenatedString = string.Empty;

                if (infoParagraphs[i].GetParagraphText().Contains("Projet"))
                {
                    projet.Nom = infoParagraphsSecondColumn[i].GetParagraphText();
                }

                if (infoParagraphs[i].GetParagraphText().Contains("Mandat"))
                {
                    mandat.Numero = infoParagraphsSecondColumn[i].GetParagraphText();
                }

                if (infoParagraphs[i].GetParagraphText().Contains("Envergure"))
                {
                    envergureText = infoParagraphsSecondColumn[i].GetParagraphText().Trim();
                    if (envergureText.Any(x => char.IsDigit(x)))
                    {
                        projet.Envergure = int.Parse(string.Join("", envergureText.Where(x => char.IsDigit(x)).ToArray()));
                    }
                }


                if (infoParagraphs[i].GetParagraphText().Contains("Fonction"))
                {
                    Fonction fonction;
                    fonction = fonctionGraphRepository.CreateIfNotExists(new Dictionary <string, object> {
                        { "Description", infoParagraphsSecondColumn[i].GetParagraphText() }
                    });

                    mandat.Fonction = fonction;
                }

                if (infoParagraphs[i].GetParagraphText().Contains("Période"))
                {
                    periode = infoParagraphsSecondColumn[i].GetParagraphText().Split("à");
                    if (periode.Length > 1)
                    {
                        debut = periode[0].Trim().Split(" ").Where(x => !string.IsNullOrEmpty(x)).ToArray();
                        if (debut.Length > 1)
                        {
                            mois             = DicMois[RemoveAcentuation(debut[0].Trim().ToUpper())];
                            annee            = int.Parse(debut[1].Trim());
                            mandat.DateDebut = DateTime.Parse($"{annee}-{mois}-01");
                        }

                        if (periode[1].Contains("ce jour"))
                        {
                            mandat.DateFin = DateTime.MinValue;
                        }
                        else
                        {
                            fin = periode[1].Trim().Split(" ").Where(x => !string.IsNullOrEmpty(x)).ToArray();
                            if (fin.Length > 1)
                            {
                                mois           = DicMois[RemoveAcentuation(fin[0].Trim().ToUpper())];
                                annee          = int.Parse(fin[1].Sanitize());
                                mandat.DateFin = DateTime.Parse($"{annee}-{mois}-01");
                            }
                        }
                    }
                }

                if (infoParagraphs[i].GetParagraphText().Contains("Efforts"))
                {
                    splitedString = infoParagraphsSecondColumn[i].GetParagraphText().Split(" ");
                    parseInt      = 0;

                    if (int.TryParse(splitedString[0], out parseInt))
                    {
                        mandat.Efforts = parseInt;
                    }
                }


                if (infoParagraphs[i].GetParagraphText().Contains("Référence"))
                {
                    projet.NomReference = infoParagraphsSecondColumn[i].GetParagraphText();
                }
            }


            infoParagraphsSecondColumn.Clear();
            infoParagraphsSecondColumn = null;

            infoParagraphs.Clear();
            infoParagraphs = mandatNodes.SkipWhile(x => x is XmlDocTable).Cast <XmlDocParagraph>().ToList();

            var sections = new List <CVSection>();
            SectionsExtractor CvSectionsExtractor = new SectionsExtractor();

            List <XmlNode>   Nodes       = (List <XmlNode>)infoParagraphs.Select(x => x.OriginalNode).ToList();
            List <IXmlToken> matchTokens = new List <IXmlToken>();

            matchTokens.Add(MandatTextToken.CreateTextToken());

            try
            {
                sections = CvSectionsExtractor.GetCVSections(Nodes, matchTokens, "DESCRIPTION");

                aSection = sections.DefaultIfEmpty(null).FirstOrDefault(x => x.Identifiant == "DESCRIPTION");
                AssemblerDescription(aSection, projet);
            }
            catch (Exception ex)
            {
                WriteToErrorLog(ex);
            }

            try
            {
                aSection = sections.DefaultIfEmpty(null).FirstOrDefault(x => x.Identifiant == "ENVIRONNEMENT TECHNOLOGIQUE");
                AssemblerEnvironnementTecnologic(aSection, projet);
            }
            catch (Exception ex)
            {
                WriteToErrorMessageLog("Mandat" + projet.Description);
                WriteToErrorLog(ex);
            }

            try
            {
                aSection = sections.DefaultIfEmpty(null).FirstOrDefault(x => x.Identifiant == "LES TÂCHES SUIVANTES");
                AssemblerTache(aSection, mandat);
            }
            catch (Exception ex)
            {
                WriteToErrorMessageLog("Mandat:  " + projet.Nom);
                WriteToErrorLog(ex);
            }

            mandat.Titre  = projet.Nom;
            mandat.Projet = projet;

            projet.DateDebut = mandat.DateDebut;
            projet.DateFin   = mandat.DateFin;

            return(mandat);
        }