/// ------------------------------------------------------------------------------------ /// <summary> /// Use this for slow operations that should happen during the splash screen instead of /// during app construction /// </summary> /// <param name="progressDlg">The progress dialog to use.</param> /// ------------------------------------------------------------------------------------ public override void DoApplicationInitialization(IProgress progressDlg) { base.DoApplicationInitialization(progressDlg); if (FwUtils.IsTEInstalled) { ScrReference.InitializeVersification(DirectoryFinder.TeFolder, false); } //usage report UsageEmailDialog.DoTrivialUsageReport(ApplicationName, SettingsKey, FeedbackEmailAddress, xWorksStrings.ThankYouForCheckingOutFlex, false, 1); UsageEmailDialog.DoTrivialUsageReport(ApplicationName, SettingsKey, FeedbackEmailAddress, xWorksStrings.HaveLaunchedFLEXTenTimes, true, 10); UsageEmailDialog.DoTrivialUsageReport(ApplicationName, SettingsKey, FeedbackEmailAddress, xWorksStrings.HaveLaunchedFLEXFortyTimes, true, 40); }
/// <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); }