/// <summary> /// Have the utility do what it does. /// </summary> public void Process() { if (!PathwayUtils.IsPathwayInstalled) { MessageBox.Show(ResourceHelper.GetResourceString("kstidInvalidPathwayInstallation"), string.Empty, MessageBoxButtons.OK); return; } const string MainXhtml = "main.xhtml"; const string RevXhtml = "FlexRev.xhtml"; const string SketchXml = "sketch.xml"; IApp app = (IApp)exportDialog.Mediator.PropertyTable.GetValue("App"); string cssDialog = Path.Combine(PathwayUtils.PathwayInstallDirectory, "CssDialog.dll"); var sf = ReflectionHelper.CreateObject(cssDialog, "SIL.PublishingSolution.Contents", null); Debug.Assert(sf != null); FdoCache cache = (FdoCache)exportDialog.Mediator.PropertyTable.GetValue("cache"); ReflectionHelper.SetProperty(sf, "DatabaseName", cache.ProjectId.Name); bool fContentsExists = ContentsExists("lexicon", "reversalToolEditComplete", "ReversalIndexXHTML"); ReflectionHelper.SetProperty(sf, "ExportReversal", fContentsExists); ReflectionHelper.SetProperty(sf, "ReversalExists", fContentsExists); ReflectionHelper.SetProperty(sf, "GrammarExists", false); DialogResult result = (DialogResult)ReflectionHelper.GetResult(sf, "ShowDialog"); if (result == DialogResult.Cancel) { return; } string strOutputPath = (string)ReflectionHelper.GetProperty(sf, "OutputLocationPath"); string strDictionaryName = (string)ReflectionHelper.GetProperty(sf, "DictionaryName"); string outPath = Path.Combine(strOutputPath, strDictionaryName); bool fExistingDirectoryInput = (bool)ReflectionHelper.GetProperty(sf, "ExistingDirectoryInput"); if (fExistingDirectoryInput) { string inputPath = (string)ReflectionHelper.GetProperty(sf, "ExistingDirectoryLocationPath"); if (inputPath != outPath) { string dirFilter = string.Empty; if (strOutputPath == inputPath) { dirFilter = strDictionaryName; } try { if (!MyFolders.Copy(inputPath, outPath, dirFilter, app.ApplicationName)) { return; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } if (!MyFolders.CreateDirectory(outPath, app.ApplicationName)) { return; } string mainFullName = Path.Combine(outPath, MainXhtml); string revFullXhtml = Path.Combine(outPath, RevXhtml); string gramFullName = Path.Combine(outPath, SketchXml); if (!(bool)ReflectionHelper.GetProperty(sf, "ExportMain")) { mainFullName = ""; } if (!fContentsExists) { revFullXhtml = ""; } switch (result) { // No = Skip export of data from Flex but still prepare exported output (ODT, PDF or whatever) case DialogResult.No: break; case DialogResult.Yes: if (!DeFlexExports(ExpCss, mainFullName, revFullXhtml, gramFullName)) { return; } break; } string psExport = Path.Combine(PathwayUtils.PathwayInstallDirectory, "PsExport.dll"); var exporter = ReflectionHelper.CreateObject(psExport, "SIL.PublishingSolution.PsExport", null); Debug.Assert(exporter != null); ReflectionHelper.SetProperty(exporter, "DataType", "Dictionary"); ReflectionHelper.SetProperty(exporter, "ProgressBar", exportDialog.ProgressBar); ReflectionHelper.CallMethod(exporter, "Export", mainFullName != "" ? mainFullName : revFullXhtml); RegistryKey applicationKey = app.SettingsKey; UsageEmailDialog.IncrementLaunchCount(applicationKey); Assembly assembly = exporter.GetType().Assembly; UsageEmailDialog.DoTrivialUsageReport(utilityLabel, applicationKey, FeedbackEmailAddress, string.Format("1. What do you hope {0} will do for you?%0A%0A2. What languages are you working on?", utilityLabel), false, 1, assembly); UsageEmailDialog.DoTrivialUsageReport(utilityLabel, applicationKey, FeedbackEmailAddress, string.Format("1. Do you have suggestions to improve the program?%0A%0A2. What are you happy with?"), false, 10, assembly); UsageEmailDialog.DoTrivialUsageReport(utilityLabel, applicationKey, FeedbackEmailAddress, string.Format("1. What would you like to say to others about {0}?%0A%0A2. What languages have you used with {0}", utilityLabel), false, 40, assembly); }
/// <summary> /// Have the utility do what it does. /// </summary> public void Process() { const string MainXhtml = "main.xhtml"; const string RevXhtml = "FlexRev.xhtml"; const string SketchXml = "sketch.xml"; IExportContents sf = DynamicLoader.CreateObject("CssDialog.dll", "SIL.PublishingSolution.Contents") as IExportContents; Debug.Assert(sf != null); FdoCache cache = (FdoCache)exportDialog.Mediator.PropertyTable.GetValue("cache"); sf.DatabaseName = cache.DatabaseName; sf.ExportReversal = sf.ReversalExists = ContentsExists("lexicon", "reversalToolEditComplete", "ReversalIndexXHTML"); sf.GrammarExists = false; DialogResult result = sf.ShowDialog(); if (result == DialogResult.Cancel) { return; } string outPath = Path.Combine(sf.OutputLocationPath, sf.DictionaryName); if (sf.ExistingDirectoryInput) { string inputPath = sf.ExistingDirectoryLocationPath; if (inputPath != outPath) { string dirFilter = string.Empty; if (sf.OutputLocationPath == inputPath) { dirFilter = sf.DictionaryName; } try { if (!MyFolders.Copy(inputPath, outPath, dirFilter)) { return; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } if (!MyFolders.CreateDirectory(outPath)) { return; } string mainFullName = Path.Combine(outPath, MainXhtml); string revFullXhtml = Path.Combine(outPath, RevXhtml); string gramFullName = Path.Combine(outPath, SketchXml); if (!sf.ExportMain) { mainFullName = ""; } if (!sf.ExportReversal) { revFullXhtml = ""; } switch (result) { // No = Skip export of data from Flex but still prepare exported output (ODT, PDF or whatever) case DialogResult.No: break; case DialogResult.Yes: if (!DeFlexExports(ExpCss, mainFullName, revFullXhtml, gramFullName)) { return; } break; } IExporter exporter = DynamicLoader.CreateObject("PsExport.dll", "SIL.PublishingSolution.PsExport") as IExporter; Debug.Assert(exporter != null); exporter.DataType = "Dictionary"; exporter.ProgressBar = exportDialog.ProgressBar; exporter.Export(mainFullName != "" ? mainFullName : revFullXhtml); Reporting(); }