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); }
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; }
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); }
/// <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; }
/// <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 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); } }