Exemplo n.º 1
0
 private void SafeRemoveInputTmxFile(InputTmxFile tmxFile)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         InputTmxFiles.Remove(tmxFile);
     }));
 }
Exemplo n.º 2
0
        private void CreateProcessingSteps()
        {
            ProcessingSteps.Clear();
            ProcessingContext context = new ProcessingContext();

            context.Settings = Settings;
            InputTmxFile existingTmtmxFile = null;

            if (Mode == WizardMode.CleanExistingTranslationMemory)
            {
                existingTmtmxFile = new InputTmxFile(new TmxFile(context.GetTempTmxFile()));
                existingTmtmxFile.CleanTmxFile = new TmxFile(context.GetTempTmxFile());

                // export TM
                ProcessingSteps.Add(new ExportStudioTmStep(InputTranslationMemory.TranslationMemory, existingTmtmxFile.TmxFile));
                // strip workbench TUs
                ProcessingSteps.Add(new StripWorkbenchTusStep(InputTranslationMemory.TranslationMemory.Name, existingTmtmxFile.TmxFile, existingTmtmxFile.CleanTmxFile));
            }

            foreach (InputTmxFile inputTmxFile in InputTmxFiles)
            {
                // clean TMX
                inputTmxFile.CleanTmxFile = new TmxFile(context.GetTempTmxFile());
                ProcessingSteps.Add(new CleanWorkbenchTmxStep(inputTmxFile.TmxFile, inputTmxFile.CleanTmxFile, null));
            }

            TranslationMemoryReference outputTranslationMemory;

            if (OutputMethod == OutputMethod.CreateNewTranslationMemory)
            {
                outputTranslationMemory = new TranslationMemoryReference {
                    FilePath = NewOutputTranslationMemoryFilePath
                };
                // create output TM
                ProcessingSteps.Add(new CreateStudioTmStep(outputTranslationMemory, SourceLanguage, TargetLanguage, InputTranslationMemory));
            }
            else
            {
                outputTranslationMemory = OutputTranslationMemory;
            }

            foreach (InputTmxFile inputTmxFile in InputTmxFiles)
            {
                // import clean TMX
                ProcessingSteps.Add(new ImportStudioTmStep(outputTranslationMemory, Path.GetFileName(inputTmxFile.TmxFile.FilePath), inputTmxFile.CleanTmxFile));
            }

            if (existingTmtmxFile != null)
            {
                ProcessingSteps.Add(new ImportStudioTmStep(outputTranslationMemory, Path.GetFileName(InputTranslationMemory.FilePath), existingTmtmxFile.CleanTmxFile));
            }

            ProcessingSteps.Add(new DeleteTempFilesStep());

            // set context of all steps
            foreach (ProcessingStep step in ProcessingSteps)
            {
                step.Context = context;
            }
        }
 public void SafeAddInputTmxFile(InputTmxFile tmxFile)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         InputTmxFiles.Add(tmxFile);
     }));
 }
Exemplo n.º 4
0
        internal void AddTmxInputFile()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Title       = "Select TMX files to clean up";
            dlg.DefaultExt  = ".tmx";
            dlg.Filter      = "TRADOS Workbench TMX (.tmx)|*.tmx";
            dlg.Multiselect = true;

            if (dlg.ShowDialog() == true)
            {
                string[] tmxFiles = dlg.FileNames;
                _worker         = new BackgroundWorker();
                _worker.DoWork += (sender, e) =>
                {
                    foreach (string fileName in tmxFiles)
                    {
                        InputTmxFile tmxFile = new InputTmxFile(new TmxFile(fileName));

                        try
                        {
                            SafeAddInputTmxFile(tmxFile);
                            tmxFile.TmxFile.Detect();
                        }
                        catch (Exception ex)
                        {
                            DisplayError(ex);
                            SafeRemoveInputTmxFile(tmxFile);
                        }
                    }
                };
                _worker.RunWorkerCompleted += (sender, e) =>
                {
                };

                _worker.RunWorkerAsync();
            }
        }
