Esempio n. 1
0
        public Report AnonymizeServerBasedCustomFields(ProgressDialogContext context, TmFile tmFile, List <CustomField> customFields, TranslationProviderServer translationProvideServer)
        {
            _tmService.BackupServerBasedTms(context, new List <TmFile> {
                tmFile
            });

            var serverBasedTm = translationProvideServer.GetTranslationMemory(tmFile.Path, TranslationMemoryProperties.All);

            var languageDirections = new List <LanguageDirection>();

            foreach (var languageDirection in serverBasedTm.LanguageDirections)
            {
                languageDirections.Add(new LanguageDirection
                {
                    Source = languageDirection.SourceLanguage,
                    Target = languageDirection.TargetLanguage
                });
            }

            var translationUnits = _tmService.LoadTranslationUnits(context, tmFile, translationProvideServer, languageDirections);

            var units = GetUpdatableTranslationUnits(customFields, translationUnits);

            var report = new Report(tmFile)
            {
                ReportFullPath = _settingsService.GetLogReportFullPath(tmFile.Name, Report.ReportScope.CustomFields),
                UpdatedCount   = units.Count,
                Scope          = Report.ReportScope.CustomFields,
            };

            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var changesReport = GetCustomFieldChangesReport(units, customFields);

            foreach (var change in changesReport)
            {
                report.Actions.AddRange(change.Value);
            }

            UpdateCustomFieldPickLists(context, customFields, serverBasedTm);

            UpdateCustomFields(context, tmFile, translationUnits, units, serverBasedTm);

            ClearPreviousCustomFieldValues(translationUnits);

            stopWatch.Stop();
            report.ElapsedSeconds = stopWatch.Elapsed.TotalSeconds;

            return(report);
        }
Esempio n. 2
0
        public Report AnonymizeServerBasedSystemFields(ProgressDialogContext context, TmFile tmFile, List <User> uniqueUsers, TranslationProviderServer translationProvideServer)
        {
            _tmService.BackupServerBasedTms(context, new List <TmFile> {
                tmFile
            });

            var serverBasedTm = translationProvideServer.GetTranslationMemory(tmFile.Path, TranslationMemoryProperties.All);

            var languageDirections = new List <LanguageDirection>();

            foreach (var languageDirection in serverBasedTm.LanguageDirections)
            {
                languageDirections.Add(new LanguageDirection
                {
                    Source = languageDirection.SourceLanguage,
                    Target = languageDirection.TargetLanguage
                });
            }

            var translationUnits = _tmService.LoadTranslationUnits(context, tmFile, translationProvideServer, languageDirections);

            var report = new Report(tmFile)
            {
                ReportFullPath = _settingsService.GetLogReportFullPath(tmFile.Name, Report.ReportScope.SystemFields),
                UpdatedCount   = translationUnits.Count,
                Scope          = Report.ReportScope.SystemFields,
            };


            report.Actions.AddRange(GetSystemFieldChangesReport(uniqueUsers));

            var stopWatch = new Stopwatch();

            stopWatch.Start();

            report.UpdatedCount = UpdateSystemFields(context, tmFile, uniqueUsers, translationUnits, serverBasedTm);

            stopWatch.Stop();
            report.ElapsedSeconds = stopWatch.Elapsed.TotalSeconds;

            return(report);
        }