Beispiel #1
0
        public CommentController()
        {
            //this.commentRepository = commentRepository;
            //this.stringRepository = stringRepository;
            var connectionString = Settings.GetStringDB();

            commentRepository = new CommentRepository(connectionString);
            stringRepository  = new TranslationSubstringRepository(connectionString);
            ur = new UserRepository(connectionString);
        }
Beispiel #2
0
        public TranslationWriter(string localDefault)
        {
            _localDefault = localDefault;
            var connectionString = Settings.GetStringDB();

            translationRep = new TranslationRepository(connectionString);
            localeRep      = new LocaleRepository(connectionString);

            ts = new TranslationSubstringRepository(connectionString);
        }
        public ReadWriteFileController()
        {
            string connectionString = Settings.GetStringDB();

            _localizationProjectRepository = new LocalizationProjectRepository(connectionString);
            _localeRepository               = new LocaleRepository(connectionString);
            _translationRepository          = new TranslationRepository(connectionString);
            _translationSubstringRepository = new TranslationSubstringRepository(connectionString);
            _IXmlNodeExtensions             = new IXmlNodeExtensions(connectionString);
            _glossaryRepository             = new GlossaryRepository(connectionString);
            _partOfSpeechRepository         = new PartOfSpeechRepository(connectionString);
        }
Beispiel #4
0
        public void Initialize(Guid id)
        {
            var connectionString = Settings.GetStringDB();

            //TOD нужно передавать глассарий
            //memoryId = Guid.Parse("47faa0d8-56da-4e09-b151-ded06b587338");
            memoryId = id;
            gsr      = new TranslationMemoryRepository(connectionString);
            IEnumerable <TranslationMemory> gList = gsr.GetForEditAsync(memoryId).Result;
            List <TranslationMemory>        tt    = gList.ToList();

            memory = tt[0];
            //TODO нужно обработать создание нового глоссария, если текущего нет

            glossaryRep = new GlossaryRepository(connectionString);
            tWriter     = new TranslationWriter(_localDefault);
            ts          = new TranslationSubstringRepository(connectionString);
        }
Beispiel #5
0
        public async Task <Guid?> AddNewTermAsync(Guid glossaryId, TranslationSubstring newTerm, Guid?partOfSpeechId)
        {
            var glossary = await this.GetByIDAsync(id : glossaryId);

            newTerm.id_file_owner = glossary.ID_File;
            newTerm.word_count    = TranslationSubstringRepository.GetWordsCount(newTerm.substring_to_translate);
            try
            {
                using (var dbConnection = new NpgsqlConnection(connectionString))
                {
                    var insertNewStingSql =
                        "INSERT INTO translation_substrings " +
                        "(" +
                        "substring_to_translate, " +
                        "description, " +
                        "context_file, " +
                        "translation_max_length, " +
                        "id_file_owner, " +
                        "value, " +
                        "position_in_text, " +
                        "word_count" +
                        ") VALUES " +
                        "(" +
                        "@substring_to_translate, " +
                        "@description, " +
                        "@context_file, " +
                        "@translation_max_length, " +
                        "@id_file_owner, " +
                        "@value, " +
                        "@position_in_text, " +
                        "@word_count" +
                        ") " +
                        "RETURNING id";
                    var insertNewStingParam = newTerm;
                    this.LogQuery(insertNewStingSql, newTerm.GetType(), insertNewStingParam);
                    var idOfNewTerm = await dbConnection
                                      .ExecuteScalarAsync <Guid>(
                        sql : insertNewStingSql,
                        param : insertNewStingParam);

                    var instertGlossaryStringAssotiationSql =
                        "INSERT INTO glossaries_strings (id_glossary, id_string,id_part_of_speech) VALUES (@glossary_id, @string_id, @parts_of_speechId)";
                    var instertGlossaryStringAssotiationParam = new { glossary_id = glossaryId, string_id = idOfNewTerm, parts_of_speechId = partOfSpeechId };
                    this.LogQuery(instertGlossaryStringAssotiationSql, instertGlossaryStringAssotiationParam);
                    await dbConnection
                    .ExecuteAsync(
                        sql : instertGlossaryStringAssotiationSql,
                        param : instertGlossaryStringAssotiationParam);

                    return(idOfNewTerm);
                }
            }

            catch (NpgsqlException exception)
            {
                this._loggerError.WriteLn(
                    $"Ошибка в {nameof(GlossaryRepository)}.{nameof(GlossaryRepository.AddNewTermAsync)} {nameof(NpgsqlException)} ",
                    exception);
                return(null);
            }
            catch (Exception exception)
            {
                this._loggerError.WriteLn(
                    $"Ошибка в {nameof(GlossaryRepository)}.{nameof(GlossaryRepository.AddNewTermAsync)} {nameof(Exception)} ",
                    exception);
                return(null);
            }
        }
Beispiel #6
0
 public FilesRepository(string connectionStr) : base(connectionStr)
 {
     _action = new UserActionRepository(connectionStr);
     _tsr    = new TranslationSubstringRepository(connectionStr);
 }