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 SemanticDomainIndex(InProcess inProcess, string contentFolder, string html5Folder) { var xDoc = Common.DeclareXMLDocument(false); var domain = new SortedDictionary <string, string>(); var entries = new Dictionary <string, List <string> >(); var files = new DirectoryInfo(contentFolder).GetFiles("PartFile*.xhtml"); inProcess.AddToMaximum(files.Length); foreach (FileInfo fileInfo in files) { var sr = new StreamReader(fileInfo.FullName); xDoc.Load(sr); sr.Close(); // ReSharper disable once PossibleNullReferenceException foreach (XmlElement node in xDoc.SelectNodes("//*[starts-with(@class,'semanticdomain')]")) { inProcess.PerformStep(); var firstSibling = node.NextSibling as XmlElement; if (firstSibling == null || !firstSibling.GetAttribute("class").StartsWith("abbr")) { continue; } var domainKey = firstSibling.InnerText; var domainMenuItem = new StringBuilder(); var haveAbbr = false; var haveName = false; while (firstSibling != null) { var firstClass = firstSibling.GetAttribute("class"); if (firstClass.StartsWith("abbr")) { if (haveAbbr) { break; } haveAbbr = true; } else if (firstClass.StartsWith("name")) { if (haveName) { break; } haveName = true; } else if (!firstClass.StartsWith("semanticdomain") || haveName) { break; } domainMenuItem.Append(firstSibling.InnerText); firstSibling = firstSibling.NextSibling as XmlElement; } domain[domainKey] = domainMenuItem.ToString(); AddParts(domainKey, domain); var entryNode = node.SelectSingleNode("ancestor::*[starts-with(@class,'entry') or starts-with(@class,'minorentry') or starts-with(@class,'reversalindexentry')]"); var anchor = xDoc.CreateElement("a"); anchor.SetAttribute("href", (entryNode.FirstChild as XmlElement).GetAttribute("href").Replace(".xhtml", ".html")); anchor.SetAttribute("lang", (entryNode.FirstChild.FirstChild as XmlElement).GetAttribute("lang")); anchor.InnerText = (entryNode.FirstChild.FirstChild as XmlElement).InnerText; if (entries.ContainsKey(domainKey)) { entries[domainKey].Add(anchor.OuterXml); } else { entries[domainKey] = new List <string> { anchor.OuterXml }; } } Debug.Assert(xDoc.DocumentElement != null); xDoc.DocumentElement.RemoveAll(); } xDoc.LoadXml(@"<html lang=""en"" xmlns=""http://www.w3.org/1999/xhtml""><head><title>sindex</title></head><body></body></html>"); var curNode = xDoc.SelectSingleNode("//*[local-name()='body']"); var level = 1; XmlElement saveLevel = null; foreach (var domainKey in domain.Keys) { var parts = domainKey.Split('.'); while (level > parts.Length) { curNode = curNode.ParentNode.ParentNode; level -= 1; } if (parts.Length > level) { level += 1; if (saveLevel == null) { curNode = curNode.LastChild; var nextLevel = CreateElement(xDoc, "ul"); nextLevel.SetAttribute("class", "nav nav-second-level"); curNode.AppendChild(nextLevel); curNode = curNode.LastChild; } else { curNode = saveLevel; } } saveLevel = null; var header = CreateElement(xDoc, "li"); var headAnchor = CreateElement(xDoc, "a"); headAnchor.SetAttribute("class", "s"); headAnchor.InnerXml = domain[domainKey]; var arrowSpan = CreateElement(xDoc, "span"); arrowSpan.SetAttribute("class", "fa arrow"); headAnchor.AppendChild(arrowSpan); header.AppendChild(headAnchor); curNode.AppendChild(header); if (entries.ContainsKey(domainKey)) { var group = CreateElement(xDoc, "ul"); group.SetAttribute("class", "nav nav-third-level"); foreach (var entry in entries[domainKey]) { var itemNode = CreateElement(xDoc, "li"); itemNode.InnerXml = entry; group.AppendChild(itemNode); } header.AppendChild(group); saveLevel = group; } } var sw = new StreamWriter(Path.Combine(html5Folder, "bootstrapSem.html")); xDoc.Save(sw); sw.Close(); Debug.Assert(xDoc.DocumentElement != null); xDoc.DocumentElement.RemoveAll(); }
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); }
/// <summary> /// Entry point for TheWord converter /// </summary> /// <param name="projInfo">values passed including xhtml and css names</param> /// <returns>true if succeeds</returns> public bool Export(PublicationInformation projInfo) { if (projInfo == null) return false; bool success; var myCursor = Cursor.Current; var originalDir = Environment.CurrentDirectory; var inProcess = new InProcess(0, 7); try { Cursor.Current = Cursors.WaitCursor; var assemblyLocation = Assembly.GetExecutingAssembly().Location; var codePath = Path.GetDirectoryName(assemblyLocation); Debug.Assert(codePath != null); Environment.CurrentDirectory = codePath; inProcess.Show(); LoadXslt(); inProcess.PerformStep(); var exportTheWordInputPath = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); Debug.Assert(exportTheWordInputPath != null); LoadMetadata(); inProcess.PerformStep(); FindParatextProject(); inProcess.PerformStep(); CreateUsxIfNecessary(projInfo.DefaultXhtmlFileWithPath); var xsltArgs = LoadXsltParameters(exportTheWordInputPath); inProcess.PerformStep(); var otBooks = new List<string>(); var ntBooks = new List<string>(); CollectTestamentBooks(otBooks, ntBooks); inProcess.PerformStep(); var output = GetSsfValue("//EthnologueCode", _defaultLanguage); var fullName = UsxDir(exportTheWordInputPath); LogStatus("Processing: {0}", fullName); xsltArgs.XsltMessageEncountered += XsltMessage; MessageFullName = Common.PathCombine(exportTheWordInputPath, "Messages.html"); var codeNames = new Dictionary<string, string>(); var otFlag = OtFlag(fullName, codeNames, otBooks); inProcess.AddToMaximum(codeNames.Count*2); inProcess.PerformStep(); var resultName = output + (otFlag ? ".ont" : ".nt"); var resultFullName = Common.PathCombine(exportTheWordInputPath, resultName); ProcessAllBooks(resultFullName, otFlag, otBooks, ntBooks, codeNames, xsltArgs, inProcess); if (_hasMessages) { XsltMessageClose(); DisplayMessageReport(); } xsltArgs.XsltMessageEncountered -= XsltMessage; string theWordFullPath = Common.FromRegistry("TheWord"); string tempTheWordCreatorPath = TheWordCreatorTempDirectory(theWordFullPath); xsltArgs.AddParam("refPref", "", "b"); inProcess.PerformStep(); var mySwordFullName = Common.PathCombine(tempTheWordCreatorPath, resultName); ProcessAllBooks(mySwordFullName, otFlag, otBooks, ntBooks, codeNames, xsltArgs, inProcess); var mySwordResult = ConvertToMySword(resultName, tempTheWordCreatorPath, exportTheWordInputPath); inProcess.PerformStep(); if (_tempGlossaryName != "") { File.Delete(_tempGlossaryName); _tempGlossaryName = ""; } if (Directory.Exists(tempTheWordCreatorPath)) { Common.DeleteDirectory(tempTheWordCreatorPath); } inProcess.Close(); Environment.CurrentDirectory = originalDir; Cursor.Current = myCursor; success = ReportResults(resultFullName, mySwordResult, exportTheWordInputPath); Common.CleanupExportFolder(projInfo.DefaultXhtmlFileWithPath, ".tmp,.de", "layout.css", string.Empty); CreateRamp(projInfo); } catch (Exception ex) { Console.WriteLine(ex.Message); success = false; inProcess.PerformStep(); inProcess.Close(); Environment.CurrentDirectory = originalDir; Cursor.Current = myCursor; ReportFailure(ex); } Ssf = string.Empty; return success; }
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); } } }
private static InProcess SetupProgressReporting(int steps) { var inProcess = new InProcess(0, steps) { Text = Resources.Exportepub_Export_Exporting__epub_file }; // create a progress bar with 7 steps (we'll add more below) inProcess.Text = LocalizationManager.GetString("Exportepub.InProcessWindow.Title", "Exporting .epub file", ""); inProcess.Show(); inProcess.ShowStatus = true; return inProcess; }
/// <summary> /// Helper method to change the relative hyperlinks in the references file to absolute ones. /// This is done after the scripture files are split out into individual books of 100K or less in size. /// </summary> /// <param name="contentFolder"></param> /// <param name="inProcess"></param> private void UpdateReferenceSourcelinks(string contentFolder, InProcess inProcess) { string[] files = Directory.GetFiles(contentFolder, "PartFile*.xhtml"); foreach (var file in files) { XmlDocument xmlDocument = Common.DeclareXMLDocument(false); var namespaceManager = new XmlNamespaceManager(xmlDocument.NameTable); namespaceManager.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml"); var xmlReaderSettings = new XmlReaderSettings { XmlResolver = null, ProhibitDtd = false }; var xmlReader = XmlReader.Create(file, xmlReaderSettings); xmlDocument.Load(xmlReader); xmlReader.Close(); XmlNodeList footnoteNodes = null; footnoteNodes = xmlDocument.SelectNodes("//span[@class='Note_General_Paragraph']/a"); if (footnoteNodes == null || footnoteNodes.Count == 0) { footnoteNodes = xmlDocument.SelectNodes("//xhtml:span[@class='Note_General_Paragraph']/xhtml:a", namespaceManager); } if (footnoteNodes != null) { foreach (XmlNode footnoteNode in footnoteNodes) { if (footnoteNode.Attributes != null) footnoteNode.Attributes["href"].Value = "zzReferences.xhtml" + footnoteNode.Attributes["href"].Value; } } footnoteNodes = xmlDocument.SelectNodes("//span[@class='Note_CrossHYPHENReference_Paragraph']/a"); if (footnoteNodes == null || footnoteNodes.Count == 0) { footnoteNodes = xmlDocument.SelectNodes("//xhtml:span[@class='Note_CrossHYPHENReference_Paragraph']/xhtml:a", namespaceManager); if (footnoteNodes == null) return; } foreach (XmlNode footnoteNode in footnoteNodes) { if (footnoteNode.Attributes != null) footnoteNode.Attributes["href"].Value = "zzReferences.xhtml" + footnoteNode.Attributes["href"].Value; } xmlDocument.Save(file); inProcess.PerformStep(); } }
/// <summary> /// Helper method to change the relative hyperlinks in the references file to absolute ones. /// This is done after the scripture files are split out into individual books of 100K or less in size. /// </summary> /// <param name="contentFolder"></param> /// <param name="inProcess"></param> private void UpdateReferenceHyperlinks(string contentFolder, InProcess inProcess) { var outFilename = Common.PathCombine(contentFolder, ReferencesFilename); var hrefs = FindBrokenRelativeHrefIds(outFilename); //inProcess.AddToMaximum(hrefs.Count + 1); var reader = new StreamReader(outFilename); var content = new StringBuilder(); content.Append(reader.ReadToEnd()); reader.Close(); string[] files = Directory.GetFiles(contentFolder, "PartFile*.xhtml"); int index = 0; bool looped = false; foreach (var href in hrefs) { if (string.IsNullOrEmpty(href)) continue; // A glossary term with no glossary entry // find where the target is for this reference - // since the lists are sequential in the references file, we're using an index instead // of a foreach loop (so the search continues in the same file the last href left off on). while (true) { // search the current file in the list if (IsStringInFile(files[index], href)) { content.Replace(("a href=\"#" + href + "\""), ("a href=\"" + Path.GetFileName(files[index]) + "#" + href + "\"")); break; } // update the index and try again index++; if (index == files.Length) { if (looped) break; // already searched through the list -- this item isn't found, get out index = 0; looped = true; } } inProcess.PerformStep(); looped = false; } var writer = new StreamWriter(outFilename); writer.Write(content); writer.Close(); inProcess.PerformStep(); }
/// <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; }
public bool Export(PublicationInformation projInfo) { Param.SetLoadType = projInfo.ProjectInputType; Param.LoadSettings(); bool success = false; projInfo.OutputExtension = "jar"; if (projInfo == null || string.IsNullOrEmpty(projInfo.DefaultXhtmlFileWithPath) || string.IsNullOrEmpty(projInfo.DefaultCssFileWithPath)) { return(false); } WorkDir = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); _isUnixOS = Common.UnixVersionCheck(); var inProcess = new InProcess(0, 7); var curdir = Environment.CurrentDirectory; var myCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; inProcess.Show(); inProcess.PerformStep(); LoadCss(projInfo); _DictionaryForMIDsInput = null; inProcess.PerformStep(); ReformatData(projInfo); inProcess.PerformStep(); CreateProperties(projInfo); inProcess.PerformStep(); CreateDictionaryForMIDs(projInfo); inProcess.PerformStep(); CreateSubmission(projInfo); inProcess.PerformStep(); ReportReults(projInfo); inProcess.PerformStep(); success = true; } catch (Exception ex) { var msg = LocalizationManager.GetString("ExportDictionaryForMIDs.ExportClick.Message", "{0} Display partial results?", ""); string caption = LocalizationManager.GetString("ExportDictionaryForMIDs.ExportClick.Caption", "Report: Failure", ""); var result = Utils.MsgBox(string.Format(msg, ex.Message), caption, MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { DisplayOutput(projInfo); } } inProcess.Close(); Environment.CurrentDirectory = curdir; Cursor.Current = myCursor; CleanUp(projInfo.DefaultXhtmlFileWithPath); if (Common.Testing == false) { MoveJarFile(projInfo); CreateRAMP(projInfo); Common.CleanupExportFolder(projInfo.DefaultXhtmlFileWithPath, ".txt,.xhtml,.css,.log,.jar,.jad,.properties,.xml", String.Empty, "pictures"); } return(success); }
public bool Export(PublicationInformation projInfo) { bool success = false; projInfo.OutputExtension = "jar"; if (projInfo == null || string.IsNullOrEmpty(projInfo.DefaultXhtmlFileWithPath) || string.IsNullOrEmpty(projInfo.DefaultCssFileWithPath)) { return false; } WorkDir = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); _isUnixOS = Common.UnixVersionCheck(); var inProcess = new InProcess(0, 8); var curdir = Environment.CurrentDirectory; var myCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; inProcess.Show(); inProcess.PerformStep(); LoadParameters(); inProcess.PerformStep(); LoadCss(projInfo); _DictionaryForMIDsInput = null; inProcess.PerformStep(); ReformatData(projInfo); inProcess.PerformStep(); CreateProperties(projInfo); inProcess.PerformStep(); CreateDictionaryForMIDs(projInfo); inProcess.PerformStep(); CreateSubmission(projInfo); inProcess.PerformStep(); ReportReults(projInfo); inProcess.PerformStep(); success = true; } catch (Exception ex) { var msg = LocalizationManager.GetString("ExportDictionaryForMIDs.ExportClick.Message", "{0} Display partial results?", ""); string caption = LocalizationManager.GetString("ExportDictionaryForMIDs.ExportClick.Caption", "Report: Failure", ""); var result = Utils.MsgBox(string.Format(msg, ex.Message), caption, MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { DisplayOutput(projInfo); } } inProcess.Close(); Environment.CurrentDirectory = curdir; Cursor.Current = myCursor; CleanUp(projInfo.DefaultXhtmlFileWithPath); if (Common.Testing == false) { MoveJarFile(projInfo); CreateRAMP(projInfo); } 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); } }