Beispiel #1
0
        public Report AnonymizeFileBasedCustomFields(ProgressDialogContext context, TmFile tmFile, List <CustomField> customFields)
        {
            _tmService.BackupFileBasedTms(context, new List <TmFile> {
                tmFile
            });

            var tm = new FileBasedTranslationMemory(tmFile.Path);

            var translationUnits = _tmService.LoadTranslationUnits(context, tmFile, null,
                                                                   new LanguageDirection
            {
                Source = tm.LanguageDirection.SourceLanguage,
                Target = tm.LanguageDirection.TargetLanguage
            });

            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, tm);

            var settings = _settingsService.GetSettings();

            if (settings.UseSqliteApiForFileBasedTm)
            {
                UpdateCustomFieldsSqlite(context, tmFile, units);
            }
            else
            {
                UpdateCustomFields(context, tm, units);
            }

            ClearPreviousCustomFieldValues(translationUnits);

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

            return(report);
        }
Beispiel #2
0
        public Report AnonymizeFileBasedSystemFields(ProgressDialogContext context, TmFile tmFile, List <User> uniqueUsers)
        {
            _tmService.BackupFileBasedTms(context, new List <TmFile> {
                tmFile
            });

            var tm = new FileBasedTranslationMemory(tmFile.Path);

            var translationUnits = _tmService.LoadTranslationUnits(context, tmFile, null, new LanguageDirection
            {
                Source = tm.LanguageDirection.SourceLanguage,
                Target = tm.LanguageDirection.TargetLanguage
            });

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

            var stopWatch = new Stopwatch();

            stopWatch.Start();

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

            var settings = _settingsService.GetSettings();

            report.UpdatedCount = settings.UseSqliteApiForFileBasedTm
                                ? UpdateSystemFieldsSqlite(context, tmFile, translationUnits, uniqueUsers)
                                : UpdateSystemFields(context, translationUnits, tm, uniqueUsers);

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

            return(report);
        }