private void AssamblerTechnologies(CVSection sectionTechnologies) { TechnologieGraphRepository technologieGraphRepository = new TechnologieGraphRepository(); CategorieDeTechnologieGraphRepository categorieDeTechnologieGraphRepository = new CategorieDeTechnologieGraphRepository(); XmlDocTable tableTechnologies = (XmlDocTable)sectionTechnologies.Nodes.First(x => x is XmlDocTable); List <XmlDocParagraph> lineParagraphsColumn1 = new List <XmlDocParagraph>(), lineParagraphsColumn2 = new List <XmlDocParagraph>(); List <KeyValuePair <string, string> > listOfTech = new List <KeyValuePair <string, string> >(); Technologie technologie; CategorieDeTechnologie categorie = null; string techNom, mois; for (int i = 1; i <= tableTechnologies.CountColumns(); i = i + 3) { lineParagraphsColumn1 = tableTechnologies.GetParagraphsFromColumn(i); lineParagraphsColumn2 = tableTechnologies.GetParagraphsFromColumn(i + 1); for (int j = 1; j < lineParagraphsColumn1.Count; j++) { if (string.IsNullOrEmpty(lineParagraphsColumn1[j].GetParagraphText())) { continue; } if (string.IsNullOrEmpty(lineParagraphsColumn2[j].GetParagraphText())) { categorie = categorieDeTechnologieGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Nom", lineParagraphsColumn1[j].GetParagraphText().Replace(":", "").Trim() } }); } else { techNom = lineParagraphsColumn1[j].GetParagraphText(); mois = lineParagraphsColumn2[j].GetParagraphText().Replace(".", ","); technologie = technologieGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Nom", techNom } }); technologie.MoisDExperience = Convert.ToInt32(mois); if (categorie != null) { technologie.Categorie = categorie; } conseiller.Technologies.Add(technologie); } } } }
private void AssemblerCertifications(CVSection sectionFormation) { XmlDocTable tableFormation = (XmlDocTable)sectionFormation.Nodes.First(x => x is XmlDocTable); List <XmlDocParagraph> formationParagraphs = tableFormation.GetParagraphsFromColumn(2).Skip(1).ToList(); FormationGraphRepository formationGraphRepository = new FormationGraphRepository(); GenreGraphRepository genreGraphRepository = new GenreGraphRepository(); formationParagraphs.ForEach(x => { Formation formation; Genre genre = new Genre(); genre.Descriminator = "Formation"; genre.Description = "Certification"; genre = genreGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Description", genre.Description }, { "Descriminator", genre.Descriminator } }); string text = x.GetParagraphText(); if (!string.IsNullOrEmpty(text)) { formation = formationGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Description", text } }); formation.Type = genre; conseiller.Formations.Add(formation); } }); }
private void AssemblerPerfectionnement(CVSection sectionPerfectionnement) { GenreGraphRepository genreGraphRepository = new GenreGraphRepository(); FormationGraphRepository formationGraphRepository = new FormationGraphRepository(); Genre genre = new Genre(); genre.Descriminator = "Formation"; genre.Description = "Perfectionnement"; genre = genreGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Description", genre.Description }, { "Descriminator", genre.Descriminator } }); int annee = 0; XmlDocTable perfcTable = (XmlDocTable)sectionPerfectionnement.Nodes.First(x => x is XmlDocTable); List <XmlDocParagraph> firstColumn = new List <XmlDocParagraph>(), secondColumn = new List <XmlDocParagraph>(); firstColumn.AddRange(perfcTable.GetParagraphsFromColumn(1)); secondColumn.AddRange(perfcTable.GetParagraphsFromColumn(2)); for (int i = 0; i < firstColumn.Count; i++) { Formation formation; if (!int.TryParse(firstColumn[i].GetParagraphText(), out annee)) { annee = 0; } formation = formationGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Description", secondColumn[i].GetParagraphText() }, { "AnAcquisition", annee } }); formation.Type = genre; conseiller.Formations.Add(formation); } }
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); }
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); } }