protected void CreateArchiveSubmission(PublicationInformation projInfo, InProcess inProcess, string epub3Path) { inProcess.SetStatus("Archive"); var ramp = new Ramp { ProjInputType = projInfo.ProjectInputType }; ramp.Create(projInfo.DefaultXhtmlFileWithPath, ".zip", projInfo.ProjectInputType); inProcess.PerformStep(); }
protected static void FinalCleanUp(InProcess inProcess, string outputPathWithFileName) { inProcess.SetStatus("Final Clean up"); CopyToParentFolder(outputPathWithFileName); var extn = Path.GetExtension(outputPathWithFileName); var rampfileName = outputPathWithFileName.Substring(0, outputPathWithFileName.Length - extn.Length) + ".ramp"; CopyToParentFolder(rampfileName); Common.CleanupExportFolder(Path.GetDirectoryName(outputPathWithFileName), string.Empty, string.Empty, "Epub2,Epub3,AudioVisual,pictures"); inProcess.PerformStep(); }
protected string PackageHtml5(PublicationInformation projInfo, InProcess inProcess, string path) { inProcess.SetStatus("Packaging for Html5"); string fileNameV3 = CreateFileNameFromTitle(projInfo); var resultFileName = Path.Combine(projInfo.DictionaryPath, fileNameV3 + ".zip"); var zf = new ZipFolder(); zf.CreateZip(path, resultFileName, 0); #if (TIME_IT) TimeSpan tsTotal = DateTime.Now - dt1; Debug.WriteLine("Exportepub: time spent in .epub conversion: " + tsTotal); #endif inProcess.PerformStep(); return(resultFileName); }
protected string CreateHtml5(PublicationInformation projInfo, InProcess inProcess, string epub3Path) { inProcess.SetStatus("Copy html files"); string htmlFolderPath = Common.PathCombine(Path.GetDirectoryName(epub3Path), "HTML5"); string oebpsFolderPath = Common.PathCombine(epub3Path, "OEBPS"); var bootstrapToc = Common.PathCombine(epub3Path, "bootstrapToc.html"); File.Copy(Path.Combine(oebpsFolderPath, "toc.ncx"), bootstrapToc); Common.ApplyXslt(bootstrapToc, _toc2Html5); Common.CustomizedFileCopy(inProcess, oebpsFolderPath, htmlFolderPath, "content.opf,toc.xhtml,toc.ncx,File3TOC00000_.html,File2TOC00000_.html,File1TOC00000_.html,File0TOC00000_.html"); var avFolder = Path.Combine(projInfo.ProjectPath, "AudioVisual"); if (Directory.Exists(avFolder)) { FolderTree.Copy(avFolder, Path.Combine(htmlFolderPath, "pages", "AudioVisual")); } File.Delete(bootstrapToc); return(htmlFolderPath); }
protected static void CleanUp(InProcess inProcess, string outputPathWithFileName) { inProcess.SetStatus("Clean up"); Common.CleanupExportFolder(outputPathWithFileName, ".tmp,.de", "_1.x", string.Empty); inProcess.PerformStep(); }
private void ExportProcess(List<XmlDocument> usxBooksToExport, string publicationName, string format, string outputLocationPath, DialogResult result) { #if (TIME_IT) DateTime dt1 = DateTime.Now; // time this thing #endif bool success; var inProcess = new InProcess(0, 6); var curdir = Environment.CurrentDirectory; var myCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; inProcess.Text = "Scripture Export"; inProcess.Show(); inProcess.PerformStep(); inProcess.ShowStatus = true; inProcess.SetStatus("Processing Scripture Export"); string pubName = publicationName; MFormat = format; // Get the file name as set on the dialog. MOutputLocationPath = outputLocationPath; inProcess.PerformStep(); if (MFormat.StartsWith("theWord")) { ExportUsx(usxBooksToExport); } inProcess.PerformStep(); string cssFullPath = Common.PathCombine(MOutputLocationPath, pubName + ".css"); StyToCss styToCss = new StyToCss(); styToCss.ConvertStyToCss(_mProjectName, cssFullPath, string.Empty); string fileName = Common.PathCombine(MOutputLocationPath, pubName + ".xhtml"); inProcess.PerformStep(); if (File.Exists(fileName)) { // TODO: Localize string var msg = LocalizationManager.GetString("ParatextPathwayLink.ExportProcess.Message1", " already exists. Overwrite?", ""); result = MessageBox.Show(string.Format("{0}" + Environment.NewLine + msg, fileName), string.Empty, MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { fileName = Common.PathCombine(MOutputLocationPath, pubName + "-" + DateTime.Now.Second + ".xhtml"); } else if (result == DialogResult.No) { return; } } inProcess.PerformStep(); XmlDocument scrBooksDoc = CombineUsxDocs(usxBooksToExport, MFormat); inProcess.PerformStep(); if (string.IsNullOrEmpty(scrBooksDoc.InnerText)) { var message = LocalizationManager.GetString("ParatextPathwayLink.ExportProcess.Message2", "The current book has no content to export.", ""); MessageBox.Show(message, string.Empty, MessageBoxButtons.OK); return; } ConvertUsxToPathwayXhtmlFile(scrBooksDoc.InnerXml, fileName); success = true; Cursor.Current = myCursor; inProcess.PerformStep(); inProcess.Close(); PsExport exporter = new PsExport(); exporter.DataType = "Scripture"; exporter.Export(fileName); }
private void AddBooksMoveNotes(InProcess inProcess, List<string> htmlFiles, IEnumerable<string> splitFiles) { string xsltFullName = GetXsltFile(); string getPsApplicationPath = Common.GetPSApplicationPath(); string xsltProcessExe = Common.PathCombine(getPsApplicationPath, "XslProcess.exe"); inProcess.SetStatus("Apply Xslt Process in html file"); if (File.Exists(xsltProcessExe)) { foreach (string file in splitFiles) { const string outputExtension = "_.xhtml"; var inputExtension = Path.GetExtension(file); Debug.Assert(inputExtension != null); var xhtmlOutputFile = file.Replace(inputExtension, outputExtension); if (_isUnixOs) { if (file.Contains("File2Cpy")) { File.Copy(file, xhtmlOutputFile); } else { Common.XsltProcess(file, xsltFullName, outputExtension); } } else { var args = string.Format(@"""{0}"" ""{1}"" {2} ""{3}""", file, xsltFullName, outputExtension, getPsApplicationPath); Common.RunCommand(xsltProcessExe, args, 1); } if (File.Exists(xhtmlOutputFile)) { File.Delete(file); // clean up the un-transformed file } else if (File.Exists(file)) // SE version doesn't have the XSLT Transform { File.Move(file, xhtmlOutputFile); } htmlFiles.Add(xhtmlOutputFile); } } }
/// <summary> /// Entry point for GoBible converter /// </summary> /// <param name="projInfo">values passed including xhtml and css names</param> /// <returns>true if succeeds</returns> public bool Export(PublicationInformation projInfo) { bool success; #if (TIME_IT) DateTime dt1 = DateTime.Now; // time this thing #endif var inProcess = new InProcess(0, 7); try { var myCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; inProcess.Text = "GoBible Export"; inProcess.Show(); inProcess.PerformStep(); inProcess.ShowStatus = true; inProcess.SetStatus("Processing GoBible Export"); Param.LoadSettings(); Param.SetValue(Param.InputType, "Scripture"); Param.LoadSettings(); string fileTitle = "GoBibleOutput" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString(); _isLinux = Common.UnixVersionCheck(); string exportGoBibleInputPath = string.Empty; exportGoBibleInputPath = Path.GetDirectoryName(projInfo.DefaultCssFileWithPath).Replace("\\\\", "\\"); processFolder = exportGoBibleInputPath; PartialBooks.AddChapters(Common.PathCombine(processFolder, "SFM")); inProcess.PerformStep(); CreateCollectionsTextFile(exportGoBibleInputPath, fileTitle); inProcess.PerformStep(); var iconFullName = Common.FromRegistry(Common.PathCombine("GoBible/GoBibleCore", "Icon.png")); var iconDirectory = Path.GetDirectoryName(iconFullName); _iconFile = Path.GetFileName(iconFullName); const bool overwrite = true; if (iconDirectory != exportGoBibleInputPath) { File.Copy(iconFullName, Common.PathCombine(exportGoBibleInputPath, _iconFile), overwrite); } string layout = Param.GetItem("//settings/property[@name='LayoutSelected']/@value").Value; Dictionary <string, string> mobilefeature = Param.GetItemsAsDictionary("//stylePick/styles/mobile/style[@name='" + layout + "']/styleProperty"); string languageSelection = string.Empty; inProcess.PerformStep(); if (mobilefeature.ContainsKey("Language") && mobilefeature["Language"] != null) { languageSelection = mobilefeature["Language"].ToString(); } string goBibleFullPath = Common.FromRegistry("GoBible"); string tempGoBibleCreatorPath = GoBibleCreatorTempDirectory(goBibleFullPath); string goBibleCreatorPath = Common.PathCombine(tempGoBibleCreatorPath, "GoBibleCore"); inProcess.PerformStep(); string languageLocationPath = Common.PathCombine(goBibleFullPath, "User Interface"); languageLocationPath = Common.PathCombine(languageLocationPath, languageSelection); string[] filePaths = Directory.GetFiles(languageLocationPath, "*.properties"); goBibleCreatorPath = Common.PathCombine(goBibleCreatorPath, "ui.properties"); UIPropertiesCopyToTempFolder(goBibleCreatorPath, filePaths); BuildApplication(tempGoBibleCreatorPath); string jarFile = string.Empty; if (String.IsNullOrEmpty(NoSp(GetInfo(Param.Title)))) { jarFile = Common.PathCombine(processFolder, fileTitle + ".jar"); } else { jarFile = Common.PathCombine(processFolder, NoSp(GetInfo(Param.Title)) + ".jar"); } inProcess.PerformStep(); string caption = LocalizationManager.GetString("ExportGoBible.ExportClick.Caption", "Go Bible Export", ""); if (File.Exists(jarFile)) { Common.CleanupExportFolder(projInfo.DefaultXhtmlFileWithPath, ".tmp,.de", string.Empty, string.Empty); CreateRamp(projInfo); Common.DeleteDirectory(tempGoBibleCreatorPath); success = true; Cursor.Current = myCursor; inProcess.PerformStep(); inProcess.Close(); if (!Common.Testing) { // Failed to send the .jar to a bluetooth device. Tell the user to do it manually. var msg = LocalizationManager.GetString("ExportGoBible.ExportClick.Message1", "Please copy the file {0} to your phone.\n\nDo you want to open the folder?", ""); msg = string.Format(msg, jarFile); DialogResult dialogResult = Utils.MsgBox(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { string dirPath = Path.GetDirectoryName(jarFile); Process.Start(dirPath); } } } else { success = false; Cursor.Current = myCursor; inProcess.PerformStep(); inProcess.Close(); if (!Common.Testing) { var msg = LocalizationManager.GetString("ExportGoBible.ExportClick.Message2", "Failed Exporting GoBible Process.", ""); Utils.MsgBox(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { Console.WriteLine(ex.Message); success = false; inProcess.PerformStep(); inProcess.Close(); } return(success); }
/// <summary> /// Entry point for GoBible converter /// </summary> /// <param name="projInfo">values passed including xhtml and css names</param> /// <returns>true if succeeds</returns> public bool Export(PublicationInformation projInfo) { bool success; #if (TIME_IT) DateTime dt1 = DateTime.Now; // time this thing #endif var inProcess = new InProcess(0, 7); try { var curdir = Environment.CurrentDirectory; var myCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; inProcess.Text = "GoBible Export"; inProcess.Show(); inProcess.PerformStep(); inProcess.ShowStatus = true; inProcess.SetStatus("Processing GoBible Export"); _isLinux = Common.UnixVersionCheck(); string exportGoBibleInputPath = string.Empty; exportGoBibleInputPath = Path.GetDirectoryName(projInfo.DefaultCssFileWithPath); processFolder = exportGoBibleInputPath; PartialBooks.AddChapters(Common.PathCombine(processFolder, "SFM")); inProcess.PerformStep(); CreateCollectionsTextFile(exportGoBibleInputPath); inProcess.PerformStep(); var iconFullName = Common.FromRegistry(Common.PathCombine("GoBible/GoBibleCore", "Icon.png")); var iconDirectory = Path.GetDirectoryName(iconFullName); _iconFile = Path.GetFileName(iconFullName); const bool overwrite = true; if (iconDirectory != exportGoBibleInputPath) File.Copy(iconFullName, Common.PathCombine(exportGoBibleInputPath, _iconFile), overwrite); Param.LoadSettings(); Param.SetValue(Param.InputType, "Scripture"); Param.LoadSettings(); string layout = Param.GetItem("//settings/property[@name='LayoutSelected']/@value").Value; Dictionary<string, string> mobilefeature = Param.GetItemsAsDictionary("//stylePick/styles/mobile/style[@name='" + layout + "']/styleProperty"); string languageSelection = string.Empty; inProcess.PerformStep(); if (mobilefeature.ContainsKey("Language") && mobilefeature["Language"] != null) { languageSelection = mobilefeature["Language"].ToString(); } string goBibleFullPath = Common.FromRegistry("GoBible"); string tempGoBibleCreatorPath = GoBibleCreatorTempDirectory(goBibleFullPath); string goBibleCreatorPath = Common.PathCombine(tempGoBibleCreatorPath, "GoBibleCore"); inProcess.PerformStep(); string languageLocationPath = Common.PathCombine(goBibleFullPath, "User Interface"); languageLocationPath = Common.PathCombine(languageLocationPath, languageSelection); string[] filePaths = Directory.GetFiles(languageLocationPath, "*.properties"); goBibleCreatorPath = Common.PathCombine(goBibleCreatorPath, "ui.properties"); UIPropertiesCopyToTempFolder(goBibleCreatorPath, filePaths); BuildApplication(tempGoBibleCreatorPath); string jarFile = Common.PathCombine(processFolder, NoSp(GetInfo(Param.Title)) + ".jar"); inProcess.PerformStep(); string caption = LocalizationManager.GetString("ExportGoBible.ExportClick.Caption", "Go Bible Export", ""); if (File.Exists(jarFile)) { Common.CleanupExportFolder(projInfo.DefaultXhtmlFileWithPath, ".tmp,.de", string.Empty, string.Empty); CreateRamp(projInfo); Common.DeleteDirectory(tempGoBibleCreatorPath); success = true; Cursor.Current = myCursor; inProcess.PerformStep(); inProcess.Close(); if (!Common.Testing) { // Failed to send the .jar to a bluetooth device. Tell the user to do it manually. var msg = LocalizationManager.GetString("ExportGoBible.ExportClick.Message1", "Please copy the file {0} to your phone.\n\nDo you want to open the folder?", ""); msg = string.Format(msg, jarFile); DialogResult dialogResult = Utils.MsgBox(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { string dirPath = Path.GetDirectoryName(jarFile); Process.Start(dirPath); } } } else { success = false; Cursor.Current = myCursor; inProcess.PerformStep(); inProcess.Close(); if (!Common.Testing) { var msg = LocalizationManager.GetString("ExportGoBible.ExportClick.Message2", "Failed Exporting GoBible Process.", ""); Utils.MsgBox(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { var msg = ex.Message; success = false; inProcess.PerformStep(); inProcess.Close(); } return success; }
private void ExportProcess(List <XmlDocument> usxBooksToExport, string publicationName, string format, string outputLocationPath, DialogResult result) { #if (TIME_IT) DateTime dt1 = DateTime.Now; // time this thing #endif var inProcess = new InProcess(0, 6); var myCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; inProcess.Text = "Scripture Export"; inProcess.Show(); inProcess.PerformStep(); inProcess.ShowStatus = true; inProcess.SetStatus("Processing Scripture Export"); string pubName = publicationName; MFormat = format; // Get the file name as set on the dialog. MOutputLocationPath = outputLocationPath; inProcess.PerformStep(); if (MFormat.StartsWith("theWord")) { ExportUsx(usxBooksToExport); } inProcess.PerformStep(); string cssFullPath = Common.PathCombine(MOutputLocationPath, pubName + ".css"); StyToCss styToCss = new StyToCss(); styToCss.ConvertStyToCss(_mDatabaseName, cssFullPath); string fileName = Common.PathCombine(MOutputLocationPath, pubName + ".xhtml"); inProcess.PerformStep(); if (File.Exists(fileName)) { var msg = LocalizationManager.GetString("ParatextPathwayLink.ExportProcess.Message1", " already exists. Overwrite?", ""); result = MessageBox.Show(string.Format("{0}" + Environment.NewLine + msg, fileName), string.Empty, MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { fileName = Common.PathCombine(MOutputLocationPath, pubName + "-" + DateTime.Now.Second + ".xhtml"); } else if (result == DialogResult.No) { return; } } inProcess.PerformStep(); XmlDocument scrBooksDoc = CombineUsxDocs(usxBooksToExport, MFormat); inProcess.PerformStep(); if (string.IsNullOrEmpty(scrBooksDoc.InnerText)) { var message = LocalizationManager.GetString("ParatextPathwayLink.ExportProcess.Message2", "The current book has no content to export.", ""); MessageBox.Show(message, string.Empty, MessageBoxButtons.OK); return; } ConvertUsxToPathwayXhtmlFile(scrBooksDoc.InnerXml, fileName); Cursor.Current = myCursor; inProcess.PerformStep(); inProcess.Close(); if (!Common.Testing) { PsExport exporter = new PsExport(); exporter.DataType = "Scripture"; exporter.Export(fileName); } }