コード例 #1
0
ファイル: ExportDialog.cs プロジェクト: sillsdev/WorldPad
		protected void DoExport(string outPath, bool fLiftOutput)
		{
			string fxtPath = (string)m_exportList.SelectedItems[0].Tag;
			FxtType ft = m_rgFxtTypes[FxtIndex(fxtPath)];
			using (new SIL.FieldWorks.Common.Utils.WaitCursor(this))
			{
				using (ProgressDialogWithTask progressDlg = new ProgressDialogWithTask(this))
				{
					try
					{
						progressDlg.Title = String.Format(xWorksStrings.Exporting0,
							m_exportList.SelectedItems[0].SubItems[0].Text);
						progressDlg.Message = xWorksStrings.Exporting_;

						switch (ft.m_ft)
						{
							case FxtTypes.kftFxt:
								using (m_dumper = new XDumper(m_cache))
								{
									m_dumper.UpdateProgress +=
										new XDumper.ProgressHandler(OnDumperUpdateProgress);
									m_dumper.SetProgressMessage +=
										new EventHandler<XDumper.MessageArgs>(OnDumperSetProgressMessage);
									progressDlg.SetRange(0, m_dumper.GetProgressMaximum());
									progressDlg.CancelButtonVisible = true;
									progressDlg.Restartable = true;
									progressDlg.ProgressBarStyle = ProgressBarStyle.Continuous;
									progressDlg.Cancel += new CancelHandler(Onm_progressDlg_Cancel);

									progressDlg.RunTask(true, new BackgroundTaskInvoker(ExportFxt),
										outPath, fxtPath, fLiftOutput);
								}
								break;
							case FxtTypes.kftConfigured:
							case FxtTypes.kftReversal:
								progressDlg.SetRange(0, m_seqView.ObjectCount);
								progressDlg.CancelButtonVisible = true;
								progressDlg.Cancel += new CancelHandler(ce_Cancel);

								progressDlg.RunTask(true, new BackgroundTaskInvoker(ExportConfiguredDocView),
									outPath, fxtPath, ft);
								break;
						}
					}
					catch (WorkerThreadException e)
					{
						if (e.InnerException is CancelException)
						{
							MessageBox.Show(this, e.InnerException.Message);
							m_ce = null;
						}
						else
						{
							string msg = xWorksStrings.ErrorExporting_ProbablyBug + "\n" + e.InnerException.Message;
							MessageBox.Show(this, msg);
						}
					}
					finally
					{
						m_progressDlg = null;
						m_dumper = null;
						this.Close();
					}
				}
			}
		}
コード例 #2
0
ファイル: ExportDialog.cs プロジェクト: bbriggs/FieldWorks
        protected void DoExport(string outPath, bool fLiftOutput)
        {
            string fxtPath = (string)m_exportItems[0].Tag;
            FxtType ft = m_rgFxtTypes[FxtIndex(fxtPath)];
            using (new WaitCursor(this))
            {
                using (var progressDlg = new ProgressDialogWithTask(this))
                {
                    try
                    {
                        progressDlg.Title = String.Format(xWorksStrings.Exporting0,
                            m_exportItems[0].SubItems[0].Text);
                        progressDlg.Message = xWorksStrings.Exporting_;

                        switch (ft.m_ft)
                        {
                            case FxtTypes.kftFxt:
                                m_dumper = new XDumper(m_cache);
                                m_dumper.UpdateProgress += OnDumperUpdateProgress;
                                m_dumper.SetProgressMessage += OnDumperSetProgressMessage;
                                progressDlg.Minimum = 0;
                                progressDlg.Maximum = m_dumper.GetProgressMaximum();
                                progressDlg.AllowCancel = true;
                                progressDlg.Restartable = true;

                                progressDlg.RunTask(true, ExportFxt, outPath, fxtPath, fLiftOutput);
                                break;
                            case FxtTypes.kftConfigured:
                            case FxtTypes.kftReversal:
                            case FxtTypes.kftClassifiedDict:
                                progressDlg.Minimum = 0;
                                progressDlg.Maximum = m_seqView.ObjectCount;
                                progressDlg.AllowCancel = true;

                                IVwStylesheet vss = m_seqView.RootBox == null ? null : m_seqView.RootBox.Stylesheet;
                                progressDlg.RunTask(true, ExportConfiguredDocView,
                                    outPath, fxtPath, ft, vss);
                                break;
                            case FxtTypes.kftTranslatedLists:
                                progressDlg.Minimum = 0;
                                progressDlg.Maximum = m_translatedLists.Count;
                                progressDlg.AllowCancel = true;

                                progressDlg.RunTask(true, ExportTranslatedLists, outPath);
                                break;
                            case FxtTypes.kftSemanticDomains:
                                // Potentially, we could count semantic domains and try to make the export update for each.
                                // In practice this only takes a second or two on a typical modern computer
                                // an the main export routine is borrowed from kftTranslatedLists and set up to count each
                                // list as one step. For now, claiming this export just has one step seems good enough.
                                progressDlg.Minimum = 0;
                                progressDlg.Maximum = 1;
                                progressDlg.AllowCancel = true;

                                progressDlg.RunTask(true, ExportSemanticDomains, outPath, ft, fxtPath, m_allQuestions);
                                break;
                            case FxtTypes.kftPathway:
                                break;
                            case FxtTypes.kftLift:
                                progressDlg.Minimum = 0;
                                progressDlg.Maximum = 1000;
                                progressDlg.AllowCancel = true;
                                progressDlg.Restartable = true;
                                progressDlg.RunTask(true, ExportLift, outPath, ft.m_filtered);
                                break;
                            case FxtTypes.kftGrammarSketch:
                                progressDlg.Minimum = 0;
                                progressDlg.Maximum = 1000;
                                progressDlg.AllowCancel = true;
                                progressDlg.Restartable = true;
                                progressDlg.RunTask(true, ExportGrammarSketch, outPath, ft.m_sDataType, ft.m_sXsltFiles);
                                break;
                        }
                    }
                    catch (WorkerThreadException e)
                    {
                        if (e.InnerException is CancelException)
                        {
                            MessageBox.Show(this, e.InnerException.Message);
                            m_ce = null;
                        }
                        else if (e.InnerException is LiftFormatException)
                        {
                            // Show the pretty yellow semi-crash dialog box, with instructions for the
                            // user to report the bug.
                            var app = (IApp) m_mediator.PropertyTable.GetValue("App");
                            ErrorReporter.ReportException(new Exception(xWorksStrings.ksLiftExportBugReport, e.InnerException),
                                app.SettingsKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress, this, false);
                        }
                        else
                        {
                            string msg = xWorksStrings.ErrorExporting_ProbablyBug + Environment.NewLine + e.InnerException.Message;
                            MessageBox.Show(this, msg);
                        }
                    }
                    finally
                    {
                        m_progressDlg = null;
                        m_dumper = null;
                        Close();
                    }
                }
            }
        }
