public void AddOrUpdateCustomFields(int tuId, CustomFieldValues fieldValues) { var translationUnit = _db.translation_units.Find(_db.translation_units.id == tuId); if (translationUnit == null) { return; } if (fieldValues == null) { return; } if (_addSourceTmConfiguration.StoreFilename) { AddOrUpdateCustomField(translationUnit.translation_memory_id, tuId, _addSourceTmConfiguration.FileNameField, fieldValues.FileName); } if (_addSourceTmConfiguration.StoreFullPath) { AddOrUpdateCustomField(translationUnit.translation_memory_id, tuId, _addSourceTmConfiguration.FullPathField, fieldValues.FileNameFullPath); } if (_addSourceTmConfiguration.StoreProjectName) { AddOrUpdateCustomField(translationUnit.translation_memory_id, tuId, _addSourceTmConfiguration.ProjectNameField, fieldValues.ProjectName); } }
public ImportResult[] AddOrUpdateTranslationUnitsMasked(TranslationUnit[] translationUnits, int[] previousTranslationHashes, ImportSettings settings, bool[] mask) { var results = _fileBasedTranslationProviderLanguageDirection.AddOrUpdateTranslationUnitsMasked(translationUnits, previousTranslationHashes, settings, mask); var tmDataAccess = TmDataAccess.OpenConnection(TranslationProvider.Uri); for (int i = 0; i < results.Length; i++) { var result = results[i]; if (result == null) continue; var translationUnit = translationUnits[i]; if (result.Action == Action.Add || result.Action == Action.Merge || result.Action == Action.Overwrite) { var customFieldsValue = new CustomFieldValues { FileNameFullPath = translationUnit.GetFilePath(), ProjectName = translationUnit.GetProjectName() }; tmDataAccess.AddOrUpdateCustomFields(result.TuId.Id, customFieldsValue); } } return results; }
public ImportResult AddTranslationUnit(TranslationUnit translationUnit, ImportSettings settings) { var result = _fileBasedTranslationProviderLanguageDirection.AddTranslationUnit(translationUnit, settings); if (result == null) { return(null); } var tmDataAccess = TmDataAccess.OpenConnection(TranslationProvider.Uri); if (result.Action == Action.Add || result.Action == Action.Merge || result.Action == Action.Overwrite) { var customFieldsValue = new CustomFieldValues { FileNameFullPath = translationUnit.GetFilePath(), ProjectName = translationUnit.GetProjectName() }; tmDataAccess.AddOrUpdateCustomFields(result.TuId.Id, customFieldsValue); } return(result); }
public ImportResult[] AddOrUpdateTranslationUnitsMasked(TranslationUnit[] translationUnits, int[] previousTranslationHashes, ImportSettings settings, bool[] mask) { var results = _fileBasedTranslationProviderLanguageDirection.AddOrUpdateTranslationUnitsMasked(translationUnits, previousTranslationHashes, settings, mask); var tmDataAccess = TmDataAccess.OpenConnection(TranslationProvider.Uri); for (int i = 0; i < results.Length; i++) { var result = results[i]; if (result == null) { continue; } var translationUnit = translationUnits[i]; if (result.Action == Action.Add || result.Action == Action.Merge || result.Action == Action.Overwrite) { var customFieldsValue = new CustomFieldValues { FileNameFullPath = translationUnit.GetFilePath(), ProjectName = translationUnit.GetProjectName() }; tmDataAccess.AddOrUpdateCustomFields(result.TuId.Id, customFieldsValue); } } return(results); }
private void ProcessTranslationUnits(TranslationUnit[] translationUnits, ImportResult[] results) { var tmDataAccess = TmDataAccess.OpenConnection(TranslationProvider.Uri); for (int i = 0; i < results.Length; i++) { var result = results[i]; if (result == null) { continue; } var translationUnit = translationUnits[i]; if (result.Action == Action.Add || result.Action == Action.Merge || result.Action == Action.Overwrite) { var customFieldsValue = new CustomFieldValues { FileNameFullPath = translationUnit.GetFilePath(), ProjectName = translationUnit.GetProjectName() }; tmDataAccess.AddOrUpdateCustomFields(result.TuId.Id, customFieldsValue); } } }
public void AddOrUpdateCustomFields(int tuId, CustomFieldValues fieldValues) { var translationUnit = _db.translation_units.Find(_db.translation_units.id == tuId); if (translationUnit == null) return; if (fieldValues == null) return; if (_addSourceTmConfiguration.StoreFilename) { AddOrUpdateCustomField(translationUnit.translation_memory_id, tuId, _addSourceTmConfiguration.FileNameField, fieldValues.FileName); } if (_addSourceTmConfiguration.StoreFullPath) { AddOrUpdateCustomField(translationUnit.translation_memory_id, tuId, _addSourceTmConfiguration.FullPathField, fieldValues.FileNameFullPath); } if (_addSourceTmConfiguration.StoreProjectName) { AddOrUpdateCustomField(translationUnit.translation_memory_id, tuId, _addSourceTmConfiguration.ProjectNameField, fieldValues.ProjectName); } }
public ImportResult AddTranslationUnit(TranslationUnit translationUnit, ImportSettings settings) { var result = _fileBasedTranslationProviderLanguageDirection.AddTranslationUnit(translationUnit, settings); if (result == null) return null; var tmDataAccess = TmDataAccess.OpenConnection(TranslationProvider.Uri); if (result.Action == Action.Add || result.Action == Action.Merge || result.Action == Action.Overwrite) { var customFieldsValue = new CustomFieldValues { FileNameFullPath = translationUnit.GetFilePath(), ProjectName = translationUnit.GetProjectName() }; tmDataAccess.AddOrUpdateCustomFields(result.TuId.Id, customFieldsValue); } return result; }