示例#1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Exports as FXT.
		/// </summary>
		/// <param name="progressDialog">The progress dialog.</param>
		/// <param name="parameters">The parameters: 1) output file, 2) template file path.
		/// </param>
		/// <returns>Always null.</returns>
		/// ------------------------------------------------------------------------------------
		private object ExportFxt(IAdvInd4 progressDialog, params object[] parameters)
		{
			Debug.Assert(parameters.Length == 3);
			m_progressDlg = progressDialog;
			string outPath = (string)parameters[0];
			string fxtPath = (string)parameters[1];
			bool fLiftOutput = (bool)parameters[2];
			MapFlidsInDumperAsNeeded(fxtPath);
#if DEBUG
			DateTime dtStart = DateTime.Now;
#endif
			using (TextWriter w = new StreamWriter(outPath))
			{
				m_dumper.ExportPicturesAndMedia = m_fExportPicturesAndMedia;
				m_dumper.Go(m_cache.LangProject as CmObject, fxtPath, w);
			}
#if DEBUG
			DateTime dtExport = DateTime.Now;
#endif
			if (fLiftOutput)
			{
				try
				{
					progressDialog.Message = String.Format(xWorksStrings.ksValidatingOutputFile,
						Path.GetFileName(outPath));
					ValidationProgress prog = new ValidationProgress(progressDialog);
					LiftIO.Validation.Validator.CheckLiftWithPossibleThrow(outPath, prog);
				}
				catch (LiftIO.LiftFormatException lfe)
				{
					// Show the pretty yellow semi-crash dialog box, with instructions for the
					// user to report the bug.
					SIL.Utils.ErrorReporter.ReportException(
						new Exception(xWorksStrings.ksLiftExportBugReport, lfe), this, false);
				}
			}
#if DEBUG
			DateTime dtValidate = DateTime.Now;
			TimeSpan exportDelta = new TimeSpan(dtExport.Ticks - dtStart.Ticks);
			TimeSpan validateDelta = new TimeSpan(dtValidate.Ticks - dtExport.Ticks);
			Debug.WriteLine(String.Format("Export time = {0}, Validation time = {1}",
				exportDelta, validateDelta));
#endif
			return null;
		}
示例#2
0
		private bool Validate(string sFilename, string sOrigFile)
		{
			try
			{
				m_progressDlg.Message = LexTextControls.ksValidatingInputFile;
				ValidationProgress prog = new ValidationProgress(m_progressDlg);
				LiftIO.Validation.Validator.CheckLiftWithPossibleThrow(sFilename, prog);
				return true;
			}
			catch (LiftIO.LiftFormatException lfe)
			{
				string sProducer = GetLiftProducer(sOrigFile);
				string sMsg;
				if (sProducer == null)
				{
					sMsg = String.Format(LexTextControls.ksFileNotALIFTFile, sOrigFile);
				}
				else if (sFilename == sOrigFile)
				{
					sMsg = String.Format(LexTextControls.ksInvalidLiftFile, sOrigFile, sProducer);
				}
				else
				{
					sMsg = String.Format(LexTextControls.ksInvalidMigratedLiftFile, sOrigFile, sProducer);
				}
				// Show the pretty yellow semi-crash dialog box, with instructions for the
				// user to report the bug.  Then ask the user whether to continue.
				SIL.Utils.ErrorReporter.ReportException(new Exception(sMsg, lfe), this, false);
				return MessageBox.Show(LexTextControls.ksContinueLiftImportQuestion,
					LexTextControls.ksProblemImporting,
					MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes;
			}
		}