コード例 #3
0
ファイル: FlexChorusDlg.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Export the contents of the lexicon to the given file (first and only parameter).
		/// </summary>
		/// <returns>the name of the exported LIFT file if successful, or null if an error occurs.</returns>
		protected object ExportLexicon(IAdvInd4 progressDialog, params object[] parameters)
		{
			try
			{
				if (m_progressDlg == null)
					m_progressDlg = progressDialog;
				string outPath = (string)parameters[0];
				progressDialog.Message = String.Format(FlexChorusStrings.ksExportingEntries,
					m_cache.LangProject.LexDbOA.EntriesOC.Count);
				using (XDumper dumper = new XDumper(m_cache))
				{
					dumper.UpdateProgress += new XDumper.ProgressHandler(OnDumperUpdateProgress);
					dumper.SetProgressMessage += new EventHandler<XDumper.MessageArgs>(OnDumperSetProgressMessage);
					// Don't bother writing out the range information in the export.
					dumper.SetTestVariable("SkipRanges", true);
					dumper.SkipAuxFileOutput = true;
					progressDialog.SetRange(0, dumper.GetProgressMaximum());
					progressDialog.Position = 0;
					// TODO: get better output/input filename?
					string p = Path.Combine(DirectoryFinder.FWCodeDirectory, @"Language Explorer\Export Templates");
					string fxtPath = Path.Combine(p, "LIFT.fxt.xml");
					using (TextWriter w = new StreamWriter(outPath))
					{
						dumper.ExportPicturesAndMedia = true;	// useless without Pictures directory...
						dumper.Go(m_cache.LangProject as CmObject, fxtPath, w);
					}
					// TODO: validate output?
					return outPath;
				}
			}
			catch
			{
				return null;
			}
		}
コード例 #4
0
		private void ExportLiftData(string outPath)
		{
			// TODO: if file exists, read it to obtain the list of entries it contains, including
			// deleted entries.  Then use this information in exporting to identify deleted entries
			// in the LIFT file.  This will require something other than FXT to export LIFT files.
			using (m_progressDlg = new ProgressDialogWithTask(this))
			{
				m_progressDlg.CancelButtonVisible = true;
				m_progressDlg.Restartable = true;
				m_progressDlg.Cancel += new CancelHandler(OnProgressDlgCancel);
				m_progressDlg.Message = "Exporting data in preparation for synchronization";
				using (m_dumper = new SIL.FieldWorks.Common.FXT.XDumper(m_cache))
				{
					m_dumper.UpdateProgress += new XDumper.ProgressHandler(OnDumperUpdateProgress);
					m_progressDlg.SetRange(0, m_dumper.GetProgressMaximum());
					m_progressDlg.RunTask(true, new BackgroundTaskInvoker(ExportLift), outPath);
				}
			}
			m_progressDlg = null;
		}