Exemplo n.º 5
0
        private void CreateProcessingSteps()
        {
            ProcessingSteps.Clear();
            ProcessingContext context = new ProcessingContext();
            context.Settings = Settings;
            InputTmxFile existingTmtmxFile = null;
            if (Mode == WizardMode.CleanExistingTranslationMemory)
            {
                existingTmtmxFile = new InputTmxFile(new TmxFile(context.GetTempTmxFile()));
                existingTmtmxFile.CleanTmxFile = new TmxFile(context.GetTempTmxFile());
                
                // export TM
                ProcessingSteps.Add(new ExportStudioTmStep(InputTranslationMemory.TranslationMemory, existingTmtmxFile.TmxFile));
                // strip workbench TUs
                ProcessingSteps.Add(new StripWorkbenchTusStep(InputTranslationMemory.TranslationMemory.Name, existingTmtmxFile.TmxFile, existingTmtmxFile.CleanTmxFile));
            }

            foreach (InputTmxFile inputTmxFile in InputTmxFiles)
            {
                // clean TMX
                inputTmxFile.CleanTmxFile = new TmxFile(context.GetTempTmxFile());
                ProcessingSteps.Add(new CleanWorkbenchTmxStep(inputTmxFile.TmxFile, inputTmxFile.CleanTmxFile, null));
            }

            TranslationMemoryReference outputTranslationMemory;

            if (OutputMethod == OutputMethod.CreateNewTranslationMemory)
            {
                outputTranslationMemory = new TranslationMemoryReference { FilePath = NewOutputTranslationMemoryFilePath };
                // create output TM
                ProcessingSteps.Add(new CreateStudioTmStep(outputTranslationMemory, SourceLanguage, TargetLanguage, InputTranslationMemory));
            }
            else
            {
                outputTranslationMemory = OutputTranslationMemory;
            }

            foreach (InputTmxFile inputTmxFile in InputTmxFiles)
            {
                // import clean TMX
                ProcessingSteps.Add(new ImportStudioTmStep(outputTranslationMemory, Path.GetFileName(inputTmxFile.TmxFile.FilePath), inputTmxFile.CleanTmxFile));
            }

            if (existingTmtmxFile != null)
            {
                ProcessingSteps.Add(new ImportStudioTmStep(outputTranslationMemory, Path.GetFileName(InputTranslationMemory.FilePath), existingTmtmxFile.CleanTmxFile));
            }

            ProcessingSteps.Add(new DeleteTempFilesStep());

            // set context of all steps
            foreach (ProcessingStep step in ProcessingSteps)
            {
                step.Context = context;
            }
        }
Exemplo n.º 6
0
 private void SafeRemoveInputTmxFile(InputTmxFile tmxFile)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         InputTmxFiles.Remove(tmxFile);
     }));
 }
Exemplo n.º 7
0
        internal void AddTmxInputFile()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Title = "Select TMX files to clean up";
            dlg.DefaultExt = ".tmx";
            dlg.Filter = "TRADOS Workbench TMX (.tmx)|*.tmx";
            dlg.Multiselect = true;

            if (dlg.ShowDialog() == true)
            {
                string[] tmxFiles = dlg.FileNames;
                _worker = new BackgroundWorker();
                _worker.DoWork += (sender, e) =>
                {
                    foreach (string fileName in tmxFiles)
                    {
                        InputTmxFile tmxFile = new InputTmxFile(new TmxFile(fileName));

                        try
                        {
                            SafeAddInputTmxFile(tmxFile);
                            tmxFile.TmxFile.Detect();
                        }
                        catch (Exception ex)
                        {
                            DisplayError(ex);
                            SafeRemoveInputTmxFile(tmxFile);
                        }
                    }
                };
                _worker.RunWorkerCompleted += (sender, e) =>
                {
                    
                };
                
                _worker.RunWorkerAsync();               
            }
        }