private void saveAsDocButton_Click(object sender, EventArgs e) { ICVFormat cvformat = CVFactory.getCVFormat(m_ChosenDesign); CVCreator cvDecorater = new CVCreator(cvformat); cvDecorater.createCV(m_UserInfo, "doc"); MessageBox.Show("File Saved successfuly"); }
private void GenerateCVXml(string documentXmlPath, string outputPath) { string currentIdent = string.Empty; Utilisateur newUtilisateur = null; SectionsExtractor CvSectionsExtractor = new SectionsExtractor(); List <XmlNode> nodes = CvSectionsExtractor.GetCVNodes(documentXmlPath); CVFactory cVFactory = new CVFactory(documentXmlPath); Console.WriteLine($"Fichier actuel: {documentXmlPath}"); try { newUtilisateur = cVFactory.CreateConseiller(nodes); PersistCV(newUtilisateur); } catch (Exception ex) { using (StreamWriter sw = new StreamWriter("Error.log", true)) { sw.WriteLine(documentXmlPath); sw.WriteLine(ex.Message); sw.WriteLine(ex.StackTrace); sw.WriteLine("=============================X=============================="); sw.WriteLine(string.Empty); } } finally { FileInfo fileInfo = new FileInfo(outputPath); if (fileInfo.Exists) { fileInfo.Delete(); } XmlSerializer xmlSerializer = new XmlSerializer(typeof(Utilisateur)); using (Stream fileStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlSerializer.Serialize(fileStream, newUtilisateur); } } }