private void ProcessLanguageCode2(string buffer) { bool found = false; foreach (LanguageMapping mapping in m_languageMappings) { if (!found && mapping.LlCode == buffer) { found = true; m_current = mapping; } } //We shouldn't need the following code, but sometimes LL dumps unexpected language codes if (!found && m_languageMappings.Length > 0) m_current = m_languageMappings[0]; }
private void ProcessLanguageCode(string buffer, BinaryWriter bw) { bool found = false; foreach (LanguageMapping mapping in m_languageMappings) { if (!found && mapping.LlCode == buffer) { found = true; for (int j = 0; j < mapping.FwCode.Length; j++) { bw.Write((byte)mapping.FwCode[j]); } m_current = mapping; } } //We shouldn't need the following code, but sometimes LL dumps unexpected language codes if (!found) { for (int j = 0; j < buffer.Length; j++) { bw.Write((byte)buffer[j]); } if (m_languageMappings.Length > 0) m_current = m_languageMappings[0]; } }
private void btnImport_Click(object sender, EventArgs e) { // if the shift key is down, then just build the phaseNoutput files bool runToCompletion = ((ModifierKeys & Keys.Shift) != Keys.Shift); using (var dlg = new ProgressDialogWithTask(this, m_cache.ThreadHelper)) { dlg.AllowCancel = true; LanguageMapping[] languageMappings = new LanguageMapping[listViewMapping.Items.Count]; for (int i = 0; i < listViewMapping.Items.Count; i++) { languageMappings[i] = new LanguageMapping(listViewMapping.Items[i].SubItems); } dlg.Minimum = 0; dlg.Maximum = 500; using (new WaitCursor(this, true)) { // This needs to be reset when cancel is pressed with out clicking the // browse button. This resolves a noted issue in the code where an exception // is processed when run a second time... m_nextInput = m_LinguaLinksXmlFileName.Text; var import = new LinguaLinksImport(m_cache, m_sTempDir, m_sRootDir); import.NextInput = m_nextInput; import.Error += OnImportError; Debug.Assert(m_nextInput == m_LinguaLinksXmlFileName.Text); // Ensure the idle time processing for change record doesn't cause problems // because the import creates a record to change to. See FWR-3700. var clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk; var fSuppressedSave = false; try { if (clerk != null) { fSuppressedSave = clerk.SuppressSaveOnChangeRecord; clerk.SuppressSaveOnChangeRecord = true; } bool fSuccess = (bool)dlg.RunTask(true, import.Import, runToCompletion, languageMappings, m_startPhase); if (fSuccess) { MessageBox.Show(this, String.Format(ITextStrings.ksSuccessLoadingLL, Path.GetFileName(m_LinguaLinksXmlFileName.Text), m_cache.ProjectId.Name, Environment.NewLine, import.LogFile), ITextStrings.ksLLImportSucceeded, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; // only 'OK' if not exception } else { DialogResult = DialogResult.Abort; // unsuccessful import } Close(); m_nextInput = import.NextInput; } catch (WorkerThreadException ex) { if (ex.InnerException is InvalidDataException) { // Special handling for this case... ShowFinishLabel(); CheckImportEnabled(); } else { Debug.WriteLine("Error: " + ex.InnerException.Message); MessageBox.Show(String.Format(import.ErrorMessage, ex.InnerException.Message), ITextStrings.ksUnhandledError, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Cancel; // only 'OK' if not exception Close(); } } finally { if (clerk != null) { clerk.SuppressSaveOnChangeRecord = fSuppressedSave; } } } } }
private void btnImport_Click(object sender, System.EventArgs e) { // if the shift key is down, then just build the phaseNoutput files bool runToCompletion = ((Control.ModifierKeys & Keys.Shift) != Keys.Shift); using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(this)) { dlg.CancelButtonVisible = true; LanguageMapping[] languageMappings = new LanguageMapping[listViewMapping.Items.Count]; for (int i = 0; i < listViewMapping.Items.Count; i++) languageMappings[i] = new LanguageMapping(listViewMapping.Items[i].SubItems); dlg.SetRange(0, 500); using (new WaitCursor(this, true)) { // This needs to be reset when cancel is pressed with out clicking the // browse button. This resolves a noted issue in the code where an exception // is processed when run a second time... m_nextInput = m_LinguaLinksXmlFileName.Text; LinguaLinksImport import = new LinguaLinksImport(m_cache, m_sTempDir, m_sRootDir); import.NextInput = m_nextInput; import.Error += new LinguaLinksImport.ErrorHandler(OnImportError); dlg.Cancel += new CancelHandler(import.On_ProgressDlg_Cancel); Debug.Assert(m_nextInput == m_LinguaLinksXmlFileName.Text); try { bool fSuccess = (bool)dlg.RunTask(true, new BackgroundTaskInvoker(import.Import), runToCompletion, languageMappings, m_startPhase); if (fSuccess) { string sLogFile = m_sTempDir + "LLPhase3Output-Import.log"; MessageBox.Show(this, String.Format(ITextStrings.ksSuccessLoadingLL, Path.GetFileName(m_LinguaLinksXmlFileName.Text), m_cache.DatabaseName, System.Environment.NewLine, sLogFile), ITextStrings.ksLLImportSucceeded, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; // only 'OK' if not exception } else { this.DialogResult = DialogResult.Abort; // unsuccessful import } Close(); m_nextInput = import.NextInput; } catch (WorkerThreadException ex) { if (ex.InnerException is InvalidDataException) { // Special handling for this case... ShowFinishLabel(); CheckImportEnabled(); } else { System.Diagnostics.Debug.WriteLine("Error: " + ex.InnerException.Message); MessageBox.Show(String.Format(import.ErrorMessage, ex.InnerException.Message), ITextStrings.ksUnhandledError, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; // only 'OK' if not exception Close(); } } } } }
private void btnImport_Click(object sender, System.EventArgs e) { // if the shift key is down, then just build the phaseNoutput files bool runToCompletion = ((Control.ModifierKeys & Keys.Shift) != Keys.Shift); using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(this)) { dlg.CancelButtonVisible = true; LanguageMapping[] languageMappings = new LanguageMapping[listViewMapping.Items.Count]; for (int i = 0; i < listViewMapping.Items.Count; i++) { languageMappings[i] = new LanguageMapping(listViewMapping.Items[i].SubItems); } dlg.SetRange(0, 500); using (new WaitCursor(this, true)) { // This needs to be reset when cancel is pressed with out clicking the // browse button. This resolves a noted issue in the code where an exception // is processed when run a second time... m_nextInput = m_LinguaLinksXmlFileName.Text; LinguaLinksImport import = new LinguaLinksImport(m_cache, m_sTempDir, m_sRootDir); import.NextInput = m_nextInput; import.Error += new LinguaLinksImport.ErrorHandler(OnImportError); dlg.Cancel += new CancelHandler(import.On_ProgressDlg_Cancel); Debug.Assert(m_nextInput == m_LinguaLinksXmlFileName.Text); try { bool fSuccess = (bool)dlg.RunTask(true, new BackgroundTaskInvoker(import.Import), runToCompletion, languageMappings, m_startPhase); if (fSuccess) { string sLogFile = m_sTempDir + "LLPhase3Output-Import.log"; MessageBox.Show(this, String.Format(ITextStrings.ksSuccessLoadingLL, Path.GetFileName(m_LinguaLinksXmlFileName.Text), m_cache.DatabaseName, System.Environment.NewLine, sLogFile), ITextStrings.ksLLImportSucceeded, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; // only 'OK' if not exception } else { this.DialogResult = DialogResult.Abort; // unsuccessful import } Close(); m_nextInput = import.NextInput; } catch (WorkerThreadException ex) { if (ex.InnerException is InvalidDataException) { // Special handling for this case... ShowFinishLabel(); CheckImportEnabled(); } else { System.Diagnostics.Debug.WriteLine("Error: " + ex.InnerException.Message); MessageBox.Show(String.Format(import.ErrorMessage, ex.InnerException.Message), ITextStrings.ksUnhandledError, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; // only 'OK' if not exception Close(); } } } } }
private void btnImport_Click(object sender, EventArgs e) { // if the shift key is down, then just build the phaseNoutput files bool runToCompletion = ((ModifierKeys & Keys.Shift) != Keys.Shift); using (var dlg = new ProgressDialogWithTask(this)) { dlg.AllowCancel = true; LanguageMapping[] languageMappings = new LanguageMapping[listViewMapping.Items.Count]; for (int i = 0; i < listViewMapping.Items.Count; i++) languageMappings[i] = new LanguageMapping(listViewMapping.Items[i].SubItems); dlg.Minimum = 0; dlg.Maximum = 500; using (new WaitCursor(this, true)) { // This needs to be reset when cancel is pressed with out clicking the // browse button. This resolves a noted issue in the code where an exception // is processed when run a second time... m_nextInput = m_LinguaLinksXmlFileName.Text; var import = new LinguaLinksImport(m_cache, m_sTempDir, m_sRootDir); import.NextInput = m_nextInput; import.Error += OnImportError; Debug.Assert(m_nextInput == m_LinguaLinksXmlFileName.Text); // Ensure the idle time processing for change record doesn't cause problems // because the import creates a record to change to. See FWR-3700. var clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk; var fSuppressedSave = false; try { if (clerk != null) { fSuppressedSave = clerk.SuppressSaveOnChangeRecord; clerk.SuppressSaveOnChangeRecord = true; } bool fSuccess = (bool)dlg.RunTask(true, import.Import, runToCompletion, languageMappings, m_startPhase); if (fSuccess) { MessageBox.Show(this, String.Format(ITextStrings.ksSuccessLoadingLL, Path.GetFileName(m_LinguaLinksXmlFileName.Text), m_cache.ProjectId.Name, Environment.NewLine, import.LogFile), ITextStrings.ksLLImportSucceeded, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; // only 'OK' if not exception } else { DialogResult = DialogResult.Abort; // unsuccessful import } Close(); m_nextInput = import.NextInput; } catch (WorkerThreadException ex) { if (ex.InnerException is InvalidDataException) { // Special handling for this case... ShowFinishLabel(); CheckImportEnabled(); } else { Debug.WriteLine("Error: " + ex.InnerException.Message); MessageBox.Show(String.Format(import.ErrorMessage, ex.InnerException.Message), ITextStrings.ksUnhandledError, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Cancel; // only 'OK' if not exception Close(); } } finally { if (clerk != null) clerk.SuppressSaveOnChangeRecord = fSuppressedSave; } } } }