private List <Client> AssemblerClients(CVSection employeurSection, Employeur emp) { List <Client> clients = new List <Client>(); List <CVSection> clientSections = new List <CVSection>(); List <XmlDocNode> empNodes = new List <XmlDocNode>(); SectionsExtractor sectionsExtractor = new SectionsExtractor(); clientSections.AddRange(sectionsExtractor.GetCVSections(employeurSection.GetOriginalNodes, new List <IXmlToken>() { FormatationToken.CreateFormatationToken(new KeyValuePair <string, string>("w:val", "Titre2")) }, "Titre2", true)); clientSections.ForEach(x => { try { Client client = AssemblerClient(x, emp); clients.Add(client); } catch (Exception ex) { WriteToErrorLog(ex); } }); return(clients); }
private void AssemblerLangues(CVSection langueSection) { LangueGraphRepository langueGraphRepository = new LangueGraphRepository(); List <Langue> langues = new List <Langue>(); List <CVSection> langueSections; SectionsExtractor extractor = new SectionsExtractor(); langueSections = extractor.GetCVSections(langueSection.GetOriginalNodes.Skip(1).ToList(), new List <IXmlToken>() { FormatationToken.CreateFormatationToken(new KeyValuePair <string, string>("w:val", "Puce1")) }, "w:b", true); foreach (CVSection section in langueSections) { Langue curLangue = new Langue(); XmlDocParagraph langueNom = (XmlDocParagraph)section.Nodes.First(x => x is XmlDocParagraph); curLangue.Nom = langueNom.GetParagraphText(); curLangue = langueGraphRepository.CreateIfNotExists(new Dictionary <string, object> { { "Nom", curLangue.Nom } }); if (section.Nodes.Skip(1).Count() > 0) { foreach (XmlDocParagraph langueNiveau in section.Nodes.Skip(1).Cast <XmlDocParagraph>().ToList()) { string[] niveau = langueNiveau.GetParagraphText().Split(':'); if (niveau[0].Contains("Parlé")) { curLangue.Parle = (Niveau)System.Enum.Parse(typeof(Niveau), niveau[1].Trim().Replace("-", "").ToCamelCase()); } if (niveau[0].Contains("Écrit")) { curLangue.Ecrit = (Niveau)System.Enum.Parse(typeof(Niveau), niveau[1].Trim().Replace("-", "").ToCamelCase()); } if (niveau[0].Contains("Lu")) { curLangue.Lu = (Niveau)System.Enum.Parse(typeof(Niveau), niveau[1].Trim().Replace("-", "").ToCamelCase()); } } } else { curLangue.Parle = curLangue.Ecrit = curLangue.Lu = Niveau.Avancé; } langues.Add(curLangue); } conseiller.Langues.AddRange(langues); }
public Utilisateur CreateConseiller(List <XmlNode> Nodes) { SectionsExtractor CvSectionsExtractor = new SectionsExtractor(); List <IXmlToken> matchTokens = new List <IXmlToken>(); matchTokens.Add(TextToken.CreateTextToken()); matchTokens.Add(FormatationToken.CreateFormatationToken(new KeyValuePair <string, string>("w:val", "Titre1"))); List <CVSection> Sections = null; try { Sections = CvSectionsExtractor.GetCVSections(Nodes, matchTokens, "IDENTIFICATION"); conseiller = new Conseiller(); AssemblerConseiller(Sections); } catch (Exception ex) { WriteToErrorLog(ex); } return(utilisateur); }
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); }