Пример #1
0
        private void _BuildFromTRO(string path, UnitOfWork uow)
        {
            var conn  = GetConnection(path);
            var words = GetTroVerseInfos(conn);
            var c     = new GreekTransliterationController();

            uow.BeginTransaction();
            var strongs           = new XPQuery <StrongCode>(uow).ToList();
            var grammarCodes      = new XPQuery <GrammarCode>(uow).ToList();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var exsistingWords = new List <TroVerseWord>();
            var exsistingItems = new XPQuery <AncientDictionaryItem>(uow);

            foreach (var item in exsistingItems)
            {
                exsistingWords.Add(new TroVerseWord()
                {
                    SourceWord = item.Word
                });
            }

            foreach (var word in words)
            {
                if (!exsistingWords.Where(x => x.SourceWord == word.SourceWord).Any())
                {
                    var item = new AncientDictionaryItem(uow)
                    {
                        Dictionary      = dic,
                        Word            = word.SourceWord,
                        Translation     = word.Translation,
                        Transliteration = c.TransliterateWord(word.SourceWord),
                        StrongCode      = strongs.Where(x => x.Lang == Language.Greek && x.Code == word.StrongCode).FirstOrDefault(),
                        GrammarCode     = grammarCodes.Where(x => x.GrammarCodeVariant1 == word.GrammarCode || x.GrammarCodeVariant2 == word.GrammarCode || x.GrammarCodeVariant3 == word.GrammarCode).FirstOrDefault()
                    };
                    item.Save();
                    exsistingWords.Add(new TroVerseWord()
                    {
                        SourceWord = word.SourceWord
                    });
                }
            }

            uow.CommitChanges();
        }
Пример #2
0
        private void _BuildFromExisting(UnitOfWork uow)
        {
            uow.BeginTransaction();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var c = new GreekTransliterationController();

            var exsistingWords = new List <TroVerseWord>();
            var exsistingItems = new XPQuery <AncientDictionaryItem>(uow);

            foreach (var item in exsistingItems)
            {
                exsistingWords.Add(new TroVerseWord()
                {
                    SourceWord = item.Word
                });
            }

            var words = new XPQuery <VerseWord>(uow).Where(x => x.Translation != null && x.Translation != "").ToList();

            foreach (var word in words)
            {
                var w = c.GetSourceWordWithoutBreathAndAccent(word.SourceWord.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\""), out var isUpper).ToLower();
                if (!exsistingWords.Where(x => x.SourceWord == w).Any())
                {
                    var item = new AncientDictionaryItem(uow)
                    {
                        Dictionary      = dic,
                        Word            = w,
                        Translation     = word.Translation.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\"" /*, "<n>", "</n>"*/),
                        Transliteration = word.Transliteration.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\""),
                        StrongCode      = word.StrongCode,
                        GrammarCode     = word.GrammarCode
                    };
                    item.Save();
                    exsistingWords.Add(new TroVerseWord()
                    {
                        SourceWord = w
                    });
                }
            }
            uow.CommitChanges();
        }
Пример #3
0
        private void BuildFromTRO(string path, UnitOfWork uow)
        {
            var conn  = GetConnection(path);
            var words = GetTroVerseInfos(conn);
            var c     = new GreekTransliterationController();

            uow.BeginTransaction();
            var strongs           = new XPQuery <StrongCode>(uow).ToList();
            var grammarCodes      = new XPQuery <GrammarCode>(uow).ToList();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var ancientDictionaryItemView = new XPView(uow, typeof(AncientDictionaryItem))
            {
                CriteriaString = "Translation is not null AND Translation != ''"
            };

            ancientDictionaryItemView.Properties.Add(new ViewProperty("Word", SortDirection.None, "[Word]", false, true));

            var exsistingWords = new List <TroVerseWord>();

            foreach (ViewRecord item in ancientDictionaryItemView)
            {
                exsistingWords.Add(new TroVerseWord()
                {
                    SourceWord = item["Word"].ToString()
                });
            }

            foreach (var word in words)
            {
                if (!exsistingWords.Where(x => x.SourceWord == word.SourceWord).Any())
                {
                    var item = new AncientDictionaryItem(uow)
                    {
                        Dictionary      = dic,
                        Word            = word.SourceWord,
                        Translation     = word.Translation,
                        Transliteration = c.TransliterateWord(word.SourceWord),
                        StrongCode      = strongs.Where(x => x.Lang == Language.Greek && x.Code == word.StrongCode).FirstOrDefault(),
                        GrammarCode     = grammarCodes.Where(x => x.GrammarCodeVariant1 == word.GrammarCode || x.GrammarCodeVariant2 == word.GrammarCode || x.GrammarCodeVariant3 == word.GrammarCode).FirstOrDefault()
                    };
                    item.Save();
                    exsistingWords.Add(new TroVerseWord()
                    {
                        SourceWord = word.SourceWord
                    });
                }
            }

            uow.CommitChanges();
        }