示例#1
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
                }
            }
        }
示例#6
0
        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;
        }