Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        protected override void OnLoad(EventArgs e)
        {
            var persistance = new Persistance();

            _addSourceTmConfigurations = persistance.Load();

            var addSourceTmConfiguration =
                _addSourceTmConfigurations.Configurations.FirstOrDefault(x => x.ProviderUri == _providerUri);

            if (addSourceTmConfiguration == null)
            {
                addSourceTmConfiguration             = _addSourceTmConfigurations.Default;
                addSourceTmConfiguration.ProviderUri = _providerUri;
                _addSourceTmConfigurations.Configurations.Add(addSourceTmConfiguration);
            }
            else
            {
                _isUsed = true;
            }

            var dataAccess           = TmDataAccess.OpenConnection(addSourceTmConfiguration.ProviderUri);
            var existingCustomFields = dataAccess.GetCustomFields();

            var fileNameFields = new List <string>(existingCustomFields);

            fileNameFields.Insert(0, SelectCustomField);
            cmbFilenameFields.Items.AddRange(fileNameFields.ToArray());

            var fullPathFields = new List <string>(existingCustomFields);

            fullPathFields.Insert(0, SelectCustomField);
            cmbCompletePathField.Items.AddRange(fullPathFields.ToArray());

            var projectNameFields = new List <string>(existingCustomFields);

            projectNameFields.Insert(0, SelectCustomField);
            cmbProjectNameField.Items.AddRange(projectNameFields.ToArray());

            cmbFilenameFields.SelectedIndexChanged    += Boxes_SelectedIndexChanged;
            cmbCompletePathField.SelectedIndexChanged += Boxes_SelectedIndexChanged;
            cmbProjectNameField.SelectedIndexChanged  += Boxes_SelectedIndexChanged;

            SetConfigurationData(txtFilenameField, cmbFilenameFields, addSourceTmConfiguration.FileNameField);
            SetConfigurationData(txtCompletePathField, cmbCompletePathField, addSourceTmConfiguration.FullPathField);
            SetConfigurationData(txtProjectNameField, cmbProjectNameField, addSourceTmConfiguration.ProjectNameField);

            chkFullPath.Checked    = addSourceTmConfiguration.StoreFullPath;
            chkFileName.Checked    = addSourceTmConfiguration.StoreFilename;
            chkProjectName.Checked = addSourceTmConfiguration.StoreProjectName;
        }
Exemple #4
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);
                }
            }
        }