コード例 #1
0
ファイル: PhraseCreator.cs プロジェクト: elital/ConcoRep
        public Phrase Create(string phraseText)
        {
            var phraseWords = phraseText.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);

            if (!phraseWords.Any())
                return null;

            var phraseNumber = SequenceQuery.Instance.GetPhraseNumber();
            var wordSequence = 0;

            foreach (var phraseWord in phraseWords)
            {
                var id = SequenceQuery.Instance.GetPhraseWordId();
                wordSequence++;
                var wordId = new WordQuery().GetOrCreateWord(phraseWord, false, false).Id;

                OracleDataLayer.Instance.DmlAction(_createNewPhraseWord,
                    new KeyValuePair<string, object>(IdText, id),
                    new KeyValuePair<string, object>(PhraseNumberText, phraseNumber),
                    new KeyValuePair<string, object>(WordSequenceText, wordSequence),
                    new KeyValuePair<string, object>(WordIdText, wordId));
            }

            OracleDataLayer.Instance.Commit();

            return new PhraseQuery {PhraseNumber = phraseNumber}.Get().SingleOrDefault();
        }
コード例 #2
0
ファイル: GroupQuery.cs プロジェクト: elital/ConcoRep
        private Group ReadGroupWord(OracleDataReader reader, out Word word)
        {
            word = null;

            if (!reader.Read())
                return null;

            word = new WordQuery().GetWordById((int) reader[WordIdText]);

            return new Group
                {
                    Name = (string) reader[GroupNameText]
                };
        }
コード例 #3
0
ファイル: SongWordCreator.cs プロジェクト: elital/ConcoRep
        internal void Create(string wordText, int songId, int line, int column, bool commit)
        {
            if (string.IsNullOrEmpty(wordText))
                return;

            var word = new WordQuery().GetOrCreateWord(wordText, true, commit);
            var id = SequenceQuery.Instance.GetSongWordId();

            OracleDataLayer.Instance.DmlAction(_createSongWordStatement,
                new KeyValuePair<string, object>(IdText, id),
                new KeyValuePair<string, object>(SongIdText, songId),
                new KeyValuePair<string, object>(WordLineText, line),
                new KeyValuePair<string, object>(WordColumnText, column),
                new KeyValuePair<string, object>(WordIdText, word.Id));

            if (commit)
                OracleDataLayer.Instance.Commit();
        }
コード例 #4
0
ファイル: WordQuery.cs プロジェクト: elital/ConcoRep
        //public IEnumerable<Word> GetLike()
        //{
        //    var statement = _getStatement;
        //    var parameters = new List<KeyValuePair<string, object>>();
        //    AddOrLikeComparison(ref statement, WordText, Word, parameters);
        //    AddComparison(ref statement, RepetitionText, Repetition, parameters);
        //    return OracleDataLayer.Instance.Select(ReadWords, statement, parameters.ToArray());
        //}
        internal Word GetOrCreateWord(string text, bool increaseRepetition, bool commit)
        {
            if (string.IsNullOrEmpty(text))
                return null;

            var word = new WordQuery {Word = text}.Get().SingleOrDefault();

            if (word == null)
            {
                var repetition = increaseRepetition ? 1 : 0;
                word = WordCreator.Instance.Create(text, repetition, commit);
            }
            else if (increaseRepetition)
            {
                WordCreator.Instance.IncreaseRepetition(word.Id, commit);
                word.Repetitions++;
            }

            return word;
        }